From 0f10ef6643337b7e7cfcc987324fb3b8fcf9ced0 Mon Sep 17 00:00:00 2001 From: yanghang Date: Tue, 22 Jul 2025 17:06:59 +0800 Subject: [PATCH] fix: Modification of the near-light delay task Signed-off-by: yanghang --- .../src/runninglock/running_lock_mgr.cpp | 30 ++++++++++++++++++- .../native/src/runninglock/running_lock_mgr.h | 1 + 2 files changed, 30 insertions(+), 1 deletion(-) diff --git a/services/native/src/runninglock/running_lock_mgr.cpp b/services/native/src/runninglock/running_lock_mgr.cpp index 504c05a2..9b4e57f6 100644 --- a/services/native/src/runninglock/running_lock_mgr.cpp +++ b/services/native/src/runninglock/running_lock_mgr.cpp @@ -42,6 +42,7 @@ const string TASK_RUNNINGLOCK_FORCEUNLOCK = "RunningLock_ForceUnLock"; constexpr int32_t VALID_PID_LIMIT = 1; sptr g_runningLockCallback = nullptr; const string INCALL_APP_BUNDLE_NAME = "com.ohos.callui"; +const string WECHAT_APP_BUNDLE_NAME = "com.tencent.wechat"; #ifdef HAS_SENSORS_SENSOR_PART constexpr uint32_t FOREGROUND_INCALL_DELAY_TIME_MS = 300; constexpr uint32_t BACKGROUND_INCALL_DELAY_TIME_MS = 800; @@ -935,6 +936,33 @@ void RunningLockMgr::ProximityController::OnAway() runningLock->HandleProximityAwayEvent(); } +bool RunningLockMgr::IsVoiceAppForeground() +{ + if (PowerUtils::IsForegroundApplication(INCALL_APP_BUNDLE_NAME)) { + POWER_HILOGI(FEATURE_RUNNING_LOCK, "call in foreground"); + return true; + } + + if (!PowerUtils::IsForegroundApplication(WECHAT_APP_BUNDLE_NAME)) { + POWER_HILOGI(FEATURE_RUNNING_LOCK, "WeChat is not in foreground"); + return false; + } + + std::lock_guard lock(mutex_); + for (auto& iter : runningLocks_) { + if (iter.second == nullptr) { + POWER_HILOGE(FEATURE_RUNNING_LOCK, "GetRunningLockInnerByName nullptr"); + continue; + } + if (iter.second->GetBundleName() == WECHAT_APP_BUNDLE_NAME && + iter.second->GetType() == RunningLockType::RUNNINGLOCK_PROXIMITY_SCREEN_CONTROL) { + POWER_HILOGI(FEATURE_RUNNING_LOCK, "WeChat is in foreground with voicing or calling."); + return true; + } + } + return false; +} + void RunningLockMgr::HandleProximityCloseEvent() { auto pms = DelayedSpSingleton::GetInstance(); @@ -950,7 +978,7 @@ void RunningLockMgr::HandleProximityCloseEvent() if (GetValidRunningLockNum(RunningLockType::RUNNINGLOCK_PROXIMITY_SCREEN_CONTROL) > 0) { POWER_HILOGI(FEATURE_RUNNING_LOCK, "Change state to INACITVE when holding PROXIMITY LOCK"); uint32_t delayTime = FOREGROUND_INCALL_DELAY_TIME_MS; - if (!PowerUtils::IsForegroundApplication(INCALL_APP_BUNDLE_NAME)) { + if (!IsVoiceAppForeground()) { delayTime = BACKGROUND_INCALL_DELAY_TIME_MS; } POWER_HILOGI(FEATURE_RUNNING_LOCK, "Start proximity-screen-off timer, delay time:%{public}u", delayTime); diff --git a/services/native/src/runninglock/running_lock_mgr.h b/services/native/src/runninglock/running_lock_mgr.h index ef94ff26..ca317018 100644 --- a/services/native/src/runninglock/running_lock_mgr.h +++ b/services/native/src/runninglock/running_lock_mgr.h @@ -90,6 +90,7 @@ private: bool InitProximityController(); void HandleProximityCloseEvent(); void HandleProximityAwayEvent(); + bool IsVoiceAppForeground(); #endif class LockCounter { -- Gitee