diff --git a/services/BUILD.gn b/services/BUILD.gn index 22e404ad59263f0da6b01dabdc922acfe68adcbc..c437bae8c29d8f533fea6884889d83df38239478 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 0741f57d33f22ef0d39160d81a186be76f7defde..6b5962a04220b152fb8f6218a6282d299a4c5397 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 502d870f7820220ede7d07d0bff972b6692f68ba..c2668ea9165db207d87675b2738c515389509b42 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 { @@ -371,6 +372,10 @@ private: bool IsProximityClose(); #endif void StartSleepTimer(PowerState from); +#ifdef HAS_HIVIEWDFX_HISYSEVENT_PART + bool ReportScreenOffInvalidEvent(StateChangeReason reason); + bool ReportAbnormalScreenOffEvent(StateChangeReason reason); +#endif 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 f5b3c5638a1f55002ec18a8d6e5be8bec049697a..d6a254e1202e96554fe660c94464fba0b14ced7b 100644 --- a/services/native/src/power_mgr_service.cpp +++ b/services/native/src/power_mgr_service.cpp @@ -1464,6 +1464,12 @@ void PowerMgrService::QueryRunningLockListsInner(std::mapQueryRunningLockLists(runningLockLists); } +bool PowerMgrService::IsExistAudioStream(pid_t uid) +{ + std::lock_guard lock(lockMutex_); + return runningLockMgr_->IsExistAudioStream(uid); +} + bool PowerMgrService::RegisterRunningLockCallback(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 cbc2c59056685068983c28f6b7a7052777b4feb6..13872186db1fad1b8187a515bff9c1d0b9603607 100644 --- a/services/native/src/power_state_machine.cpp +++ b/services/native/src/power_state_machine.cpp @@ -70,6 +70,10 @@ 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"; +#ifdef HAS_HIVIEWDFX_HISYSEVENT_PART +constexpr int32_t SCREEN_OFF_ABNORMAL = 0; +constexpr int32_t SCREEN_OFF_INVALID = 1; +#endif } #ifdef POWER_MANAGER_ENABLE_WATCH_CUSTOMIZED_SCREEN_COMMON_EVENT_RULES const std::vector WATCH_CUSTOMIZED_STATE_CHANGE_REASONS { @@ -363,6 +367,9 @@ void PowerStateMachine::EmplaceInactive() && isDozeEnabled_.load(std::memory_order_relaxed)) { state = DisplayState::DISPLAY_DOZE; } +#ifdef HAS_HIVIEWDFX_HISYSEVENT_PART + ReportScreenOffInvalidEvent(reason); +#endif 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); @@ -443,6 +450,9 @@ 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); } +#ifdef HAS_HIVIEWDFX_HISYSEVENT_PART + ReportAbnormalScreenOffEvent(reason); +#endif 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. @@ -2536,5 +2546,70 @@ bool PowerStateMachine::IsSwitchOpenByPath() POWER_HILOGI(FEATURE_POWER_STATE, "IsSwitchOpenByPath status: %{public}d", status); return status; } + +bool PowerStateMachine::ReportScreenOffInvalidEvent(StateChangeReason reason) +{ + if (reason != StateChangeReason::STATE_CHANGE_REASON_HARD_KEY) { + POWER_HILOGD(FEATURE_POWER_STATE, "ReportScreenOffInvalidEvent fail, reason: %{public}d", reason); + return false; + } + FFRTTask task = [this] { + // condition 1: no audiolock + // condition 2: has screenlock + if (!IsRunningLockEnabled(RunningLockType::RUNNINGLOCK_BACKGROUND_AUDIO)) { + std::map screenOnLockLists; + auto pms = DelayedSpSingleton::GetInstance(); + if (pms == nullptr) { + POWER_HILOGE(FEATURE_POWER_STATE, "ReportScreenOffInvalidEvent fail, Pms is nullptr"); + return; + } + pms->QueryRunningLockListsInner(screenOnLockLists); + for (const auto &it : screenOnLockLists) { + 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", ""); + } + } + }; + FFRTUtils::SubmitTask(task); + return true; +} + +bool PowerStateMachine::ReportAbnormalScreenOffEvent(StateChangeReason reason) +{ + if (reason != StateChangeReason::STATE_CHANGE_REASON_TIMEOUT && + reason != StateChangeReason::STATE_CHANGE_REASON_TIMEOUT_NO_SCREEN_LOCK) { + POWER_HILOGD(FEATURE_POWER_STATE, "ReportAbnormalScreenOffEvent fail, reason: %{public}d", reason); + return false; + } + FFRTTask task = [this] { + // condition 1: no cast + if (forceTimingOut_.load()) { + POWER_HILOGD(FEATURE_POWER_STATE, "ReportAbnormalScreenOffEvent fail, Currently casting"); + return; + } + auto pms = DelayedSpSingleton::GetInstance(); + if (pms == nullptr) { + POWER_HILOGE(FEATURE_POWER_STATE, "ReportAbnormalScreenOffEvent fail, Pms is nullptr"); + return; + } + // condition 2: current visible window is not desktop + // condition 3: audio stream exist in the window + std::vector> infos; + Rosen::WindowManagerLite::GetInstance().GetVisibilityWindowInfo(infos); + for (const auto &it: infos) { + if (it != nullptr && it->visibilityState_ < Rosen::WindowVisibilityState::WINDOW_LAYER_STATE_MAX + && it->bundleName_.compare(it->abilityName_) != 0 && pms->IsExistAudioStream(it->uid_)) { + 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", ""); + } + } + }; + FFRTUtils::SubmitTask(task); + return true; +} } // 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 570e6192921d521f9c7931d32d3cc857921ab0d1..be89a18fc7b2e4aa764a98702c661e4dc1fa3ffb 100644 --- a/services/native/src/runninglock/running_lock_mgr.cpp +++ b/services/native/src/runninglock/running_lock_mgr.cpp @@ -953,6 +953,11 @@ void RunningLockMgr::SetProximity(uint32_t status) } } +bool RunningLockMgr::IsExistAudioStream(pid_t uid) +{ + return runninglockProxy_->IsExistAudioStream(uid); +} + bool RunningLockMgr::IsProximityClose() { return proximityController_.IsClose(); diff --git a/services/native/src/runninglock/running_lock_mgr.h b/services/native/src/runninglock/running_lock_mgr.h index 88f3cc28b727f3e1d568928108f747f2b9c6a732..6ca4ef2400baef2890b7d9417b96627d1f53862b 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 699bcd6a667627b5677df1c91eae5a53f73ef8a4..4e5a5fa726d908aa42b714c16e66be80e45ce445 100644 --- a/services/native/src/runninglock/running_lock_proxy.cpp +++ b/services/native/src/runninglock/running_lock_proxy.cpp @@ -349,6 +349,39 @@ 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_) { + TokenWorkSourceMap& tokenWksMap = proxyItem.second; + for (auto &tokenWksItem : tokenWksMap) { + auto lockInner = rlmgr->GetRunningLockInner(tokenWksItem.first); + if (lockInner == nullptr) { + POWER_HILOGW(FEATURE_RUNNING_LOCK, "RunninglockInner is nullptr"); + continue; + } + if (lockInner->GetType() != RunningLockType::RUNNINGLOCK_BACKGROUND_AUDIO) { + continue; + } + WksMap& wksMap = tokenWksItem.second.first; + auto wksMapIter = wksMap.find(uid); + if (wksMapIter != wksMap.end() && !wksMapIter->second.second) { + 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 87062493035a089a2b99cfaac1a8f82f22640dbc..8bd72bd27ef3abb35de79327c6d02eb23deceb19 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 80cde21cb12d291d2426868e95b689fa1abf11cc..ff0a01cf3776b69fe8bf50498942873c46df1f8e 100644 --- a/test/apitest/inner_api/shutdown/BUILD.gn +++ b/test/apitest/inner_api/shutdown/BUILD.gn @@ -58,6 +58,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 e1b464e5e088e33456b43c5fbb5c7e8ce19dbcd5..88c04bbf4fd414f0961d86098e5aa081656bc543 100644 --- a/test/fuzztest/asyncshutdowncallback_fuzzer/BUILD.gn +++ b/test/fuzztest/asyncshutdowncallback_fuzzer/BUILD.gn @@ -69,6 +69,7 @@ ohos_fuzztest("AsyncShutdownCallbackFuzzTest") { "libxml2:libxml2", "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 88bf822b3f471254b8453a5f7336d56aaeacdf6f..a724e6f9a2916d31632cbb20d8c6585930be5ec1 100644 --- a/test/fuzztest/createrunninglock_fuzzer/BUILD.gn +++ b/test/fuzztest/createrunninglock_fuzzer/BUILD.gn @@ -69,6 +69,7 @@ ohos_fuzztest("CreateRunningLockFuzzTest") { "libxml2:libxml2", "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 2c8d1a3a7842ea83efe8414be0cffc18dc4231df..3174204dd12104c401317dec555b4ddfb44732cc 100644 --- a/test/fuzztest/forcesuspenddevice_fuzzer/BUILD.gn +++ b/test/fuzztest/forcesuspenddevice_fuzzer/BUILD.gn @@ -69,6 +69,7 @@ ohos_fuzztest("ForceSuspendDeviceFuzzTest") { "libxml2:libxml2", "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 70eda90dcd7d4637af6b8c2f9ddc524b5d6ac243..5081d1d310e606d00e8f38256ceab0fe9641ee1a 100644 --- a/test/fuzztest/getsetdevicemode_fuzzer/BUILD.gn +++ b/test/fuzztest/getsetdevicemode_fuzzer/BUILD.gn @@ -69,6 +69,7 @@ ohos_fuzztest("GetSetDeviceModeFuzzTest") { "libxml2:libxml2", "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 14049f5d3768acaa617bf91ae39bf02a1523c807..7e64ff2de234a45d03072734e4bcce9095adb1e3 100644 --- a/test/fuzztest/getstate_fuzzer/BUILD.gn +++ b/test/fuzztest/getstate_fuzzer/BUILD.gn @@ -68,6 +68,7 @@ ohos_fuzztest("GetStateFuzzTest") { "libxml2:libxml2", "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 c8822fadc2cd235a0cc91760051f394b8297dc47..45c50a0b25640960223c8e4070c3e58ad55d4750 100644 --- a/test/fuzztest/hibernate_fuzzer/BUILD.gn +++ b/test/fuzztest/hibernate_fuzzer/BUILD.gn @@ -68,6 +68,7 @@ ohos_fuzztest("HibernateFuzzTest") { "libxml2:libxml2", "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 7f46109f303575f5192bbb065ba2ac36d73b2614..ba3b2ccd16a9685246cebdb57092595d862c5f50 100644 --- a/test/fuzztest/iscollaborationscreenon_fuzzer/BUILD.gn +++ b/test/fuzztest/iscollaborationscreenon_fuzzer/BUILD.gn @@ -69,6 +69,7 @@ ohos_fuzztest("IsCollaborationScreenOnFuzzTest") { "libxml2:libxml2", "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 d5f0a9c764f091bb0a7993f1463d06692cab5c86..958ca94b3a7302f62ac251960daff54f84d5b8e1 100644 --- a/test/fuzztest/isfoldscreenon_fuzzer/BUILD.gn +++ b/test/fuzztest/isfoldscreenon_fuzzer/BUILD.gn @@ -68,6 +68,7 @@ ohos_fuzztest("IsFoldScreenOnFuzzTest") { "libxml2:libxml2", "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 8816956d6bd4ae606ee05582d53ebd0aa62acbd1..c786d9c909dd7c0acf6dd7161e59c23c6e5b3123 100644 --- a/test/fuzztest/isrunninglocktypesupported_fuzzer/BUILD.gn +++ b/test/fuzztest/isrunninglocktypesupported_fuzzer/BUILD.gn @@ -69,6 +69,7 @@ ohos_fuzztest("IsRunningLockTypeSupportedFuzzTest") { "libxml2:libxml2", "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 b9e9d0f31e29020ae725810b80d3900e76d606b9..b67795b1d4ff25699e093f2744e62243b8d6a205 100644 --- a/test/fuzztest/isscreenon_fuzzer/BUILD.gn +++ b/test/fuzztest/isscreenon_fuzzer/BUILD.gn @@ -68,6 +68,7 @@ ohos_fuzztest("IsScreenOnFuzzTest") { "libxml2:libxml2", "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 b9ed4b7c0e7f952fe0722716e1b59567b0a1b7dc..dfb70ed0d8ec6fef8122ef7bff8abd859a21656b 100644 --- a/test/fuzztest/isstandby_fuzzer/BUILD.gn +++ b/test/fuzztest/isstandby_fuzzer/BUILD.gn @@ -68,6 +68,7 @@ ohos_fuzztest("IsStandbyFuzzTest") { "libxml2:libxml2", "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 1b2a35f8c2ecc9e4bd707b608ce14aeae04d7451..d6ded0ad6d2f6936fce6a6f298f42edc10f78092 100644 --- a/test/fuzztest/lockscreenaftertimingout_fuzzer/BUILD.gn +++ b/test/fuzztest/lockscreenaftertimingout_fuzzer/BUILD.gn @@ -69,6 +69,7 @@ ohos_fuzztest("LockScreenAfterTimingOutFuzzTest") { "libxml2:libxml2", "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 0531119237c1b8b53b765401b80a2f1960815303..caca781e7cb8d2a6bf73a9271283418d0d73a106 100644 --- a/test/fuzztest/lockunlockisused_fuzzer/BUILD.gn +++ b/test/fuzztest/lockunlockisused_fuzzer/BUILD.gn @@ -69,6 +69,7 @@ ohos_fuzztest("LockUnLockIsUsedFuzzTest") { "libxml2:libxml2", "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 aaeb5c7d9465cfb014e637f65b901766103ea1ce..bf58f7d6869deb6271eca5b565aed75b4067bcf3 100644 --- a/test/fuzztest/overridescreenofftime_fuzzer/BUILD.gn +++ b/test/fuzztest/overridescreenofftime_fuzzer/BUILD.gn @@ -69,6 +69,7 @@ ohos_fuzztest("OverrideScreenOffTimeFuzzTest") { "libxml2:libxml2", "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 8f8896125ca35c51bde4bd0940944f74a721609c..8c0a68b8a192109f1e0a9f22df15ad672be06768 100644 --- a/test/fuzztest/powermodecallback_fuzzer/BUILD.gn +++ b/test/fuzztest/powermodecallback_fuzzer/BUILD.gn @@ -69,6 +69,7 @@ ohos_fuzztest("PowerModeCallbackFuzzTest") { "libxml2:libxml2", "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 3f267ada9824f0ab06a3f7244b1dfe698aa13fd2..1a25629ab1ae65cf85445f5c8d4081d7a17b3552 100644 --- a/test/fuzztest/powerstatecallback_fuzzer/BUILD.gn +++ b/test/fuzztest/powerstatecallback_fuzzer/BUILD.gn @@ -69,6 +69,7 @@ ohos_fuzztest("PowerStateCallbackFuzzTest") { "libxml2:libxml2", "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 f9da0f0b9baa7a5805c5e95ea644538ed6f369d2..05c5d68859f0e9c3d1fa349120cf91e66051c79c 100644 --- a/test/fuzztest/proxyrunninglock_fuzzer/BUILD.gn +++ b/test/fuzztest/proxyrunninglock_fuzzer/BUILD.gn @@ -69,6 +69,7 @@ ohos_fuzztest("ProxyRunningLockFuzzTest") { "libxml2:libxml2", "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 d595909b58e32179e8488f5e0f280d8e96f6cddb..739741d1baf79c3249b92934d3f0e61fd3944311 100644 --- a/test/fuzztest/proxyrunninglocks_fuzzer/BUILD.gn +++ b/test/fuzztest/proxyrunninglocks_fuzzer/BUILD.gn @@ -69,6 +69,7 @@ ohos_fuzztest("ProxyRunningLocksFuzzTest") { "libxml2:libxml2", "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 e606441dd241ebf2744a43e3870780aecaf04abb..79ba3e9609899991e56aa4d24996516f3eeb94a2 100644 --- a/test/fuzztest/queryrunninglocklists_fuzzer/BUILD.gn +++ b/test/fuzztest/queryrunninglocklists_fuzzer/BUILD.gn @@ -69,6 +69,7 @@ ohos_fuzztest("QueryRunningLockListsFuzzTest") { "libxml2:libxml2", "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 fc9bc91b559a3540cfe84e7488dc4af4b95c25c9..a5f99b51c5e0917091436855e9a03f81a8d375a8 100644 --- a/test/fuzztest/rebootdevice_fuzzer/BUILD.gn +++ b/test/fuzztest/rebootdevice_fuzzer/BUILD.gn @@ -68,6 +68,7 @@ ohos_fuzztest("RebootDeviceFuzzTest") { "libxml2:libxml2", "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 eb4b205150bf2d9e86ff1e6a1870e4afb0e628e1..0c08af1aed495ce6b63590683227e58756603566 100644 --- a/test/fuzztest/refreshactivity_fuzzer/BUILD.gn +++ b/test/fuzztest/refreshactivity_fuzzer/BUILD.gn @@ -69,6 +69,7 @@ ohos_fuzztest("RefreshActivityFuzzTest") { "libxml2:libxml2", "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 c0e92730e3d71e53c38677eeaff85364b2c1631b..572c90d81b82b2e71e9b515337288c66d721eafe 100644 --- a/test/fuzztest/releaserunninglock_fuzzer/BUILD.gn +++ b/test/fuzztest/releaserunninglock_fuzzer/BUILD.gn @@ -69,6 +69,7 @@ ohos_fuzztest("ReleaseRunningLockFuzzTest") { "libxml2:libxml2", "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 5042f7f92eb56d9879aeb8e7abc6463e8b6fd167..a420aea2216319e3abbd5eb28a44d27baf129516 100644 --- a/test/fuzztest/resetrunninglocks_fuzzer/BUILD.gn +++ b/test/fuzztest/resetrunninglocks_fuzzer/BUILD.gn @@ -69,6 +69,7 @@ ohos_fuzztest("ResetRunningLocksFuzzTest") { "libxml2:libxml2", "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 4f79f85a7ac611cd6fe006045131308a1f46f508..00157244089b9dce5c1518dcae92d0e7c99fdc5d 100644 --- a/test/fuzztest/runninglockcallback_fuzzer/BUILD.gn +++ b/test/fuzztest/runninglockcallback_fuzzer/BUILD.gn @@ -69,6 +69,7 @@ ohos_fuzztest("RunningLockCallbackFuzzTest") { "libxml2:libxml2", "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 404ea65f34b205bd7aebf8e8fec1b993d606fdec..d40d0769cfd1820d6a0eca6b858af5c970246569 100644 --- a/test/fuzztest/screenstatecallback_fuzzer/BUILD.gn +++ b/test/fuzztest/screenstatecallback_fuzzer/BUILD.gn @@ -69,6 +69,7 @@ ohos_fuzztest("ScreenStateCallbackFuzzTest") { "libxml2:libxml2", "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 14e9056d3eaafd064e735dbfb713ab414a75ae10..11462c6829aeee7362d76ee3eb669d9500560dc3 100644 --- a/test/fuzztest/setdisplaysuspend_fuzzer/BUILD.gn +++ b/test/fuzztest/setdisplaysuspend_fuzzer/BUILD.gn @@ -69,6 +69,7 @@ ohos_fuzztest("SetDisplaySuspendFuzzTest") { "libxml2:libxml2", "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 a789cdc0e7e1475d4a19ea97ac9fa66aebf786c9..93499befcfd79d280650da026bd71dd7a69a43c2 100644 --- a/test/fuzztest/setforcetimingout_fuzzer/BUILD.gn +++ b/test/fuzztest/setforcetimingout_fuzzer/BUILD.gn @@ -69,6 +69,7 @@ ohos_fuzztest("SetForceTimingOutFuzzTest") { "libxml2:libxml2", "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 909e6c3fdf6ae664ffb75deada85a54d0cee38e4..93600915564db89a078537b51d20efb0c3aec4da 100644 --- a/test/fuzztest/setsuspendtag_fuzzer/BUILD.gn +++ b/test/fuzztest/setsuspendtag_fuzzer/BUILD.gn @@ -68,6 +68,7 @@ ohos_fuzztest("SetSuspendTagFuzzTest") { "libxml2:libxml2", "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 6cd02553aebaeca9048b5d98f4c80fe7d2ef8723..e26f670a0da3f5a0150fcea67541e0b9c63a61e7 100644 --- a/test/fuzztest/shelldump_fuzzer/BUILD.gn +++ b/test/fuzztest/shelldump_fuzzer/BUILD.gn @@ -68,6 +68,7 @@ ohos_fuzztest("ShellDumpFuzzTest") { "libxml2:libxml2", "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 0baf9e917e7a0bb797ec3e390187297cdba78842..576c5707935fac069970791287912cb53c368a0f 100644 --- a/test/fuzztest/shutdowndevice_fuzzer/BUILD.gn +++ b/test/fuzztest/shutdowndevice_fuzzer/BUILD.gn @@ -68,6 +68,7 @@ ohos_fuzztest("ShutDownDeviceFuzzTest") { "libxml2:libxml2", "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 280be3cadaecdf8607b22271487236527059d2ef..28507057b099fecf08566adca8042160fc3e7958 100644 --- a/test/fuzztest/suspenddevice_fuzzer/BUILD.gn +++ b/test/fuzztest/suspenddevice_fuzzer/BUILD.gn @@ -68,6 +68,7 @@ ohos_fuzztest("SuspendDeviceFuzzTest") { "libxml2:libxml2", "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 8b3c7f1eca51bdfe44768cb42c9801ca003605b3..b2aa4b8d6dee6c9b1b515bcfd764d88539ae52d7 100644 --- a/test/fuzztest/synchibernatecallback_fuzzer/BUILD.gn +++ b/test/fuzztest/synchibernatecallback_fuzzer/BUILD.gn @@ -69,6 +69,7 @@ ohos_fuzztest("SyncHibernateCallbackFuzzTest") { "libxml2:libxml2", "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 faff00c53a08d5e394acb27e575241981c6c6d37..6ac45a309988749a0eac8c04b9535f4c8f8a6286 100644 --- a/test/fuzztest/syncshutdowncallback_fuzzer/BUILD.gn +++ b/test/fuzztest/syncshutdowncallback_fuzzer/BUILD.gn @@ -69,6 +69,7 @@ ohos_fuzztest("SyncShutdownCallbackFuzzTest") { "libxml2:libxml2", "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 f936cee1c5dd97c6b09c06fd73de2f963f5cd338..2edcf02b1b97f2906e9d3353aa3771ed429218f2 100644 --- a/test/fuzztest/syncsleepcallback_fuzzer/BUILD.gn +++ b/test/fuzztest/syncsleepcallback_fuzzer/BUILD.gn @@ -69,6 +69,7 @@ ohos_fuzztest("SyncSleepCallbackFuzzTest") { "libxml2:libxml2", "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 02130828238f7d04966deb13e094ce61b7be7049..c22cdc227754625362cd6fcc7060a18f13949a53 100644 --- a/test/fuzztest/takeovershutdowncallback_fuzzer/BUILD.gn +++ b/test/fuzztest/takeovershutdowncallback_fuzzer/BUILD.gn @@ -69,6 +69,7 @@ ohos_fuzztest("TakeOverShutdownCallbackFuzzTest") { "libxml2:libxml2", "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 62db1f4b46e12c33ea3ea45192be08503991e19f..807bd712c7130d09c20e5d43f9a2859e7a9cf4da 100644 --- a/test/fuzztest/wakeupdevice_fuzzer/BUILD.gn +++ b/test/fuzztest/wakeupdevice_fuzzer/BUILD.gn @@ -68,6 +68,7 @@ ohos_fuzztest("WakeupDeviceFuzzTest") { "libxml2:libxml2", "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 14ea2f4bee7486ad4ccabffa9a8fb801083d16d5..d49c268bf405e6f9b4a5800c86fabfbe8caf49e3 100644 --- a/test/systemtest/BUILD.gn +++ b/test/systemtest/BUILD.gn @@ -56,6 +56,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 50847cb4e1ab69936d5670fae315b5af4bceaf83..e6390f059abd8bfe2224b135e71c244e0d7dac89 100644 --- a/test/unittest/BUILD.gn +++ b/test/unittest/BUILD.gn @@ -76,6 +76,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 df0ea72ddb64c0436f4cd2894dd4fd148895de40..000310aacb27bc43a51494d41270b670ce26fe58 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/native_power_state_machine_test.cpp b/test/unittest/src/native_power_state_machine_test.cpp index d142bb4ccf121d99acc105daa91eaf6a29c57bf4..54ff5b77da29b7fa190232b14ca70d6da8b9fd11 100644 --- a/test/unittest/src/native_power_state_machine_test.cpp +++ b/test/unittest/src/native_power_state_machine_test.cpp @@ -345,6 +345,11 @@ HWTEST_F(NativePowerStateMachineTest, NativePowerStateMachine007, TestSize.Level pmsTest->UnLock(token); EXPECT_EQ(pmsTest->IsUsed(token), false); + + ret = stateMachine->ReportScreenOffInvalidEvent(StateChangeReason::STATE_CHANGE_REASON_HARD_KEY); + EXPECT_TRUE(ret); + ret = stateMachine->ReportAbnormalScreenOffEvent(StateChangeReason::STATE_CHANGE_REASON_TIMEOUT); + EXPECT_TRUE(ret); POWER_HILOGI(LABEL_TEST, "NativePowerStateMachine007 function end!"); GTEST_LOG_(INFO) << "NativePowerStateMachine007: Suspend Device end."; } diff --git a/test/unittest/src/servicetest/BUILD.gn b/test/unittest/src/servicetest/BUILD.gn index 75635d4c2e728d3dce51c7330d53063bfadf21b9..af34dbd02055b6bc9e677a78f86fe7507a817fe2 100644 --- a/test/unittest/src/servicetest/BUILD.gn +++ b/test/unittest/src/servicetest/BUILD.gn @@ -64,6 +64,7 @@ deps_ex = [ "safwk:system_ability_fwk", "samgr:samgr_proxy", "googletest:gtest_main", + "window_manager:libwm_lite", ] if (has_sensors_sensor_part) {