From c14fea4012649c4bff67615b52647db848a5615c Mon Sep 17 00:00:00 2001 From: Laiganlu Date: Mon, 8 Sep 2025 10:31:34 +0800 Subject: [PATCH] =?UTF-8?q?=E6=88=AA=E5=9B=BE=E7=BC=93=E5=AD=98=E4=BC=98?= =?UTF-8?q?=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Laiganlu --- window_scene/session/host/src/session.cpp | 13 +++------- .../include/scene_session_manager.h | 1 - .../src/scene_session_manager.cpp | 26 ++----------------- .../src/window_manager_lru.cpp | 6 ++--- .../unittest/scene_session_manager_test5.cpp | 21 --------------- 5 files changed, 9 insertions(+), 58 deletions(-) diff --git a/window_scene/session/host/src/session.cpp b/window_scene/session/host/src/session.cpp index 70d6f6d9f4..efefc1928e 100644 --- a/window_scene/session/host/src/session.cpp +++ b/window_scene/session/host/src/session.cpp @@ -2776,10 +2776,6 @@ void Session::SaveSnapshot(bool useFfrt, bool needPersist, std::shared_ptraddSnapshotCallback_(); } session->SetAddSnapshotCallback([]() {}); - { - std::lock_guard lock(session->saveSnapshotCallbackMutex_); - session->saveSnapshotCallback_(); - } if (!requirePersist) { return; } @@ -2797,13 +2793,12 @@ void Session::SaveSnapshot(bool useFfrt, bool needPersist, std::shared_ptrscenePersistence_->ResetSnapshotCache(); - Task removeSnapshotCallback = []() {}; + Task saveSnapshotCallback = []() {}; { - std::lock_guard lock(session->removeSnapshotCallbackMutex_); - removeSnapshotCallback = session->removeSnapshotCallback_; + std::lock_guard lock(session->saveSnapshotCallbackMutex_); + saveSnapshotCallback = session->saveSnapshotCallback_; } - session->scenePersistence_->SaveSnapshot(pixelMap, removeSnapshotCallback, key, rotate, + session->scenePersistence_->SaveSnapshot(pixelMap, saveSnapshotCallback, key, rotate, session->freeMultiWindow_.load()); if (updateSnapshot) { session->SetExitSplitOnBackground(false); diff --git a/window_scene/session_manager/include/scene_session_manager.h b/window_scene/session_manager/include/scene_session_manager.h index bcd182dc60..f52b5170d0 100644 --- a/window_scene/session_manager/include/scene_session_manager.h +++ b/window_scene/session_manager/include/scene_session_manager.h @@ -791,7 +791,6 @@ public: std::shared_ptr GetPreLoadStartingWindow(const SessionInfo& sessionInfo); void RemovePreLoadStartingWindowFromMap(const SessionInfo& sessionInfo); WSError RegisterSaveSnapshotFunc(const sptr& sceneSession); - WSError RegisterRemoveSnapshotFunc(const sptr& sceneSession); std::shared_ptr GetPixelMap(uint32_t resourceId, std::shared_ptr abilityInfo); bool GetPersistentImageFit(int32_t persistentId, int32_t& imageFit); diff --git a/window_scene/session_manager/src/scene_session_manager.cpp b/window_scene/session_manager/src/scene_session_manager.cpp index 660c206894..7cc0699376 100644 --- a/window_scene/session_manager/src/scene_session_manager.cpp +++ b/window_scene/session_manager/src/scene_session_manager.cpp @@ -147,8 +147,8 @@ constexpr uint64_t VIRTUAL_DISPLAY_ID = 999; constexpr uint32_t DEFAULT_LOCK_SCREEN_ZORDER = 2000; constexpr int32_t MAX_LOCK_STATUS_CACHE_SIZE = 1000; constexpr std::size_t MAX_SNAPSHOT_IN_RECENT_PC = 50; -constexpr std::size_t MAX_SNAPSHOT_IN_RECENT_PAD = 8; -constexpr std::size_t MAX_SNAPSHOT_IN_RECENT_PHONE = 3; +constexpr std::size_t MAX_SNAPSHOT_IN_RECENT_PAD = 0; +constexpr std::size_t MAX_SNAPSHOT_IN_RECENT_PHONE = 1; constexpr uint64_t NOTIFY_START_ABILITY_TIMEOUT = 4000; constexpr uint64_t START_UI_ABILITY_TIMEOUT = 5000; constexpr int32_t FORCE_SPLIT_MODE = 5; @@ -2785,9 +2785,6 @@ void SceneSessionManager::InitSceneSession(sptr& sceneSession, con if (systemConfig_.IsPcOrPcMode()) { RegisterGetStartWindowConfigCallback(sceneSession); } - if (systemConfig_.windowUIType_ == WindowUIType::PAD_WINDOW) { - RegisterRemoveSnapshotFunc(sceneSession); - } // Skip FillSessionInfo when atomicService free-install start. if (!IsAtomicServiceFreeInstall(sessionInfo)) { FillSessionInfo(sceneSession); @@ -3307,22 +3304,6 @@ WSError SceneSessionManager::RegisterSaveSnapshotFunc(const sptr& return WSError::WS_OK; } -WSError SceneSessionManager::RegisterRemoveSnapshotFunc(const sptr& sceneSession) -{ - if (sceneSession == nullptr) { - TLOGE(WmsLogTag::WMS_PATTERN, "session is nullptr"); - return WSError::WS_ERROR_NULLPTR; - } - if (!WindowHelper::IsMainWindow(sceneSession->GetWindowType())) { - return WSError::WS_ERROR_INVALID_WINDOW; - } - auto persistentId = sceneSession->GetPersistentId(); - sceneSession->SetRemoveSnapshotCallback([this, persistentId]() { - this->RemoveSnapshotFromCache(persistentId); - }); - return WSError::WS_OK; -} - void SceneSessionManager::ConfigSupportSnapshotAllSessionStatus() { TLOGI(WmsLogTag::WMS_PATTERN, "support"); @@ -3626,9 +3607,6 @@ WSError SceneSessionManager::RequestSceneSessionDestruction(const sptrGetSessionInfo(), ActionType::SINGLE_CLOSE); - sceneSession->SetRemoveSnapshotCallback([this, persistentId]() { - this->RemoveSnapshotFromCache(persistentId); - }); sceneSession->DisconnectTask(false, isSaveSnapshot); ClearWatermarkRecordWhenAppExit(sceneSession); if (!GetSceneSession(persistentId)) { diff --git a/window_scene/session_manager/src/window_manager_lru.cpp b/window_scene/session_manager/src/window_manager_lru.cpp index eb0af7940b..2d5d4484de 100644 --- a/window_scene/session_manager/src/window_manager_lru.cpp +++ b/window_scene/session_manager/src/window_manager_lru.cpp @@ -36,13 +36,13 @@ int32_t LruCache::Put(int32_t key) int32_t lastRemovedKey = UNDEFINED_REMOVED_KEY; std::lock_guard lock(lruCacheMutex_); if (!LocalVisit(key)) { - if (cacheList_.size() >= capacity_) { + cacheList_.push_front(key); + cacheMap_[key] = cacheList_.begin(); + if (cacheList_.size() > capacity_) { lastRemovedKey = cacheList_.back(); cacheList_.pop_back(); cacheMap_.erase(lastRemovedKey); } - cacheList_.push_front(key); - cacheMap_[key] = cacheList_.begin(); } return lastRemovedKey; } diff --git a/window_scene/test/unittest/scene_session_manager_test5.cpp b/window_scene/test/unittest/scene_session_manager_test5.cpp index 9a11a8c1fd..f435141354 100644 --- a/window_scene/test/unittest/scene_session_manager_test5.cpp +++ b/window_scene/test/unittest/scene_session_manager_test5.cpp @@ -1773,27 +1773,6 @@ HWTEST_F(SceneSessionManagerTest5, RegisterSaveSnapshotFunc, TestSize.Level1) ASSERT_EQ(WSError::WS_OK, ssm_->RegisterSaveSnapshotFunc(sceneSession)); } -/** - * @tc.name: RegisterRemoveSnapshotFunc - * @tc.desc: RegisterRemoveSnapshotFunc Test - * @tc.type: FUNC - */ -HWTEST_F(SceneSessionManagerTest5, RegisterRemoveSnapshotFunc, TestSize.Level1) -{ - ASSERT_NE(ssm_, nullptr); - sptr sceneSession = nullptr; - ASSERT_EQ(WSError::WS_ERROR_NULLPTR, ssm_->RegisterSaveSnapshotFunc(sceneSession)); - - SessionInfo info; - info.windowType_ = 1000; - sceneSession = sptr::MakeSptr(info, nullptr); - sceneSession->property_->SetPersistentId(1); - ASSERT_EQ(WSError::WS_ERROR_INVALID_WINDOW, ssm_->RegisterSaveSnapshotFunc(sceneSession)); - - sceneSession->property_->SetWindowType(WindowType::APP_MAIN_WINDOW_BASE); - ASSERT_EQ(WSError::WS_OK, ssm_->RegisterSaveSnapshotFunc(sceneSession)); -} - /** * @tc.name: GetDelayRemoveSnapshot * @tc.desc: GetDelayRemoveSnapshot Test -- Gitee