From a98d7c58f8904f4ea9c0b5e95b3f28d73d21ef7f Mon Sep 17 00:00:00 2001 From: fanrui0 Date: Wed, 27 Aug 2025 12:50:58 +0800 Subject: [PATCH 1/3] modify missed call notification Signed-off-by: fanrui0 --- .../include/call_data_base_helper.h | 1 - .../src/call_data_base_helper.cpp | 62 +++++-------------- .../src/missed_call_notification.cpp | 10 +-- .../call/include/call_broadcast_subscriber.h | 3 - .../call/src/call_broadcast_subscriber.cpp | 28 --------- services/call/src/call_control_manager.cpp | 1 - .../src/zero_branch8_test.cpp | 20 +++--- 7 files changed, 24 insertions(+), 101 deletions(-) diff --git a/services/call/call_state_observer/include/call_data_base_helper.h b/services/call/call_state_observer/include/call_data_base_helper.h index 72f6d356..d2be872f 100644 --- a/services/call/call_state_observer/include/call_data_base_helper.h +++ b/services/call/call_state_observer/include/call_data_base_helper.h @@ -97,7 +97,6 @@ public: bool Delete(DataShare::DataSharePredicates &predicates); bool QueryCallLog( std::map &phonesAndUnreadCountMap, DataShare::DataSharePredicates &predicates); - bool GetHelperAndUrl(std::shared_ptr &helper, std::string &url); bool QueryAndDeleteLimitedIds(DataShare::DataSharePredicates &predicates); int32_t QueryIsBlockPhoneNumber(const std::string &phoneNum, bool &result); int32_t GetAirplaneMode(bool &isAirplaneModeOn); diff --git a/services/call/call_state_observer/src/call_data_base_helper.cpp b/services/call/call_state_observer/src/call_data_base_helper.cpp index 91259b13..e23d97ea 100644 --- a/services/call/call_state_observer/src/call_data_base_helper.cpp +++ b/services/call/call_state_observer/src/call_data_base_helper.cpp @@ -22,16 +22,12 @@ #include "phonenumbers/phonenumber.pb.h" #include "phonenumberutil.h" #include "telephony_log_wrapper.h" -#include "os_account_manager.h" -#include "system_ability_definition.h" namespace OHOS { namespace Telephony { class AbsSharedResultSet; static constexpr const char *CALLLOG_URI = "datashare:///com.ohos.calllogability"; static constexpr const char *CALL_SUBSECTION = "datashare:///com.ohos.calllogability/calls/calllog"; -static const std::string CALL_SUBSECTION_SILENCE = - "datashareproxy://com.ohos.contactsdataability/calls/calllog?Proxy=true&user="; static constexpr const char *CONTACT_URI = "datashare:///com.ohos.contactsdataability"; static constexpr const char *CALL_BLOCK = "datashare:///com.ohos.contactsdataability/contacts/contact_blocklist"; static constexpr const char *CONTACT_DATA = "datashare:///com.ohos.contactsdataability/contacts/contact_data"; @@ -130,16 +126,13 @@ void CallDataBaseHelper::UnRegisterObserver() bool CallDataBaseHelper::Insert(DataShare::DataShareValuesBucket &values) { - std::shared_ptr helper = nullptr; - std::string url; - bool result = GetHelperAndUrl(helper, url); - if (!result) { - TELEPHONY_LOGE("GetHelperAndUrl fail!"); + std::shared_ptr helper = CreateDataShareHelper(CALLLOG_URI); + if (helper == nullptr) { + TELEPHONY_LOGE("helper is nullptr"); return false; } - - Uri uri(url); - result = (helper->Insert(uri, values) > 0); + Uri uri(CALL_SUBSECTION); + bool result = (helper->Insert(uri, values) > 0); helper->Release(); return result; } @@ -225,39 +218,15 @@ bool CallDataBaseHelper::Query(ContactInfo &contactInfo, DataShare::DataSharePre return true; } -bool CallDataBaseHelper::GetHelperAndUrl(std::shared_ptr &helper, std::string &url) -{ - int32_t userId = 0; - bool isUserUnlocked = false; - AccountSA::OsAccountManager::GetForegroundOsAccountLocalId(userId); - AccountSA::OsAccountManager::IsOsAccountVerified(userId, isUserUnlocked); - TELEPHONY_LOGI("isUserUnlocked: %{public}d", isUserUnlocked); - if (!isUserUnlocked) { - helper = CreateDataShareHelper(CALL_SUBSECTION_SILENCE + std::to_string(userId)); - url = CALL_SUBSECTION_SILENCE + std::to_string(userId); - } else { - helper = CreateDataShareHelper(CALLLOG_URI); - url = CALL_SUBSECTION; - } - if (helper == nullptr) { - TELEPHONY_LOGE("helper is nullptr!"); - return false; - } - return true; -} - bool CallDataBaseHelper::QueryCallLog( std::map &phoneNumAndUnreadCountMap, DataShare::DataSharePredicates &predicates) { - std::shared_ptr helper = nullptr; - std::string url; - bool result = GetHelperAndUrl(helper, url); - if (!result) { - TELEPHONY_LOGE("GetHelperAndUrl fail!"); + std::shared_ptr helper = CreateDataShareHelper(CALLLOG_URI); + if (helper == nullptr) { + TELEPHONY_LOGE("helper is nullptr!"); return false; } - - Uri uri(url); + Uri uri(CALL_SUBSECTION); std::vector columns; columns.push_back(CALL_PHONE_NUMBER); auto resultSet = helper->Query(uri, predicates, columns); @@ -291,15 +260,12 @@ bool CallDataBaseHelper::QueryCallLog( bool CallDataBaseHelper::QueryAndDeleteLimitedIds(DataShare::DataSharePredicates &predicates) { - std::shared_ptr helper = nullptr; - std::string url; - bool result = GetHelperAndUrl(helper, url); - if (!result) { - TELEPHONY_LOGE("GetHelperAndUrl fail!"); + std::shared_ptr helper = CreateDataShareHelper(CALLLOG_URI); + if (helper == nullptr) { + TELEPHONY_LOGE("helper is nullptr"); return false; } - - Uri uri(url); + Uri uri(CALL_SUBSECTION); std::vector columns; columns.push_back(CALL_ID); auto resultSet = helper->Query(uri, predicates, columns); @@ -318,7 +284,7 @@ bool CallDataBaseHelper::QueryAndDeleteLimitedIds(DataShare::DataSharePredicates TELEPHONY_LOGI("need delete call log id: %{public}d", id); DataShare::DataSharePredicates deletePredicates; deletePredicates.EqualTo(CALL_ID, id); - result = (helper->Delete(uri, deletePredicates) > 0); + bool result = (helper->Delete(uri, deletePredicates) > 0); TELEPHONY_LOGI("delete result: %{public}d", result); } operationResult = resultSet->GoToNextRow(); diff --git a/services/call/call_state_observer/src/missed_call_notification.cpp b/services/call/call_state_observer/src/missed_call_notification.cpp index cee4cf46..6bfcb964 100644 --- a/services/call/call_state_observer/src/missed_call_notification.cpp +++ b/services/call/call_state_observer/src/missed_call_notification.cpp @@ -26,7 +26,6 @@ #include "telephony_log_wrapper.h" #include "telephony_permission.h" #include "want.h" -#include "os_account_manager.h" namespace OHOS { namespace Telephony { @@ -50,14 +49,7 @@ void MissedCallNotification::CallStateUpdated( callObjectPtr->GetCallDirection() == CallDirection::CALL_DIRECTION_IN && ((answerType == CallAnswerType::CALL_ANSWER_MISSED) || (answerType == CallAnswerType::CALL_ANSWER_ACTIVED && callObjectPtr->IsAiAutoAnswer()))) { - int32_t userId = 0; - bool isUserUnlocked = false; - AccountSA::OsAccountManager::GetForegroundOsAccountLocalId(userId); - AccountSA::OsAccountManager::IsOsAccountVerified(userId, isUserUnlocked); - TELEPHONY_LOGI("isUserUnlocked: %{public}d", isUserUnlocked); - if (isUserUnlocked) { - PublishMissedCallEvent(callObjectPtr); - } + PublishMissedCallEvent(callObjectPtr); } } diff --git a/services/call/include/call_broadcast_subscriber.h b/services/call/include/call_broadcast_subscriber.h index b7534dc8..1bf56bb3 100644 --- a/services/call/include/call_broadcast_subscriber.h +++ b/services/call/include/call_broadcast_subscriber.h @@ -43,8 +43,6 @@ private: USER_SWITCHED, SHUTDOWN, HSDR_EVENT, - HFP_EVENT, - SCREEN_UNLOCKED, MUTE_KEY_PRESS }; using broadcastSubscriberFunc = std::function; @@ -59,7 +57,6 @@ private: void ShutdownBroadcast(const EventFwk::CommonEventData &data); void HsdrEventBroadcast(const EventFwk::CommonEventData &data); void HfpConnectBroadcast(const EventFwk::CommonEventData &data); - void ScreenUnlockedBroadcast(const EventFwk::CommonEventData &data); void MuteKeyBroadcast(const EventFwk::CommonEventData &data); std::map memberFuncMap_; }; diff --git a/services/call/src/call_broadcast_subscriber.cpp b/services/call/src/call_broadcast_subscriber.cpp index 7666eee6..da24657f 100644 --- a/services/call/src/call_broadcast_subscriber.cpp +++ b/services/call/src/call_broadcast_subscriber.cpp @@ -34,8 +34,6 @@ namespace OHOS { namespace Telephony { using namespace OHOS::EventFwk; -static constexpr int16_t INCOMING_CALL_MISSED_CODE = 0; -static constexpr int16_t PUBLISH_MISSCALL_EVENT_DELAY_TIME = 2000; CallBroadcastSubscriber::CallBroadcastSubscriber(const OHOS::EventFwk::CommonEventSubscribeInfo &subscriberInfo) : CommonEventSubscriber(subscriberInfo) { @@ -59,8 +57,6 @@ CallBroadcastSubscriber::CallBroadcastSubscriber(const OHOS::EventFwk::CommonEve [this](const EventFwk::CommonEventData &data) { HsdrEventBroadcast(data); }; memberFuncMap_[HFP_EVENT] = [this](const EventFwk::CommonEventData &data) { HfpConnectBroadcast(data); }; - memberFuncMap_[SCREEN_UNLOCKED] = - [this](const EventFwk::CommonEventData &data) { ScreenUnlockedBroadcast(data); }; memberFuncMap_[MUTE_KEY_PRESS] = [this](const EventFwk::CommonEventData &data) { MuteKeyBroadcast(data); }; } @@ -87,8 +83,6 @@ void CallBroadcastSubscriber::OnReceiveEvent(const EventFwk::CommonEventData &da code = USER_SWITCHED; } else if (action == EventFwk::CommonEventSupport::COMMON_EVENT_SHUTDOWN) { code = SHUTDOWN; - } else if (action == EventFwk::CommonEventSupport::COMMON_EVENT_SCREEN_UNLOCKED) { - code = SCREEN_UNLOCKED; } else if (action == "usual.event.bluetooth.CONNECT_HFP_HF") { code = HFP_EVENT; } else if (action == "multimodal.event.MUTE_KEY_PRESS") { @@ -227,28 +221,6 @@ void CallBroadcastSubscriber::HfpConnectBroadcast(const EventFwk::CommonEventDat TELEPHONY_LOGI("HfpConnectBroadcast end"); } -void CallBroadcastSubscriber::ScreenUnlockedBroadcast(const EventFwk::CommonEventData &data) -{ - int32_t userId = 0; - bool isUserUnlocked = false; - AccountSA::OsAccountManager::GetForegroundOsAccountLocalId(userId); - AccountSA::OsAccountManager::IsOsAccountVerified(userId, isUserUnlocked); - TELEPHONY_LOGI("isUserUnlocked: %{public}d", isUserUnlocked); - if (!isUserUnlocked) { - std::this_thread::sleep_for(std::chrono::milliseconds(PUBLISH_MISSCALL_EVENT_DELAY_TIME)); - AAFwk::Want want; - want.SetAction(EventFwk::CommonEventSupport::COMMON_EVENT_INCOMING_CALL_MISSED); - EventFwk::CommonEventData eventData; - eventData.SetWant(want); - eventData.SetCode(INCOMING_CALL_MISSED_CODE); - EventFwk::CommonEventPublishInfo publishInfo; - publishInfo.SetOrdered(true); - EventFwk::CommonEventManager::PublishCommonEvent(eventData, publishInfo, nullptr); - } else { - DelayedSingleton::GetInstance()->StopFlashRemind(); - } -} - void CallBroadcastSubscriber::MuteKeyBroadcast(const EventFwk::CommonEventData &data) { DelayedSingleton::GetInstance()->StopFlashRemind(); diff --git a/services/call/src/call_control_manager.cpp b/services/call/src/call_control_manager.cpp index 8135cd3e..4d10ba3c 100644 --- a/services/call/src/call_control_manager.cpp +++ b/services/call/src/call_control_manager.cpp @@ -1817,7 +1817,6 @@ void CallControlManager::SystemAbilityListener::CommonBroadcastSubscriber() { EventFwk::MatchingSkills matchingSkills; matchingSkills.AddEvent(EventFwk::CommonEventSupport::COMMON_EVENT_SIM_STATE_CHANGED); - matchingSkills.AddEvent(EventFwk::CommonEventSupport::COMMON_EVENT_SCREEN_UNLOCKED); matchingSkills.AddEvent(EventFwk::CommonEventSupport::COMMON_EVENT_BLUETOOTH_REMOTEDEVICE_NAME_UPDATE); matchingSkills.AddEvent(EventFwk::CommonEventSupport::COMMON_EVENT_USER_SWITCHED); matchingSkills.AddEvent(EventFwk::CommonEventSupport::COMMON_EVENT_SHUTDOWN); diff --git a/test/unittest/call_manager_zero_gtest/src/zero_branch8_test.cpp b/test/unittest/call_manager_zero_gtest/src/zero_branch8_test.cpp index 8bb60df1..4b158c0b 100644 --- a/test/unittest/call_manager_zero_gtest/src/zero_branch8_test.cpp +++ b/test/unittest/call_manager_zero_gtest/src/zero_branch8_test.cpp @@ -76,17 +76,15 @@ HWTEST_F(ZeroBranch7Test, Telephony_CallBroadcastSubscriber_001, TestSize.Level0 EventFwk::CommonEventSubscribeInfo subscriberInfo(matchingSkills); CallBroadcastSubscriber subscriber(subscriberInfo); EventFwk::CommonEventData eventData; - ASSERT_NO_THROW(subscriber.OnReceiveEvent(eventData)); - ASSERT_NO_THROW(subscriber.UnknownBroadcast(eventData)); - ASSERT_NO_THROW(subscriber.SimStateBroadcast(eventData)); - ASSERT_NO_THROW(subscriber.ConnectCallUiServiceBroadcast(eventData)); - ASSERT_NO_THROW(subscriber.HighTempLevelChangedBroadcast(eventData)); - ASSERT_NO_THROW(subscriber.ConnectCallUiSuperPrivacyModeBroadcast(eventData)); - ASSERT_NO_THROW(subscriber.UpdateBluetoothDeviceName(eventData)); - ASSERT_NO_THROW(subscriber.ConnectCallUiUserSwitchedBroadcast(eventData)); - ASSERT_NO_THROW(subscriber.ShutdownBroadcast(eventData)); - ASSERT_NO_THROW(subscriber.HsdrEventBroadcast(eventData)); - ASSERT_NO_THROW(subscriber.ScreenUnlockedBroadcast(eventData)); + subscriber.OnReceiveEvent(eventData); + subscriber.UnknownBroadcast(eventData); + subscriber.SimStateBroadcast(eventData); + subscriber.ConnectCallUiServiceBroadcast(eventData); + subscriber.HighTempLevelChangedBroadcast(eventData); + subscriber.ConnectCallUiSuperPrivacyModeBroadcast(eventData); + subscriber.UpdateBluetoothDeviceName(eventData); + subscriber.ConnectCallUiUserSwitchedBroadcast(eventData); + ASSERT_NE(sizeof(eventData), 0); } /** -- Gitee From 288170f2fa5d045269a94f75894356071ea38334 Mon Sep 17 00:00:00 2001 From: fanrui0 Date: Wed, 27 Aug 2025 12:59:49 +0800 Subject: [PATCH 2/3] modify missed call notification Signed-off-by: fanrui0 --- services/call/include/call_broadcast_subscriber.h | 1 + 1 file changed, 1 insertion(+) diff --git a/services/call/include/call_broadcast_subscriber.h b/services/call/include/call_broadcast_subscriber.h index 1bf56bb3..67cae06c 100644 --- a/services/call/include/call_broadcast_subscriber.h +++ b/services/call/include/call_broadcast_subscriber.h @@ -43,6 +43,7 @@ private: USER_SWITCHED, SHUTDOWN, HSDR_EVENT, + HFP_EVENT, MUTE_KEY_PRESS }; using broadcastSubscriberFunc = std::function; -- Gitee From d5458cdd4847e17e5154ead7e8ebe5dce4ea2d61 Mon Sep 17 00:00:00 2001 From: fanrui0 Date: Wed, 27 Aug 2025 16:36:55 +0800 Subject: [PATCH 3/3] modify missed call notification Signed-off-by: fanrui0 --- .../include/call_data_base_helper.h | 1 - .../src/call_data_base_helper.cpp | 62 +++++-------------- .../src/missed_call_notification.cpp | 10 +-- .../call/src/call_broadcast_subscriber.cpp | 14 +---- .../src/zero_branch8_test.cpp | 20 +++--- 5 files changed, 25 insertions(+), 82 deletions(-) diff --git a/services/call/call_state_observer/include/call_data_base_helper.h b/services/call/call_state_observer/include/call_data_base_helper.h index 72f6d356..d2be872f 100644 --- a/services/call/call_state_observer/include/call_data_base_helper.h +++ b/services/call/call_state_observer/include/call_data_base_helper.h @@ -97,7 +97,6 @@ public: bool Delete(DataShare::DataSharePredicates &predicates); bool QueryCallLog( std::map &phonesAndUnreadCountMap, DataShare::DataSharePredicates &predicates); - bool GetHelperAndUrl(std::shared_ptr &helper, std::string &url); bool QueryAndDeleteLimitedIds(DataShare::DataSharePredicates &predicates); int32_t QueryIsBlockPhoneNumber(const std::string &phoneNum, bool &result); int32_t GetAirplaneMode(bool &isAirplaneModeOn); diff --git a/services/call/call_state_observer/src/call_data_base_helper.cpp b/services/call/call_state_observer/src/call_data_base_helper.cpp index 91259b13..e23d97ea 100644 --- a/services/call/call_state_observer/src/call_data_base_helper.cpp +++ b/services/call/call_state_observer/src/call_data_base_helper.cpp @@ -22,16 +22,12 @@ #include "phonenumbers/phonenumber.pb.h" #include "phonenumberutil.h" #include "telephony_log_wrapper.h" -#include "os_account_manager.h" -#include "system_ability_definition.h" namespace OHOS { namespace Telephony { class AbsSharedResultSet; static constexpr const char *CALLLOG_URI = "datashare:///com.ohos.calllogability"; static constexpr const char *CALL_SUBSECTION = "datashare:///com.ohos.calllogability/calls/calllog"; -static const std::string CALL_SUBSECTION_SILENCE = - "datashareproxy://com.ohos.contactsdataability/calls/calllog?Proxy=true&user="; static constexpr const char *CONTACT_URI = "datashare:///com.ohos.contactsdataability"; static constexpr const char *CALL_BLOCK = "datashare:///com.ohos.contactsdataability/contacts/contact_blocklist"; static constexpr const char *CONTACT_DATA = "datashare:///com.ohos.contactsdataability/contacts/contact_data"; @@ -130,16 +126,13 @@ void CallDataBaseHelper::UnRegisterObserver() bool CallDataBaseHelper::Insert(DataShare::DataShareValuesBucket &values) { - std::shared_ptr helper = nullptr; - std::string url; - bool result = GetHelperAndUrl(helper, url); - if (!result) { - TELEPHONY_LOGE("GetHelperAndUrl fail!"); + std::shared_ptr helper = CreateDataShareHelper(CALLLOG_URI); + if (helper == nullptr) { + TELEPHONY_LOGE("helper is nullptr"); return false; } - - Uri uri(url); - result = (helper->Insert(uri, values) > 0); + Uri uri(CALL_SUBSECTION); + bool result = (helper->Insert(uri, values) > 0); helper->Release(); return result; } @@ -225,39 +218,15 @@ bool CallDataBaseHelper::Query(ContactInfo &contactInfo, DataShare::DataSharePre return true; } -bool CallDataBaseHelper::GetHelperAndUrl(std::shared_ptr &helper, std::string &url) -{ - int32_t userId = 0; - bool isUserUnlocked = false; - AccountSA::OsAccountManager::GetForegroundOsAccountLocalId(userId); - AccountSA::OsAccountManager::IsOsAccountVerified(userId, isUserUnlocked); - TELEPHONY_LOGI("isUserUnlocked: %{public}d", isUserUnlocked); - if (!isUserUnlocked) { - helper = CreateDataShareHelper(CALL_SUBSECTION_SILENCE + std::to_string(userId)); - url = CALL_SUBSECTION_SILENCE + std::to_string(userId); - } else { - helper = CreateDataShareHelper(CALLLOG_URI); - url = CALL_SUBSECTION; - } - if (helper == nullptr) { - TELEPHONY_LOGE("helper is nullptr!"); - return false; - } - return true; -} - bool CallDataBaseHelper::QueryCallLog( std::map &phoneNumAndUnreadCountMap, DataShare::DataSharePredicates &predicates) { - std::shared_ptr helper = nullptr; - std::string url; - bool result = GetHelperAndUrl(helper, url); - if (!result) { - TELEPHONY_LOGE("GetHelperAndUrl fail!"); + std::shared_ptr helper = CreateDataShareHelper(CALLLOG_URI); + if (helper == nullptr) { + TELEPHONY_LOGE("helper is nullptr!"); return false; } - - Uri uri(url); + Uri uri(CALL_SUBSECTION); std::vector columns; columns.push_back(CALL_PHONE_NUMBER); auto resultSet = helper->Query(uri, predicates, columns); @@ -291,15 +260,12 @@ bool CallDataBaseHelper::QueryCallLog( bool CallDataBaseHelper::QueryAndDeleteLimitedIds(DataShare::DataSharePredicates &predicates) { - std::shared_ptr helper = nullptr; - std::string url; - bool result = GetHelperAndUrl(helper, url); - if (!result) { - TELEPHONY_LOGE("GetHelperAndUrl fail!"); + std::shared_ptr helper = CreateDataShareHelper(CALLLOG_URI); + if (helper == nullptr) { + TELEPHONY_LOGE("helper is nullptr"); return false; } - - Uri uri(url); + Uri uri(CALL_SUBSECTION); std::vector columns; columns.push_back(CALL_ID); auto resultSet = helper->Query(uri, predicates, columns); @@ -318,7 +284,7 @@ bool CallDataBaseHelper::QueryAndDeleteLimitedIds(DataShare::DataSharePredicates TELEPHONY_LOGI("need delete call log id: %{public}d", id); DataShare::DataSharePredicates deletePredicates; deletePredicates.EqualTo(CALL_ID, id); - result = (helper->Delete(uri, deletePredicates) > 0); + bool result = (helper->Delete(uri, deletePredicates) > 0); TELEPHONY_LOGI("delete result: %{public}d", result); } operationResult = resultSet->GoToNextRow(); diff --git a/services/call/call_state_observer/src/missed_call_notification.cpp b/services/call/call_state_observer/src/missed_call_notification.cpp index cee4cf46..6bfcb964 100644 --- a/services/call/call_state_observer/src/missed_call_notification.cpp +++ b/services/call/call_state_observer/src/missed_call_notification.cpp @@ -26,7 +26,6 @@ #include "telephony_log_wrapper.h" #include "telephony_permission.h" #include "want.h" -#include "os_account_manager.h" namespace OHOS { namespace Telephony { @@ -50,14 +49,7 @@ void MissedCallNotification::CallStateUpdated( callObjectPtr->GetCallDirection() == CallDirection::CALL_DIRECTION_IN && ((answerType == CallAnswerType::CALL_ANSWER_MISSED) || (answerType == CallAnswerType::CALL_ANSWER_ACTIVED && callObjectPtr->IsAiAutoAnswer()))) { - int32_t userId = 0; - bool isUserUnlocked = false; - AccountSA::OsAccountManager::GetForegroundOsAccountLocalId(userId); - AccountSA::OsAccountManager::IsOsAccountVerified(userId, isUserUnlocked); - TELEPHONY_LOGI("isUserUnlocked: %{public}d", isUserUnlocked); - if (isUserUnlocked) { - PublishMissedCallEvent(callObjectPtr); - } + PublishMissedCallEvent(callObjectPtr); } } diff --git a/services/call/src/call_broadcast_subscriber.cpp b/services/call/src/call_broadcast_subscriber.cpp index 7666eee6..d62bcb3d 100644 --- a/services/call/src/call_broadcast_subscriber.cpp +++ b/services/call/src/call_broadcast_subscriber.cpp @@ -34,8 +34,6 @@ namespace OHOS { namespace Telephony { using namespace OHOS::EventFwk; -static constexpr int16_t INCOMING_CALL_MISSED_CODE = 0; -static constexpr int16_t PUBLISH_MISSCALL_EVENT_DELAY_TIME = 2000; CallBroadcastSubscriber::CallBroadcastSubscriber(const OHOS::EventFwk::CommonEventSubscribeInfo &subscriberInfo) : CommonEventSubscriber(subscriberInfo) { @@ -234,17 +232,7 @@ void CallBroadcastSubscriber::ScreenUnlockedBroadcast(const EventFwk::CommonEven AccountSA::OsAccountManager::GetForegroundOsAccountLocalId(userId); AccountSA::OsAccountManager::IsOsAccountVerified(userId, isUserUnlocked); TELEPHONY_LOGI("isUserUnlocked: %{public}d", isUserUnlocked); - if (!isUserUnlocked) { - std::this_thread::sleep_for(std::chrono::milliseconds(PUBLISH_MISSCALL_EVENT_DELAY_TIME)); - AAFwk::Want want; - want.SetAction(EventFwk::CommonEventSupport::COMMON_EVENT_INCOMING_CALL_MISSED); - EventFwk::CommonEventData eventData; - eventData.SetWant(want); - eventData.SetCode(INCOMING_CALL_MISSED_CODE); - EventFwk::CommonEventPublishInfo publishInfo; - publishInfo.SetOrdered(true); - EventFwk::CommonEventManager::PublishCommonEvent(eventData, publishInfo, nullptr); - } else { + if (isUserUnlocked) { DelayedSingleton::GetInstance()->StopFlashRemind(); } } diff --git a/test/unittest/call_manager_zero_gtest/src/zero_branch8_test.cpp b/test/unittest/call_manager_zero_gtest/src/zero_branch8_test.cpp index 8bb60df1..4b158c0b 100644 --- a/test/unittest/call_manager_zero_gtest/src/zero_branch8_test.cpp +++ b/test/unittest/call_manager_zero_gtest/src/zero_branch8_test.cpp @@ -76,17 +76,15 @@ HWTEST_F(ZeroBranch7Test, Telephony_CallBroadcastSubscriber_001, TestSize.Level0 EventFwk::CommonEventSubscribeInfo subscriberInfo(matchingSkills); CallBroadcastSubscriber subscriber(subscriberInfo); EventFwk::CommonEventData eventData; - ASSERT_NO_THROW(subscriber.OnReceiveEvent(eventData)); - ASSERT_NO_THROW(subscriber.UnknownBroadcast(eventData)); - ASSERT_NO_THROW(subscriber.SimStateBroadcast(eventData)); - ASSERT_NO_THROW(subscriber.ConnectCallUiServiceBroadcast(eventData)); - ASSERT_NO_THROW(subscriber.HighTempLevelChangedBroadcast(eventData)); - ASSERT_NO_THROW(subscriber.ConnectCallUiSuperPrivacyModeBroadcast(eventData)); - ASSERT_NO_THROW(subscriber.UpdateBluetoothDeviceName(eventData)); - ASSERT_NO_THROW(subscriber.ConnectCallUiUserSwitchedBroadcast(eventData)); - ASSERT_NO_THROW(subscriber.ShutdownBroadcast(eventData)); - ASSERT_NO_THROW(subscriber.HsdrEventBroadcast(eventData)); - ASSERT_NO_THROW(subscriber.ScreenUnlockedBroadcast(eventData)); + subscriber.OnReceiveEvent(eventData); + subscriber.UnknownBroadcast(eventData); + subscriber.SimStateBroadcast(eventData); + subscriber.ConnectCallUiServiceBroadcast(eventData); + subscriber.HighTempLevelChangedBroadcast(eventData); + subscriber.ConnectCallUiSuperPrivacyModeBroadcast(eventData); + subscriber.UpdateBluetoothDeviceName(eventData); + subscriber.ConnectCallUiUserSwitchedBroadcast(eventData); + ASSERT_NE(sizeof(eventData), 0); } /** -- Gitee