From 2dbf39da676d8c266058a3c94fd11bcb4c3f36ec Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9A=AE=E9=9B=A8=E6=B8=85=E9=A3=8E?= Date: Wed, 31 Jul 2024 12:37:49 +0800 Subject: [PATCH] =?UTF-8?q?=E5=AE=8C=E6=88=90=E9=80=9A=E8=AF=9D=E4=B8=93?= =?UTF-8?q?=E6=B3=A8=E6=A8=A1=E5=BC=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 暮雨清风 --- services/call/include/call_status_manager.h | 1 + services/call/src/call_status_manager.cpp | 25 +++++++++++++++++++++ 2 files changed, 26 insertions(+) diff --git a/services/call/include/call_status_manager.h b/services/call/include/call_status_manager.h index 20cc6314..8bff6736 100644 --- a/services/call/include/call_status_manager.h +++ b/services/call/include/call_status_manager.h @@ -99,6 +99,7 @@ private: int32_t HandleRingOnceCall(sptr &call); void CarrierAndVoipConflictProcess(int32_t callId); void SetVideoCallState(sptr &call, TelCallState nextState); + bool IsFocusModeOpen(); private: CallDetailInfo callReportInfo_; diff --git a/services/call/src/call_status_manager.cpp b/services/call/src/call_status_manager.cpp index 196e2592..129a7639 100644 --- a/services/call/src/call_status_manager.cpp +++ b/services/call/src/call_status_manager.cpp @@ -384,6 +384,9 @@ int32_t CallStatusManager::IncomingHandle(const CallDetailInfo &info) if (ShouldRejectIncomingCall() || state == (int32_t)CallStateToApp::CALL_STATE_RINGING) { return HandleRejectCall(call, false); } + if (IsFocusModeOpen()) { + TELEPHONY_LOGI("focus mode open"); + } if (info.callType != CallType::TYPE_VOIP && ShouldBlockIncomingCall(call, info)) { return HandleRejectCall(call, true); } @@ -1447,5 +1450,27 @@ void CallStatusManager::PackParaInfo( paraInfo.crsType = info.crsType; paraInfo.originalCallType = info.originalCallType; } + +bool CallStatusManager::IsFocusModeOpen() +{ + auto datashareHelper = SettingsDataShareHelper::GetInstance(); + std::string focusModeEnable {"0"}; + std::vector activedOsAccountIds; + OHOS::AccountSA::OsAccountManager::QueryActiveOsAccountIds(activedOsAccountIds); + if (activedOsAccountIds.empty()) { + TELEPHONY_LOGW("ShouldRejectIncomingCall: activedOsAccountIds is empty"); + return false; + } + int userId = activedOsAccountIds[0]; + OHOS::Uri uri( + "datashare:///com.ohos.settingsdata/entry/settingsdata/USER_SETTINGSDATA_SECURE_" + + std::to_string(userId) + "?Proxy=true&key=focus_mode_enable"); + int resp = datashareHelper->Query(uri, "focus_mode_enable", focusModeEnable); + if (resp == TELEPHONY_SUCCESS && focusModeEnable == "1") { + TELEPHONY_LOGI("IsFocusModeOpen: focus_mode_enable = 1"); + return true; + } + return false; +} } // namespace Telephony } // namespace OHOS -- Gitee