From 646199263ce80ee1f09e500cbc48df5941f8d4eb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=90=B4=E6=B0=B8=E9=91=AB?= Date: Fri, 16 May 2025 14:17:45 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E6=81=AF=E5=B1=8F=E5=BC=82=E5=B8=B8?= =?UTF-8?q?=E6=A3=80=E6=B5=8B=E6=89=93=E7=82=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 吴永鑫 --- services/BUILD.gn | 1 + services/native/include/power_mgr_service.h | 1 + services/native/include/power_state_machine.h | 3 ++ services/native/src/power_mgr_service.cpp | 5 ++ services/native/src/power_state_machine.cpp | 54 +++++++++++++++++++ .../src/runninglock/running_lock_mgr.cpp | 4 ++ .../native/src/runninglock/running_lock_mgr.h | 1 + .../src/runninglock/running_lock_proxy.cpp | 40 ++++++++++++++ .../src/runninglock/running_lock_proxy.h | 1 + test/apitest/inner_api/shutdown/BUILD.gn | 1 + .../asyncshutdowncallback_fuzzer/BUILD.gn | 1 + .../createrunninglock_fuzzer/BUILD.gn | 1 + .../forcesuspenddevice_fuzzer/BUILD.gn | 1 + .../fuzztest/getsetdevicemode_fuzzer/BUILD.gn | 1 + test/fuzztest/getstate_fuzzer/BUILD.gn | 1 + test/fuzztest/hibernate_fuzzer/BUILD.gn | 1 + .../iscollaborationscreenon_fuzzer/BUILD.gn | 1 + test/fuzztest/isfoldscreenon_fuzzer/BUILD.gn | 1 + .../BUILD.gn | 1 + test/fuzztest/isscreenon_fuzzer/BUILD.gn | 1 + test/fuzztest/isstandby_fuzzer/BUILD.gn | 1 + .../lockscreenaftertimingout_fuzzer/BUILD.gn | 1 + .../fuzztest/lockunlockisused_fuzzer/BUILD.gn | 1 + .../overridescreenofftime_fuzzer/BUILD.gn | 1 + .../powermodecallback_fuzzer/BUILD.gn | 1 + .../powerstatecallback_fuzzer/BUILD.gn | 1 + .../fuzztest/proxyrunninglock_fuzzer/BUILD.gn | 1 + .../proxyrunninglocks_fuzzer/BUILD.gn | 1 + .../queryrunninglocklists_fuzzer/BUILD.gn | 1 + test/fuzztest/rebootdevice_fuzzer/BUILD.gn | 1 + test/fuzztest/refreshactivity_fuzzer/BUILD.gn | 1 + .../releaserunninglock_fuzzer/BUILD.gn | 1 + .../resetrunninglocks_fuzzer/BUILD.gn | 1 + .../runninglockcallback_fuzzer/BUILD.gn | 1 + .../screenstatecallback_fuzzer/BUILD.gn | 1 + .../setdisplaysuspend_fuzzer/BUILD.gn | 1 + .../setforcetimingout_fuzzer/BUILD.gn | 1 + test/fuzztest/setsuspendtag_fuzzer/BUILD.gn | 1 + test/fuzztest/shelldump_fuzzer/BUILD.gn | 1 + test/fuzztest/shutdowndevice_fuzzer/BUILD.gn | 1 + test/fuzztest/suspenddevice_fuzzer/BUILD.gn | 1 + .../synchibernatecallback_fuzzer/BUILD.gn | 1 + .../syncshutdowncallback_fuzzer/BUILD.gn | 1 + .../syncsleepcallback_fuzzer/BUILD.gn | 1 + .../takeovershutdowncallback_fuzzer/BUILD.gn | 1 + test/fuzztest/wakeupdevice_fuzzer/BUILD.gn | 1 + test/systemtest/BUILD.gn | 1 + test/unittest/BUILD.gn | 1 + .../src/interface_test/running_lock_test.cpp | 24 +++++++++ test/unittest/src/servicetest/BUILD.gn | 1 + 50 files changed, 174 insertions(+) diff --git a/services/BUILD.gn b/services/BUILD.gn index c1495f03..6a6f3518 100644 --- a/services/BUILD.gn +++ b/services/BUILD.gn @@ -127,6 +127,7 @@ ohos_shared_library("powermgrservice") { "libxml2:libxml2", "safwk:system_ability_fwk", "samgr:samgr_proxy", + "window_manager:libwm_lite", ] if (power_manager_feature_tv_dreaming) { diff --git a/services/native/include/power_mgr_service.h b/services/native/include/power_mgr_service.h index 0741f57d..6b5962a0 100644 --- a/services/native/include/power_mgr_service.h +++ b/services/native/include/power_mgr_service.h @@ -166,6 +166,7 @@ public: #endif bool IsCollaborationState(); void QueryRunningLockListsInner(std::map& runningLockLists); + bool IsExistAudioStream(pid_t uid); #ifdef POWER_MANAGER_WAKEUP_ACTION void WakeupActionControllerInit(); #endif diff --git a/services/native/include/power_state_machine.h b/services/native/include/power_state_machine.h index 65678146..313471ce 100644 --- a/services/native/include/power_state_machine.h +++ b/services/native/include/power_state_machine.h @@ -31,6 +31,7 @@ #include "running_lock_info.h" #include "power_mgr_notify.h" #include "proximity_controller_base.h" +#include "window_manager_lite.h" namespace OHOS { namespace PowerMgr { @@ -368,6 +369,8 @@ private: bool IsProximityClose(); #endif void StartSleepTimer(PowerState from); + void ReportScreenOffInvalidEvent(); + void ReportAbnormalScreenOffEvent(); const wptr pms_; std::shared_ptr ffrtTimer_ {nullptr}; diff --git a/services/native/src/power_mgr_service.cpp b/services/native/src/power_mgr_service.cpp index e10f232a..d1a0cb8e 100644 --- a/services/native/src/power_mgr_service.cpp +++ b/services/native/src/power_mgr_service.cpp @@ -1476,6 +1476,11 @@ bool PowerMgrService::RegisterRunningLockCallback(const sptrIsExistAudioStream(uid); +} + bool PowerMgrService::UnRegisterRunningLockCallback(const sptr& callback) { std::lock_guard lock(lockMutex_); diff --git a/services/native/src/power_state_machine.cpp b/services/native/src/power_state_machine.cpp index 4cf06fb9..4bd12027 100644 --- a/services/native/src/power_state_machine.cpp +++ b/services/native/src/power_state_machine.cpp @@ -70,6 +70,8 @@ std::atomic_bool g_prepareResult = true; pid_t g_callSetForceTimingOutPid = 0; pid_t g_callSetForceTimingOutUid = 0; const std::string LID_STATUS_SCENE_NAME = "lid_status"; +constexpr int32_t SCREEN_OFF_ABNORMAL = 0; +constexpr int32_t SCREEN_OFF_INVALID = 1; } PowerStateMachine::PowerStateMachine(const wptr& pms, const std::shared_ptr& ffrtTimer) : pms_(pms), ffrtTimer_(ffrtTimer), currentState_(PowerState::UNKNOWN) @@ -352,6 +354,9 @@ void PowerStateMachine::EmplaceInactive() && isDozeEnabled_.load(std::memory_order_relaxed)) { state = DisplayState::DISPLAY_DOZE; } + if (IsRunningLockEnabled(RunningLockType::RUNNINGLOCK_SCREEN)) { + ReportScreenOffInvalidEvent(); + } uint32_t ret = this->stateAction_->SetDisplayState(state, reason); if (ret != ActionResult::SUCCESS) { POWER_HILOGE(FEATURE_POWER_STATE, "Failed to go to INACTIVE, display error, ret: %{public}u", ret); @@ -432,6 +437,7 @@ void PowerStateMachine::EmplaceDim() // failed but not return, still need to set screen off POWER_HILOGE(FEATURE_POWER_STATE, "Failed to go to DIM, display error, ret: %{public}u", ret); } + ReportAbnormalScreenOffEvent(); CancelDelayTimer(PowerStateMachine::CHECK_USER_ACTIVITY_TIMEOUT_MSG); CancelDelayTimer(PowerStateMachine::CHECK_USER_ACTIVITY_OFF_TIMEOUT_MSG); // Set a timer without checking runninglock, but the actual timeout event can still be blocked. @@ -2493,5 +2499,53 @@ bool PowerStateMachine::IsSwitchOpenByPath() POWER_HILOGI(FEATURE_POWER_STATE, "IsSwitchOpenByPath status: %{public}d", status); return status; } + +void PowerStateMachine::ReportScreenOffInvalidEvent() +{ + // when screenlock and no audiostream + auto pms = pms_.promote(); + if (pms == nullptr) { + POWER_HILOGE(FEATURE_POWER_STATE, "Pms is nullptr"); + return; + } + std::map screenOnLockLists; + pms_->QueryRunningLockListsInner(screenOnLockLists); + for (auto it : screenOnLockLists) { + if (!IsRunningLockEnabled(RunningLockType::RUNNINGLOCK_BACKGROUND_AUDIO)) { +#ifdef HAS_HIVIEWDFX_HISYSEVENT_PART + HiSysEventWrite(HiviewDFX::HiSysEvent::Domain::POWER, "SCREEN_OFF_EXCEPTION", + HiviewDFX::HiSysEvent::EventType::FAULT, "EXCEPTION_TYPE", SCREEN_OFF_INVALID, + "PID", it.second.pid, "UID", it.second.uid, "BUNDLE_NAME", it.second.bundleName.c_str(), + "ABILITY_NAME", "", "WINDOW_ID", 0, "APP_BEHAVIOR", ""); +#endif + } + } +} + +void PowerStateMachine::ReportAbnormalScreenOffEvent() +{ + // The current visible window is not desktop + std::vector> infos; + Rosen::WindowManagerLite::GetInstance().GetVisibilityWindowInfo(infos); + for (const auto &it: infos) { + if (it->visibilityState_ < Rosen::WindowVisibilityState::WINDOW_LAYER_STATE_MAX && + it->bundleName_.compare(it->abilityName_) != 0) { + auto pms = pms_.promote(); + if (pms == nullptr) { + POWER_HILOGE(FEATURE_POWER_STATE, "Pms is nullptr"); + return; + } + // Audio streams exist in tne window, but no projection + if (pms_->IsExistAudioStream(it->uid_) && !forceTimingOut_.load()) { +#ifdef HAS_HIVIEWDFX_HISYSEVENT_PART + HiSysEventWrite(HiviewDFX::HiSysEvent::Domain::POWER, "SCREEN_OFF_EXCEPTION", + HiviewDFX::HiSysEvent::EventType::FAULT, "EXCEPTION_TYPE", SCREEN_OFF_ABNORMAL, + "PID", it->pid_, "UID", it->uid_, "BUNDLE_NAME", it->bundleName_.c_str(), "ABILITY_NAME", + it->abilityName_.c_str(), "WINDOW_ID", it->windowId_, "APP_BEHAVIOR", ""); +#endif + } + } + } +} } // namespace PowerMgr } // namespace OHOS diff --git a/services/native/src/runninglock/running_lock_mgr.cpp b/services/native/src/runninglock/running_lock_mgr.cpp index 570e6192..582af871 100644 --- a/services/native/src/runninglock/running_lock_mgr.cpp +++ b/services/native/src/runninglock/running_lock_mgr.cpp @@ -939,6 +939,10 @@ void RunningLockMgr::ProximityController::OnAway() } } +bool RunningLockMgr::IsExistAudioStream(pid_t uid) { + return runninglockProxy_->IsExistAudioStream(uid); +} + void RunningLockMgr::SetProximity(uint32_t status) { switch (status) { diff --git a/services/native/src/runninglock/running_lock_mgr.h b/services/native/src/runninglock/running_lock_mgr.h index 88f3cc28..6ca4ef24 100644 --- a/services/native/src/runninglock/running_lock_mgr.h +++ b/services/native/src/runninglock/running_lock_mgr.h @@ -82,6 +82,7 @@ public: #endif void DumpInfo(std::string& result); void EnableMock(IRunningLockAction* mockAction); + bool IsExistAudioStream(pid_t uid); private: void AsyncWakeup(); diff --git a/services/native/src/runninglock/running_lock_proxy.cpp b/services/native/src/runninglock/running_lock_proxy.cpp index 3ee484e1..43040a4f 100644 --- a/services/native/src/runninglock/running_lock_proxy.cpp +++ b/services/native/src/runninglock/running_lock_proxy.cpp @@ -349,6 +349,46 @@ bool RunningLockProxy::UpdateProxyState(pid_t pid, pid_t uid, const sptr::GetInstance(); + if (pms == nullptr) { + POWER_HILOGW(FEATURE_RUNNING_LOCK, "Power service is nullptr"); + return false; + } + auto rlmgr = pms->GetRunningLockMgr(); + if (rlmgr == nullptr) { + POWER_HILOGW(FEATURE_RUNNING_LOCK, "RunninglockMgr is nullptr"); + return false; + } + for (auto &proxyItem : proxyMap_) { + auto& tokenWksMap = proxyItem.second; + for (const auto &tokenWksItem : tokenWksMap) { + auto lockInner = rlmgr->GetRunningLockInner(tokenWksItem.first); + if (lockInner == nullptr) { + POWER_HILOGW(FEATURE_RUNNING_LOCK, "RunninglockMgr is nullptr"); + continue; + } + if (lockInner->GetType() != RunningLockType::RUNNINGLOCK_BACKGROUND_AUDIO) { + continue; + } + auto& wksMap = tokenWksItem.second.first; + bool existAudioStream = false; + for (auto &wksMapItem : wksMap) { + // Audio stream exist in the uid window + if (wksMapItem.first == uid && !wksMapItem.second.second) { + existAudioStream = true; + break; + } + } + if (wksMap.find(uid) != wksMap.end() && existAudioStream) { + return true; + } + } + } + return false; +} + void RunningLockProxy::Clear() { proxyMap_.clear(); diff --git a/services/native/src/runninglock/running_lock_proxy.h b/services/native/src/runninglock/running_lock_proxy.h index 87062493..8bd72bd2 100644 --- a/services/native/src/runninglock/running_lock_proxy.h +++ b/services/native/src/runninglock/running_lock_proxy.h @@ -48,6 +48,7 @@ public: std::string DumpProxyInfo(); void ResetRunningLocks(); bool UpdateProxyState(pid_t pid, pid_t uid, const sptr& remoteObj, bool state); + bool IsExistAudioStream(pid_t uid); private: std::string AssembleProxyKey(pid_t pid, pid_t uid); void ProxyInner(const sptr& remoteObj, const std::string& bundleNames, RunningLockEvent event); diff --git a/test/apitest/inner_api/shutdown/BUILD.gn b/test/apitest/inner_api/shutdown/BUILD.gn index 874a6a6a..85672138 100644 --- a/test/apitest/inner_api/shutdown/BUILD.gn +++ b/test/apitest/inner_api/shutdown/BUILD.gn @@ -54,6 +54,7 @@ deps_ex = [ "power_manager:power_ffrt", "safwk:system_ability_fwk", "samgr:samgr_proxy", + "window_manager:libwm_lite", ] if (has_sensors_sensor_part) { diff --git a/test/fuzztest/asyncshutdowncallback_fuzzer/BUILD.gn b/test/fuzztest/asyncshutdowncallback_fuzzer/BUILD.gn index 55902fc3..6339938a 100644 --- a/test/fuzztest/asyncshutdowncallback_fuzzer/BUILD.gn +++ b/test/fuzztest/asyncshutdowncallback_fuzzer/BUILD.gn @@ -68,6 +68,7 @@ ohos_fuzztest("AsyncShutdownCallbackFuzzTest") { "ipc:ipc_core", "power_manager:power_ffrt", "safwk:system_ability_fwk", + "window_manager:libwm_lite", ] defines = [] diff --git a/test/fuzztest/createrunninglock_fuzzer/BUILD.gn b/test/fuzztest/createrunninglock_fuzzer/BUILD.gn index a2f43028..9e154ee6 100644 --- a/test/fuzztest/createrunninglock_fuzzer/BUILD.gn +++ b/test/fuzztest/createrunninglock_fuzzer/BUILD.gn @@ -68,6 +68,7 @@ ohos_fuzztest("CreateRunningLockFuzzTest") { "ipc:ipc_core", "power_manager:power_ffrt", "safwk:system_ability_fwk", + "window_manager:libwm_lite", ] defines = [] diff --git a/test/fuzztest/forcesuspenddevice_fuzzer/BUILD.gn b/test/fuzztest/forcesuspenddevice_fuzzer/BUILD.gn index d2e95926..4709ff99 100644 --- a/test/fuzztest/forcesuspenddevice_fuzzer/BUILD.gn +++ b/test/fuzztest/forcesuspenddevice_fuzzer/BUILD.gn @@ -68,6 +68,7 @@ ohos_fuzztest("ForceSuspendDeviceFuzzTest") { "ipc:ipc_core", "power_manager:power_ffrt", "safwk:system_ability_fwk", + "window_manager:libwm_lite", ] defines = [] diff --git a/test/fuzztest/getsetdevicemode_fuzzer/BUILD.gn b/test/fuzztest/getsetdevicemode_fuzzer/BUILD.gn index 0930fbf7..c0414f2b 100644 --- a/test/fuzztest/getsetdevicemode_fuzzer/BUILD.gn +++ b/test/fuzztest/getsetdevicemode_fuzzer/BUILD.gn @@ -68,6 +68,7 @@ ohos_fuzztest("GetSetDeviceModeFuzzTest") { "ipc:ipc_core", "power_manager:power_ffrt", "safwk:system_ability_fwk", + "window_manager:libwm_lite", ] defines = [] diff --git a/test/fuzztest/getstate_fuzzer/BUILD.gn b/test/fuzztest/getstate_fuzzer/BUILD.gn index 0a0aa431..df56aa53 100644 --- a/test/fuzztest/getstate_fuzzer/BUILD.gn +++ b/test/fuzztest/getstate_fuzzer/BUILD.gn @@ -67,6 +67,7 @@ ohos_fuzztest("GetStateFuzzTest") { "ipc:ipc_core", "power_manager:power_ffrt", "safwk:system_ability_fwk", + "window_manager:libwm_lite", ] defines = [] diff --git a/test/fuzztest/hibernate_fuzzer/BUILD.gn b/test/fuzztest/hibernate_fuzzer/BUILD.gn index bd603fef..7d2db4cb 100644 --- a/test/fuzztest/hibernate_fuzzer/BUILD.gn +++ b/test/fuzztest/hibernate_fuzzer/BUILD.gn @@ -67,6 +67,7 @@ ohos_fuzztest("HibernateFuzzTest") { "ipc:ipc_core", "power_manager:power_ffrt", "safwk:system_ability_fwk", + "window_manager:libwm_lite", ] defines = [] diff --git a/test/fuzztest/iscollaborationscreenon_fuzzer/BUILD.gn b/test/fuzztest/iscollaborationscreenon_fuzzer/BUILD.gn index 1e9e2858..2aa5b857 100644 --- a/test/fuzztest/iscollaborationscreenon_fuzzer/BUILD.gn +++ b/test/fuzztest/iscollaborationscreenon_fuzzer/BUILD.gn @@ -68,6 +68,7 @@ ohos_fuzztest("IsCollaborationScreenOnFuzzTest") { "ipc:ipc_core", "power_manager:power_ffrt", "safwk:system_ability_fwk", + "window_manager:libwm_lite", ] defines = [] diff --git a/test/fuzztest/isfoldscreenon_fuzzer/BUILD.gn b/test/fuzztest/isfoldscreenon_fuzzer/BUILD.gn index 61057ee3..ed278848 100644 --- a/test/fuzztest/isfoldscreenon_fuzzer/BUILD.gn +++ b/test/fuzztest/isfoldscreenon_fuzzer/BUILD.gn @@ -67,6 +67,7 @@ ohos_fuzztest("IsFoldScreenOnFuzzTest") { "ipc:ipc_core", "power_manager:power_ffrt", "safwk:system_ability_fwk", + "window_manager:libwm_lite", ] defines = [] diff --git a/test/fuzztest/isrunninglocktypesupported_fuzzer/BUILD.gn b/test/fuzztest/isrunninglocktypesupported_fuzzer/BUILD.gn index 89c45974..b9451362 100644 --- a/test/fuzztest/isrunninglocktypesupported_fuzzer/BUILD.gn +++ b/test/fuzztest/isrunninglocktypesupported_fuzzer/BUILD.gn @@ -68,6 +68,7 @@ ohos_fuzztest("IsRunningLockTypeSupportedFuzzTest") { "ipc:ipc_core", "power_manager:power_ffrt", "safwk:system_ability_fwk", + "window_manager:libwm_lite", ] defines = [] diff --git a/test/fuzztest/isscreenon_fuzzer/BUILD.gn b/test/fuzztest/isscreenon_fuzzer/BUILD.gn index 6f36e4b7..235958ed 100644 --- a/test/fuzztest/isscreenon_fuzzer/BUILD.gn +++ b/test/fuzztest/isscreenon_fuzzer/BUILD.gn @@ -67,6 +67,7 @@ ohos_fuzztest("IsScreenOnFuzzTest") { "ipc:ipc_core", "power_manager:power_ffrt", "safwk:system_ability_fwk", + "window_manager:libwm_lite", ] defines = [] diff --git a/test/fuzztest/isstandby_fuzzer/BUILD.gn b/test/fuzztest/isstandby_fuzzer/BUILD.gn index 0edfac90..b4513cdc 100644 --- a/test/fuzztest/isstandby_fuzzer/BUILD.gn +++ b/test/fuzztest/isstandby_fuzzer/BUILD.gn @@ -67,6 +67,7 @@ ohos_fuzztest("IsStandbyFuzzTest") { "ipc:ipc_core", "power_manager:power_ffrt", "safwk:system_ability_fwk", + "window_manager:libwm_lite", ] defines = [] diff --git a/test/fuzztest/lockscreenaftertimingout_fuzzer/BUILD.gn b/test/fuzztest/lockscreenaftertimingout_fuzzer/BUILD.gn index f1a7e208..49736afd 100644 --- a/test/fuzztest/lockscreenaftertimingout_fuzzer/BUILD.gn +++ b/test/fuzztest/lockscreenaftertimingout_fuzzer/BUILD.gn @@ -68,6 +68,7 @@ ohos_fuzztest("LockScreenAfterTimingOutFuzzTest") { "jsoncpp:jsoncpp", "power_manager:power_ffrt", "safwk:system_ability_fwk", + "window_manager:libwm_lite", ] defines = [] diff --git a/test/fuzztest/lockunlockisused_fuzzer/BUILD.gn b/test/fuzztest/lockunlockisused_fuzzer/BUILD.gn index 5c531e82..f4e398cf 100644 --- a/test/fuzztest/lockunlockisused_fuzzer/BUILD.gn +++ b/test/fuzztest/lockunlockisused_fuzzer/BUILD.gn @@ -68,6 +68,7 @@ ohos_fuzztest("LockUnLockIsUsedFuzzTest") { "ipc:ipc_core", "power_manager:power_ffrt", "safwk:system_ability_fwk", + "window_manager:libwm_lite", ] defines = [] diff --git a/test/fuzztest/overridescreenofftime_fuzzer/BUILD.gn b/test/fuzztest/overridescreenofftime_fuzzer/BUILD.gn index 9bb12af3..56c479ad 100644 --- a/test/fuzztest/overridescreenofftime_fuzzer/BUILD.gn +++ b/test/fuzztest/overridescreenofftime_fuzzer/BUILD.gn @@ -68,6 +68,7 @@ ohos_fuzztest("OverrideScreenOffTimeFuzzTest") { "ipc:ipc_core", "power_manager:power_ffrt", "safwk:system_ability_fwk", + "window_manager:libwm_lite", ] defines = [] diff --git a/test/fuzztest/powermodecallback_fuzzer/BUILD.gn b/test/fuzztest/powermodecallback_fuzzer/BUILD.gn index e0bc0aec..59eba1fc 100644 --- a/test/fuzztest/powermodecallback_fuzzer/BUILD.gn +++ b/test/fuzztest/powermodecallback_fuzzer/BUILD.gn @@ -68,6 +68,7 @@ ohos_fuzztest("PowerModeCallbackFuzzTest") { "ipc:ipc_core", "power_manager:power_ffrt", "safwk:system_ability_fwk", + "window_manager:libwm_lite", ] defines = [] diff --git a/test/fuzztest/powerstatecallback_fuzzer/BUILD.gn b/test/fuzztest/powerstatecallback_fuzzer/BUILD.gn index 1b73f0b7..dc6a5bfa 100644 --- a/test/fuzztest/powerstatecallback_fuzzer/BUILD.gn +++ b/test/fuzztest/powerstatecallback_fuzzer/BUILD.gn @@ -68,6 +68,7 @@ ohos_fuzztest("PowerStateCallbackFuzzTest") { "ipc:ipc_core", "power_manager:power_ffrt", "safwk:system_ability_fwk", + "window_manager:libwm_lite", ] defines = [] diff --git a/test/fuzztest/proxyrunninglock_fuzzer/BUILD.gn b/test/fuzztest/proxyrunninglock_fuzzer/BUILD.gn index 67f63a44..24153f29 100644 --- a/test/fuzztest/proxyrunninglock_fuzzer/BUILD.gn +++ b/test/fuzztest/proxyrunninglock_fuzzer/BUILD.gn @@ -68,6 +68,7 @@ ohos_fuzztest("ProxyRunningLockFuzzTest") { "ipc:ipc_core", "power_manager:power_ffrt", "safwk:system_ability_fwk", + "window_manager:libwm_lite", ] defines = [] diff --git a/test/fuzztest/proxyrunninglocks_fuzzer/BUILD.gn b/test/fuzztest/proxyrunninglocks_fuzzer/BUILD.gn index 4b8315cd..07e595ce 100644 --- a/test/fuzztest/proxyrunninglocks_fuzzer/BUILD.gn +++ b/test/fuzztest/proxyrunninglocks_fuzzer/BUILD.gn @@ -68,6 +68,7 @@ ohos_fuzztest("ProxyRunningLocksFuzzTest") { "ipc:ipc_core", "power_manager:power_ffrt", "safwk:system_ability_fwk", + "window_manager:libwm_lite", ] defines = [] diff --git a/test/fuzztest/queryrunninglocklists_fuzzer/BUILD.gn b/test/fuzztest/queryrunninglocklists_fuzzer/BUILD.gn index aa0854d8..41ee512f 100644 --- a/test/fuzztest/queryrunninglocklists_fuzzer/BUILD.gn +++ b/test/fuzztest/queryrunninglocklists_fuzzer/BUILD.gn @@ -68,6 +68,7 @@ ohos_fuzztest("QueryRunningLockListsFuzzTest") { "ipc:ipc_core", "power_manager:power_ffrt", "safwk:system_ability_fwk", + "window_manager:libwm_lite", ] defines = [] diff --git a/test/fuzztest/rebootdevice_fuzzer/BUILD.gn b/test/fuzztest/rebootdevice_fuzzer/BUILD.gn index e90fb0b1..7de3efc4 100644 --- a/test/fuzztest/rebootdevice_fuzzer/BUILD.gn +++ b/test/fuzztest/rebootdevice_fuzzer/BUILD.gn @@ -67,6 +67,7 @@ ohos_fuzztest("RebootDeviceFuzzTest") { "ipc:ipc_core", "power_manager:power_ffrt", "safwk:system_ability_fwk", + "window_manager:libwm_lite", ] defines = [] diff --git a/test/fuzztest/refreshactivity_fuzzer/BUILD.gn b/test/fuzztest/refreshactivity_fuzzer/BUILD.gn index d9b23f89..5df5de66 100644 --- a/test/fuzztest/refreshactivity_fuzzer/BUILD.gn +++ b/test/fuzztest/refreshactivity_fuzzer/BUILD.gn @@ -68,6 +68,7 @@ ohos_fuzztest("RefreshActivityFuzzTest") { "ipc:ipc_core", "power_manager:power_ffrt", "safwk:system_ability_fwk", + "window_manager:libwm_lite", ] defines = [] diff --git a/test/fuzztest/releaserunninglock_fuzzer/BUILD.gn b/test/fuzztest/releaserunninglock_fuzzer/BUILD.gn index 8fee4eaf..2116b675 100644 --- a/test/fuzztest/releaserunninglock_fuzzer/BUILD.gn +++ b/test/fuzztest/releaserunninglock_fuzzer/BUILD.gn @@ -68,6 +68,7 @@ ohos_fuzztest("ReleaseRunningLockFuzzTest") { "ipc:ipc_core", "power_manager:power_ffrt", "safwk:system_ability_fwk", + "window_manager:libwm_lite", ] defines = [] diff --git a/test/fuzztest/resetrunninglocks_fuzzer/BUILD.gn b/test/fuzztest/resetrunninglocks_fuzzer/BUILD.gn index d329905d..6b49d767 100644 --- a/test/fuzztest/resetrunninglocks_fuzzer/BUILD.gn +++ b/test/fuzztest/resetrunninglocks_fuzzer/BUILD.gn @@ -68,6 +68,7 @@ ohos_fuzztest("ResetRunningLocksFuzzTest") { "ipc:ipc_core", "power_manager:power_ffrt", "safwk:system_ability_fwk", + "window_manager:libwm_lite", ] defines = [] diff --git a/test/fuzztest/runninglockcallback_fuzzer/BUILD.gn b/test/fuzztest/runninglockcallback_fuzzer/BUILD.gn index c88e2406..54a4ddbd 100644 --- a/test/fuzztest/runninglockcallback_fuzzer/BUILD.gn +++ b/test/fuzztest/runninglockcallback_fuzzer/BUILD.gn @@ -68,6 +68,7 @@ ohos_fuzztest("RunningLockCallbackFuzzTest") { "ipc:ipc_core", "power_manager:power_ffrt", "safwk:system_ability_fwk", + "window_manager:libwm_lite", ] defines = [] diff --git a/test/fuzztest/screenstatecallback_fuzzer/BUILD.gn b/test/fuzztest/screenstatecallback_fuzzer/BUILD.gn index 2be27e9a..7de96439 100644 --- a/test/fuzztest/screenstatecallback_fuzzer/BUILD.gn +++ b/test/fuzztest/screenstatecallback_fuzzer/BUILD.gn @@ -68,6 +68,7 @@ ohos_fuzztest("ScreenStateCallbackFuzzTest") { "ipc:ipc_core", "power_manager:power_ffrt", "safwk:system_ability_fwk", + "window_manager:libwm_lite", ] defines = [] diff --git a/test/fuzztest/setdisplaysuspend_fuzzer/BUILD.gn b/test/fuzztest/setdisplaysuspend_fuzzer/BUILD.gn index 70ccb8eb..3a734be5 100644 --- a/test/fuzztest/setdisplaysuspend_fuzzer/BUILD.gn +++ b/test/fuzztest/setdisplaysuspend_fuzzer/BUILD.gn @@ -68,6 +68,7 @@ ohos_fuzztest("SetDisplaySuspendFuzzTest") { "ipc:ipc_core", "power_manager:power_ffrt", "safwk:system_ability_fwk", + "window_manager:libwm_lite", ] defines = [] diff --git a/test/fuzztest/setforcetimingout_fuzzer/BUILD.gn b/test/fuzztest/setforcetimingout_fuzzer/BUILD.gn index 32d741ae..653bea58 100644 --- a/test/fuzztest/setforcetimingout_fuzzer/BUILD.gn +++ b/test/fuzztest/setforcetimingout_fuzzer/BUILD.gn @@ -68,6 +68,7 @@ ohos_fuzztest("SetForceTimingOutFuzzTest") { "jsoncpp:jsoncpp", "power_manager:power_ffrt", "safwk:system_ability_fwk", + "window_manager:libwm_lite", ] defines = [] diff --git a/test/fuzztest/setsuspendtag_fuzzer/BUILD.gn b/test/fuzztest/setsuspendtag_fuzzer/BUILD.gn index 8d49e924..c3ddc0ec 100644 --- a/test/fuzztest/setsuspendtag_fuzzer/BUILD.gn +++ b/test/fuzztest/setsuspendtag_fuzzer/BUILD.gn @@ -67,6 +67,7 @@ ohos_fuzztest("SetSuspendTagFuzzTest") { "ipc:ipc_core", "power_manager:power_ffrt", "safwk:system_ability_fwk", + "window_manager:libwm_lite", ] defines = [] diff --git a/test/fuzztest/shelldump_fuzzer/BUILD.gn b/test/fuzztest/shelldump_fuzzer/BUILD.gn index 8993e976..5384ebf4 100644 --- a/test/fuzztest/shelldump_fuzzer/BUILD.gn +++ b/test/fuzztest/shelldump_fuzzer/BUILD.gn @@ -67,6 +67,7 @@ ohos_fuzztest("ShellDumpFuzzTest") { "ipc:ipc_core", "power_manager:power_ffrt", "safwk:system_ability_fwk", + "window_manager:libwm_lite", ] defines = [] diff --git a/test/fuzztest/shutdowndevice_fuzzer/BUILD.gn b/test/fuzztest/shutdowndevice_fuzzer/BUILD.gn index 564985c3..85c6b326 100644 --- a/test/fuzztest/shutdowndevice_fuzzer/BUILD.gn +++ b/test/fuzztest/shutdowndevice_fuzzer/BUILD.gn @@ -67,6 +67,7 @@ ohos_fuzztest("ShutDownDeviceFuzzTest") { "ipc:ipc_core", "power_manager:power_ffrt", "safwk:system_ability_fwk", + "window_manager:libwm_lite", ] defines = [] diff --git a/test/fuzztest/suspenddevice_fuzzer/BUILD.gn b/test/fuzztest/suspenddevice_fuzzer/BUILD.gn index cc5b61b6..9a0ae420 100644 --- a/test/fuzztest/suspenddevice_fuzzer/BUILD.gn +++ b/test/fuzztest/suspenddevice_fuzzer/BUILD.gn @@ -67,6 +67,7 @@ ohos_fuzztest("SuspendDeviceFuzzTest") { "ipc:ipc_core", "power_manager:power_ffrt", "safwk:system_ability_fwk", + "window_manager:libwm_lite", ] defines = [] diff --git a/test/fuzztest/synchibernatecallback_fuzzer/BUILD.gn b/test/fuzztest/synchibernatecallback_fuzzer/BUILD.gn index e7f52f97..0b64e88a 100644 --- a/test/fuzztest/synchibernatecallback_fuzzer/BUILD.gn +++ b/test/fuzztest/synchibernatecallback_fuzzer/BUILD.gn @@ -68,6 +68,7 @@ ohos_fuzztest("SyncHibernateCallbackFuzzTest") { "ipc:ipc_core", "power_manager:power_ffrt", "safwk:system_ability_fwk", + "window_manager:libwm_lite", ] defines = [] diff --git a/test/fuzztest/syncshutdowncallback_fuzzer/BUILD.gn b/test/fuzztest/syncshutdowncallback_fuzzer/BUILD.gn index a7ff865e..74c33bb6 100644 --- a/test/fuzztest/syncshutdowncallback_fuzzer/BUILD.gn +++ b/test/fuzztest/syncshutdowncallback_fuzzer/BUILD.gn @@ -68,6 +68,7 @@ ohos_fuzztest("SyncShutdownCallbackFuzzTest") { "ipc:ipc_core", "power_manager:power_ffrt", "safwk:system_ability_fwk", + "window_manager:libwm_lite", ] defines = [] diff --git a/test/fuzztest/syncsleepcallback_fuzzer/BUILD.gn b/test/fuzztest/syncsleepcallback_fuzzer/BUILD.gn index 6ba9e783..1b7b8871 100644 --- a/test/fuzztest/syncsleepcallback_fuzzer/BUILD.gn +++ b/test/fuzztest/syncsleepcallback_fuzzer/BUILD.gn @@ -68,6 +68,7 @@ ohos_fuzztest("SyncSleepCallbackFuzzTest") { "ipc:ipc_core", "power_manager:power_ffrt", "safwk:system_ability_fwk", + "window_manager:libwm_lite", ] defines = [] diff --git a/test/fuzztest/takeovershutdowncallback_fuzzer/BUILD.gn b/test/fuzztest/takeovershutdowncallback_fuzzer/BUILD.gn index 6f186dec..e71db36c 100644 --- a/test/fuzztest/takeovershutdowncallback_fuzzer/BUILD.gn +++ b/test/fuzztest/takeovershutdowncallback_fuzzer/BUILD.gn @@ -68,6 +68,7 @@ ohos_fuzztest("TakeOverShutdownCallbackFuzzTest") { "ipc:ipc_core", "power_manager:power_ffrt", "safwk:system_ability_fwk", + "window_manager:libwm_lite", ] defines = [] diff --git a/test/fuzztest/wakeupdevice_fuzzer/BUILD.gn b/test/fuzztest/wakeupdevice_fuzzer/BUILD.gn index 644a650f..62f84676 100644 --- a/test/fuzztest/wakeupdevice_fuzzer/BUILD.gn +++ b/test/fuzztest/wakeupdevice_fuzzer/BUILD.gn @@ -67,6 +67,7 @@ ohos_fuzztest("WakeupDeviceFuzzTest") { "ipc:ipc_core", "power_manager:power_ffrt", "safwk:system_ability_fwk", + "window_manager:libwm_lite", ] defines = [] diff --git a/test/systemtest/BUILD.gn b/test/systemtest/BUILD.gn index 963d52bb..d7fb7561 100644 --- a/test/systemtest/BUILD.gn +++ b/test/systemtest/BUILD.gn @@ -54,6 +54,7 @@ deps_ex = [ "power_manager:power_ffrt", "safwk:system_ability_fwk", "samgr:samgr_proxy", + "window_manager:libwm_lite", ] if (has_sensors_sensor_part) { diff --git a/test/unittest/BUILD.gn b/test/unittest/BUILD.gn index 15b113f4..cd68f884 100644 --- a/test/unittest/BUILD.gn +++ b/test/unittest/BUILD.gn @@ -75,6 +75,7 @@ deps_ex = [ "safwk:system_ability_fwk", "samgr:samgr_proxy", "window_manager:libdm_lite", + "window_manager:libwm_lite", ] if (has_sensors_sensor_part) { diff --git a/test/unittest/src/interface_test/running_lock_test.cpp b/test/unittest/src/interface_test/running_lock_test.cpp index 3e0d0edd..4206c1ea 100644 --- a/test/unittest/src/interface_test/running_lock_test.cpp +++ b/test/unittest/src/interface_test/running_lock_test.cpp @@ -538,4 +538,28 @@ HWTEST_F (RunningLockTest, RunningLockTest019, TestSize.Level1) EXPECT_TRUE(runninglockProxy->DecreaseProxyCnt(pid, uid)); POWER_HILOGI(LABEL_TEST, "RunningLockTest019 function end!"); } + +/** + * @tc.name: RunningLockTest020 + * @tc.desc: Test UpdateWorkSource function + * @tc.type: FUNC + * @tc.require + */ +HWTEST_F (RunningLockTest, RunningLockTest020, TestSize.Level1) +{ + POWER_HILOGI(LABEL_TEST, "RunningLockTest020 function start!"); + auto runninglockProxy = std::make_shared(); + auto& powerMgrClient = PowerMgrClient::GetInstance(); + std::shared_ptr runningLock = powerMgrClient.CreateRunningLock("backgroudAudio.test020", + RunningLockType::RUNNINGLOCK_BACKGROUND_AUDIO); + ASSERT_NE(runningLock, nullptr); + + pid_t curUid = 1; + runningLock->Lock(); + EXPECT_TRUE(runningLock->IsUsed()); + EXPECT_FALSE(runninglockProxy->IsExistAudioStream(curUid)); + runningLock->UnLock(); + EXPECT_FALSE(runningLock->IsUsed()); + POWER_HILOGI(LABEL_TEST, "RunningLockTest020 function end!"); +} } // namespace \ No newline at end of file diff --git a/test/unittest/src/servicetest/BUILD.gn b/test/unittest/src/servicetest/BUILD.gn index 40c80aa6..a2b8cd87 100644 --- a/test/unittest/src/servicetest/BUILD.gn +++ b/test/unittest/src/servicetest/BUILD.gn @@ -63,6 +63,7 @@ deps_ex = [ "power_manager:power_ffrt", "safwk:system_ability_fwk", "samgr:samgr_proxy", + "window_manager:libwm_lite", ] if (has_sensors_sensor_part) { -- Gitee