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 72f6d35673f6ff5bade6fff3aca88162530999d1..d2be872fc506454ca2f68b149146cd6377102b8d 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 91259b13ee793fd33d8fc30ee5f6ada5895100de..e23d97ea621e7f25d179c9bbd7319c32f9500f94 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 cee4cf46507902f46e41c5f15c9a15d52cdb0f05..6bfcb964d582b853c21ed85c6574a700ab5af433 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 b7534dc80456e6d7286156099643158dfb1c447e..67cae06c12b8e23f369246f646d23f93fd23b5b6 100644 --- a/services/call/include/call_broadcast_subscriber.h +++ b/services/call/include/call_broadcast_subscriber.h @@ -44,7 +44,6 @@ private: SHUTDOWN, HSDR_EVENT, HFP_EVENT, - SCREEN_UNLOCKED, MUTE_KEY_PRESS }; using broadcastSubscriberFunc = std::function; @@ -59,7 +58,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 7666eee610f64e3cd6afd455fec5df73fd718d8a..e8cb65d68a9f5d3936e87fb70deda53677593f24 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") { @@ -234,17 +228,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/services/call/src/call_control_manager.cpp b/services/call/src/call_control_manager.cpp index 8135cd3ed69bd1bac6ce5a45f58b3c9f414bd85e..4d10ba3c964cfc11c5efd8bd3d3061692ea4fa6a 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 8bb60df16955fd7e22271a6dc5e0b20b269f005e..4b158c0b0b762c7fb0e57cc6d1a4233a825f41fb 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); } /**