diff --git a/services/audio/src/audio_scene_processor.cpp b/services/audio/src/audio_scene_processor.cpp index 4b02cbe80437c3ca372a5744d4c7967b134bd662..eecd1041b2088c2aaa5b4ef9e2c37f9ecd55feb1 100644 --- a/services/audio/src/audio_scene_processor.cpp +++ b/services/audio/src/audio_scene_processor.cpp @@ -75,6 +75,12 @@ void AudioSceneProcessor::ProcessEventInner(AudioEvent event) case AudioEvent::SWITCH_AUDIO_INACTIVE_STATE: if (DelayedSingleton::GetInstance()->ShouldStopSoundtone()) { DelayedSingleton::GetInstance()->StopSoundtone(); + // Acquire disconnected lock in DisconnectedHandle when the remote hangup + DelayedSingleton::GetInstance()->ReleaseDisconnectedLock(); + if (call->GetTelCallState() != TelCallState::CALL_STATUS_DISCONNECTING) { + // Acquire disconnected lock when the remote hangup and will release after StopSoundtone + DelayedSingleton::GetInstance()->AcquireDisconnectedLock(); + } } SwitchState(event); break; diff --git a/services/call/include/call_control_manager.h b/services/call/include/call_control_manager.h index 49ab5c24f56ca553230e14dcfb54094f04c9b2c0..1fb8c1b5b1443bbe44208a5ef4f0b14b13692c03 100644 --- a/services/call/include/call_control_manager.h +++ b/services/call/include/call_control_manager.h @@ -34,6 +34,10 @@ #include "system_ability_status_change_stub.h" #include "ffrt.h" +#ifdef ABILITY_POWER_SUPPORT +#include "power_mgr_client.h" +#endif + /** * Singleton * @ClassName:CallControlManager @@ -144,6 +148,8 @@ public: int32_t CarrierAndVoipConflictProcess(int32_t callId, TelCallState callState); void AcquireIncomingLock(); void ReleaseIncomingLock(); + void AcquireDisconnectedLock(); + void ReleaseDisconnectedLock(); void DisconnectAllCalls(); #ifdef NOT_SUPPORT_MULTICALL bool HangUpFirstCallBtAndESIM(int32_t secondCallId); @@ -203,6 +209,10 @@ private: std::unique_ptr CallRequestHandlerPtr_; // notify when incoming calls are ignored, not rejected or answered std::shared_ptr incomingCallWakeup_; +#ifdef ABILITY_POWER_SUPPORT + std::shared_ptr disconnectedRunningLock_; +#endif + const int32_t DISCONNECTED_LOCK_TIMEOUT = 2000; std::shared_ptr missedCallNotification_; std::unique_ptr callSettingManagerPtr_; sptr statusChangeListener_ = nullptr; diff --git a/services/call/src/call_control_manager.cpp b/services/call/src/call_control_manager.cpp index 1af720f618162ebc9d50a4b546ccc55b351824c6..fc604f8d195fd4a6d76991a6a23f06e82a8f182d 100644 --- a/services/call/src/call_control_manager.cpp +++ b/services/call/src/call_control_manager.cpp @@ -49,6 +49,10 @@ #include "interoperable_communication_manager.h" #include "settings_datashare_helper.h" +#ifdef ABILITY_POWER_SUPPORT +#include "power_mgr_client.h" +#endif + namespace OHOS { namespace Telephony { bool CallControlManager::alarmSeted = false; @@ -1726,6 +1730,31 @@ void CallControlManager::ReleaseIncomingLock() incomingCallWakeup_->ReleaseIncomingLock(); } +void CallControlManager::AcquireDisconnectedLock() +{ +#ifdef ABILITY_POWER_SUPPORT + if (disconnectedRunningLock_ == nullptr) { + disconnectedRunningLock_ = PowerMgr::PowerMgrClient::GetInstance(). + CreateRunningLock("disconnectedrunninglock", PowerMgr::RunningLockType::RUNNINGLOCK_BACKGROUND_PHONE); + } + if (disconnectedRunningLock_ != nullptr) { + disconnectedRunningLock_->Lock(DISCONNECTED_LOCK_TIMEOUT); + TELEPHONY_LOGI("disconnectedRunningLock_ locked"); + } +#endif +} + +void CallControlManager::ReleaseDisconnectedLock() +{ +#ifdef ABILITY_POWER_SUPPORT + if (disconnectedRunningLock_ == nullptr || !disconnectedRunningLock_->IsUsed()) { + return; + } + disconnectedRunningLock_->UnLock(); + TELEPHONY_LOGI("disconnectedRunningLock_ unlocked"); +#endif +} + void CallControlManager::DisconnectAllCalls() { std::list> allCallList = CallObjectManager::GetAllCallList();