From b89cad66be888adab202e3fc92d723b8a5f9d94d Mon Sep 17 00:00:00 2001 From: nzy Date: Mon, 6 Jan 2025 18:47:25 +0800 Subject: [PATCH] =?UTF-8?q?visibleWindowCountMap=5F=20=E7=BA=BF=E7=A8=8B?= =?UTF-8?q?=E5=AE=89=E5=85=A8=E6=95=B4=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: nzy --- .../session/host/include/scene_session.h | 12 ++++---- window_scene/session/host/include/session.h | 17 +++++------ .../session/host/src/extension_session.cpp | 2 +- .../session/host/src/main_session.cpp | 3 +- .../session/host/src/scene_session.cpp | 20 ++++++------- window_scene/session/host/src/session.cpp | 2 +- .../include/scene_session_manager.h | 13 +++++---- .../src/extension_session_manager.cpp | 2 +- .../src/scene_session_manager.cpp | 26 ++++++++--------- window_scene/test/unittest/BUILD.gn | 28 +++++++++++++++++++ .../scene_session_dirty_manager_test2.cpp | 8 ++---- window_scene/test/unittest/session_test2.cpp | 1 - 12 files changed, 81 insertions(+), 53 deletions(-) diff --git a/window_scene/session/host/include/scene_session.h b/window_scene/session/host/include/scene_session.h index 5f3da9c743..ce59f7726a 100644 --- a/window_scene/session/host/include/scene_session.h +++ b/window_scene/session/host/include/scene_session.h @@ -189,7 +189,7 @@ public: virtual WSError Reconnect(const sptr& sessionStage, const sptr& eventChannel, const std::shared_ptr& surfaceNode, sptr property = nullptr, sptr token = nullptr, int32_t pid = -1, int32_t uid = -1); - WSError ReconnectInner(sptr property); + WSError ReconnectInner(sptr property) REQUIRES(SCENE_GUARD); bool IsRecovered() const { return isRecovered_; } void SetRecovered(bool isRecovered) { isRecovered_ = isRecovered; } @@ -454,6 +454,7 @@ public: virtual WSError HideSync() { return WSError::WS_DO_NOTHING; } void RegisterUpdateAppUseControlCallback(UpdateAppUseControlFunc&& func); void NotifyUpdateAppUseControl(ControlAppType type, bool isNeedControl); + void SetVisibilityChangedDetectFunc(VisibilityChangedDetectFunc&& func); void SendPointerEventToUI(std::shared_ptr pointerEvent); bool SendKeyEventToUI(std::shared_ptr keyEvent, bool isPreImeEvent = false); @@ -523,8 +524,10 @@ public: // WMSPipeline-related: only accessed on SSM thread virtual void SyncScenePanelGlobalPosition(bool needSync) {} void SetNeedSyncSessionRect(bool needSync); - uint32_t UpdateUIParam(const SessionUIParam& uiParam); // update visible session, return dirty flags - uint32_t UpdateUIParam(); // update invisible session, return dirty flags + // update visible session, return dirty flags + uint32_t UpdateUIParam(const SessionUIParam& uiParam) REQUIRES(SCENE_GUARD); + // update invisible session, return dirty flags + uint32_t UpdateUIParam() REQUIRES(SCENE_GUARD); void SetPostProcessFocusState(PostProcessFocusState state); PostProcessFocusState GetPostProcessFocusState() const; void ResetPostProcessFocusState(); @@ -540,7 +543,6 @@ public: void SetMinimizedFlagByUserSwitch(bool isMinimized); bool IsMinimizedByUserSwitch() const; void UnregisterSessionChangeListeners() override; - void SetVisibilityChangedDetectFunc(const VisibilityChangedDetectFunc& func); /* * Window ZOrder: PC @@ -615,7 +617,7 @@ protected: /* * Window Pipeline */ - bool UpdateVisibilityInner(bool visibility); + bool UpdateVisibilityInner(bool visibility) REQUIRES(SCENE_GUARD); bool UpdateInteractiveInner(bool interactive); virtual void NotifyClientToUpdateInteractive(bool interactive) {} bool PipelineNeedNotifyClientToUpdateRect() const; diff --git a/window_scene/session/host/include/session.h b/window_scene/session/host/include/session.h index c61826a4d2..236dd68999 100644 --- a/window_scene/session/host/include/session.h +++ b/window_scene/session/host/include/session.h @@ -15,6 +15,7 @@ #ifndef OHOS_ROSEN_WINDOW_SCENE_SESSION_H #define OHOS_ROSEN_WINDOW_SCENE_SESSION_H + #include #include #include @@ -29,6 +30,7 @@ #include "session/container/include/zidl/session_stage_interface.h" #include "session/host/include/zidl/session_stub.h" #include "session/host/include/scene_persistence.h" +#include "thread_safety_annotations.h" #include "vsync_station.h" #include "window_visibility_info.h" #include "wm_common.h" @@ -87,8 +89,7 @@ using NotifySystemSessionKeyEventFunc = std::function; using NotifyContextTransparentFunc = std::function; using NotifyFrameLayoutFinishFunc = std::function; -using VisibilityChangedDetectFunc = std::function; +using VisibilityChangedDetectFunc = std::function; using AcquireRotateAnimationConfigFunc = std::function; using RequestVsyncFunc = std::function& callback)>; using NotifyWindowMovingFunc = std::function; @@ -143,15 +144,15 @@ public: virtual WSError ConnectInner(const sptr& sessionStage, const sptr& eventChannel, const std::shared_ptr& surfaceNode, SystemSessionConfig& systemConfig, sptr property = nullptr, sptr token = nullptr, - int32_t pid = -1, int32_t uid = -1, const std::string& identityToken = ""); + int32_t pid = -1, int32_t uid = -1, const std::string& identityToken = "") REQUIRES(SCENE_GUARD); WSError Foreground(sptr property, bool isFromClient = false, const std::string& identityToken = "") override; WSError Background(bool isFromClient = false, const std::string& identityToken = "") override; - WSError Disconnect(bool isFromClient = false, const std::string& identityToken = "") override; + WSError Disconnect(bool isFromClient = false, const std::string& identityToken = "") override REQUIRES(SCENE_GUARD); WSError Show(sptr property) override; WSError Hide() override; WSError DrawingCompleted() override; - void ResetSessionConnectState(); + void ResetSessionConnectState() REQUIRES(SCENE_GUARD); void ResetIsActive(); WSError PendingSessionToForeground(); WSError PendingSessionToBackgroundForDelegator(bool shouldBackToCaller); @@ -174,7 +175,7 @@ public: */ WSError Reconnect(const sptr& sessionStage, const sptr& eventChannel, const std::shared_ptr& surfaceNode, sptr property = nullptr, - sptr token = nullptr, int32_t pid = -1, int32_t uid = -1); + sptr token = nullptr, int32_t pid = -1, int32_t uid = -1) REQUIRES(SCENE_GUARD); /* * Callbacks for ILifecycleListener @@ -413,7 +414,7 @@ public: int32_t GetWindowId() const; void SetAppIndex(const int32_t appIndex); int32_t GetAppIndex() const; - void SetCallingPid(int32_t id); + void SetCallingPid(int32_t id) REQUIRES(SCENE_GUARD); void SetCallingUid(int32_t id); int32_t GetCallingPid() const; int32_t GetCallingUid() const; @@ -673,7 +674,6 @@ protected: NotifySystemSessionKeyEventFunc systemSessionKeyEventFunc_; NotifyContextTransparentFunc contextTransparentFunc_; NotifyFrameLayoutFinishFunc frameLayoutFinishFunc_; - VisibilityChangedDetectFunc visibilityChangedDetectFunc_; /* * Window LifeCycle @@ -687,6 +687,7 @@ protected: NotifyTerminateSessionFuncTotal terminateSessionFuncTotal_; NotifySessionExceptionFunc sessionExceptionFunc_; NotifySessionExceptionFunc jsSceneSessionExceptionFunc_; + VisibilityChangedDetectFunc visibilityChangedDetectFunc_ GUARDED_BY(SCENE_GUARD); /* * Window Rotate Animation diff --git a/window_scene/session/host/src/extension_session.cpp b/window_scene/session/host/src/extension_session.cpp index 72c2e8ea97..d0370be551 100644 --- a/window_scene/session/host/src/extension_session.cpp +++ b/window_scene/session/host/src/extension_session.cpp @@ -176,7 +176,7 @@ WSError ExtensionSession::ConnectInner( return WSError::WS_ERROR_INVALID_PARAM; } auto task = [weakThis = wptr(this), sessionStage, eventChannel, surfaceNode, - &systemConfig, property, token, pid, uid]() { + &systemConfig, property, token, pid, uid]() NO_THREAD_SAFETY_ANALYSIS { auto session = weakThis.promote(); if (!session) { TLOGNE(WmsLogTag::WMS_UIEXT, "session is null"); diff --git a/window_scene/session/host/src/main_session.cpp b/window_scene/session/host/src/main_session.cpp index c3d83fc417..f6a8baadcb 100644 --- a/window_scene/session/host/src/main_session.cpp +++ b/window_scene/session/host/src/main_session.cpp @@ -67,7 +67,8 @@ WSError MainSession::Reconnect(const sptr& sessionStage, const sp WLOGFE("session is null"); return WSError::WS_ERROR_DESTROYED_OBJECT; } - WSError ret = session->Session::Reconnect(sessionStage, eventChannel, surfaceNode, property, token, pid, uid); + WSError ret = LOCK_GUARD_EXPR(SCENE_GUARD, + session->Session::Reconnect(sessionStage, eventChannel, surfaceNode, property, token, pid, uid)); if (ret != WSError::WS_OK) { return ret; } diff --git a/window_scene/session/host/src/scene_session.cpp b/window_scene/session/host/src/scene_session.cpp index 93c2c0843b..f9026a75fa 100644 --- a/window_scene/session/host/src/scene_session.cpp +++ b/window_scene/session/host/src/scene_session.cpp @@ -123,8 +123,8 @@ WSError SceneSession::ConnectInner(const sptr& sessionStage, property->SetAppInstanceKey(session->GetAppInstanceKey()); } session->RetrieveStatusBarDefaultVisibility(); - auto ret = session->Session::ConnectInner( - sessionStage, eventChannel, surfaceNode, systemConfig, property, token, pid, uid); + auto ret = LOCK_GUARD_EXPR(SCENE_GUARD, session->Session::ConnectInner( + sessionStage, eventChannel, surfaceNode, systemConfig, property, token, pid, uid)); if (ret != WSError::WS_OK) { return ret; } @@ -159,11 +159,12 @@ WSError SceneSession::Reconnect(const sptr& sessionStage, const s WLOGFE("session is null"); return WSError::WS_ERROR_DESTROYED_OBJECT; } - WSError ret = session->Session::Reconnect(sessionStage, eventChannel, surfaceNode, property, token, pid, uid); + WSError ret = LOCK_GUARD_EXPR(SCENE_GUARD, + session->Session::Reconnect(sessionStage, eventChannel, surfaceNode, property, token, pid, uid)); if (ret != WSError::WS_OK) { return ret; } - return session->ReconnectInner(property); + return LOCK_GUARD_EXPR(SCENE_GUARD, session->ReconnectInner(property)); }); } @@ -556,7 +557,7 @@ WSError SceneSession::Disconnect(bool isFromClient, const std::string& identityT WSError SceneSession::DisconnectTask(bool isFromClient, bool isSaveSnapshot) { - PostTask([weakThis = wptr(this), isFromClient, isSaveSnapshot]() { + PostTask([weakThis = wptr(this), isFromClient, isSaveSnapshot]() THREAD_SAFETY_GUARD(SCENE_GUARD) { auto session = weakThis.promote(); if (!session) { TLOGNE(WmsLogTag::WMS_LIFE, "session is null"); @@ -3288,7 +3289,7 @@ std::string SceneSession::GetUpdatedIconPath() const void SceneSession::UpdateNativeVisibility(bool visible) { - PostTask([weakThis = wptr(this), visible]() { + PostTask([weakThis = wptr(this), visible]() THREAD_SAFETY_GUARD(SCENE_GUARD) { auto session = weakThis.promote(); if (!session) { TLOGNE(WmsLogTag::WMS_LIFE, "session is null"); @@ -3306,7 +3307,6 @@ void SceneSession::UpdateNativeVisibility(bool visible) TLOGNW(WmsLogTag::WMS_SCB, "specific callback is null."); return; } - if (visible) { session->specificCallback_->onWindowInfoUpdate_(persistentId, WindowUpdateType::WINDOW_UPDATE_ADDED); } else { @@ -3316,7 +3316,7 @@ void SceneSession::UpdateNativeVisibility(bool visible) session->specificCallback_->onUpdateAvoidArea_(persistentId); // update private state if (!session->GetSessionProperty()) { - WLOGFE("UpdateNativeVisibility property is null"); + TLOGNE(WmsLogTag::WMS_SCB, "property is null"); return; } if (session->updatePrivateStateAndNotifyFunc_ != nullptr) { @@ -5960,9 +5960,9 @@ void SceneSession::UnregisterSessionChangeListeners() }, "UnregisterSessionChangeListeners"); } -void SceneSession::SetVisibilityChangedDetectFunc(const VisibilityChangedDetectFunc& func) +void SceneSession::SetVisibilityChangedDetectFunc(VisibilityChangedDetectFunc&& func) { - visibilityChangedDetectFunc_ = func; + LOCK_GUARD_EXPR(SCENE_GUARD, visibilityChangedDetectFunc_ = std::move(func)); } void SceneSession::SetDefaultDisplayIdIfNeed() diff --git a/window_scene/session/host/src/session.cpp b/window_scene/session/host/src/session.cpp index 32e14d0c79..21e8eb32cf 100644 --- a/window_scene/session/host/src/session.cpp +++ b/window_scene/session/host/src/session.cpp @@ -759,7 +759,7 @@ void Session::SetCallingPid(int32_t id) { TLOGI(WmsLogTag::WMS_EVENT, "id:%{public}d, %{public}d", persistentId_, id); callingPid_ = id; - if (isVisible_) { + if (visibilityChangedDetectFunc_ && isVisible_) { visibilityChangedDetectFunc_(callingPid_, false, isVisible_); } } diff --git a/window_scene/session_manager/include/scene_session_manager.h b/window_scene/session_manager/include/scene_session_manager.h index 8c1c458e47..5984f19247 100644 --- a/window_scene/session_manager/include/scene_session_manager.h +++ b/window_scene/session_manager/include/scene_session_manager.h @@ -636,7 +636,7 @@ private: sptr GetSceneSessionBySessionInfo(const SessionInfo& sessionInfo); void CreateRootSceneSession(); void InitSceneSession(sptr& sceneSession, const SessionInfo& sessionInfo, - const sptr& property); + const sptr& property) REQUIRES(SCENE_GUARD); void RegisterSessionExceptionFunc(const sptr& sceneSession); void NotifySessionForeground(const sptr& session, uint32_t reason, bool withAnimation); void NotifySessionBackground(const sptr& session, uint32_t reason, bool withAnimation, @@ -688,7 +688,7 @@ private: void RegisterGetStateFromManagerFunc(sptr& sceneSession); void RegisterSessionChangeByActionNotifyManagerFunc(sptr& sceneSession); - WSError DestroyDialogWithMainWindow(const sptr& sceneSession); + WSError DestroyDialogWithMainWindow(const sptr& sceneSession) REQUIRES(SCENE_GUARD); sptr FindMainWindowWithToken(sptr targetToken); WSError UpdateParentSessionForDialog(const sptr& sceneSession, sptr property); void UpdateCameraFloatWindowStatus(uint32_t accessTokenId, bool isShowing); @@ -730,7 +730,8 @@ private: WSError GetTotalUITreeInfo(std::string& dumpInfo); void PerformRegisterInRequestSceneSession(sptr& sceneSession); - WSError RequestSceneSessionActivationInner(sptr& sceneSession, bool isNewActive); + WSError RequestSceneSessionActivationInner(sptr& sceneSession, bool isNewActive) + REQUIRES(SCENE_GUARD); WSError SetBrightness(const sptr& sceneSession, float brightness); void PostBrightnessTask(float brightness); WSError UpdateBrightness(int32_t persistentId); @@ -824,7 +825,7 @@ private: void RecoverCachedSubSession(int32_t persistentId); void RecoverCachedDialogSession(int32_t persistentId); void RemoveFailRecoveredSession(); - void ClearUnrecoveredSessions(const std::vector& recoveredPersistentIds); + void ClearUnrecoveredSessions(const std::vector& recoveredPersistentIds) REQUIRES(SCENE_GUARD); SessionInfo RecoverSessionInfo(const sptr& property); bool IsNeedRecover(const int32_t persistentId); WSError CheckSessionPropertyOnRecovery(const sptr& property, bool isSpecificSession); @@ -847,7 +848,6 @@ private: std::map> sceneSessionMap_; std::map> systemTopSceneSessionMap_; std::map> nonSystemFloatSceneSessionMap_; - std::map visibleWindowCountMap_; sptr scbSessionHandler_; std::shared_ptr listenerController_; std::unordered_map, int32_t, SptrHash> remoteObjectMap_; @@ -1080,7 +1080,7 @@ private: WMError MakeScreenFoldData(const std::vector& screenFoldInfo, ScreenFoldData& screenFoldData); WMError CheckAndReportScreenFoldStatus(ScreenFoldData& data); WMError ReportScreenFoldStatus(const ScreenFoldData& data); - void RecoveryVisibilityPidCount(int32_t pid); + void RecoveryVisibilityPidCount(int32_t pid) REQUIRES(SCENE_GUARD); /* * Window Watermark @@ -1203,6 +1203,7 @@ private: * Window Lifecycle */ NotifyAppUseControlListFunc notifyAppUseControlListFunc_; + std::unordered_map visibleWindowCountMap_ GUARDED_BY(SCENE_GUARD); }; } // namespace OHOS::Rosen diff --git a/window_scene/session_manager/src/extension_session_manager.cpp b/window_scene/session_manager/src/extension_session_manager.cpp index 4226700e22..d8a7b6ee8c 100644 --- a/window_scene/session_manager/src/extension_session_manager.cpp +++ b/window_scene/session_manager/src/extension_session_manager.cpp @@ -178,7 +178,7 @@ WSError ExtensionSessionManager::RequestExtensionSessionDestruction(const sptr&& resultCallback) { wptr weakExtSession(extensionSession); - auto task = [this, weakExtSession, callback = std::move(resultCallback)]() { + auto task = [this, weakExtSession, callback = std::move(resultCallback)]() NO_THREAD_SAFETY_ANALYSIS { auto extSession = weakExtSession.promote(); if (extSession == nullptr) { WLOGFE("session is nullptr"); diff --git a/window_scene/session_manager/src/scene_session_manager.cpp b/window_scene/session_manager/src/scene_session_manager.cpp index efc2cbd33d..3cf967cd66 100644 --- a/window_scene/session_manager/src/scene_session_manager.cpp +++ b/window_scene/session_manager/src/scene_session_manager.cpp @@ -847,7 +847,7 @@ void SceneSessionManager::UpdateRecoveredSessionInfo(const std::vector& TLOGI(WmsLogTag::WMS_RECOVER, "persistentIds recovered=%{public}zu. CurrentUserId=%{public}d", recoveredPersistentIds.size(), currentUserId_.load()); - auto task = [this, recoveredPersistentIds]() { + taskScheduler_->PostAsyncTask([this, recoveredPersistentIds]() THREAD_SAFETY_GUARD(SCENE_GUARD) { ClearUnrecoveredSessions(recoveredPersistentIds); std::list abilitySessionInfos; for (const auto& persistentId : recoveredPersistentIds) { @@ -889,8 +889,7 @@ void SceneSessionManager::UpdateRecoveredSessionInfo(const std::vector& sceneSession->NotifySessionExceptionInner(sceneSessionInfo, false); } RemoveFailRecoveredSession(); - }; - taskScheduler_->PostAsyncTask(task, __func__); + }, __func__); } bool SceneSessionManager::ConfigAppWindowShadow(const WindowSceneConfig::ConfigItem& shadowConfig, @@ -2004,7 +2003,7 @@ sptr SceneSessionManager::RequestSceneSession(const SessionInfo& s MultiInstanceManager::GetInstance().IsMultiInstance(sceneSession->GetSessionInfo().bundleName_)) { MultiInstanceManager::GetInstance().FillInstanceKeyIfNeed(sceneSession); } - InitSceneSession(sceneSession, sessionInfo, property); + LOCK_GUARD_EXPR(SCENE_GUARD, InitSceneSession(sceneSession, sessionInfo, property)); if (CheckCollaboratorType(sceneSession->GetCollaboratorType())) { TLOGNI(WmsLogTag::WMS_LIFE, "%{public}s: ancoSceneState: %{public}d", where, sceneSession->GetSessionInfo().ancoSceneState); @@ -2233,7 +2232,7 @@ WSError SceneSessionManager::PrepareTerminate(int32_t persistentId, bool& isPrep WSError SceneSessionManager::RequestSceneSessionActivation(const sptr& sceneSession, bool isNewActive) { wptr weakSceneSession(sceneSession); - auto task = [this, weakSceneSession, isNewActive]() { + auto task = [this, weakSceneSession, isNewActive]() THREAD_SAFETY_GUARD(SCENE_GUARD) { sptr sceneSession = weakSceneSession.promote(); if (sceneSession == nullptr) { TLOGNE(WmsLogTag::WMS_MAIN, "Request active session is nullptr"); @@ -2641,7 +2640,7 @@ WSError SceneSessionManager::RequestSceneSessionDestruction(const sptr(sceneSession), - needRemoveSession, isSaveSnapshot, isForceClean]() { + needRemoveSession, isSaveSnapshot, isForceClean]() THREAD_SAFETY_GUARD(SCENE_GUARD) { auto sceneSession = weakSceneSession.promote(); if (sceneSession == nullptr) { TLOGNE(WmsLogTag::WMS_MAIN, "Destruct session is nullptr"); @@ -4695,11 +4694,12 @@ void SceneSessionManager::RegisterVisibilityChangedDetectFunc(const sptrSetVisibilityChangedDetectFunc( + [this](int32_t pid, bool isVisible, bool newIsVisible) THREAD_SAFETY_GUARD(SCENE_GUARD) { if (isVisible == newIsVisible || pid == -1) { return; } - sptr windowPidVisibilityInfo = sptr::MakeSptr(); + auto windowPidVisibilityInfo = sptr::MakeSptr(); windowPidVisibilityInfo->pid_ = pid; int32_t currentCount = 0; int32_t beforeCount = 0; @@ -4723,8 +4723,7 @@ void SceneSessionManager::RegisterVisibilityChangedDetectFunc(const sptrSetVisibilityChangedDetectFunc(func); + }); } void SceneSessionManager::RecoveryVisibilityPidCount(int32_t pid) @@ -7684,7 +7683,7 @@ sptr SceneSessionManager::GetCollaboratorByT WSError SceneSessionManager::RequestSceneSessionByCall(const sptr& sceneSession) { const char* const where = __func__; - auto task = [this, weakSceneSession = wptr(sceneSession), where] { + auto task = [this, weakSceneSession = wptr(sceneSession), where]() THREAD_SAFETY_GUARD(SCENE_GUARD) { auto sceneSession = weakSceneSession.promote(); if (sceneSession == nullptr) { TLOGNE(WmsLogTag::WMS_MAIN, "%{public}s: session is nullptr", where); @@ -10141,7 +10140,7 @@ void SceneSessionManager::FlushUIParams(ScreenId screenId, std::unordered_mapPostAsyncTask([this, screenId, uiParams = std::move(uiParams)]() THREAD_SAFETY_GUARD(SCENE_GUARD) { HITRACE_METER_FMT(HITRACE_TAG_WINDOW_MANAGER, "SceneSessionManager::FlushUIParams"); TLOGND(WmsLogTag::WMS_PIPELINE, "FlushUIParams"); { @@ -10211,8 +10210,7 @@ void SceneSessionManager::FlushUIParams(ScreenId screenId, std::unordered_mapPostAsyncTask(task, "FlushUIParams"); + }, __func__); } void SceneSessionManager::ProcessUpdateLastFocusedAppId(const std::vector& zOrderList) diff --git a/window_scene/test/unittest/BUILD.gn b/window_scene/test/unittest/BUILD.gn index 12afdc1273..ac6fd78d93 100644 --- a/window_scene/test/unittest/BUILD.gn +++ b/window_scene/test/unittest/BUILD.gn @@ -140,6 +140,8 @@ ohos_unittest("ws_scene_input_manager_test") { sources = [ "scene_input_manager_test.cpp" ] + cflags_cc = [ "-Wno-thread-safety" ] + deps = [ ":ws_unittest_common" ] external_deps = [ @@ -426,6 +428,8 @@ ohos_unittest("ws_session_test") { "session_test4.cpp", ] + cflags_cc = [ "-Wno-thread-safety" ] + deps = [ ":ws_unittest_common" ] external_deps = [ @@ -445,6 +449,8 @@ ohos_unittest("ws_session_lifecycle_test") { sources = [ "session_lifecycle_test.cpp" ] + cflags_cc = [ "-Wno-thread-safety" ] + deps = [ ":ws_unittest_common" ] external_deps = [ @@ -647,6 +653,8 @@ ohos_unittest("ws_scene_session_manager_test3") { sources = [ "scene_session_manager_test3.cpp" ] + cflags_cc = [ "-Wno-thread-safety" ] + deps = [ ":ws_unittest_common" ] external_deps = [ @@ -667,6 +675,8 @@ ohos_unittest("ws_scene_session_manager_test4") { sources = [ "scene_session_manager_test4.cpp" ] + cflags_cc = [ "-Wno-thread-safety" ] + deps = [ ":ws_unittest_common" ] external_deps = [ @@ -694,6 +704,8 @@ ohos_unittest("ws_scene_session_manager_test5") { } sources = [ "scene_session_manager_test5.cpp" ] + cflags_cc = [ "-Wno-thread-safety" ] + deps = [ ":ws_unittest_common", "${window_base_path}/test/common/utils:libtestutil", @@ -784,6 +796,8 @@ ohos_unittest("ws_scene_session_manager_test9") { sources = [ "scene_session_manager_test9.cpp" ] + cflags_cc = [ "-Wno-thread-safety" ] + deps = [ ":ws_unittest_common" ] external_deps = [ @@ -824,6 +838,8 @@ ohos_unittest("ws_scene_session_manager_test11") { sources = [ "scene_session_manager_test11.cpp" ] + cflags_cc = [ "-Wno-thread-safety" ] + deps = [ ":ws_unittest_common" ] external_deps = [ @@ -873,6 +889,8 @@ ohos_unittest("ws_ssmgr_specific_window_test") { sources = [ "ssmgr_specific_window_test.cpp" ] + cflags_cc = [ "-Wno-thread-safety" ] + deps = [ ":ws_unittest_common" ] external_deps = [ @@ -1034,6 +1052,8 @@ ohos_unittest("ws_scene_session_manager_supplement_test") { include_dirs = [ "${window_base_path}/test/common/utils/include/" ] sources = [ "scene_session_manager_supplement_test.cpp" ] + cflags_cc = [ "-Wno-thread-safety" ] + deps = [ ":ws_unittest_common", "${window_base_path}/test/common/utils:libtestutil", @@ -1066,6 +1086,8 @@ ohos_unittest("ws_scene_session_test") { "scene_session_test5.cpp", ] + cflags_cc = [ "-Wno-thread-safety" ] + deps = [ ":ws_unittest_common" ] external_deps = [ @@ -1099,6 +1121,8 @@ ohos_unittest("ws_scene_session_lifecycle_test") { sources = [ "scene_session_lifecycle_test.cpp" ] + cflags_cc = [ "-Wno-thread-safety" ] + deps = [ ":ws_unittest_common" ] external_deps = [ @@ -1113,6 +1137,8 @@ ohos_unittest("ws_scene_session_dirty_manager_test") { sources = [ "scene_session_dirty_manager_test.cpp" ] + cflags_cc = [ "-Wno-thread-safety" ] + deps = [ ":ws_unittest_common" ] external_deps = [ @@ -1135,6 +1161,8 @@ ohos_unittest("ws_scene_session_dirty_manager_test2") { sources = [ "scene_session_dirty_manager_test2.cpp" ] + cflags_cc = [ "-Wno-thread-safety" ] + deps = [ ":ws_unittest_common" ] external_deps = [ diff --git a/window_scene/test/unittest/scene_session_dirty_manager_test2.cpp b/window_scene/test/unittest/scene_session_dirty_manager_test2.cpp index 5a3ded024e..a22d7c4150 100644 --- a/window_scene/test/unittest/scene_session_dirty_manager_test2.cpp +++ b/window_scene/test/unittest/scene_session_dirty_manager_test2.cpp @@ -109,11 +109,9 @@ void InitSceneSession(sptr &sceneSession, int32_t pid, int windowI WSRect windowRect = {0, 0, 1270, 2700}; sceneSession->SetSessionRect(windowRect); - VisibilityChangedDetectFunc visibility = [](const int32_t pid, const bool isVisible, - const bool newIsVisible) { - return; - }; - sceneSession->SetVisibilityChangedDetectFunc(visibility); + sceneSession->SetVisibilityChangedDetectFunc([](int32_t pid, bool isVisible, bool newIsVisible) { + return; + }); sceneSession->SetCallingPid(pid); int32_t uid = 1315; sceneSession->SetCallingUid(uid); diff --git a/window_scene/test/unittest/session_test2.cpp b/window_scene/test/unittest/session_test2.cpp index ecadfce282..23ba50bca7 100644 --- a/window_scene/test/unittest/session_test2.cpp +++ b/window_scene/test/unittest/session_test2.cpp @@ -1527,7 +1527,6 @@ HWTEST_F(WindowSessionTest2, NeedCheckContextTransparent, Function | SmallTest | session_->SetContextTransparentFunc(func); ASSERT_EQ(session_->NeedCheckContextTransparent(), true); } - } } // namespace Rosen } // namespace OHOS \ No newline at end of file -- Gitee