From 359e54ed44418a67711d097fa4c36d9aee5aab78 Mon Sep 17 00:00:00 2001 From: jiangbinghan Date: Thu, 27 Apr 2023 14:59:44 +0800 Subject: [PATCH 1/8] airplane Signed-off-by: jiangbinghan --- frameworks/js/napi/js_error_code.h | 5 + frameworks/js/napi/napi_util.cpp | 5 + frameworks/native/src/core_manager_inner.cpp | 20 ++++ .../innerkits/include/core_manager_inner.h | 2 + .../innerkits/include/i_network_search.h | 2 + .../include/network_search_callback_base.h | 1 + .../innerkits/include/telephony_errors.h | 1 + .../include/network_search_manager.h | 7 +- .../network_search/include/setting_utils.h | 6 +- .../src/network_search_handler.cpp | 14 ++- .../src/network_search_manager.cpp | 94 ++++++++++++++----- services/network_search/src/nitz_update.cpp | 4 +- services/network_search/src/radio_info.cpp | 22 ++++- services/network_search/src/setting_utils.cpp | 31 +++--- .../core_service_gtest/zero_branch_test.cpp | 9 ++ 15 files changed, 173 insertions(+), 50 deletions(-) diff --git a/frameworks/js/napi/js_error_code.h b/frameworks/js/napi/js_error_code.h index 48abe706..5111bc22 100644 --- a/frameworks/js/napi/js_error_code.h +++ b/frameworks/js/napi/js_error_code.h @@ -69,6 +69,11 @@ enum JsErrorCode { */ JS_ERROR_TELEPHONY_NO_SIM_CARD, + /** + * Airplane mode is on. + */ + JS_ERROR_TELEPHONY_AIRPLANE_MODE_ON, + /** * Unknown error code. */ diff --git a/frameworks/js/napi/napi_util.cpp b/frameworks/js/napi/napi_util.cpp index 60e57d85..5c4be346 100755 --- a/frameworks/js/napi/napi_util.cpp +++ b/frameworks/js/napi/napi_util.cpp @@ -53,6 +53,7 @@ static constexpr const char *JS_ERROR_CELLULAR_CALL_IMS_BASE_ERROR_STRING = "Cel static constexpr const char *JS_ERROR_CELLULAR_DATA_BASE_ERROR_STRING = "Cellular data module base error."; static constexpr const char *JS_ERROR_SMS_MMS_BASE_ERROR_STRING = "Sms mms module base error."; static constexpr const char *JS_ERROR_STATE_REGISTRY_BASE_ERROR_STRING = "State registry module base error."; +static constexpr const char *JS_ERROR_AIRPLANE_MODE_ON_STRING = "Airplane mode is on, can not call."; static std::unordered_map errorMap_ = { { JsErrorCode::JS_ERROR_TELEPHONY_PERMISSION_DENIED, JS_ERROR_TELEPHONY_PERMISSION_DENIED_STRING }, @@ -76,6 +77,7 @@ static std::unordered_map errorMap_ = { { JsErrorCode::JS_ERROR_CELLULAR_DATA_BASE_ERROR, JS_ERROR_CELLULAR_DATA_BASE_ERROR_STRING }, { JsErrorCode::JS_ERROR_SMS_MMS_BASE_ERROR, JS_ERROR_SMS_MMS_BASE_ERROR_STRING }, { JsErrorCode::JS_ERROR_STATE_REGISTRY_BASE_ERROR, JS_ERROR_STATE_REGISTRY_BASE_ERROR_STRING }, + { JsErrorCode::JS_ERROR_TELEPHONY_AIRPLANE_MODE_ON, JS_ERROR_AIRPLANE_MODE_ON_STRING }, }; std::string NapiUtil::GetErrorMessage(int32_t errorCode) @@ -564,6 +566,9 @@ bool NapiUtil::CreateCommonErrorMessageForJs(int32_t errorCode, JsErrorCode &jsE case TELEPHONY_ERR_ILLEGAL_USE_OF_SYSTEM_API: jsErrorCode = JS_ERROR_ILLEGAL_USE_OF_SYSTEM_API; break; + case TELEPHONY_ERR_AIRPLANE_MODE_ON: + jsErrorCode = JS_ERROR_TELEPHONY_AIRPLANE_MODE_ON; + break; default: flag = false; break; diff --git a/frameworks/native/src/core_manager_inner.cpp b/frameworks/native/src/core_manager_inner.cpp index 22608462..6e0eaca1 100755 --- a/frameworks/native/src/core_manager_inner.cpp +++ b/frameworks/native/src/core_manager_inner.cpp @@ -1530,6 +1530,26 @@ int32_t CoreManagerInner::GetImsRegStatus(int32_t slotId, ImsServiceType imsSrvT } return networkSearchManager_->GetImsRegStatus(slotId, imsSrvType, info); } + +int32_t CoreManagerInner::GetAirplaneMode(bool &airplaneMode) +{ + if (networkSearchManager_ == nullptr) { + TELEPHONY_LOGE("networkSearchManager is null!"); + return TELEPHONY_ERR_LOCAL_PTR_NULL; + } + return networkSearchManager_->GetAirplaneMode(airplaneMode); +} + +int32_t CoreManagerInner::UpdateRadioOn(int32_t slotId) +{ + if (networkSearchManager_ == nullptr) { + TELEPHONY_LOGE("networkSearchManager is null!"); + return TELEPHONY_ERR_LOCAL_PTR_NULL; + } + networkSearchManager_->UpdateRadioOn(slotId); + return TELEPHONY_SUCCESS; +} + /******************** networkSearchManager end ************************/ /******************** simManager_ start *******************/ diff --git a/interfaces/innerkits/include/core_manager_inner.h b/interfaces/innerkits/include/core_manager_inner.h index dcd3c37b..0aa2d44b 100755 --- a/interfaces/innerkits/include/core_manager_inner.h +++ b/interfaces/innerkits/include/core_manager_inner.h @@ -211,6 +211,8 @@ public: int32_t GetPreferredNetwork(int32_t slotId, const sptr &callback); int32_t SetPreferredNetwork(int32_t slotId, int32_t networkMode, const sptr &callback); + int32_t GetAirplaneMode(bool &airplaneMode); + int32_t UpdateRadioOn(int32_t slotId); bool IsNrSupported(int32_t slotId); int32_t GetNrOptionMode(int32_t slotId, NrMode &mode); diff --git a/interfaces/innerkits/include/i_network_search.h b/interfaces/innerkits/include/i_network_search.h index c173bcfa..d5fac8de 100755 --- a/interfaces/innerkits/include/i_network_search.h +++ b/interfaces/innerkits/include/i_network_search.h @@ -81,6 +81,8 @@ public: const sptr &callback) = 0; virtual int32_t UnregisterImsRegInfoCallback( int32_t slotId, ImsServiceType imsSrvType, const std::string &bundleName) = 0; + virtual int32_t GetAirplaneMode(bool &airplaneMode) = 0; + virtual int32_t UpdateRadioOn(int32_t slotId) = 0; /** * @brief support Nr network or not * diff --git a/interfaces/innerkits/include/network_search_callback_base.h b/interfaces/innerkits/include/network_search_callback_base.h index 736786f4..35a41483 100755 --- a/interfaces/innerkits/include/network_search_callback_base.h +++ b/interfaces/innerkits/include/network_search_callback_base.h @@ -32,6 +32,7 @@ public: } virtual void ClearCellularDataConnections(int32_t slotId) {} virtual void ClearCellularCallList(int32_t slotId) {} + virtual void SetReadyToCall(int32_t slotId, bool isReadyToCall) {} }; } // namespace Telephony } // namespace OHOS diff --git a/interfaces/innerkits/include/telephony_errors.h b/interfaces/innerkits/include/telephony_errors.h index cb9cd8a4..f795529c 100755 --- a/interfaces/innerkits/include/telephony_errors.h +++ b/interfaces/innerkits/include/telephony_errors.h @@ -73,6 +73,7 @@ enum { TELEPHONY_ERR_RIL_CMD_FAIL, TELEPHONY_ERR_UNKNOWN_NETWORK_TYPE, TELEPHONY_ERR_ILLEGAL_USE_OF_SYSTEM_API, + TELEPHONY_ERR_AIRPLANE_MODE_ON, }; // Error code for telephony call manager diff --git a/services/network_search/include/network_search_manager.h b/services/network_search/include/network_search_manager.h index a93c16c4..b79d5aec 100644 --- a/services/network_search/include/network_search_manager.h +++ b/services/network_search/include/network_search_manager.h @@ -70,6 +70,7 @@ struct NetworkSearchManagerInner { FrequencyType freqType_ = FrequencyType::FREQ_TYPE_UNKNOWN; std::mutex mutex_; bool isRadioFirstPowerOn_ = true; + bool airplaneMode_ = false; bool RegisterSetting(); bool UnRegisterSetting(); @@ -202,11 +203,14 @@ public: void GetVoiceTech(int32_t slotId); std::shared_ptr FindManagerInner(int32_t slotId); void SetLocateUpdate(int32_t slotId); - bool GetAirplaneMode(); + int32_t GetAirplaneMode(bool &airplaneMode) override; bool IsRadioFirstPowerOn(int32_t slotId); void SetRadioFirstPowerOn(int32_t slotId, bool isFirstPowerOn); void NotifyImsRegInfoChanged(int32_t slotId, ImsServiceType imsSrvType, const ImsRegInfo &info); void InitSimRadioProtocol(int32_t slotId); + int32_t SetLocalAirplaneMode(int32_t slotId, bool state); + int32_t GetLocalAirplaneMode(int32_t slotId, bool &state); + int32_t UpdateRadioOn(int32_t slotId) override; inline void InitMsgNum(int32_t slotId) { @@ -257,7 +261,6 @@ private: sptr imsCallback; }; - bool AirplaneMode_ = false; sptr cellularDataCallBack_ = nullptr; sptr cellularCallCallBack_ = nullptr; std::shared_ptr telRilManager_ = nullptr; diff --git a/services/network_search/include/setting_utils.h b/services/network_search/include/setting_utils.h index a327b1c3..812f6a11 100644 --- a/services/network_search/include/setting_utils.h +++ b/services/network_search/include/setting_utils.h @@ -49,9 +49,9 @@ public: bool RegisterSettingsObserver(const Uri &uri, const sptr &dataObserver); bool UnRegisterSettingsObserver(const Uri &uri, const sptr &dataObserver); - bool Query(Uri uri, const std::string &key, std::string &value); - bool Insert(Uri uri, const std::string &key, const std::string &value); - bool Update(Uri uri, const std::string &key, const std::string &value); + int32_t Query(Uri uri, const std::string &key, std::string &value); + int32_t Insert(Uri uri, const std::string &key, const std::string &value); + int32_t Update(Uri uri, const std::string &key, const std::string &value); private: std::shared_ptr CreateDataShareHelper(); diff --git a/services/network_search/src/network_search_handler.cpp b/services/network_search/src/network_search_handler.cpp index f7c85a61..c374ff56 100644 --- a/services/network_search/src/network_search_handler.cpp +++ b/services/network_search/src/network_search_handler.cpp @@ -356,6 +356,11 @@ void NetworkSearchHandler::RadioRilVoiceRegState(const AppExecFwk::InnerEvent::P if (networkRegister_ != nullptr) { networkRegister_->ProcessCsRegister(event); } + + sptr cellularCall = networkSearchManager->GetCellularCallCallBack(); + if (cellularCall) { + cellularCall->SetReadyToCall(slotId_, true); + } TELEPHONY_LOGD("NetworkSearchHandler::RadioRilVoiceRegState slotId:%{public}d", slotId_); } @@ -457,16 +462,23 @@ void NetworkSearchHandler::RadioOffOrUnavailableState(int32_t radioState) const } networkSearchState->NotifyStateChange(); networkSearchManager->SetNrOptionMode(slotId_, NrMode::NR_MODE_UNKNOWN); - if (!networkSearchManager->GetAirplaneMode() && radioState == CORE_SERVICE_POWER_OFF) { + bool isAirplaneModeOn = false; + if (networkSearchManager->GetAirplaneMode(isAirplaneModeOn) != TELEPHONY_SUCCESS) { + TELEPHONY_LOGE("RadioOffOrUnavailableState GetAirplaneMode fail slotId:%{public}d", slotId_); + return; + } + if (!isAirplaneModeOn && radioState == CORE_SERVICE_POWER_OFF) { networkSearchManager->SetRadioState(slotId_, static_cast(ModemPowerState::CORE_SERVICE_POWER_ON), 0); } sptr cellularData = networkSearchManager->GetCellularDataCallBack(); if (cellularData) { cellularData->ClearCellularDataConnections(slotId_); + TELEPHONY_LOGD("RadioOffOrUnavailableState ClearCellularDataConnections"); } sptr cellularCall = networkSearchManager->GetCellularCallCallBack(); if (cellularCall) { cellularCall->ClearCellularCallList(slotId_); + TELEPHONY_LOGD("RadioOffOrUnavailableState ClearCellularCallList"); } } diff --git a/services/network_search/src/network_search_manager.cpp b/services/network_search/src/network_search_manager.cpp index 25f6c88b..d3f7106c 100644 --- a/services/network_search/src/network_search_manager.cpp +++ b/services/network_search/src/network_search_manager.cpp @@ -29,11 +29,6 @@ namespace OHOS { namespace Telephony { namespace { -const std::string KEY_DEFAULT_PREFERRED_NETWORK_MODE = "preferred_network_mode"; -const int32_t AIRPLANE_MODE_UNSUPPORT = 0; -const int32_t AIRPLANE_MODE_SUPPORT = 1; -const std::string SUPPORT_AIRPLANE_MODE_PARAM = "persist.sys.support_air_plane_mode"; -const int32_t IS_SUPPORT_AIRPLANE_MODE = system::GetIntParameter(SUPPORT_AIRPLANE_MODE_PARAM, AIRPLANE_MODE_UNSUPPORT); const size_t MCC_LEN = 3; } // namespace @@ -112,7 +107,7 @@ bool NetworkSearchManagerInner::RegisterSetting() Uri autoTimeUri(SettingUtils::NETWORK_SEARCH_SETTING_AUTO_TIME_URI); Uri autoTimezoneUri(SettingUtils::NETWORK_SEARCH_SETTING_AUTO_TIMEZONE_URI); - Uri airplaneModeUri(SettingUtils::NETWORK_SEARCH_SETTING_AIRPLANE_MODE_URI); + Uri airplaneModeUri(SettingUtils::NETWORK_SEARCH_SETTING_URI); settingHelper->RegisterSettingsObserver(autoTimeUri, settingAutoTimeObserver_); settingHelper->RegisterSettingsObserver(autoTimezoneUri, settingAutoTimezoneObserver_); settingHelper->RegisterSettingsObserver(airplaneModeUri, airplaneModeObserver_); @@ -129,7 +124,7 @@ bool NetworkSearchManagerInner::UnRegisterSetting() Uri autoTimeUri(SettingUtils::NETWORK_SEARCH_SETTING_AUTO_TIME_URI); Uri autoTimezoneUri(SettingUtils::NETWORK_SEARCH_SETTING_AUTO_TIMEZONE_URI); - Uri airplaneModeUri(SettingUtils::NETWORK_SEARCH_SETTING_AIRPLANE_MODE_URI); + Uri airplaneModeUri(SettingUtils::NETWORK_SEARCH_SETTING_URI); settingHelper->UnRegisterSettingsObserver(autoTimeUri, settingAutoTimeObserver_); settingHelper->UnRegisterSettingsObserver(autoTimezoneUri, settingAutoTimezoneObserver_); settingHelper->UnRegisterSettingsObserver(airplaneModeUri, airplaneModeObserver_); @@ -170,6 +165,10 @@ bool NetworkSearchManager::OnInit() return false; } ClearManagerInner(); + bool mode = false; + if (GetAirplaneMode(mode) != TELEPHONY_SUCCESS) { + TELEPHONY_LOGE("NetworkSearchManager::Init GetAirplaneMode fail"); + } for (int32_t slotId = 0; slotId < SIM_SLOT_COUNT; slotId++) { std::shared_ptr inner = FindManagerInner(slotId); if (inner == nullptr) { @@ -189,7 +188,8 @@ bool NetworkSearchManager::OnInit() ClearManagerInner(); return false; } - TELEPHONY_LOGI("NetworkSearchManager::Init inner init slotId:%{public}d", slotId); + SetLocalAirplaneMode(slotId, mode); + TELEPHONY_LOGI("NetworkSearchManager::Init airplaneMode:%{public}d slotId:%{public}d", mode, slotId); // Prevent running crash and query the radio status at startup eventSender_->SendBase(slotId, RadioEvent::RADIO_GET_STATUS); } @@ -228,7 +228,6 @@ int32_t NetworkSearchManager::SetRadioState(int32_t slotId, bool isOn, int32_t r TELEPHONY_LOGE("slotId:%{public}d inner is null", slotId); return TELEPHONY_ERR_LOCAL_PTR_NULL; } - AirplaneMode_ = isOn ? false : true; int32_t fun = static_cast(isOn); if (!eventSender_->SendCallback(slotId, RadioEvent::RADIO_SET_STATUS, &callback, fun, rst)) { TELEPHONY_LOGE("slotId:%{public}d SetRadioState SendCallback failed.", slotId); @@ -799,11 +798,42 @@ void NetworkSearchManager::SavePreferredNetworkValue(int32_t slotId, int32_t net Uri uri(SettingUtils::NETWORK_SEARCH_SETTING_PREFERRED_NETWORK_MODE_URI); std::string key = SettingUtils::SETTINGS_NETWORK_SEARCH_PREFERRED_NETWORK_MODE + "_" + std::to_string(slotId); std::string value = std::to_string(networkMode); - if (!settingHelper->Update(uri, key, value)) { + if (settingHelper->Update(uri, key, value) != TELEPHONY_SUCCESS) { TELEPHONY_LOGE("Update %{public}s fail", key.c_str()); } } +int32_t NetworkSearchManager::UpdateRadioOn(int32_t slotId) +{ + std::shared_ptr settingHelper = SettingUtils::GetInstance(); + if (settingHelper == nullptr) { + TELEPHONY_LOGE("settingHelper is null"); + return TELEPHONY_ERR_LOCAL_PTR_NULL; + } + + Uri uri(SettingUtils::NETWORK_SEARCH_SETTING_URI); + std::string key = SettingUtils::SETTINGS_NETWORK_SEARCH_AIRPLANE_MODE; + int32_t airplaneModeOff = 0; + std::string value = std::to_string(airplaneModeOff); + int32_t ret = settingHelper->Update(uri, key, value); + if (ret != TELEPHONY_SUCCESS) { + TELEPHONY_LOGE("NetworkSearchManager::UpdateRadioOn Update fail"); + return ret; + } + SetRadioState(slotId, CORE_SERVICE_POWER_ON, 0); + AAFwk::Want want; + want.SetAction(EventFwk::CommonEventSupport::COMMON_EVENT_AIRPLANE_MODE_CHANGED); + want.SetParam("state", false); + EventFwk::CommonEventData data; + data.SetWant(want); + EventFwk::CommonEventPublishInfo publishInfo; + if (!EventFwk::CommonEventManager::PublishCommonEvent(data, publishInfo, nullptr)) { + TELEPHONY_LOGE("PublishCommonEvent fail"); + return TELEPHONY_ERR_PUBLISH_BROADCAST_FAIL; + } + return TELEPHONY_SUCCESS; +} + int32_t NetworkSearchManager::GetPreferredNetworkValue(int32_t slotId) const { int32_t networkMode = PREFERRED_NETWORK_TYPE; @@ -816,7 +846,7 @@ int32_t NetworkSearchManager::GetPreferredNetworkValue(int32_t slotId) const Uri uri(SettingUtils::NETWORK_SEARCH_SETTING_PREFERRED_NETWORK_MODE_URI); std::string key = SettingUtils::SETTINGS_NETWORK_SEARCH_PREFERRED_NETWORK_MODE + "_" + std::to_string(slotId); std::string value = ""; - if (!settingHelper->Query(uri, key, value)) { + if (settingHelper->Query(uri, key, value) != TELEPHONY_SUCCESS) { TELEPHONY_LOGI("Query %{public}s fail", key.c_str()); return networkMode; } @@ -1173,28 +1203,24 @@ void NetworkSearchManager::TriggerTimezoneRefresh(int32_t slotId) TELEPHONY_LOGE("NetworkSearchManager::TriggerTimezoneRefresh slotId:%{public}d", slotId); } -bool NetworkSearchManager::GetAirplaneMode() +int32_t NetworkSearchManager::GetAirplaneMode(bool &airplaneMode) { - if (IS_SUPPORT_AIRPLANE_MODE == AIRPLANE_MODE_SUPPORT) { - TELEPHONY_LOGI("support airplane mode, return true"); - return true; - } std::shared_ptr settingHelper = SettingUtils::GetInstance(); if (settingHelper == nullptr) { TELEPHONY_LOGI("settingHelper is null"); - return false; + return TELEPHONY_ERR_LOCAL_PTR_NULL; } - Uri uri(SettingUtils::NETWORK_SEARCH_SETTING_AIRPLANE_MODE_URI); + Uri uri(SettingUtils::NETWORK_SEARCH_SETTING_URI); std::string value = ""; std::string key = SettingUtils::SETTINGS_NETWORK_SEARCH_AIRPLANE_MODE; - if (!settingHelper->Query(uri, key, value)) { + if (settingHelper->Query(uri, key, value) != TELEPHONY_SUCCESS) { TELEPHONY_LOGI("Query airplane mode fail"); - return false; + return TELEPHONY_ERR_DATABASE_READ_FAIL; } - bool airplaneMode = value == "1"; + airplaneMode = value == "1"; TELEPHONY_LOGI("Get airplane mode:%{public}d", airplaneMode); - return airplaneMode; + return TELEPHONY_SUCCESS; } int32_t NetworkSearchManager::RegisterImsRegInfoCallback( @@ -1279,5 +1305,29 @@ void NetworkSearchManager::InitSimRadioProtocol(int32_t slotId) } simManager_->GetRadioProtocol(slotId); } + +int32_t NetworkSearchManager::SetLocalAirplaneMode(int32_t slotId, bool state) +{ + auto inner = FindManagerInner(slotId); + if (inner == nullptr) { + TELEPHONY_LOGE("SetLocalAirplaneMode inner is nullptr, slotId:%{public}d", slotId); + return TELEPHONY_ERR_LOCAL_PTR_NULL; + } + inner->airplaneMode_ = state; + TELEPHONY_LOGD("SetLocalAirplaneMode slotId:%{public}d state:%{public}d", slotId, state); + return TELEPHONY_SUCCESS; +} + +int32_t NetworkSearchManager::GetLocalAirplaneMode(int32_t slotId, bool &state) +{ + auto inner = FindManagerInner(slotId); + if (inner == nullptr) { + TELEPHONY_LOGE("GetLocalAirplaneMode inner is nullptr, slotId:%{public}d", slotId); + return TELEPHONY_ERR_LOCAL_PTR_NULL; + } + state = inner->airplaneMode_; + TELEPHONY_LOGD("GetLocalAirplaneMode slotId:%{public}d state:%{public}d", slotId, state); + return TELEPHONY_ERR_SUCCESS; +} } // namespace Telephony } // namespace OHOS diff --git a/services/network_search/src/nitz_update.cpp b/services/network_search/src/nitz_update.cpp index 55f13c12..3222971f 100644 --- a/services/network_search/src/nitz_update.cpp +++ b/services/network_search/src/nitz_update.cpp @@ -317,7 +317,7 @@ bool NitzUpdate::IsAutoTimeZone() Uri uri(SettingUtils::NETWORK_SEARCH_SETTING_AUTO_TIMEZONE_URI); std::string key = SettingUtils::SETTINGS_NETWORK_SEARCH_AUTO_TIMEZONE; std::string value; - if (!settingHelper->Query(uri, key, value)) { + if (settingHelper->Query(uri, key, value) != TELEPHONY_SUCCESS) { TELEPHONY_LOGI("Query %{public}s fail", key.c_str()); return false; } @@ -336,7 +336,7 @@ bool NitzUpdate::IsAutoTime() Uri uri(SettingUtils::NETWORK_SEARCH_SETTING_AUTO_TIME_URI); std::string key = SettingUtils::SETTINGS_NETWORK_SEARCH_AUTO_TIME; std::string value = ""; - if (!settingHelper->Query(uri, key, value)) { + if (settingHelper->Query(uri, key, value) != TELEPHONY_SUCCESS) { TELEPHONY_LOGI("Query %{public}s fail", key.c_str()); return false; } diff --git a/services/network_search/src/radio_info.cpp b/services/network_search/src/radio_info.cpp index 00e3175d..fd500076 100644 --- a/services/network_search/src/radio_info.cpp +++ b/services/network_search/src/radio_info.cpp @@ -72,7 +72,9 @@ void RadioInfo::ProcessGetRadioState(const AppExecFwk::InnerEvent::Pointer &even } NetworkUtils::RemoveCallbackFromMap(index); } else { - if (nsm->GetRadioState(slotId_) != ModemPowerState::CORE_SERVICE_POWER_ON && !nsm->GetAirplaneMode()) { + bool isAirplaneModeOn = false; + if (nsm->GetRadioState(slotId_) != ModemPowerState::CORE_SERVICE_POWER_ON && + nsm->GetAirplaneMode(isAirplaneModeOn) == TELEPHONY_SUCCESS && !isAirplaneModeOn) { nsm->SetRadioState(slotId_, static_cast(ModemPowerState::CORE_SERVICE_POWER_ON), 0); } if (nsm->GetRadioState(slotId_) == ModemPowerState::CORE_SERVICE_POWER_ON) { @@ -310,13 +312,25 @@ void RadioInfo::AirplaneModeChange() TELEPHONY_LOGE("networkSearchManager_ is nullptr slotId:%{public}d", slotId_); return; } - bool airplaneMode = nsm->GetAirplaneMode(); - if (nsm->GetRadioState(slotId_) == ModemPowerState::CORE_SERVICE_POWER_OFF && airplaneMode == false) { + bool isAirplaneModeOn = false; + if (nsm->GetAirplaneMode(isAirplaneModeOn) != TELEPHONY_SUCCESS) { + TELEPHONY_LOGE("AirplaneModeChange GetAirplaneMode fail slotId:%{public}d", slotId_); + return; + } + bool lastAirplaneMode = false; + nsm->GetLocalAirplaneMode(slotId_, lastAirplaneMode); + if (isAirplaneModeOn == lastAirplaneMode) { + TELEPHONY_LOGE("airplaneMode is not change, slotId:%{public}d", slotId_); + return; + } + if (nsm->GetRadioState(slotId_) == ModemPowerState::CORE_SERVICE_POWER_OFF && isAirplaneModeOn == false) { nsm->SetRadioState(slotId_, static_cast(ModemPowerState::CORE_SERVICE_POWER_ON), 0); } - if (nsm->GetRadioState(slotId_) == ModemPowerState::CORE_SERVICE_POWER_ON && airplaneMode == true) { + if (nsm->GetRadioState(slotId_) == ModemPowerState::CORE_SERVICE_POWER_ON && isAirplaneModeOn == true) { nsm->SetRadioState(slotId_, static_cast(ModemPowerState::CORE_SERVICE_POWER_OFF), 0); } + nsm->SetLocalAirplaneMode(slotId_, isAirplaneModeOn); + TELEPHONY_LOGD("RadioInfo::AirplaneModeChange end. airplaneMode:%{public}d", isAirplaneModeOn); } } // namespace Telephony } // namespace OHOS diff --git a/services/network_search/src/setting_utils.cpp b/services/network_search/src/setting_utils.cpp index a30b40d5..59b86742 100644 --- a/services/network_search/src/setting_utils.cpp +++ b/services/network_search/src/setting_utils.cpp @@ -16,7 +16,7 @@ #include "setting_utils.h" #include "rdb_errno.h" - +#include "telephony_errors.h" #include "telephony_log_wrapper.h" namespace OHOS { @@ -36,7 +36,7 @@ const std::string SettingUtils::NETWORK_SEARCH_SETTING_PREFERRED_NETWORK_MODE_UR const std::string SettingUtils::SETTINGS_NETWORK_SEARCH_AUTO_TIME = "settings.telephony.autotime"; const std::string SettingUtils::SETTINGS_NETWORK_SEARCH_AUTO_TIMEZONE = "settings.telephony.autotimezone"; -const std::string SettingUtils::SETTINGS_NETWORK_SEARCH_AIRPLANE_MODE = "settings.telephony.airplanemode"; +const std::string SettingUtils::SETTINGS_NETWORK_SEARCH_AIRPLANE_MODE = "airplane_mode"; const std::string SettingUtils::SETTINGS_NETWORK_SEARCH_PREFERRED_NETWORK_MODE = "settings.telephony.preferrednetworkmode"; @@ -86,12 +86,12 @@ bool SettingUtils::RegisterSettingsObserver( return true; } -bool SettingUtils::Query(Uri uri, const std::string &key, std::string &value) +int32_t SettingUtils::Query(Uri uri, const std::string &key, std::string &value) { TELEPHONY_LOGI("SettingUtils:Query"); if (settingHelper_ == nullptr) { TELEPHONY_LOGE("settingHelper_ is null"); - return false; + return TELEPHONY_ERR_LOCAL_PTR_NULL; } std::vector columns; @@ -100,12 +100,12 @@ bool SettingUtils::Query(Uri uri, const std::string &key, std::string &value) auto result = settingHelper_->Query(uri, predicates, columns); if (result == nullptr) { TELEPHONY_LOGE("SettingUtils: query error, result is null"); - return false; + return TELEPHONY_ERR_LOCAL_PTR_NULL; } if (result->GoToFirstRow() != DataShare::E_OK) { TELEPHONY_LOGE("SettingUtils: query error, go to first row error"); - return false; + return TELEPHONY_ERR_DATABASE_READ_FAIL; } int columnIndex = 0; @@ -113,15 +113,15 @@ bool SettingUtils::Query(Uri uri, const std::string &key, std::string &value) result->GetString(columnIndex, value); result->Close(); TELEPHONY_LOGI("SettingUtils: query success"); - return true; + return TELEPHONY_SUCCESS; } -bool SettingUtils::Insert(Uri uri, const std::string &key, const std::string &value) +int32_t SettingUtils::Insert(Uri uri, const std::string &key, const std::string &value) { TELEPHONY_LOGI("SettingUtils: insert start"); if (settingHelper_ == nullptr) { TELEPHONY_LOGE("settingHelper_ is null"); - return false; + return TELEPHONY_ERR_LOCAL_PTR_NULL; } DataShare::DataShareValuesBucket valuesBucket; DataShare::DataShareValueObject keyObj(key); @@ -130,14 +130,14 @@ bool SettingUtils::Insert(Uri uri, const std::string &key, const std::string &va valuesBucket.Put(SETTING_VALUE, valueObj); int32_t result = settingHelper_->Insert(uri, valuesBucket); if (result == RDB_INVALID_VALUE) { - return false; + return TELEPHONY_ERR_DATABASE_WRITE_FAIL; } TELEPHONY_LOGI("SettingUtils: insert success"); settingHelper_->NotifyChange(uri); - return true; + return TELEPHONY_SUCCESS; } -bool SettingUtils::Update(Uri uri, const std::string &key, const std::string &value) +int32_t SettingUtils::Update(Uri uri, const std::string &key, const std::string &value) { TELEPHONY_LOGI("SettingUtils:update"); if (settingHelper_ == nullptr) { @@ -145,8 +145,7 @@ bool SettingUtils::Update(Uri uri, const std::string &key, const std::string &va return false; } std::string queryValue = ""; - bool ret = Query(uri, key, queryValue); - if (!ret) { + if (Query(uri, key, queryValue) != TELEPHONY_SUCCESS) { return Insert(uri, key, value); } @@ -157,11 +156,11 @@ bool SettingUtils::Update(Uri uri, const std::string &key, const std::string &va predicates.EqualTo(SETTING_KEY, key); int32_t result = settingHelper_->Update(uri, predicates, valuesBucket); if (result == RDB_INVALID_VALUE) { - return false; + return TELEPHONY_ERR_DATABASE_WRITE_FAIL; } TELEPHONY_LOGI("SettingUtils: update success"); settingHelper_->NotifyChange(uri); - return true; + return TELEPHONY_SUCCESS; } AutoTimeObserver::AutoTimeObserver(std::shared_ptr &networkSearchHandler) diff --git a/test/unittest/core_service_gtest/zero_branch_test.cpp b/test/unittest/core_service_gtest/zero_branch_test.cpp index 1a0a6e0b..c4e599dc 100644 --- a/test/unittest/core_service_gtest/zero_branch_test.cpp +++ b/test/unittest/core_service_gtest/zero_branch_test.cpp @@ -689,6 +689,9 @@ HWTEST_F(BranchTest, Telephony_CoreManagerInner_001, Function | MediumTest | Lev EXPECT_GT(mInner.GetLinkBandwidthInfo(0, 0, 0, nullptr), TELEPHONY_ERR_SUCCESS); LinkBandwidthRule mLinkBandwidthRule; EXPECT_GT(mInner.SetLinkBandwidthReportingRule(0, 0, mLinkBandwidthRule, nullptr), TELEPHONY_ERR_SUCCESS); + bool airplaneMode = false; + EXPECT_GT(mInner.GetAirplaneMode(airplaneMode), TELEPHONY_ERR_SUCCESS); + EXPECT_GT(mInner.UpdateRadioOn(INVALID_SLOTID), TELEPHONY_ERR_SUCCESS); } /** @@ -1621,6 +1624,9 @@ HWTEST_F(BranchTest, Telephony_NetworkSearchManager_001, Function | MediumTest | EXPECT_TRUE(cellInfo.empty()); EXPECT_NE(networkSearchManager->SendUpdateCellLocationRequest(INVALID_SLOTID), TELEPHONY_ERR_SUCCESS); EXPECT_TRUE(networkSearchManager->GetCellLocation(INVALID_SLOTID) == nullptr); + bool airplaneMode = false; + EXPECT_NE(networkSearchManager->GetAirplaneMode(airplaneMode), TELEPHONY_ERR_SUCCESS); + EXPECT_NE(networkSearchManager->UpdateRadioOn(INVALID_SLOTID), TELEPHONY_ERR_SUCCESS); } /** @@ -1667,6 +1673,9 @@ HWTEST_F(BranchTest, Telephony_NetworkSearchManager_002, Function | MediumTest | networkSearchManager->SetNrOptionMode(INVALID_SLOTID, NrMode::NR_MODE_UNKNOWN); networkSearchManager->SetFrequencyType(INVALID_SLOTID, FrequencyType::FREQ_TYPE_MMWAVE); networkSearchManager->SetRadioFirstPowerOn(INVALID_SLOTID, true); + networkSearchManager->SetLocalAirplaneMode(INVALID_SLOTID, true); + bool state = false; + networkSearchManager->GetLocalAirplaneMode(INVALID_SLOTID, state); EXPECT_TRUE(networkSearchManager->GetNetworkSearchInformationValue(INVALID_SLOTID) == nullptr); EXPECT_TRUE(networkSearchManager->GetNetworkSearchState(INVALID_SLOTID) != nullptr); EXPECT_TRUE(networkSearchManager->IsRadioFirstPowerOn(INVALID_SLOTID)); From 607cfdf167b2b242ba93ae5f853e227a96a35d03 Mon Sep 17 00:00:00 2001 From: YOUR_NAME Date: Tue, 25 Apr 2023 21:54:35 +0800 Subject: [PATCH 2/8] fix: fix thread Signed-off-by: liujiandong --- BUILD.gn | 1 + services/core/include/runner_pool.h | 44 +++++++++++++ services/core/src/core_service.cpp | 3 +- services/core/src/runner_pool.cpp | 66 +++++++++++++++++++ .../sim/src/icc_dialling_numbers_cache.cpp | 5 +- .../sim/src/icc_dialling_numbers_manager.cpp | 8 +-- .../src/icc_operator_privilege_controller.cpp | 8 +-- services/sim/src/multi_sim_monitor.cpp | 3 - services/sim/src/operator_config_cache.cpp | 3 - .../sim/src/radio_protocol_controller.cpp | 6 +- services/sim/src/sim_account_manager.cpp | 7 +- services/sim/src/sim_file_manager.cpp | 14 ++-- services/sim/src/sim_manager.cpp | 9 +-- services/sim/src/sim_sms_manager.cpp | 4 +- services/sim/src/sim_state_manager.cpp | 5 +- services/sim/src/sim_state_tracker.cpp | 10 +-- services/sim/src/stk_manager.cpp | 6 +- 17 files changed, 149 insertions(+), 53 deletions(-) create mode 100755 services/core/include/runner_pool.h create mode 100644 services/core/src/runner_pool.cpp diff --git a/BUILD.gn b/BUILD.gn index 8cea80f0..43b1e524 100644 --- a/BUILD.gn +++ b/BUILD.gn @@ -32,6 +32,7 @@ ohos_shared_library("tel_core_service") { "$TELEPHONY_CORE_SERVICE_ROOT/services/core/src/core_service_dump_helper.cpp", "$TELEPHONY_CORE_SERVICE_ROOT/services/core/src/core_service_hisysevent.cpp", "$TELEPHONY_CORE_SERVICE_ROOT/services/core/src/core_service_stub.cpp", + "$TELEPHONY_CORE_SERVICE_ROOT/services/core/src/runner_pool.cpp", "$TELEPHONY_IMS_CORE_SERVICE_SRC_PATH/ims_core_service_callback_stub.cpp", "$TELEPHONY_IMS_CORE_SERVICE_SRC_PATH/ims_core_service_client.cpp", "$TELEPHONY_IMS_CORE_SERVICE_SRC_PATH/ims_core_service_proxy.cpp", diff --git a/services/core/include/runner_pool.h b/services/core/include/runner_pool.h new file mode 100755 index 00000000..a96fd1dd --- /dev/null +++ b/services/core/include/runner_pool.h @@ -0,0 +1,44 @@ +/* + * Copyright (C) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef RUNNER_POOL_H +#define RUNNER_POOL_H + +#include +#include "event_runner.h" + +namespace OHOS { +namespace Telephony { +class RunnerPool { +public: + static RunnerPool &GetInstance(); + void Init(); + std::shared_ptr GetCommonRunner(); + std::shared_ptr GetSimDbAndFileRunner(); + +private: + std::shared_ptr CreateRunner(const std::string &name); + RunnerPool() = default; + ~RunnerPool() = default; + +private: + std::shared_ptr commonRunner_ = nullptr; + std::shared_ptr simDbAndFileRunner_ = nullptr; + static RunnerPool runnerPool_; + bool isInit_ = false; +}; +} // namespace Telephony +} // namespace OHOS +#endif // RUNNER_POOL_H diff --git a/services/core/src/core_service.cpp b/services/core/src/core_service.cpp index 00c6fb4e..12012037 100644 --- a/services/core/src/core_service.cpp +++ b/services/core/src/core_service.cpp @@ -21,6 +21,7 @@ #include "network_search_manager.h" #include "network_search_types.h" #include "parameter.h" +#include "runner_pool.h" #include "sim_manager.h" #include "string_ex.h" #include "system_ability_definition.h" @@ -56,7 +57,7 @@ void CoreService::OnStart() } registerToService_ = true; } - + RunnerPool::GetInstance().Init(); if (!Init()) { TELEPHONY_LOGE("failed to init CoreService"); return; diff --git a/services/core/src/runner_pool.cpp b/services/core/src/runner_pool.cpp new file mode 100644 index 00000000..ded3322c --- /dev/null +++ b/services/core/src/runner_pool.cpp @@ -0,0 +1,66 @@ +/* + * Copyright (C) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "runner_pool.h" + +#include "telephony_log_wrapper.h" + +namespace OHOS { +namespace Telephony { +RunnerPool RunnerPool::runnerPool_; + +RunnerPool &RunnerPool::GetInstance() +{ + return runnerPool_; +} + +void RunnerPool::Init() +{ + if (isInit_) { + TELEPHONY_LOGI("RunnerPool has init"); + return; + } + commonRunner_ = CreateRunner("CoreServiceCommonRunner"); + simDbAndFileRunner_ = CreateRunner("SimDbAndFileRunner"); + if (commonRunner_ == nullptr || simDbAndFileRunner_ == nullptr) { + return; + } + isInit_ = true; + TELEPHONY_LOGI("RunnerPool init success"); +} + +std::shared_ptr RunnerPool::CreateRunner(const std::string &name) +{ + auto runner = AppExecFwk::EventRunner::Create(name); + if (runner == nullptr) { + TELEPHONY_LOGE("%{public}s runner create thread fail!", name.c_str()); + return nullptr; + } + runner->Run(); + return runner; +} + +std::shared_ptr RunnerPool::GetCommonRunner() +{ + return commonRunner_; +} + +std::shared_ptr RunnerPool::GetSimDbAndFileRunner() +{ + return simDbAndFileRunner_; +} + +} // namespace Telephony +} // namespace OHOS \ No newline at end of file diff --git a/services/sim/src/icc_dialling_numbers_cache.cpp b/services/sim/src/icc_dialling_numbers_cache.cpp index 626639c6..89a61366 100644 --- a/services/sim/src/icc_dialling_numbers_cache.cpp +++ b/services/sim/src/icc_dialling_numbers_cache.cpp @@ -15,6 +15,8 @@ #include "icc_dialling_numbers_cache.h" +#include "runner_pool.h" + namespace OHOS { namespace Telephony { IccDiallingNumbersCache::IccDiallingNumbersCache( @@ -42,7 +44,7 @@ void IccDiallingNumbersCache::Init() return; } - std::shared_ptr loaderLoop = AppExecFwk::EventRunner::Create("usimpdiallingnumbers"); + std::shared_ptr loaderLoop = RunnerPool::GetInstance().GetCommonRunner(); if (loaderLoop.get() == nullptr) { TELEPHONY_LOGE("IccDiallingNumbersCache failed to create usimpdiallingnumbers loop"); return; @@ -54,7 +56,6 @@ void IccDiallingNumbersCache::Init() } std::shared_ptr fileController = simFileManager_->GetIccFileController(); usimDiallingNumberSrv_->SetFileControllerAndDiallingNumberHandler(fileController, diallingNumbersHandler_); - loaderLoop->Run(); } void IccDiallingNumbersCache::ProcessEvent(const AppExecFwk::InnerEvent::Pointer &event) diff --git a/services/sim/src/icc_dialling_numbers_manager.cpp b/services/sim/src/icc_dialling_numbers_manager.cpp index 35df9da0..beb20d78 100644 --- a/services/sim/src/icc_dialling_numbers_manager.cpp +++ b/services/sim/src/icc_dialling_numbers_manager.cpp @@ -17,6 +17,7 @@ #include "core_service_errors.h" #include "radio_event.h" +#include "runner_pool.h" #include "telephony_errors.h" namespace OHOS { @@ -36,7 +37,7 @@ void IccDiallingNumbersManager::Init() return; } - eventLoopDiallingNumbers_ = AppExecFwk::EventRunner::Create("diallingNumbersCacheLoop"); + eventLoopDiallingNumbers_ = RunnerPool::GetInstance().GetCommonRunner(); if (eventLoopDiallingNumbers_.get() == nullptr) { TELEPHONY_LOGE("IccDiallingNumbersManager failed to create EventRunner"); return; @@ -53,7 +54,6 @@ void IccDiallingNumbersManager::Init() return; } - eventLoopDiallingNumbers_->Run(); stateDiallingNumbers_ = HandleRunningState::STATE_RUNNING; diallingNumbersCache_->Init(); @@ -340,8 +340,7 @@ bool IccDiallingNumbersManager::IsValidType(int type) std::shared_ptr IccDiallingNumbersManager::CreateInstance( const std::shared_ptr &simFile, const std::shared_ptr &simState) { - std::shared_ptr eventLoop = - AppExecFwk::EventRunner::Create("diallingNumbersManagerLoop"); + std::shared_ptr eventLoop = RunnerPool::GetInstance().GetCommonRunner(); if (eventLoop.get() == nullptr) { TELEPHONY_LOGE("IccDiallingNumbersManager failed to create EventRunner"); return nullptr; @@ -356,7 +355,6 @@ std::shared_ptr IccDiallingNumbersManager::CreateInst TELEPHONY_LOGE("IccDiallingNumbersManager::Init manager create nullptr."); return nullptr; } - eventLoop->Run(); return manager; } diff --git a/services/sim/src/icc_operator_privilege_controller.cpp b/services/sim/src/icc_operator_privilege_controller.cpp index b9481e27..e47f64e4 100644 --- a/services/sim/src/icc_operator_privilege_controller.cpp +++ b/services/sim/src/icc_operator_privilege_controller.cpp @@ -21,9 +21,10 @@ #include #include "inner_event.h" +#include "radio_event.h" +#include "runner_pool.h" #include "sim_data_type.h" #include "telephony_log_wrapper.h" -#include "radio_event.h" namespace OHOS { namespace Telephony { @@ -193,15 +194,12 @@ void IccOperatorPrivilegeController::Init(const int32_t slotId) return; } if (this->GetEventRunner() == nullptr) { - auto runner = AppExecFwk::EventRunner::Create("UsimOperatorPrivilegeManager"); + auto runner = RunnerPool::GetInstance().GetCommonRunner(); if (runner == nullptr) { TELEPHONY_LOGE("IccOperatorPrivilegeController::Init Create thread fail!"); return; } this->SetEventRunner(runner); - if (runner->Run() != ERR_OK) { - TELEPHONY_LOGE("runner->Run() fail!!"); - } } auto self = this->shared_from_this(); simStateManager_->RegisterCoreNotify(self, RadioEvent::RADIO_SIM_STATE_CHANGE); diff --git a/services/sim/src/multi_sim_monitor.cpp b/services/sim/src/multi_sim_monitor.cpp index 08c5fb11..d272d9c4 100755 --- a/services/sim/src/multi_sim_monitor.cpp +++ b/services/sim/src/multi_sim_monitor.cpp @@ -30,9 +30,6 @@ MultiSimMonitor::MultiSimMonitor(const std::shared_ptr : AppExecFwk::EventHandler(runner), controller_(controller), simStateManager_(simStateManager), simFileManager_(simFileManager) { - if (runner != nullptr) { - runner->Run(); - } if (observerHandler_ == nullptr) { observerHandler_ = std::make_unique(); } diff --git a/services/sim/src/operator_config_cache.cpp b/services/sim/src/operator_config_cache.cpp index 76b38af2..e06c4e2e 100644 --- a/services/sim/src/operator_config_cache.cpp +++ b/services/sim/src/operator_config_cache.cpp @@ -30,9 +30,6 @@ OperatorConfigCache::OperatorConfigCache(const std::shared_ptr simFileManager, int32_t slotId) : AppExecFwk::EventHandler(runner), simFileManager_(simFileManager), slotId_(slotId) { - if (runner != nullptr) { - runner->Run(); - } TELEPHONY_LOGI("OperatorConfigCache create"); } diff --git a/services/sim/src/radio_protocol_controller.cpp b/services/sim/src/radio_protocol_controller.cpp index 7eaf01a3..65183443 100644 --- a/services/sim/src/radio_protocol_controller.cpp +++ b/services/sim/src/radio_protocol_controller.cpp @@ -27,11 +27,7 @@ std::condition_variable RadioProtocolController::cv_; RadioProtocolController::RadioProtocolController(std::shared_ptr telRilManager, const std::shared_ptr &runner) : AppExecFwk::EventHandler(runner), telRilManager_(telRilManager) -{ - if (runner != nullptr) { - runner->Run(); - } -} +{} void RadioProtocolController::Init() { diff --git a/services/sim/src/sim_account_manager.cpp b/services/sim/src/sim_account_manager.cpp index 37e939b7..ad7ed580 100755 --- a/services/sim/src/sim_account_manager.cpp +++ b/services/sim/src/sim_account_manager.cpp @@ -15,6 +15,7 @@ #include "sim_account_manager.h" +#include "runner_pool.h" #include "string_ex.h" namespace OHOS { @@ -47,7 +48,7 @@ void SimAccountManager::Init(int32_t slotId) TELEPHONY_LOGE("SimAccountManager::init SimAccountManager invalid slotId = %{public}d", slotId); return; } - operatorConfigCacheRunner_ = AppExecFwk::EventRunner::Create("OperatorConfigCache"); + operatorConfigCacheRunner_ = RunnerPool::GetInstance().GetSimDbAndFileRunner(); if (operatorConfigCacheRunner_.get() == nullptr) { TELEPHONY_LOGE("SimAccountManager::Init operatorConfigCacheRunner_ failed"); return; @@ -58,7 +59,7 @@ void SimAccountManager::Init(int32_t slotId) return; } operatorConfigCache_->RegisterForIccChange(); - simStateTrackerRunner_ = AppExecFwk::EventRunner::Create("SimStateTracker"); + simStateTrackerRunner_ = RunnerPool::GetInstance().GetSimDbAndFileRunner(); if (simStateTrackerRunner_.get() == nullptr) { TELEPHONY_LOGE("SimAccountManager::Init simStateTrackerRunner_ failed"); return; @@ -111,7 +112,7 @@ int32_t SimAccountManager::HasOperatorPrivileges(const int32_t slotId, bool &has } if (privilegesRunner_.get() == nullptr) { TELEPHONY_LOGE("make privilegesRunner_"); - privilegesRunner_ = AppExecFwk::EventRunner::Create("PrivilegeController"); + privilegesRunner_ = RunnerPool::GetInstance().GetCommonRunner(); } if ((privilegesRunner_ == nullptr) || (telRilManager_ == nullptr) || (simStateManager_ == nullptr)) { TELEPHONY_LOGE("has nullptr at privilegesRunner_ or telRilManager_ or simStateManager_"); diff --git a/services/sim/src/sim_file_manager.cpp b/services/sim/src/sim_file_manager.cpp index 1cbf8c53..dacbe767 100755 --- a/services/sim/src/sim_file_manager.cpp +++ b/services/sim/src/sim_file_manager.cpp @@ -17,6 +17,7 @@ #include "network_state.h" #include "radio_event.h" +#include "runner_pool.h" namespace OHOS { namespace Telephony { @@ -89,7 +90,7 @@ bool SimFileManager::InitSimFile(SimFileManager::IccType type) return false; } if (eventLoopRecord_ == nullptr) { - eventLoopRecord_ = AppExecFwk::EventRunner::Create("IccFile"); + eventLoopRecord_ = RunnerPool::GetInstance().GetCommonRunner(); if (eventLoopRecord_.get() == nullptr) { TELEPHONY_LOGE("IccFile failed to create EventRunner"); return false; @@ -116,7 +117,6 @@ bool SimFileManager::InitSimFile(SimFileManager::IccType type) return false; } simFile_->SetRilAndFileController(telRilManager_, fileController_, diallingNumberHandler_); - eventLoopRecord_->Run(); simFile_->SetId(slotId_); simFile_->Init(); return true; @@ -125,7 +125,7 @@ bool SimFileManager::InitSimFile(SimFileManager::IccType type) bool SimFileManager::InitIccFileController(SimFileManager::IccType type) { if (eventLoopFileController_ == nullptr) { - eventLoopFileController_ = AppExecFwk::EventRunner::Create("SIMController"); + eventLoopFileController_ = RunnerPool::GetInstance().GetCommonRunner(); if (eventLoopFileController_.get() == nullptr) { TELEPHONY_LOGE("SIMHandler failed to create EventRunner"); return false; @@ -153,7 +153,6 @@ bool SimFileManager::InitIccFileController(SimFileManager::IccType type) return false; } fileController_->SetRilManager(telRilManager_); - eventLoopFileController_->Run(); return true; } @@ -468,7 +467,7 @@ bool SimFileManager::InitDiallingNumberHandler() diallingNumberHandler_->UpdateFileController(fileController_); return true; } - std::shared_ptr loaderLoop = AppExecFwk::EventRunner::Create("msisdnLoader"); + std::shared_ptr loaderLoop = RunnerPool::GetInstance().GetCommonRunner(); if (loaderLoop.get() == nullptr) { TELEPHONY_LOGE("SimFileManager failed to create diallingNumberloader loop"); return false; @@ -478,7 +477,6 @@ bool SimFileManager::InitDiallingNumberHandler() TELEPHONY_LOGE("SimFileManager failed to create IccDiallingNumbersHandler."); return false; } - loaderLoop->Run(); return true; } @@ -527,7 +525,7 @@ void SimFileManager::ProcessEvent(const AppExecFwk::InnerEvent::Pointer &event) std::shared_ptr SimFileManager::CreateInstance( const std::shared_ptr &ril, const std::shared_ptr &simState) { - std::shared_ptr eventLoop = AppExecFwk::EventRunner::Create("simFileMgrLoop"); + std::shared_ptr eventLoop = RunnerPool::GetInstance().GetCommonRunner(); if (eventLoop.get() == nullptr) { TELEPHONY_LOGE("SimFileManager failed to create EventRunner"); return nullptr; @@ -541,7 +539,7 @@ std::shared_ptr SimFileManager::CreateInstance( TELEPHONY_LOGE("SimFileManager::Init manager create nullptr."); return nullptr; } - eventLoop->Run(); + return manager; } diff --git a/services/sim/src/sim_manager.cpp b/services/sim/src/sim_manager.cpp index 90c8a137..ee49adcd 100755 --- a/services/sim/src/sim_manager.cpp +++ b/services/sim/src/sim_manager.cpp @@ -17,6 +17,7 @@ #include "core_service_errors.h" #include "radio_event.h" +#include "runner_pool.h" #include "telephony_errors.h" namespace OHOS { @@ -92,7 +93,7 @@ void SimManager::InitMultiSimObject() void SimManager::InitSingleSimObject() { - controllerRunner_ = AppExecFwk::EventRunner::Create("MultiSimController"); + controllerRunner_ = RunnerPool::GetInstance().GetCommonRunner(); if (controllerRunner_.get() == nullptr) { TELEPHONY_LOGE("SimManager::InitSingleSimObject get controllerRunner_ failed"); return; @@ -105,11 +106,7 @@ void SimManager::InitSingleSimObject() } multiSimController_->Init(); - monitorRunner_ = AppExecFwk::EventRunner::Create("MultiSimMonitor"); - if (monitorRunner_.get() == nullptr) { - TELEPHONY_LOGE("get monitorRunner_ failed"); - return; - } + monitorRunner_ = RunnerPool::GetInstance().GetSimDbAndFileRunner(); multiSimMonitor_ = std::make_shared( monitorRunner_, multiSimController_, simStateManager_, simFileManager_); if (multiSimMonitor_ == nullptr) { diff --git a/services/sim/src/sim_sms_manager.cpp b/services/sim/src/sim_sms_manager.cpp index d48ef608..eda4afc5 100755 --- a/services/sim/src/sim_sms_manager.cpp +++ b/services/sim/src/sim_sms_manager.cpp @@ -16,6 +16,7 @@ #include "sim_sms_manager.h" #include "telephony_errors.h" +#include "runner_pool.h" namespace OHOS { namespace Telephony { @@ -42,7 +43,7 @@ void SimSmsManager::Init(int slotId) return; } - eventLoopSms_ = AppExecFwk::EventRunner::Create("simSmsController"); + eventLoopSms_ = RunnerPool::GetInstance().GetCommonRunner(); if (eventLoopSms_.get() == nullptr) { TELEPHONY_LOGE("simSmsController failed to create EventRunner"); return; @@ -61,7 +62,6 @@ void SimSmsManager::Init(int slotId) } smsController_->SetRilAndFileManager(telRilManager_, fileManager); - eventLoopSms_->Run(); stateSms_ = HandleRunningState::STATE_RUNNING; smsController_->Init(slotId_); diff --git a/services/sim/src/sim_state_manager.cpp b/services/sim/src/sim_state_manager.cpp index 5123e571..6dacdf6c 100755 --- a/services/sim/src/sim_state_manager.cpp +++ b/services/sim/src/sim_state_manager.cpp @@ -16,6 +16,7 @@ #include "sim_state_manager.h" #include "core_service_errors.h" +#include "runner_pool.h" #include "telephony_errors.h" #include "telephony_log_wrapper.h" @@ -43,7 +44,7 @@ void SimStateManager::Init(int32_t slotId) TELEPHONY_LOGE("SimStateManager::Init telRilManager_ is null."); return; } - eventLoop_ = AppExecFwk::EventRunner::Create("SimStateHandle"); + eventLoop_ = RunnerPool::GetInstance().GetCommonRunner(); if (eventLoop_.get() == nullptr) { TELEPHONY_LOGE("SimStateHandle failed to create EventRunner"); return; @@ -55,7 +56,7 @@ void SimStateManager::Init(int32_t slotId) } simStateHandle_->SetRilManager(telRilManager_); simStateHandle_->Init(slotId); - eventLoop_->Run(); + TELEPHONY_LOGI("SimStateManager::eventLoop_ is running"); simStateRun_ = STATE_RUNNING; } diff --git a/services/sim/src/sim_state_tracker.cpp b/services/sim/src/sim_state_tracker.cpp index f75d733c..4859480e 100755 --- a/services/sim/src/sim_state_tracker.cpp +++ b/services/sim/src/sim_state_tracker.cpp @@ -17,6 +17,7 @@ #include "core_manager_inner.h" #include "radio_event.h" +#include "thread" namespace OHOS { namespace Telephony { @@ -26,9 +27,6 @@ SimStateTracker::SimStateTracker(const std::shared_ptr : AppExecFwk::EventHandler(runner), simFileManager_(simFileManager), operatorConfigCache_(operatorConfigCache), slotId_(slotId) { - if (runner != nullptr) { - runner->Run(); - } if (simFileManager == nullptr) { TELEPHONY_LOGE("can not make OperatorConfigLoader"); } @@ -71,7 +69,11 @@ void SimStateTracker::ProcessEvent(const AppExecFwk::InnerEvent::Pointer &event) TELEPHONY_LOGE("sim is not exist"); return; } - operatorConfigLoader_->LoadOperatorConfig(slotId_); + std::thread loadOperatorConfigTask([&]() { + pthread_setname_np(pthread_self(), "load_operator_config"); + operatorConfigLoader_->LoadOperatorConfig(slotId_); + }); + loadOperatorConfigTask.detach(); } } diff --git a/services/sim/src/stk_manager.cpp b/services/sim/src/stk_manager.cpp index da424057..a361a239 100755 --- a/services/sim/src/stk_manager.cpp +++ b/services/sim/src/stk_manager.cpp @@ -15,6 +15,7 @@ #include "stk_manager.h" +#include "runner_pool.h" #include "telephony_errors.h" #include "telephony_log_wrapper.h" @@ -40,9 +41,7 @@ void StkManager::Init(int slotId) TELEPHONY_LOGE("StkManager[%{public}d]::Init() telRilManager or simStateManager_ is nullptr", slotId); return; } - std::string name = "StkController_"; - name.append(std::to_string(slotId)); - stkEventLoop_ = AppExecFwk::EventRunner::Create(name.c_str()); + stkEventLoop_ = RunnerPool::GetInstance().GetCommonRunner(); if (stkEventLoop_.get() == nullptr) { TELEPHONY_LOGE("StkManager[%{public}d]::Init() failed to create EventRunner", slotId); return; @@ -53,7 +52,6 @@ void StkManager::Init(int slotId) return; } stkController_->Init(); - stkEventLoop_->Run(); TELEPHONY_LOGI("StkManager[%{public}d]::Init() success", slotId); } From 9f728db3b81ab36bb44cb5647fc0b4120190be30 Mon Sep 17 00:00:00 2001 From: dingxiaochen Date: Fri, 5 May 2023 17:26:28 +0800 Subject: [PATCH 3/8] add obtain pnn index from opl5G file. Signed-off-by: dingxiaochen --- services/sim/include/icc_file.h | 3 + services/sim/include/sim_constant.h | 2 + services/sim/include/sim_file.h | 2 + services/sim/include/sim_utils.h | 1 + services/sim/src/icc_file.cpp | 22 ++++-- services/sim/src/sim_file.cpp | 76 +++++++++++++++++-- services/sim/src/usim_file_controller.cpp | 1 + .../simauthentication_fuzzer.cpp | 18 +++++ .../core_service_gtest/zero_branch_test.cpp | 37 +++++++++ 9 files changed, 149 insertions(+), 13 deletions(-) diff --git a/services/sim/include/icc_file.h b/services/sim/include/icc_file.h index 41e7e0e8..401bd755 100755 --- a/services/sim/include/icc_file.h +++ b/services/sim/include/icc_file.h @@ -131,6 +131,7 @@ protected: std::string fplmns_ = ""; std::vector> pnnFiles_; std::vector> oplFiles_; + std::vector> opl5gFiles_; int lengthOfMnc_ = DEFAULT_MNC; int indexOfMailbox_ = 1; int fileToGet_ = 0; @@ -140,6 +141,8 @@ protected: bool waitResult_ = false; static std::mutex mtx_; std::condition_variable processWait_; + const int HEXADECIMAL = 16; + const size_t OPL_5G_LENGTH = 10; const uint8_t BYTE_NUM = 0xFF; const uint8_t BYTE_NUM2 = 0x01; const uint8_t BYTE_NUM3 = 0x0F; diff --git a/services/sim/include/sim_constant.h b/services/sim/include/sim_constant.h index 4940f318..25d4a0fe 100755 --- a/services/sim/include/sim_constant.h +++ b/services/sim/include/sim_constant.h @@ -89,6 +89,7 @@ enum SimMessage { MSG_SIM_OBTAIN_CDMA_SUBSCRIPTION_DONE, MSG_SIM_SMS_ON_RUIM, MSG_SIM_OBTAIN_OPL_DONE, + MSG_SIM_OBTAIN_OPL5G_DONE, MSG_SIM_OBTAIN_IMPI_DONE, MSG_SIM_OBTAIN_CSIM_SPN_DONE, MSG_SIM_OBTAIN_IST_DONE, @@ -107,6 +108,7 @@ enum ElementaryFile { ELEMENTARY_FILE_SPN_SHORT_CPHS = 0x6F18, // 3GPP TS 51.011 V4.1.0 section 10 contents of the Elementary Files ELEMENTARY_FILE_ICCID = 0x2FE2, + ELEMENTARY_FILE_OPL5G = 0x4F08, ELEMENTARY_FILE_IMG = 0x4F20, ELEMENTARY_FILE_HPLMN = 0x6F31, ELEMENTARY_FILE_SST = 0x6F38, diff --git a/services/sim/include/sim_file.h b/services/sim/include/sim_file.h index 8fd5814f..94953b11 100755 --- a/services/sim/include/sim_file.h +++ b/services/sim/include/sim_file.h @@ -113,6 +113,7 @@ private: bool ProcessGetEhplmnDone(const AppExecFwk::InnerEvent::Pointer &event); bool ProcessGetPnnDone(const AppExecFwk::InnerEvent::Pointer &event); bool ProcessGetOplDone(const AppExecFwk::InnerEvent::Pointer &event); + bool ProcessGetOpl5gDone(const AppExecFwk::InnerEvent::Pointer &event); bool ProcessUpdateDone(const AppExecFwk::InnerEvent::Pointer &event); bool ProcessSetCphsMailbox(const AppExecFwk::InnerEvent::Pointer &event); bool ProcessGetFplmnDone(const AppExecFwk::InnerEvent::Pointer &event); @@ -145,6 +146,7 @@ private: std::string ParseSpn(const std::string &rawData, int curState); void ParsePnn(const std::vector &records); void ParseOpl(const std::vector &records); + void ParseOpl5g(const std::vector &records); }; } // namespace Telephony } // namespace OHOS diff --git a/services/sim/include/sim_utils.h b/services/sim/include/sim_utils.h index bf96c661..621035a1 100755 --- a/services/sim/include/sim_utils.h +++ b/services/sim/include/sim_utils.h @@ -30,6 +30,7 @@ namespace Telephony { static const int DECIMAL_MAX = 10; static const int HALF_LEN = 2; static const int HALF_BYTE_LEN = 4; +static const int LAC_RANGE_LEN = 6; static const int UCS_FLAG = 0x81; static const int UCS_WIDE_FLAG = 0x82; // Full Name IEI from TS 24.008 diff --git a/services/sim/src/icc_file.cpp b/services/sim/src/icc_file.cpp index 7bf0e83c..c938cb34 100755 --- a/services/sim/src/icc_file.cpp +++ b/services/sim/src/icc_file.cpp @@ -14,12 +14,14 @@ */ #include "icc_file.h" + +#include "core_manager_inner.h" #include "if_system_ability_manager.h" #include "inner_event.h" #include "iservice_registry.h" +#include "radio_event.h" #include "system_ability_definition.h" #include "telephony_state_registry_client.h" -#include "radio_event.h" using namespace std; using namespace OHOS::AppExecFwk; @@ -204,21 +206,29 @@ std::string IccFile::ObtainSPN() std::string IccFile::ObtainEons(const std::string &plmn, int32_t lac, bool longNameRequired) { + std::vector> oplFiles = oplFiles_; + sptr networkState = nullptr; + CoreManagerInner::GetInstance().GetNetworkStatus(slotId_, networkState); + if (networkState != nullptr && !(opl5gFiles_.empty())) { + NrState nrState = networkState->GetNrState(); + if (nrState == NrState::NR_NSA_STATE_SA_ATTACHED) { + oplFiles = opl5gFiles_; + } + } bool roaming = (plmn.compare(operatorNumeric_) == 0 ? false : true); TELEPHONY_LOGI("ObtainEons roaming:%{public}d", roaming); - if (plmn.empty() || pnnFiles_.empty() || (oplFiles_.empty() && roaming)) { + if (plmn.empty() || pnnFiles_.empty() || (oplFiles.empty() && roaming)) { TELEPHONY_LOGE("ObtainEons is empty"); return ""; } int pnnIndex = 1; - for (std::shared_ptr opl : oplFiles_) { + for (std::shared_ptr opl : oplFiles) { if (opl == nullptr) { continue; } pnnIndex = -1; - TELEPHONY_LOGI( - "ObtainEons plmn:%{public}s, opl->plmnNumeric:%{public}s, lac:%{public}d, " - "opl->lacStart:%{public}d, opl->lacEnd:%{public}d, opl->pnnRecordId:%{public}d", + TELEPHONY_LOGD("ObtainEons plmn:%{public}s, opl->plmnNumeric:%{public}s, lac:%{public}d, " + "opl->lacStart:%{public}d, opl->lacEnd:%{public}d, opl->pnnRecordId:%{public}d", plmn.c_str(), opl->plmnNumeric.c_str(), lac, opl->lacStart, opl->lacEnd, opl->pnnRecordId); if (plmn.compare(opl->plmnNumeric) == 0 && ((opl->lacStart == 0 && opl->lacEnd == 0xfffe) || (opl->lacStart <= lac && opl->lacEnd >= lac))) { diff --git a/services/sim/src/sim_file.cpp b/services/sim/src/sim_file.cpp index 195a3c1c..e6e5e2e1 100755 --- a/services/sim/src/sim_file.cpp +++ b/services/sim/src/sim_file.cpp @@ -231,6 +231,10 @@ void SimFile::LoadSimFiles() fileController_->ObtainAllLinearFixedFile(ELEMENTARY_FILE_OPL, eventOpl); fileToGet_++; + AppExecFwk::InnerEvent::Pointer eventOpl5g = BuildCallerInfo(MSG_SIM_OBTAIN_OPL5G_DONE); + fileController_->ObtainAllLinearFixedFile(ELEMENTARY_FILE_OPL5G, eventOpl5g); + fileToGet_++; + AppExecFwk::InnerEvent::Pointer phoneNumberEvent = CreateDiallingNumberPointer(MSG_SIM_OBTAIN_MSISDN_DONE, 0, 0, nullptr); diallingNumberHandler_->GetDiallingNumbers( @@ -461,16 +465,50 @@ void SimFile::ParseOpl(const std::vector &records) } std::shared_ptr file = std::make_shared(); file->plmnNumeric = plmn; - int base = 16; // convert to hexadecimal - file->lacStart = stoi(dataOpl.substr(MCCMNC_LEN, HALF_BYTE_LEN), 0, base); - file->lacEnd = stoi(dataOpl.substr(MCCMNC_LEN + HALF_BYTE_LEN, HALF_BYTE_LEN), 0, base); - file->pnnRecordId = stoi(dataOpl.substr(MCCMNC_LEN + BYTE_LENGTH, HALF_LEN), 0, base); + if (!regex_match(dataOpl, std::regex("[0-9a-fA-F]+"))) { + TELEPHONY_LOGI("InputValue is not a hexadecimal number"); + continue; + } + file->lacStart = stoi(dataOpl.substr(MCCMNC_LEN, HALF_BYTE_LEN), 0, HEXADECIMAL); + file->lacEnd = stoi(dataOpl.substr(MCCMNC_LEN + HALF_BYTE_LEN, HALF_BYTE_LEN), 0, HEXADECIMAL); + file->pnnRecordId = stoi(dataOpl.substr(MCCMNC_LEN + BYTE_LENGTH, HALF_LEN), 0, HEXADECIMAL); TELEPHONY_LOGI("plmnNumeric: %{public}s, lacStart: %{public}d, lacEnd: %{public}d, pnnRecordId: %{public}d", file->plmnNumeric.c_str(), file->lacStart, file->lacEnd, file->pnnRecordId); oplFiles_.push_back(file); } } +void SimFile::ParseOpl5g(const std::vector &records) +{ + opl5gFiles_.clear(); + if (records.empty()) { + TELEPHONY_LOGI("ParseOpl5g records is empty"); + return; + } + for (const auto &dataOpl : records) { + TELEPHONY_LOGD("ParseOpl5g: %{public}s", dataOpl.c_str()); + if (dataOpl.size() != (OPL_5G_LENGTH + OPL_5G_LENGTH)) { + continue; + } + std::string plmn = SIMUtils::BcdPlmnConvertToString(dataOpl, 0); + if (plmn.empty()) { + continue; + } + std::shared_ptr file = std::make_shared(); + file->plmnNumeric = plmn; + if (!regex_match(dataOpl, std::regex("[0-9a-fA-F]+"))) { + TELEPHONY_LOGI("InputValue is not a hexadecimal number"); + continue; + } + file->lacStart = stoi(dataOpl.substr(MCCMNC_LEN, LAC_RANGE_LEN), 0, HEXADECIMAL); + file->lacEnd = stoi(dataOpl.substr(MCCMNC_LEN + LAC_RANGE_LEN, LAC_RANGE_LEN), 0, HEXADECIMAL); + file->pnnRecordId = stoi(dataOpl.substr(MCCMNC_LEN + LAC_RANGE_LEN + LAC_RANGE_LEN, HALF_LEN), 0, HEXADECIMAL); + TELEPHONY_LOGD("plmnNumeric: %{public}s, lacStart: %{public}d, lacEnd: %{public}d, pnnRecordId: %{public}d", + file->plmnNumeric.c_str(), file->lacStart, file->lacEnd, file->pnnRecordId); + opl5gFiles_.push_back(file); + } +} + std::shared_ptr SimFile::ObtainUsimFunctionHandle() { return UsimFunctionHandle_; @@ -1274,9 +1312,6 @@ bool SimFile::ProcessGetOplDone(const AppExecFwk::InnerEvent::Pointer &event) if (object->exception == nullptr) { ParseOpl(object->fileResults); } - for (std::string str : object->fileResults) { - TELEPHONY_LOGI("ProcessGetOplDone: %{public}s", str.c_str()); - } } else { TELEPHONY_LOGE("ProcessGetOplDone: get null pointer!!!"); } @@ -1284,6 +1319,32 @@ bool SimFile::ProcessGetOplDone(const AppExecFwk::InnerEvent::Pointer &event) return isFileProcessResponse; } +bool SimFile::ProcessGetOpl5gDone(const AppExecFwk::InnerEvent::Pointer &event) +{ + TELEPHONY_LOGD("ProcessGetOpl5gDone: start"); + bool isFileProcessResponse = true; + if (event == nullptr) { + TELEPHONY_LOGE("event is nullptr!"); + return isFileProcessResponse; + } + std::unique_ptr fd = event->GetUniqueObject(); + if (fd != nullptr) { + if (fd->exception != nullptr) { + TELEPHONY_LOGE("ProcessGetOpl5gDone: get error result"); + } + return isFileProcessResponse; + } + std::shared_ptr object = event->GetSharedObject(); + if (object == nullptr) { + TELEPHONY_LOGE("ProcessGetOpl5gDone: get null pointer!!!"); + return isFileProcessResponse; + } + if (object->exception == nullptr) { + ParseOpl5g(object->fileResults); + } + return isFileProcessResponse; +} + bool SimFile::ProcessUpdateDone(const AppExecFwk::InnerEvent::Pointer &event) { bool isFileProcessResponse = false; @@ -1497,6 +1558,7 @@ void SimFile::InitMemberFunc() memberFuncMap_[MSG_SIM_UPDATE_DONE] = &SimFile::ProcessUpdateDone; memberFuncMap_[MSG_SIM_OBTAIN_PNN_DONE] = &SimFile::ProcessGetPnnDone; memberFuncMap_[MSG_SIM_OBTAIN_OPL_DONE] = &SimFile::ProcessGetOplDone; + memberFuncMap_[MSG_SIM_OBTAIN_OPL5G_DONE] = &SimFile::ProcessGetOpl5gDone; memberFuncMap_[MSG_SIM_OBTAIN_ALL_SMS_DONE] = &SimFile::ProcessGetAllSmsDone; memberFuncMap_[MSG_SIM_MARK_SMS_READ_DONE] = &SimFile::ProcessMarkSms; memberFuncMap_[MSG_SIM_SMS_ON_SIM] = &SimFile::ProcessSmsOnSim; diff --git a/services/sim/src/usim_file_controller.cpp b/services/sim/src/usim_file_controller.cpp index 7257e64f..a0705b95 100755 --- a/services/sim/src/usim_file_controller.cpp +++ b/services/sim/src/usim_file_controller.cpp @@ -51,6 +51,7 @@ std::string UsimFileController::ObtainUsimElementFilePath(int efId) case ELEMENTARY_FILE_MBDN: case ELEMENTARY_FILE_PNN: case ELEMENTARY_FILE_OPL: + case ELEMENTARY_FILE_OPL5G: case ELEMENTARY_FILE_SPDI: case ELEMENTARY_FILE_SST: case ELEMENTARY_FILE_CFIS: diff --git a/test/fuzztest/simauthentication_fuzzer/simauthentication_fuzzer.cpp b/test/fuzztest/simauthentication_fuzzer/simauthentication_fuzzer.cpp index 5a2eddce..7b49f0cb 100644 --- a/test/fuzztest/simauthentication_fuzzer/simauthentication_fuzzer.cpp +++ b/test/fuzztest/simauthentication_fuzzer/simauthentication_fuzzer.cpp @@ -23,6 +23,7 @@ #include "addcoreservicetoken_fuzzer.h" #include "core_service.h" #include "napi_util.h" +#include "sim_file.h" #include "system_ability_definition.h" #include "unistd.h" @@ -152,6 +153,22 @@ void SimAuthentication(const uint8_t *data, size_t size) DelayedSingleton::GetInstance()->OnSimAuthentication(dataMessageParcel, reply); } +void ParseOpl5g(const uint8_t *data, size_t size) +{ + if (!IsServiceInited()) { + return; + } + + std::shared_ptr telRilManager = std::make_shared(); + std::shared_ptr simStateManager = std::make_shared(telRilManager); + std::shared_ptr eventLoopRecord = AppExecFwk::EventRunner::Create("SimFile"); + std::shared_ptr simFile = std::make_shared(eventLoopRecord, simStateManager); + std::string fileData(reinterpret_cast(data), size); + std::vector records; + records.push_back(fileData); + simFile->ParseOpl5g(records); +} + void DoSomethingInterestingWithMyAPI(const uint8_t *data, size_t size) { if (data == nullptr || size == 0) { @@ -164,6 +181,7 @@ void DoSomethingInterestingWithMyAPI(const uint8_t *data, size_t size) GetVoiceMailNumber(data, size); QueryIccDiallingNumbers(data, size); SimAuthentication(data, size); + ParseOpl5g(data, size); return; } } // namespace OHOS diff --git a/test/unittest/core_service_gtest/zero_branch_test.cpp b/test/unittest/core_service_gtest/zero_branch_test.cpp index 1a0a6e0b..ebc75bb3 100644 --- a/test/unittest/core_service_gtest/zero_branch_test.cpp +++ b/test/unittest/core_service_gtest/zero_branch_test.cpp @@ -413,6 +413,7 @@ HWTEST_F(BranchTest, Telephony_SimFile_002, Function | MediumTest | Level1) EXPECT_TRUE(simFile->ProcessGetEhplmnDone(event)); EXPECT_TRUE(simFile->ProcessGetPnnDone(event)); EXPECT_TRUE(simFile->ProcessGetOplDone(event)); + EXPECT_TRUE(simFile->ProcessGetOpl5gDone(event)); EXPECT_FALSE(simFile->ProcessUpdateDone(event)); EXPECT_TRUE(simFile->ProcessSetCphsMailbox(event)); EXPECT_TRUE(simFile->ProcessGetFplmnDone(event)); @@ -504,6 +505,12 @@ HWTEST_F(BranchTest, Telephony_SimFile_004, Function | MediumTest | Level1) simFile->ParseOpl(emptyRecords); simFile->ParsePnn(records); simFile->ParseOpl(records); + std::vector invalidRecords = { "64F0100000GGGG02", "64F0000000GGGG01" }; + simFile->ParseOpl(invalidRecords); + std::vector invalidPlmnRecords = { "F640100000FFFE02", "F640000000FFFE01" }; + simFile->ParseOpl(invalidPlmnRecords); + std::vector records5g = { "64F0100000FFFE02", "64F0000000FFFE01" }; + simFile->ParseOpl(records5g); SimFile::SpnStatus newStatus; EXPECT_TRUE(simFile->IsContinueGetSpn(false, SimFile::SpnStatus::OBTAIN_SPN_NONE, newStatus)); EXPECT_TRUE(simFile->IsContinueGetSpn(true, SimFile::SpnStatus::OBTAIN_SPN_NONE, newStatus)); @@ -522,6 +529,35 @@ HWTEST_F(BranchTest, Telephony_SimFile_004, Function | MediumTest | Level1) EXPECT_EQ(simFile->ParseSpn("", 0), ""); } +/** + * @tc.number Telephony_SimFile_005 + * @tc.name test error branch + * @tc.desc Function test + */ +HWTEST_F(BranchTest, Telephony_SimFile_005, Function | MediumTest | Level1) +{ + std::shared_ptr telRilManager = std::make_shared(); + telRilManager->OnInit(); + std::shared_ptr simStateManager = std::make_shared(telRilManager); + std::shared_ptr eventLoopRecord = AppExecFwk::EventRunner::Create("SimFile"); + std::shared_ptr simFile = std::make_shared(eventLoopRecord, simStateManager); + std::vector emptyRecords = {}; + simFile->ParseOpl5g(emptyRecords); + EXPECT_TRUE(simFile->opl5gFiles_.empty()); + std::vector records = { "46000", "46002", "46004", "46007", "46008" }; + simFile->ParseOpl5g(records); + EXPECT_TRUE(simFile->opl5gFiles_.empty()); + std::vector invalidRecords = { "64F010000000GGGGGG02", "64F000000000GGGGGG01" }; + simFile->ParseOpl5g(invalidRecords); + EXPECT_TRUE(simFile->opl5gFiles_.empty()); + std::vector invalidPlmnRecords = { "F64010000000FFFFFE02", "F64000000000FFFFFE01" }; + simFile->ParseOpl5g(invalidPlmnRecords); + EXPECT_TRUE(simFile->opl5gFiles_.empty()); + std::vector records5g = { "64F010000000FFFFFE02", "64F000000000FFFFFE01" }; + simFile->ParseOpl5g(records5g); + EXPECT_FALSE(simFile->opl5gFiles_.empty()); +} + /** * @tc.number Telephony_ISimFile_001 * @tc.name test error branch @@ -1890,6 +1926,7 @@ HWTEST_F(BranchTest, Telephony_UsimFileController_001, Function | MediumTest | L EXPECT_NE(uSimFileController->ObtainElementFilePath(ELEMENTARY_FILE_MBDN), ""); EXPECT_NE(uSimFileController->ObtainElementFilePath(ELEMENTARY_FILE_PNN), ""); EXPECT_NE(uSimFileController->ObtainElementFilePath(ELEMENTARY_FILE_OPL), ""); + EXPECT_NE(uSimFileController->ObtainElementFilePath(ELEMENTARY_FILE_OPL5G), ""); EXPECT_NE(uSimFileController->ObtainElementFilePath(ELEMENTARY_FILE_SPDI), ""); EXPECT_NE(uSimFileController->ObtainElementFilePath(ELEMENTARY_FILE_SST), ""); EXPECT_NE(uSimFileController->ObtainElementFilePath(ELEMENTARY_FILE_CFIS), ""); From 1c233a38e803b1b9f3748e8b2c345703d9467a8d Mon Sep 17 00:00:00 2001 From: dingxiaochen Date: Fri, 5 May 2023 17:57:30 +0800 Subject: [PATCH 4/8] sim authentication. Signed-off-by: dingxiaochen --- frameworks/native/src/core_service_client.cpp | 4 +- frameworks/native/src/core_service_proxy.cpp | 4 +- .../innerkits/include/core_service_client.h | 2 +- .../innerkits/include/core_service_proxy.h | 4 +- interfaces/innerkits/include/i_core_service.h | 2 +- interfaces/innerkits/include/i_sim_manager.h | 2 +- interfaces/innerkits/include/sim_state_type.h | 5 ++ services/core/include/core_service.h | 4 +- services/core/src/core_service.cpp | 4 +- services/core/src/core_service_stub.cpp | 4 +- services/sim/include/sim_manager.h | 5 +- services/sim/include/sim_state_handle.h | 7 +- services/sim/include/sim_state_manager.h | 2 +- services/sim/src/sim_manager.cpp | 20 ++++- services/sim/src/sim_state_handle.cpp | 23 +++++- services/sim/src/sim_state_manager.cpp | 4 +- services/tel_ril/src/tel_ril_sim.cpp | 7 +- services/tel_ril/test/tel_ril_test.cpp | 21 ++++- .../simauthentication_fuzzer.cpp | 10 ++- test/unittest/core_service_gtest/sim_test.cpp | 79 +++++++++++++++++-- .../core_service_gtest/zero_branch_test.cpp | 35 ++++++-- 21 files changed, 206 insertions(+), 42 deletions(-) diff --git a/frameworks/native/src/core_service_client.cpp b/frameworks/native/src/core_service_client.cpp index a7437f53..622fa7d7 100755 --- a/frameworks/native/src/core_service_client.cpp +++ b/frameworks/native/src/core_service_client.cpp @@ -851,14 +851,14 @@ int32_t CoreServiceClient::HasOperatorPrivileges(const int32_t slotId, bool &has } int32_t CoreServiceClient::SimAuthentication( - int32_t slotId, const std::string &aid, const std::string &authData, SimAuthenticationResponse &response) + int32_t slotId, AuthType authType, const std::string &authData, SimAuthenticationResponse &response) { auto proxy = GetProxy(); if (proxy == nullptr) { TELEPHONY_LOGE("proxy is null!"); return false; } - return proxy->SimAuthentication(slotId, aid, authData, response); + return proxy->SimAuthentication(slotId, authType, authData, response); } int32_t CoreServiceClient::GetPrimarySlotId(int32_t &slotId) diff --git a/frameworks/native/src/core_service_proxy.cpp b/frameworks/native/src/core_service_proxy.cpp index 666697fa..798d2530 100755 --- a/frameworks/native/src/core_service_proxy.cpp +++ b/frameworks/native/src/core_service_proxy.cpp @@ -2547,7 +2547,7 @@ int32_t CoreServiceProxy::HasOperatorPrivileges(const int32_t slotId, bool &hasO } int32_t CoreServiceProxy::SimAuthentication( - int32_t slotId, const std::string &aid, const std::string &authData, SimAuthenticationResponse &response) + int32_t slotId, AuthType authType, const std::string &authData, SimAuthenticationResponse &response) { MessageParcel data; MessageParcel reply; @@ -2557,7 +2557,7 @@ int32_t CoreServiceProxy::SimAuthentication( return ERROR; } data.WriteInt32(slotId); - data.WriteString(aid); + data.WriteInt32(static_cast(authType)); data.WriteString(authData); auto remote = Remote(); if (remote == nullptr) { diff --git a/interfaces/innerkits/include/core_service_client.h b/interfaces/innerkits/include/core_service_client.h index e74fdb20..9513bf88 100755 --- a/interfaces/innerkits/include/core_service_client.h +++ b/interfaces/innerkits/include/core_service_client.h @@ -114,7 +114,7 @@ public: int32_t UnlockSimLock(int32_t slotId, const PersoLockInfo &lockInfo, LockStatusResponse &response); int32_t HasOperatorPrivileges(const int32_t slotId, bool &hasOperatorPrivileges); int32_t SimAuthentication( - int32_t slotId, const std::string &aid, const std::string &authData, SimAuthenticationResponse &response); + int32_t slotId, AuthType authType, const std::string &authData, SimAuthenticationResponse &response); int32_t GetPrimarySlotId(int32_t &slotId); int32_t SetPrimarySlotId(int32_t slotId); int32_t GetCellInfoList(int32_t slotId, std::vector> &cellInfo); diff --git a/interfaces/innerkits/include/core_service_proxy.h b/interfaces/innerkits/include/core_service_proxy.h index 33a8702b..540add9f 100755 --- a/interfaces/innerkits/include/core_service_proxy.h +++ b/interfaces/innerkits/include/core_service_proxy.h @@ -120,8 +120,8 @@ public: int32_t GetCellInfoList(int32_t slotId, std::vector> &cellInfo) override; int32_t SendUpdateCellLocationRequest(int32_t slotId) override; int32_t HasOperatorPrivileges(const int32_t slotId, bool &hasOperatorPrivileges) override; - int32_t SimAuthentication(int32_t slotId, const std::string &aid, const std::string &authData, - SimAuthenticationResponse &response) override; + int32_t SimAuthentication( + int32_t slotId, AuthType authType, const std::string &authData, SimAuthenticationResponse &response) override; int32_t RegisterImsRegInfoCallback( int32_t slotId, ImsServiceType imsSrvType, const sptr &callback) override; int32_t UnregisterImsRegInfoCallback(int32_t slotId, ImsServiceType imsSrvType) override; diff --git a/interfaces/innerkits/include/i_core_service.h b/interfaces/innerkits/include/i_core_service.h index cfae7d1b..a8b009dd 100755 --- a/interfaces/innerkits/include/i_core_service.h +++ b/interfaces/innerkits/include/i_core_service.h @@ -126,7 +126,7 @@ public: virtual int32_t SendUpdateCellLocationRequest(int32_t slotId) = 0; virtual int32_t HasOperatorPrivileges(const int32_t slotId, bool &hasOperatorPrivileges) = 0; virtual int32_t SimAuthentication( - int32_t slotId, const std::string &aid, const std::string &authData, SimAuthenticationResponse &response) = 0; + int32_t slotId, AuthType authType, const std::string &authData, SimAuthenticationResponse &response) = 0; virtual int32_t RegisterImsRegInfoCallback( int32_t slotId, ImsServiceType imsSrvType, const sptr &callback) = 0; virtual int32_t UnregisterImsRegInfoCallback(int32_t slotId, ImsServiceType imsSrvType) = 0; diff --git a/interfaces/innerkits/include/i_sim_manager.h b/interfaces/innerkits/include/i_sim_manager.h index e5e0b94c..ed798d53 100755 --- a/interfaces/innerkits/include/i_sim_manager.h +++ b/interfaces/innerkits/include/i_sim_manager.h @@ -71,7 +71,7 @@ public: virtual int32_t GetOperatorConfigs(int slotId, OperatorConfig &poc) = 0; virtual int32_t HasOperatorPrivileges(const int32_t slotId, bool &hasOperatorPrivileges) = 0; virtual int32_t SimAuthentication( - int32_t slotId, const std::string &aid, const std::string &authData, SimAuthenticationResponse &response) = 0; + int32_t slotId, AuthType authType, const std::string &authData, SimAuthenticationResponse &response) = 0; virtual int32_t GetRadioProtocolTech(int32_t slotId) = 0; virtual void GetRadioProtocol(int32_t slotId) = 0; // STK diff --git a/interfaces/innerkits/include/sim_state_type.h b/interfaces/innerkits/include/sim_state_type.h index 451b9f1f..04da1e15 100755 --- a/interfaces/innerkits/include/sim_state_type.h +++ b/interfaces/innerkits/include/sim_state_type.h @@ -126,6 +126,11 @@ enum class LockType { FDN_LOCK = 2, }; +enum AuthType { + SIM_AUTH_EAP_SIM_TYPE = 128, + SIM_AUTH_EAP_AKA_TYPE = 129, +}; + enum class LockState { /**Indicates that the lock state card is in the off state. */ LOCK_OFF = 0, diff --git a/services/core/include/core_service.h b/services/core/include/core_service.h index 1c460a59..932ef00e 100755 --- a/services/core/include/core_service.h +++ b/services/core/include/core_service.h @@ -208,8 +208,8 @@ public: int32_t HasOperatorPrivileges(const int32_t slotId, bool &hasOperatorPrivileges) override; - int32_t SimAuthentication(int32_t slotId, const std::string &aid, const std::string &authData, - SimAuthenticationResponse &response) override; + int32_t SimAuthentication( + int32_t slotId, AuthType authType, const std::string &authData, SimAuthenticationResponse &response) override; int32_t RegisterImsRegInfoCallback( int32_t slotId, ImsServiceType imsSrvType, const sptr &callback) override; diff --git a/services/core/src/core_service.cpp b/services/core/src/core_service.cpp index 12012037..3e1980c3 100644 --- a/services/core/src/core_service.cpp +++ b/services/core/src/core_service.cpp @@ -1135,7 +1135,7 @@ int32_t CoreService::HasOperatorPrivileges(const int32_t slotId, bool &hasOperat } int32_t CoreService::SimAuthentication( - int32_t slotId, const std::string &aid, const std::string &authData, SimAuthenticationResponse &response) + int32_t slotId, AuthType authType, const std::string &authData, SimAuthenticationResponse &response) { if (!TelephonyPermission::CheckPermission(Permission::GET_TELEPHONY_STATE)) { TELEPHONY_LOGE("Failed because no permission:GET_TELEPHONY_STATE"); @@ -1146,7 +1146,7 @@ int32_t CoreService::SimAuthentication( TELEPHONY_LOGE("simManager_ is null"); return TELEPHONY_ERR_LOCAL_PTR_NULL; } - return simManager_->SimAuthentication(slotId, aid, authData, response); + return simManager_->SimAuthentication(slotId, authType, authData, response); } int32_t CoreService::RegisterImsRegInfoCallback( diff --git a/services/core/src/core_service_stub.cpp b/services/core/src/core_service_stub.cpp index d2dfebd7..808a4de7 100644 --- a/services/core/src/core_service_stub.cpp +++ b/services/core/src/core_service_stub.cpp @@ -1459,10 +1459,10 @@ int32_t CoreServiceStub::OnHasOperatorPrivileges(MessageParcel &data, MessagePar int32_t CoreServiceStub::OnSimAuthentication(MessageParcel &data, MessageParcel &reply) { int32_t slotId = data.ReadInt32(); - std::string aid = data.ReadString(); + AuthType authType = static_cast(data.ReadInt32()); std::string authData = data.ReadString(); SimAuthenticationResponse response = { 0 }; - int32_t result = SimAuthentication(slotId, aid, authData, response); + int32_t result = SimAuthentication(slotId, authType, authData, response); reply.WriteInt32(result); reply.WriteInt32(response.sw1); reply.WriteInt32(response.sw2); diff --git a/services/sim/include/sim_manager.h b/services/sim/include/sim_manager.h index 861fcabf..cad44f78 100755 --- a/services/sim/include/sim_manager.h +++ b/services/sim/include/sim_manager.h @@ -77,8 +77,8 @@ public: int32_t GetActiveSimAccountInfoList(std::vector &iccAccountInfoList) override; int32_t GetOperatorConfigs(int32_t slotId, OperatorConfig &poc) override; int32_t HasOperatorPrivileges(const int32_t slotId, bool &hasOperatorPrivileges) override; - int32_t SimAuthentication(int32_t slotId, const std::string &aid, const std::string &authData, - SimAuthenticationResponse &response) override; + int32_t SimAuthentication( + int32_t slotId, AuthType authType, const std::string &authData, SimAuthenticationResponse &response) override; int32_t GetRadioProtocolTech(int32_t slotId) override; void GetRadioProtocol(int32_t slotId) override; // STK @@ -135,6 +135,7 @@ public: private: bool IsValidSlotId(int32_t slotId); + bool IsValidAuthType(AuthType authType); bool IsValidSlotIdForDefault(int32_t slotId); void InitMultiSimObject(); void InitSingleSimObject(); diff --git a/services/sim/include/sim_state_handle.h b/services/sim/include/sim_state_handle.h index 70a001cb..b49f2af2 100644 --- a/services/sim/include/sim_state_handle.h +++ b/services/sim/include/sim_state_handle.h @@ -89,6 +89,10 @@ constexpr const char *FDN_PIN_LOCK = "P2"; // FDN lock type constexpr const char *FDN_PIN2_LOCK = "FD"; +constexpr const char *USIM_AID = "USIM_AID"; +constexpr const char *CDMA_FAKE_AID = "CDMA_FAKE_AID"; +constexpr const char *GSM_FAKE_AID = "GSM_FAKE_AID"; + struct UnlockData { int32_t result = 0; int32_t remain = 0; @@ -122,7 +126,7 @@ public: bool IsIccReady(); void RegisterCoreNotify(const std::shared_ptr &handler, int what); void UnRegisterCoreNotify(const std::shared_ptr &observerCallBack, int what); - int32_t SimAuthentication(int32_t slotId, const std::string &aid, const std::string &authData); + int32_t SimAuthentication(int32_t slotId, AuthType authType, const std::string &authData); SimAuthenticationResponse GetSimAuthenticationResponse(); private: @@ -143,6 +147,7 @@ private: void NotifySimLock(int slotId); void GetUnlockSimLockResult(const AppExecFwk::InnerEvent::Pointer &event, int32_t slotId); void GetSimAuthenticationResult(int32_t slotId, const AppExecFwk::InnerEvent::Pointer &event); + std::string GetAidByCardType(CardType type); private: int32_t oldSimType_ = ICC_UNKNOWN_TYPE; diff --git a/services/sim/include/sim_state_manager.h b/services/sim/include/sim_state_manager.h index a71dfd0c..d0bc7757 100755 --- a/services/sim/include/sim_state_manager.h +++ b/services/sim/include/sim_state_manager.h @@ -50,7 +50,7 @@ public: void RegisterCoreNotify(const HANDLE &handler, int what); void UnRegisterCoreNotify(const HANDLE &observerCallBack, int what); int32_t SimAuthentication( - int32_t slotId, const std::string &aid, const std::string &authData, SimAuthenticationResponse &response); + int32_t slotId, AuthType authType, const std::string &authData, SimAuthenticationResponse &response); public: static bool responseReady_; diff --git a/services/sim/src/sim_manager.cpp b/services/sim/src/sim_manager.cpp index ee49adcd..a75746aa 100755 --- a/services/sim/src/sim_manager.cpp +++ b/services/sim/src/sim_manager.cpp @@ -496,14 +496,21 @@ int32_t SimManager::HasOperatorPrivileges(const int32_t slotId, bool &hasOperato } int32_t SimManager::SimAuthentication( - int32_t slotId, const std::string &aid, const std::string &authData, SimAuthenticationResponse &response) + int32_t slotId, AuthType authType, const std::string &authData, SimAuthenticationResponse &response) { - TELEPHONY_LOGI("SimManager::SimAuthentication slotId:%{public}d", slotId); - if ((!IsValidSlotId(slotId)) || (simStateManager_[slotId] == nullptr)) { + if (!HasSimCardInner(slotId)) { + TELEPHONY_LOGE("SimAuthentication has no sim card!"); + return TELEPHONY_ERR_NO_SIM_CARD; + } + if (!IsValidAuthType(authType)) { + TELEPHONY_LOGE("SimAuthentication authType is invalid!"); + return TELEPHONY_ERR_ARGUMENT_INVALID; + } + if (simStateManager_[slotId] == nullptr) { TELEPHONY_LOGE("simStateManager_ can not be null!"); return TELEPHONY_ERR_LOCAL_PTR_NULL; } - return simStateManager_[slotId]->SimAuthentication(slotId, aid, authData, response); + return simStateManager_[slotId]->SimAuthentication(slotId, authType, authData, response); } int32_t SimManager::GetRadioProtocolTech(int32_t slotId) @@ -979,6 +986,11 @@ bool SimManager::IsValidSlotId(int32_t slotId) return true; } +bool SimManager::IsValidAuthType(AuthType authType) +{ + return (authType == AuthType::SIM_AUTH_EAP_SIM_TYPE || authType == AuthType::SIM_AUTH_EAP_AKA_TYPE); +} + bool SimManager::IsValidSlotIdForDefault(int32_t slotId) { if ((slotId < DEFAULT_SIM_SLOT_ID_REMOVE) || (slotId >= slotCount_)) { diff --git a/services/sim/src/sim_state_handle.cpp b/services/sim/src/sim_state_handle.cpp index 272db9e6..e1d13e72 100755 --- a/services/sim/src/sim_state_handle.cpp +++ b/services/sim/src/sim_state_handle.cpp @@ -294,7 +294,7 @@ void SimStateHandle::ObtainRealtimeIccStatus(int32_t slotId) telRilManager_->GetSimStatus(slotId, event); // get sim card state } -int32_t SimStateHandle::SimAuthentication(int32_t slotId, const std::string &aid, const std::string &authData) +int32_t SimStateHandle::SimAuthentication(int32_t slotId, AuthType authType, const std::string &authData) { if (telRilManager_ == nullptr) { TELEPHONY_LOGE("SimStateHandle::SimAuthentication() telRilManager_ is nullptr!!"); @@ -307,11 +307,30 @@ int32_t SimStateHandle::SimAuthentication(int32_t slotId, const std::string &aid } event->SetOwner(shared_from_this()); SimAuthenticationRequestInfo requireInfo; - requireInfo.aid = aid; + requireInfo.serial = static_cast(authType); + requireInfo.aid = GetAidByCardType(externalType_); requireInfo.authData = authData; return telRilManager_->SimAuthentication(slotId, requireInfo, event); } +std::string SimStateHandle::GetAidByCardType(CardType type) +{ + switch (type) { + case CardType::SINGLE_MODE_RUIM_CARD: + return CDMA_FAKE_AID; + case CardType::SINGLE_MODE_SIM_CARD: + case CardType::DUAL_MODE_CG_CARD: + case CardType::CT_NATIONAL_ROAMING_CARD: + case CardType::CU_DUAL_MODE_CARD: + case CardType::DUAL_MODE_TELECOM_LTE_CARD: + case CardType::DUAL_MODE_UG_CARD: + return GSM_FAKE_AID; + default: + break; + } + return USIM_AID; +} + void SimStateHandle::GetSimCardData(const AppExecFwk::InnerEvent::Pointer &event, int32_t slotId) { TELEPHONY_LOGI("SimStateHandle::GetSimCardData slotId = %{public}d", slotId); diff --git a/services/sim/src/sim_state_manager.cpp b/services/sim/src/sim_state_manager.cpp index 6dacdf6c..4b9b7376 100755 --- a/services/sim/src/sim_state_manager.cpp +++ b/services/sim/src/sim_state_manager.cpp @@ -458,7 +458,7 @@ int32_t SimStateManager::UnlockSimLock(int32_t slotId, const PersoLockInfo &lock } int32_t SimStateManager::SimAuthentication( - int32_t slotId, const std::string &aid, const std::string &authData, SimAuthenticationResponse &response) + int32_t slotId, AuthType authType, const std::string &authData, SimAuthenticationResponse &response) { if (simStateHandle_ == nullptr) { TELEPHONY_LOGE("SimAuthentication(), simStateHandle_ is nullptr!!!"); @@ -467,7 +467,7 @@ int32_t SimStateManager::SimAuthentication( std::unique_lock lck(ctx_); responseReady_ = false; int32_t ret = SIM_AUTH_FAIL; - ret = simStateHandle_->SimAuthentication(slotId, aid, authData); + ret = simStateHandle_->SimAuthentication(slotId, authType, authData); while (!responseReady_) { TELEPHONY_LOGI("SimAuthentication::wait(), response = false"); if (cv_.wait_for(lck, std::chrono::seconds(WAIT_TIME_SECOND)) == std::cv_status::timeout) { diff --git a/services/tel_ril/src/tel_ril_sim.cpp b/services/tel_ril/src/tel_ril_sim.cpp index f39a368f..a5a4f527 100644 --- a/services/tel_ril/src/tel_ril_sim.cpp +++ b/services/tel_ril/src/tel_ril_sim.cpp @@ -283,7 +283,11 @@ int32_t TelRilSim::SimTransmitApduBasicChannelResponse( int32_t TelRilSim::SimAuthenticationResponse( const HDI::Ril::V1_1::RilRadioResponseInfo &responseInfo, const HDI::Ril::V1_1::IccIoResultInfo &result) { - return ResponseIccIo(responseInfo, result); + std::shared_ptr simAuthResp = std::make_shared(); + simAuthResp->sw1 = result.sw1; + simAuthResp->sw2 = result.sw2; + simAuthResp->response = result.response; + return Response(TELEPHONY_LOG_FUNC_NAME, responseInfo, simAuthResp); } int32_t TelRilSim::UnlockSimLockResponse( @@ -459,6 +463,7 @@ int32_t TelRilSim::SimAuthentication( const SimAuthenticationRequestInfo &reqInfo, const AppExecFwk::InnerEvent::Pointer &response) { OHOS::HDI::Ril::V1_1::SimAuthenticationRequestInfo simAuthInfo; + simAuthInfo.serial = reqInfo.serial; simAuthInfo.aid = reqInfo.aid; simAuthInfo.authData = reqInfo.authData; return Request(TELEPHONY_LOG_FUNC_NAME, response, HREQ_SIM_AUTHENTICATION, &HDI::Ril::V1_1::IRil::SimAuthentication, diff --git a/services/tel_ril/test/tel_ril_test.cpp b/services/tel_ril/test/tel_ril_test.cpp index eea83fb6..aa88d18c 100755 --- a/services/tel_ril/test/tel_ril_test.cpp +++ b/services/tel_ril/test/tel_ril_test.cpp @@ -714,8 +714,27 @@ void TelRilTest::OnRequestSimAuthenticationTest(int32_t slotId, std::cerr << "telRilManager is nullptr" << std::endl; return; } + int32_t authType; + std::string aid; + std::string authData; + + std::cout << "please enter the authType:" << std::endl; + std::cout << "SIM_AUTH_EAP_SIM_TYPE is 128" << std::endl; + std::cout << "SIM_AUTH_EAP_AKA_TYPE is 129" << std::endl; + std::cin >> authType; + std::cout << "please enter the aid:" << std::endl; + std::cout << "USIM_AID" << std::endl; + std::cout << "CDMA_FAKE_AID" << std::endl; + std::cout << "GSM_FAKE_AID" << std::endl; + std::cin >> aid; + std::cout << "please enter the authData base64 encoded:" << std::endl; + std::cin >> authData; SimAuthenticationRequestInfo reqInfo; - telRilManager_->SimAuthentication(slotId, reqInfo, event); + reqInfo.serial = authType; + reqInfo.aid = aid; + reqInfo.authData = authData; + int ret = telRilManager_->SimAuthentication(slotId, reqInfo, event); + TELEPHONY_LOGI("OnRequestSimAuthenticationTest ret = %{public}d", ret); std::cout << "TelRilTest::OnRequestSimAuthenticationTest end" << std::endl; } diff --git a/test/fuzztest/simauthentication_fuzzer/simauthentication_fuzzer.cpp b/test/fuzztest/simauthentication_fuzzer/simauthentication_fuzzer.cpp index 5a2eddce..c7c6864c 100644 --- a/test/fuzztest/simauthentication_fuzzer/simauthentication_fuzzer.cpp +++ b/test/fuzztest/simauthentication_fuzzer/simauthentication_fuzzer.cpp @@ -33,6 +33,8 @@ constexpr int32_t SLOT_NUM = 2; constexpr int32_t TYPE_NUM = 2; constexpr int32_t TWO_INT_NUM = 2; constexpr int32_t SLEEP_TIME_SECONDS = 10; +constexpr int32_t SIM_AUTH_EAP_SIM_TYPE = 128; +constexpr int32_t SIM_AUTH_EAP_AKA_TYPE = 129; bool IsServiceInited() { @@ -141,11 +143,15 @@ void SimAuthentication(const uint8_t *data, size_t size) } int32_t slotId = static_cast(size % SLOT_NUM); - std::string aid(reinterpret_cast(data), size); std::string authData(reinterpret_cast(data), size); MessageParcel dataMessageParcel; dataMessageParcel.WriteInt32(slotId); - dataMessageParcel.WriteString(aid); + int32_t authType = static_cast(size % TYPE_NUM); + if (authType) { + dataMessageParcel.WriteInt32(SIM_AUTH_EAP_AKA_TYPE); + } else { + dataMessageParcel.WriteInt32(SIM_AUTH_EAP_SIM_TYPE); + } dataMessageParcel.WriteString(authData); dataMessageParcel.RewindRead(0); MessageParcel reply; diff --git a/test/unittest/core_service_gtest/sim_test.cpp b/test/unittest/core_service_gtest/sim_test.cpp index 749e9a5c..43f8afd3 100755 --- a/test/unittest/core_service_gtest/sim_test.cpp +++ b/test/unittest/core_service_gtest/sim_test.cpp @@ -3336,9 +3336,9 @@ HWTEST_F(SimTest, Telephony_Sim_UnlockSimLock_0300, Function | MediumTest | Leve void SimAuthenticationTestFunc(CoreServiceTestHelper &helper) { SimAuthenticationResponse response = { 0 }; - std::string aid = "aa"; + AuthType authType = AuthType::SIM_AUTH_EAP_SIM_TYPE; std::string authData = "1234"; - int32_t result = CoreServiceClient::GetInstance().SimAuthentication(SimTest::slotId_, aid, authData, response); + int32_t result = CoreServiceClient::GetInstance().SimAuthentication(SimTest::slotId_, authType, authData, response); helper.SetBoolResult(result == 0); helper.NotifyAll(); } @@ -3369,9 +3369,10 @@ void SimAuthenticationTestFunc1(CoreServiceTestHelper &helper) { AccessToken token; SimAuthenticationResponse response = { 0 }; - std::string aid = "aa"; + AuthType authType = AuthType::SIM_AUTH_EAP_SIM_TYPE; std::string authData = "1234"; - int32_t result = CoreServiceClient::GetInstance().SimAuthentication(SimTest::slotId1_, aid, authData, response); + int32_t result = + CoreServiceClient::GetInstance().SimAuthentication(SimTest::slotId1_, authType, authData, response); helper.SetBoolResult(result == 0); helper.NotifyAll(); } @@ -3418,6 +3419,70 @@ HWTEST_F(SimTest, Telephony_Sim_SimAuthentication_0300, Function | MediumTest | } } +void SimAuthenticationTestFunc2(CoreServiceTestHelper &helper) +{ + SimAuthenticationResponse response = { 0 }; + AuthType authType = AuthType::SIM_AUTH_EAP_AKA_TYPE; + std::string authData = "1234"; + int32_t result = CoreServiceClient::GetInstance().SimAuthentication(SimTest::slotId_, authType, authData, response); + helper.SetBoolResult(result == 0); + helper.NotifyAll(); +} + +/** + * @tc.number Telephony_Sim_SimAuthentication_0400 + * @tc.name Sim authentication + * @tc.desc Function test + */ +HWTEST_F(SimTest, Telephony_Sim_SimAuthentication_0400, Function | MediumTest | Level3) +{ + AccessToken token; + if (!SimTest::HasSimCard(slotId_)) { + TELEPHONY_LOGI("TelephonyTestService has no sim card"); + } else { + CoreServiceTestHelper helper; + if (!helper.Run(SimAuthenticationTestFunc2, std::ref(helper))) { + TELEPHONY_LOGI("Interface out of time"); + EXPECT_TRUE(true); + } else { + bool result = helper.GetBoolResult(); + EXPECT_TRUE(result); + } + } +} + +void SimAuthenticationTestFunc3(CoreServiceTestHelper &helper) +{ + SimAuthenticationResponse response = { 0 }; + AuthType authType = static_cast(0); + std::string authData = "1234"; + int32_t result = CoreServiceClient::GetInstance().SimAuthentication(SimTest::slotId_, authType, authData, response); + helper.SetBoolResult(result == 0); + helper.NotifyAll(); +} + +/** + * @tc.number Telephony_Sim_SimAuthentication_0500 + * @tc.name Sim authentication + * @tc.desc Function test + */ +HWTEST_F(SimTest, Telephony_Sim_SimAuthentication_0500, Function | MediumTest | Level3) +{ + AccessToken token; + if (!SimTest::HasSimCard(slotId_)) { + TELEPHONY_LOGI("TelephonyTestService has no sim card"); + } else { + CoreServiceTestHelper helper; + if (!helper.Run(SimAuthenticationTestFunc3, std::ref(helper))) { + TELEPHONY_LOGI("Interface out of time"); + EXPECT_TRUE(true); + } else { + bool result = helper.GetBoolResult(); + EXPECT_FALSE(result); + } + } +} + /** * @tc.number Telephony_Sim_GetPrimarySlotId_0100 * @tc.name Get primary slotId @@ -4093,7 +4158,8 @@ HWTEST_F(SimTest, Telephony_Sim_CoreService_0200, Function | MediumTest | Level3 EXPECT_NE(mCoreService->UnlockSimLock(0, mPersoLockInfo, mLockStatusResponse), TELEPHONY_ERR_SUCCESS); mCoreService->SendUpdateCellLocationRequest(0); SimAuthenticationResponse mSimAuthenticationResponse; - EXPECT_NE(mCoreService->SimAuthentication(0, "", "", mSimAuthenticationResponse), TELEPHONY_ERR_SUCCESS); + EXPECT_NE(mCoreService->SimAuthentication(0, AuthType::SIM_AUTH_EAP_SIM_TYPE, "", mSimAuthenticationResponse), + TELEPHONY_ERR_SUCCESS); const sptr mImsRegInfoCallback = nullptr; EXPECT_NE(mCoreService->RegisterImsRegInfoCallback(0, ImsServiceType::TYPE_VOICE, mImsRegInfoCallback), TELEPHONY_ERR_SUCCESS); @@ -4238,7 +4304,8 @@ HWTEST_F(SimTest, Telephony_Sim_CoreService_0500, Function | MediumTest | Level3 EXPECT_NE(mCoreService->UnlockSimLock(0, mPersoLockInfo, mLockStatusResponse), TELEPHONY_ERR_SUCCESS); mCoreService->SendUpdateCellLocationRequest(0); SimAuthenticationResponse mSimAuthenticationResponse; - EXPECT_NE(mCoreService->SimAuthentication(0, "", "", mSimAuthenticationResponse), TELEPHONY_ERR_SUCCESS); + EXPECT_NE(mCoreService->SimAuthentication(0, AuthType::SIM_AUTH_EAP_SIM_TYPE, "", mSimAuthenticationResponse), + TELEPHONY_ERR_SUCCESS); const sptr mImsRegInfoCallback = nullptr; EXPECT_NE(mCoreService->RegisterImsRegInfoCallback(0, ImsServiceType::TYPE_VOICE, mImsRegInfoCallback), TELEPHONY_ERR_SUCCESS); diff --git a/test/unittest/core_service_gtest/zero_branch_test.cpp b/test/unittest/core_service_gtest/zero_branch_test.cpp index 1a0a6e0b..31234bd6 100644 --- a/test/unittest/core_service_gtest/zero_branch_test.cpp +++ b/test/unittest/core_service_gtest/zero_branch_test.cpp @@ -1247,9 +1247,6 @@ HWTEST_F(BranchTest, Telephony_SimManager_003, Function | MediumTest | Level1) bool boolResult = false; EXPECT_GT(simManager->HasOperatorPrivileges(0, boolResult), TELEPHONY_ERR_SUCCESS); EXPECT_GT(simManager->HasOperatorPrivileges(INVALID_SLOTID, boolResult), TELEPHONY_ERR_SUCCESS); - SimAuthenticationResponse mResponse; - EXPECT_NE(simManager->SimAuthentication(0, "", "", mResponse), TELEPHONY_ERR_SUCCESS); - EXPECT_NE(simManager->SimAuthentication(INVALID_SLOTID, "", "", mResponse), TELEPHONY_ERR_SUCCESS); int32_t testRadioProtocolTech = static_cast(RadioProtocolTech::RADIO_PROTOCOL_TECH_UNKNOWN); EXPECT_EQ(simManager->GetRadioProtocolTech(0), testRadioProtocolTech); EXPECT_EQ(simManager->GetRadioProtocolTech(INVALID_SLOTID), testRadioProtocolTech); @@ -1304,6 +1301,13 @@ HWTEST_F(BranchTest, Telephony_SimManager_004, Function | MediumTest | Level1) std::string testString = ""; EXPECT_NE(simManager->ObtainSpnCondition(0, true, testString), TELEPHONY_ERR_SUCCESS); EXPECT_NE(simManager->ObtainSpnCondition(INVALID_SLOTID, true, testString), TELEPHONY_ERR_SUCCESS); + SimAuthenticationResponse mResponse; + EXPECT_NE(simManager->SimAuthentication(0, static_cast(0), "", mResponse), TELEPHONY_ERR_SUCCESS); + EXPECT_NE( + simManager->SimAuthentication(INVALID_SLOTID, static_cast(0), "", mResponse), TELEPHONY_ERR_SUCCESS); + EXPECT_NE(simManager->SimAuthentication(0, AuthType::SIM_AUTH_EAP_SIM_TYPE, "", mResponse), TELEPHONY_ERR_SUCCESS); + EXPECT_NE(simManager->SimAuthentication(INVALID_SLOTID, AuthType::SIM_AUTH_EAP_SIM_TYPE, "", mResponse), + TELEPHONY_ERR_SUCCESS); } /** @@ -1343,12 +1347,33 @@ HWTEST_F(BranchTest, Telephony_SimStateManager_001, Function | MediumTest | Leve PersoLockInfo mPersoLockInfo; EXPECT_GT(simStateManager->UnlockSimLock(0, mPersoLockInfo, mLockStatusResponse), TELEPHONY_ERR_SUCCESS); SimAuthenticationResponse mResponse; - EXPECT_NE(simStateManager->SimAuthentication(0, "", "", mResponse), TELEPHONY_ERR_SUCCESS); + EXPECT_NE( + simStateManager->SimAuthentication(0, AuthType::SIM_AUTH_EAP_SIM_TYPE, "", mResponse), TELEPHONY_ERR_SUCCESS); auto simStateManagerTwo = std::make_shared(telRilManager); simStateManager->simStateHandle_ = std::make_shared(runner, simStateManagerTwo); EXPECT_GE(simStateManager->GetCardType(), CardType::UNKNOWN_CARD); EXPECT_GT(simStateManager->UnlockSimLock(0, mPersoLockInfo, mLockStatusResponse), TELEPHONY_ERR_SUCCESS); - EXPECT_NE(simStateManager->SimAuthentication(0, "", "", mResponse), TELEPHONY_ERR_SUCCESS); +} + +/** + * @tc.number Telephony_SimStateHandle_001 + * @tc.name test error branch + * @tc.desc Function test + */ +HWTEST_F(BranchTest, Telephony_SimStateHandle_001, Function | MediumTest | Level1) +{ + std::shared_ptr telRilManager = std::make_shared(); + std::shared_ptr simStateManager = std::make_shared(telRilManager); + std::shared_ptr runner = AppExecFwk::EventRunner::Create("test"); + auto simStateHandle = std::make_shared(runner, simStateManager); + EXPECT_EQ(simStateHandle->GetAidByCardType(CardType::SINGLE_MODE_RUIM_CARD), CDMA_FAKE_AID); + EXPECT_EQ(simStateHandle->GetAidByCardType(CardType::SINGLE_MODE_SIM_CARD), GSM_FAKE_AID); + EXPECT_EQ(simStateHandle->GetAidByCardType(CardType::DUAL_MODE_CG_CARD), GSM_FAKE_AID); + EXPECT_EQ(simStateHandle->GetAidByCardType(CardType::CT_NATIONAL_ROAMING_CARD), GSM_FAKE_AID); + EXPECT_EQ(simStateHandle->GetAidByCardType(CardType::CU_DUAL_MODE_CARD), GSM_FAKE_AID); + EXPECT_EQ(simStateHandle->GetAidByCardType(CardType::DUAL_MODE_TELECOM_LTE_CARD), GSM_FAKE_AID); + EXPECT_EQ(simStateHandle->GetAidByCardType(CardType::DUAL_MODE_UG_CARD), GSM_FAKE_AID); + EXPECT_EQ(simStateHandle->GetAidByCardType(CardType::UNKNOWN_CARD), USIM_AID); } /** From 4c114c905a7cc4978b418c38e91e69d4ddfcab5e Mon Sep 17 00:00:00 2001 From: YOUR_NAME Date: Sat, 6 May 2023 09:29:51 +0800 Subject: [PATCH 5/8] fix: fix thread for ces Signed-off-by: liujiandong --- services/network_search/src/device_state_observer.cpp | 1 + services/network_search/src/network_search_handler.cpp | 1 + 2 files changed, 2 insertions(+) diff --git a/services/network_search/src/device_state_observer.cpp b/services/network_search/src/device_state_observer.cpp index 32301aea..77e13968 100644 --- a/services/network_search/src/device_state_observer.cpp +++ b/services/network_search/src/device_state_observer.cpp @@ -41,6 +41,7 @@ void DeviceStateObserver::StartEventSubscriber(const std::shared_ptr(subscriberInfo); subscriber_->SetEventHandler(deviceStateHandler); subscriber_->InitEventMap(); diff --git a/services/network_search/src/network_search_handler.cpp b/services/network_search/src/network_search_handler.cpp index f7c85a61..22348967 100644 --- a/services/network_search/src/network_search_handler.cpp +++ b/services/network_search/src/network_search_handler.cpp @@ -131,6 +131,7 @@ bool NetworkSearchHandler::InitOperatorName() EventFwk::MatchingSkills matchingSkills; matchingSkills.AddEvent(CommonEventSupport::COMMON_EVENT_OPERATOR_CONFIG_CHANGED); EventFwk::CommonEventSubscribeInfo subscriberInfo(matchingSkills); + subscriberInfo.SetThreadMode(EventFwk::CommonEventSubscribeInfo::COMMON); operatorName_ = std::make_shared( subscriberInfo, nsm->GetNetworkSearchState(slotId_), nsm->GetSimManager(), networkSearchManager_, slotId_); if (operatorName_ == nullptr) { From f8ff012491a0fa3ac9898db6295203a601301cff Mon Sep 17 00:00:00 2001 From: dingxiaochen Date: Sat, 6 May 2023 11:13:12 +0800 Subject: [PATCH 6/8] add obtain pnn index from opl5G file. Signed-off-by: dingxiaochen --- .../simauthentication_fuzzer/simauthentication_fuzzer.cpp | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/test/fuzztest/simauthentication_fuzzer/simauthentication_fuzzer.cpp b/test/fuzztest/simauthentication_fuzzer/simauthentication_fuzzer.cpp index 7b49f0cb..604aba53 100644 --- a/test/fuzztest/simauthentication_fuzzer/simauthentication_fuzzer.cpp +++ b/test/fuzztest/simauthentication_fuzzer/simauthentication_fuzzer.cpp @@ -34,6 +34,7 @@ constexpr int32_t SLOT_NUM = 2; constexpr int32_t TYPE_NUM = 2; constexpr int32_t TWO_INT_NUM = 2; constexpr int32_t SLEEP_TIME_SECONDS = 10; +bool g_flag = false; bool IsServiceInited() { @@ -174,6 +175,10 @@ void DoSomethingInterestingWithMyAPI(const uint8_t *data, size_t size) if (data == nullptr || size == 0) { return; } + if (g_flag) { + return; + } + g_flag = true; OnRemoteRequest(data, size); GetSimTelephoneNumber(data, size); From 59c6110c56f13bd46813f1156172264ed1c7990e Mon Sep 17 00:00:00 2001 From: dingxiaochen Date: Sat, 6 May 2023 12:06:40 +0800 Subject: [PATCH 7/8] add obtain pnn index from opl5G file. Signed-off-by: dingxiaochen --- .../simauthentication_fuzzer.cpp | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/test/fuzztest/simauthentication_fuzzer/simauthentication_fuzzer.cpp b/test/fuzztest/simauthentication_fuzzer/simauthentication_fuzzer.cpp index 604aba53..7a197780 100644 --- a/test/fuzztest/simauthentication_fuzzer/simauthentication_fuzzer.cpp +++ b/test/fuzztest/simauthentication_fuzzer/simauthentication_fuzzer.cpp @@ -160,6 +160,11 @@ void ParseOpl5g(const uint8_t *data, size_t size) return; } + if (g_flag) { + return; + } + g_flag = true; + std::shared_ptr telRilManager = std::make_shared(); std::shared_ptr simStateManager = std::make_shared(telRilManager); std::shared_ptr eventLoopRecord = AppExecFwk::EventRunner::Create("SimFile"); @@ -175,10 +180,6 @@ void DoSomethingInterestingWithMyAPI(const uint8_t *data, size_t size) if (data == nullptr || size == 0) { return; } - if (g_flag) { - return; - } - g_flag = true; OnRemoteRequest(data, size); GetSimTelephoneNumber(data, size); From 5972bb1d04318da6669a622e582bb2d1ef52b74c Mon Sep 17 00:00:00 2001 From: dingxiaochen Date: Sat, 6 May 2023 14:17:41 +0800 Subject: [PATCH 8/8] part dependence. Signed-off-by: dingxiaochen --- BUILD.gn | 51 +++++------ bundle.json | 15 +++- core_service_aafwk.gni | 17 ---- frameworks/js/network_search/BUILD.gn | 21 ++--- frameworks/js/sim/BUILD.gn | 18 ++-- interfaces/innerkits/BUILD.gn | 5 +- services/etc/param/BUILD.gn | 4 +- services/network_search/test/BUILD.gn | 16 ++-- services/sim/include/multi_sim_controller.h | 2 - services/sim/include/multi_sim_monitor.h | 2 - services/sim/include/sim_rdb_info.h | 17 ---- .../sim/src/icc_dialling_numbers_manager.cpp | 1 + services/sim/src/multi_sim_controller.cpp | 49 +++++------ services/sim/src/sim_rdb_helper.cpp | 85 ++++++++++--------- services/sim/test/BUILD.gn | 35 ++------ services/tel_ril/test/BUILD.gn | 17 ++-- telephony.gni | 20 ----- .../addiccdiallingnumbers_fuzzer/BUILD.gn | 30 +++---- .../addiccdiallingnumbers_fuzzer.cpp | 1 + test/fuzztest/getsimeons_fuzzer/BUILD.gn | 32 +++---- .../getsimeons_fuzzer/getsimeons_fuzzer.cpp | 1 + test/fuzztest/hexvectohexstr_fuzzer/BUILD.gn | 32 +++---- .../isshowableasciionly_fuzzer/BUILD.gn | 32 +++---- .../isvalidnumberstring_fuzzer/BUILD.gn | 32 +++---- test/fuzztest/sendenvelopecmd_fuzzer/BUILD.gn | 32 +++---- .../sendenvelopecmd_fuzzer.cpp | 1 + test/fuzztest/sendsmsmoremode_fuzzer/BUILD.gn | 32 +++---- .../sendterminalresponsecmd_fuzzer/BUILD.gn | 31 +++---- .../sendterminalresponsecmd_fuzzer.cpp | 1 + test/fuzztest/setaccesslimit_fuzzer/BUILD.gn | 32 +++---- test/fuzztest/setshowname_fuzzer/BUILD.gn | 32 +++---- .../setshowname_fuzzer/setshowname_fuzzer.cpp | 1 + test/fuzztest/setshownumber_fuzzer/BUILD.gn | 30 +++---- .../setshownumber_fuzzer.cpp | 1 + .../fuzztest/setvoicemailinfo_fuzzer/BUILD.gn | 30 +++---- .../setvoicemailinfo_fuzzer.cpp | 1 + .../simauthentication_fuzzer/BUILD.gn | 30 +++---- .../simauthentication_fuzzer.cpp | 1 + test/fuzztest/unmarshalling_fuzzer/BUILD.gn | 32 +++---- .../updateiccdiallingnumbers_fuzzer/BUILD.gn | 30 +++---- .../updateiccdiallingnumbers_fuzzer.cpp | 1 + test/fuzztest/updatesmsicc_fuzzer/BUILD.gn | 30 +++---- test/fuzztest/updatevoicemail_fuzzer/BUILD.gn | 32 +++---- test/unittest/core_service_gtest/BUILD.gn | 30 +++---- .../core_service_test_helper.cpp | 3 +- test/unittest/tel_ril_gtest/BUILD.gn | 22 ++--- utils/BUILD.gn | 24 ++++-- .../common_telephony_log_test/BUILD.gn | 12 +-- 48 files changed, 461 insertions(+), 545 deletions(-) delete mode 100644 core_service_aafwk.gni delete mode 100755 telephony.gni diff --git a/BUILD.gn b/BUILD.gn index 43b1e524..a7929925 100644 --- a/BUILD.gn +++ b/BUILD.gn @@ -11,28 +11,17 @@ # See the License for the specific language governing permissions and # limitations under the License. -import("//base/telephony/core_service/core_service_aafwk.gni") -import("//base/telephony/core_service/telephony.gni") import("//build/ohos.gni") -import("//drivers/hdf_core/adapter/uhdf2/uhdf.gni") -TELEPHONY_CORE_SERVICE_ROOT = "//base/telephony/core_service" -TELEPHONY_NETWORK_SEARCH_ROOT = - "//base/telephony/core_service/services/network_search" -TELEPHONY_SIM_ROOT = "//base/telephony/core_service/services/sim" -TELEPHONY_TEL_RIL_ROOT = "//base/telephony/core_service/services/tel_ril" -TELEPHONY_IMS_CORE_SERVICE_SRC_PATH = - "$TELEPHONY_CORE_SERVICE_ROOT/services/ims_service_interaction/src" +TELEPHONY_NETWORK_SEARCH_ROOT = "services/network_search" +TELEPHONY_SIM_ROOT = "services/sim" +TELEPHONY_TEL_RIL_ROOT = "services/tel_ril" +TELEPHONY_IMS_CORE_SERVICE_SRC_PATH = "services/ims_service_interaction/src" ohos_shared_library("tel_core_service") { install_enable = true sources = [ - "$TELEPHONY_CORE_SERVICE_ROOT/services/core/src/core_service.cpp", - "$TELEPHONY_CORE_SERVICE_ROOT/services/core/src/core_service_dump_helper.cpp", - "$TELEPHONY_CORE_SERVICE_ROOT/services/core/src/core_service_hisysevent.cpp", - "$TELEPHONY_CORE_SERVICE_ROOT/services/core/src/core_service_stub.cpp", - "$TELEPHONY_CORE_SERVICE_ROOT/services/core/src/runner_pool.cpp", "$TELEPHONY_IMS_CORE_SERVICE_SRC_PATH/ims_core_service_callback_stub.cpp", "$TELEPHONY_IMS_CORE_SERVICE_SRC_PATH/ims_core_service_client.cpp", "$TELEPHONY_IMS_CORE_SERVICE_SRC_PATH/ims_core_service_proxy.cpp", @@ -106,40 +95,38 @@ ohos_shared_library("tel_core_service") { "$TELEPHONY_TEL_RIL_ROOT/src/tel_ril_network.cpp", "$TELEPHONY_TEL_RIL_ROOT/src/tel_ril_sim.cpp", "$TELEPHONY_TEL_RIL_ROOT/src/tel_ril_sms.cpp", + "services/core/src/core_service.cpp", + "services/core/src/core_service_dump_helper.cpp", + "services/core/src/core_service_hisysevent.cpp", + "services/core/src/core_service_stub.cpp", + "services/core/src/runner_pool.cpp", ] include_dirs = [ - "//base/telephony/telephony_data/sim/include", - "//base/telephony/telephony_data/common/include", - "$TELEPHONY_CORE_SERVICE_ROOT/services/core/include", + "$TELEPHONY_SIM_ROOT/include", "$TELEPHONY_TEL_RIL_ROOT/include", "$TELEPHONY_NETWORK_SEARCH_ROOT/include", - "$TELEPHONY_CORE_SERVICE_ROOT/utils/log/include", - "$TELEPHONY_SIM_ROOT/include", - "//third_party/icu/icu4c/source/common/unicode", - "//third_party/icu/icu4c/source/common", - "//third_party/libphonenumber/cpp/src", - "//third_party/protobuf/src", - "//third_party/protobuf/src/google", - "//third_party/protobuf/src/google/protobuf", + "services/core/include", + "utils/log/include", ] - configs = [ "//base/telephony/core_service/utils:telephony_log_config" ] + configs = [ "utils:telephony_log_config" ] - defines += [ + defines = [ "TELEPHONY_LOG_TAG = \"CoreService\"", "LOG_DOMAIN = 0xD001F04", "OPENSSL_SUPPRESS_DEPRECATED", ] deps = [ - "${ability_runtime_inner_api_path}/dataobs_manager:dataobs_manager", - "//base/telephony/core_service/interfaces/innerkits:tel_core_service_api", - "//base/telephony/core_service/utils:libtel_common", + "interfaces/innerkits:tel_core_service_api", + "utils:libtel_common", + "//third_party/icu/icu4c:static_icustubdata", "//third_party/jsoncpp:jsoncpp", "//third_party/libphonenumber/cpp:phonenumber_standard", "//third_party/libxml2:libxml2", "//third_party/openssl:libcrypto_shared", + "//third_party/protobuf:protobuf_lite", ] external_deps = [ @@ -147,6 +134,7 @@ ohos_shared_library("tel_core_service") { "ability_base:zuri", "ability_runtime:ability_manager", "ability_runtime:data_ability_helper", + "ability_runtime:dataobs_manager", "ability_runtime:wantagent_innerkits", "battery_manager:batterysrv_client", "c_utils:utils", @@ -170,6 +158,7 @@ ohos_shared_library("tel_core_service") { "relational_store:native_rdb", "safwk:system_ability_fwk", "samgr:samgr_proxy", + "telephony_data:tel_telephony_data", "time_service:time_client", ] diff --git a/bundle.json b/bundle.json index 91519e42..fde8fc40 100644 --- a/bundle.json +++ b/bundle.json @@ -1,6 +1,6 @@ { "name": "@ohos/core_service", - "version": "3.1.0", + "version": "4.0", "description": "telephony core service", "publishAs": "code-segment", "homePage": "https://gitee.com/openharmony", @@ -41,12 +41,13 @@ "c_utils", "common_event_service", "config_policy", + "data_share", "drivers_interface_ril", "eventhandler", "hdf_core", + "hilog", "hisysevent_native", "hiviewdfx_hilog_native", - "huks", "i18n", "init", "ipc", @@ -59,10 +60,18 @@ "resource_management", "safwk", "samgr", + "telephony_data", "time_service" ], "third_party": [ - "libphonenumber" + "googletest", + "icu4c", + "jsoncpp", + "libphonenumber", + "libxml2", + "node", + "openssl", + "protobuf" ] }, "build": { diff --git a/core_service_aafwk.gni b/core_service_aafwk.gni deleted file mode 100644 index e659c0d9..00000000 --- a/core_service_aafwk.gni +++ /dev/null @@ -1,17 +0,0 @@ -# Copyright (c) 2022 Huawei Device Co., Ltd. -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -ability_runtime_path = "//foundation/ability/ability_runtime" -ability_runtime_inner_api_path = "${ability_runtime_path}/interfaces/inner_api" -ability_runtime_kits_path = "${ability_runtime_path}/frameworks/kits" -ability_runtime_services_path = "${ability_runtime_path}/services" diff --git a/frameworks/js/network_search/BUILD.gn b/frameworks/js/network_search/BUILD.gn index 27120999..bc3a2962 100755 --- a/frameworks/js/network_search/BUILD.gn +++ b/frameworks/js/network_search/BUILD.gn @@ -10,23 +10,16 @@ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. -import("//base/telephony/core_service/core_service_aafwk.gni") -import("//base/telephony/core_service/telephony.gni") +SUBSYSTEM_DIR = "../../../.." import("//build/ohos.gni") -SUBSYSTEM_DIR = "//base/telephony" - ohos_shared_library("radio") { include_dirs = [ - "//third_party/node/src", "include", "$SUBSYSTEM_DIR/core_service/interfaces/kits/native", "$SUBSYSTEM_DIR/core_service/interfaces/innerkits/include", - "//commonlibrary/c_utils/base/include", "$SUBSYSTEM_DIR/core_service/frameworks/js/napi", "$SUBSYSTEM_DIR/core_service/common/sim", - "//foundation/communication/ipc/interfaces/innerkits/ipc_core/include", - "${ability_runtime_path}/interfaces/kits/native/ability/native", ] sources = [ @@ -43,20 +36,20 @@ ohos_shared_library("radio") { "src/set_radio_state_callback.cpp", ] - configs = [ "//base/telephony/core_service/utils:telephony_log_config" ] + configs = [ "$SUBSYSTEM_DIR/core_service/utils:telephony_log_config" ] - deps = [ - "$SUBSYSTEM_DIR/core_service/interfaces/innerkits:tel_core_service_api", - "//foundation/arkui/napi:ace_napi", - ] + deps = [ "//third_party/node:node_header" ] external_deps = [ + "ability_runtime:abilitykit_native", "c_utils:utils", + "core_service:tel_core_service_api", "hiviewdfx_hilog_native:libhilog", "init:libbegetutil", "ipc:ipc_core", + "napi:ace_napi", ] - defines += [ + defines = [ "TELEPHONY_LOG_TAG = \"CoreServiceRadioJsApi\"", "LOG_DOMAIN = 0xD001F04", ] diff --git a/frameworks/js/sim/BUILD.gn b/frameworks/js/sim/BUILD.gn index 48408091..752084a7 100755 --- a/frameworks/js/sim/BUILD.gn +++ b/frameworks/js/sim/BUILD.gn @@ -10,19 +10,14 @@ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. -import("//base/telephony/core_service/core_service_aafwk.gni") import("//build/ohos.gni") -SUBSYSTEM_DIR = "//base/telephony" +SUBSYSTEM_DIR = "../../../../" ohos_shared_library("sim") { include_dirs = [ "$SUBSYSTEM_DIR/core_service/frameworks/js/napi", - "//third_party/node/src", "include", "$SUBSYSTEM_DIR/core_service/interfaces/kits/native", "$SUBSYSTEM_DIR/core_service/interfaces/innerkits/include", - "//commonlibrary/c_utils/base/include", - "//foundation/communication/ipc/interfaces/innerkits/ipc_core/include", - "${ability_runtime_path}/interfaces/kits/native/ability/native", ] sources = [ @@ -30,18 +25,19 @@ ohos_shared_library("sim") { "src/napi_sim.cpp", ] - configs = [ "//base/telephony/core_service/utils:telephony_log_config" ] + configs = [ "$SUBSYSTEM_DIR/core_service/utils:telephony_log_config" ] - deps = [ - "$SUBSYSTEM_DIR/core_service/interfaces/innerkits:tel_core_service_api", - "//foundation/arkui/napi:ace_napi", - ] + deps = [ "//third_party/node:node_header" ] external_deps = [ + "ability_runtime:abilitykit_native", "c_utils:utils", "core_service:libtel_common", + "core_service:tel_core_service_api", "hiviewdfx_hilog_native:libhilog", "init:libbegetutil", + "ipc:ipc_core", + "napi:ace_napi", ] defines = [ "TELEPHONY_LOG_TAG = \"CoreServiceSimJsApi\"", diff --git a/interfaces/innerkits/BUILD.gn b/interfaces/innerkits/BUILD.gn index 18f2d16a..d7c9a539 100755 --- a/interfaces/innerkits/BUILD.gn +++ b/interfaces/innerkits/BUILD.gn @@ -10,10 +10,9 @@ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. -import("//base/telephony/core_service/telephony.gni") import("//build/ohos.gni") -SUBSYSTEM_DIR = "//base/telephony" +SUBSYSTEM_DIR = "../../../" TELEPHONY_CORE_SERVICE_ROOT = "$SUBSYSTEM_DIR/core_service" TELEPHONY_INTERFACES_INNERKITS = "$TELEPHONY_CORE_SERVICE_ROOT/interfaces/innerkits" @@ -64,7 +63,7 @@ ohos_shared_library("tel_core_service_api") { "$TELEPHONY_IMS_CORE_SERVICE_ROOT/src/ims_core_service_callback_proxy.cpp", ] - defines += [ + defines = [ "TELEPHONY_LOG_TAG = \"CoreServiceApi\"", "LOG_DOMAIN = 0xD001F04", ] diff --git a/services/etc/param/BUILD.gn b/services/etc/param/BUILD.gn index fb23c0e7..856c5ad8 100755 --- a/services/etc/param/BUILD.gn +++ b/services/etc/param/BUILD.gn @@ -23,14 +23,14 @@ group("param_files") { } ohos_prebuilt_etc("telephony.para") { - source = "//base/telephony/core_service/services/etc/param/telephony.para" + source = "telephony.para" part_name = "core_service" subsystem_name = "telephony" module_install_dir = "etc/param" } ohos_prebuilt_etc("telephony.para.dac") { - source = "//base/telephony/core_service/services/etc/param/telephony.para.dac" + source = "telephony.para.dac" part_name = "core_service" subsystem_name = "telephony" module_install_dir = "etc/param" diff --git a/services/network_search/test/BUILD.gn b/services/network_search/test/BUILD.gn index 369f079c..72d3ec23 100644 --- a/services/network_search/test/BUILD.gn +++ b/services/network_search/test/BUILD.gn @@ -11,9 +11,8 @@ # See the License for the specific language governing permissions and # limitations under the License. -import("//base/telephony/core_service/core_service_aafwk.gni") import("//build/ohos.gni") -import("//drivers/hdf_core/adapter/uhdf2/uhdf.gni") +SOURCE_DIR = "../../../.." ohos_executable("tel_network_search_test") { install_enable = true @@ -24,24 +23,21 @@ ohos_executable("tel_network_search_test") { "test_broadcast.cpp", ] - include_dirs = [ - "${ability_runtime_inner_api_path}/ability_manager/include", - "${ability_runtime_services_path}/abilitymgr/include", - ] + configs = [ "$SOURCE_DIR/core_service/utils:telephony_log_config" ] - configs = [ "//base/telephony/core_service/utils:telephony_log_config" ] - - deps = [ "${ability_runtime_path}/frameworks/native/ability/native:abilitykit_native" ] + deps = + [ "$SOURCE_DIR/core_service/interfaces/innerkits:tel_core_service_api" ] external_deps = [ "ability_base:want", + "ability_runtime:ability_manager", + "ability_runtime:abilitykit_native", "ability_runtime:wantagent_innerkits", "access_token:libaccesstoken_sdk", "access_token:libnativetoken", "access_token:libtoken_setproc", "c_utils:utils", "common_event_service:cesfwk_innerkits", - "core_service:tel_core_service_api", "drivers_interface_ril:hril_innerkits", "eventhandler:libeventhandler", "ipc:ipc_core", diff --git a/services/sim/include/multi_sim_controller.h b/services/sim/include/multi_sim_controller.h index 5b8c3b74..30acbae8 100755 --- a/services/sim/include/multi_sim_controller.h +++ b/services/sim/include/multi_sim_controller.h @@ -21,9 +21,7 @@ #include "i_network_search.h" #include "if_system_ability_manager.h" #include "radio_protocol_controller.h" -#include "rdb_sim_helper.h" #include "sim_constant.h" -#include "sim_data.h" #include "sim_file_manager.h" #include "sim_rdb_helper.h" #include "sim_state_manager.h" diff --git a/services/sim/include/multi_sim_monitor.h b/services/sim/include/multi_sim_monitor.h index 33ea91d3..6c274881 100755 --- a/services/sim/include/multi_sim_monitor.h +++ b/services/sim/include/multi_sim_monitor.h @@ -22,8 +22,6 @@ #include "sim_file_manager.h" #include "telephony_log_wrapper.h" #include "sim_constant.h" -#include "sim_data.h" -#include "rdb_sim_helper.h" namespace OHOS { namespace Telephony { diff --git a/services/sim/include/sim_rdb_info.h b/services/sim/include/sim_rdb_info.h index 4b51d5ca..046ab391 100755 --- a/services/sim/include/sim_rdb_info.h +++ b/services/sim/include/sim_rdb_info.h @@ -20,23 +20,6 @@ namespace OHOS { namespace Telephony { class SimRdbInfo { public: - static constexpr const char *SIM_ID = "sim_id"; - static constexpr const char *ICC_ID = "icc_id"; - static constexpr const char *CARD_ID = "card_id"; - static constexpr const char *SLOT_INDEX = "slot_index"; - static constexpr const char *SHOW_NAME = "show_name"; - static constexpr const char *PHONE_NUMBER = "phone_number"; - static constexpr const char *COUNTRY_CODE = "country_code"; - static constexpr const char *LANGUAGE = "language"; - static constexpr const char *IMSI = "imsi"; - static constexpr const char *CARD_TYPE = "card_type"; - static constexpr const char *IMS_SWITCH = "ims_switch"; - static constexpr const char *IS_ACTIVE = "is_active"; - static constexpr const char *IS_MAIN_CARD = "is_main_card"; - static constexpr const char *IS_VOICE_CARD = "is_voice_card"; - static constexpr const char *IS_MESSAGE_CARD = "is_message_card"; - static constexpr const char *IS_CELLULAR_DATA_CARD = "is_cellular_data_card"; - inline static const std::string SIM_RDB_URI = "datashare:///com.ohos.simability"; inline static const std::string SIM_RDB_SELECTION = "datashare:///com.ohos.simability/sim/sim_info"; inline static const std::string SIM_RDB_DEFAULT_SET_URI = "datashare:///com.ohos.simability/sim/sim_info/set_card"; diff --git a/services/sim/src/icc_dialling_numbers_manager.cpp b/services/sim/src/icc_dialling_numbers_manager.cpp index beb20d78..be80aa8e 100644 --- a/services/sim/src/icc_dialling_numbers_manager.cpp +++ b/services/sim/src/icc_dialling_numbers_manager.cpp @@ -94,6 +94,7 @@ void IccDiallingNumbersManager::InitFdnCache() { TELEPHONY_LOGI("IccDiallingNumbersManager::InitFdnCache start"); std::thread initTask([&]() { + pthread_setname_np(pthread_self(), "init_fdn_cache"); std::vector> diallingNumbers; QueryIccDiallingNumbers(DiallingNumbersInfo::SIM_FDN, diallingNumbers); }); diff --git a/services/sim/src/multi_sim_controller.cpp b/services/sim/src/multi_sim_controller.cpp index 055111c6..ebdc30ec 100644 --- a/services/sim/src/multi_sim_controller.cpp +++ b/services/sim/src/multi_sim_controller.cpp @@ -20,6 +20,7 @@ #include "core_service_errors.h" #include "core_service_hisysevent.h" #include "parameters.h" +#include "sim_data.h" #include "string_ex.h" namespace OHOS { @@ -199,15 +200,15 @@ int32_t MultiSimController::UpdateDataByIccId(int slotId, const std::string &new DataShare::DataShareValuesBucket values; DataShare::DataShareValueObject slotObj(slotId); DataShare::DataShareValueObject valueObj(ACTIVE); - values.Put(SimRdbInfo::SLOT_INDEX, slotObj); - values.Put(SimRdbInfo::IS_ACTIVE, valueObj); + values.Put(SimData::SLOT_INDEX, slotObj); + values.Put(SimData::IS_ACTIVE, valueObj); const int32_t slotSingle = 1; if (SIM_SLOT_COUNT == slotSingle) { DataShare::DataShareValueObject mainCardObj(MAIN_CARD); - values.Put(SimRdbInfo::IS_MAIN_CARD, mainCardObj); - values.Put(SimRdbInfo::IS_VOICE_CARD, mainCardObj); - values.Put(SimRdbInfo::IS_MESSAGE_CARD, mainCardObj); - values.Put(SimRdbInfo::IS_CELLULAR_DATA_CARD, mainCardObj); + values.Put(SimData::IS_MAIN_CARD, mainCardObj); + values.Put(SimData::IS_VOICE_CARD, mainCardObj); + values.Put(SimData::IS_MESSAGE_CARD, mainCardObj); + values.Put(SimData::IS_CELLULAR_DATA_CARD, mainCardObj); } return simDbHelper_->UpdateDataByIccId(newIccId, values); // finish re active } @@ -224,23 +225,23 @@ int32_t MultiSimController::InsertData(int slotId, const std::string &newIccId) DataShare::DataShareValueObject slotObj(slotId); DataShare::DataShareValueObject iccidObj(newIccId); DataShare::DataShareValueObject valueObj(ACTIVE); - values.Put(SimRdbInfo::SLOT_INDEX, slotObj); - values.Put(SimRdbInfo::ICC_ID, iccidObj); - values.Put(SimRdbInfo::CARD_ID, iccidObj); // iccId == cardId by now - values.Put(SimRdbInfo::IS_ACTIVE, valueObj); + values.Put(SimData::SLOT_INDEX, slotObj); + values.Put(SimData::ICC_ID, iccidObj); + values.Put(SimData::CARD_ID, iccidObj); // iccId == cardId by now + values.Put(SimData::IS_ACTIVE, valueObj); const int32_t slotSingle = 1; if (SIM_SLOT_COUNT == slotSingle) { DataShare::DataShareValueObject mainCardObj(MAIN_CARD); - values.Put(SimRdbInfo::IS_MAIN_CARD, mainCardObj); - values.Put(SimRdbInfo::IS_VOICE_CARD, mainCardObj); - values.Put(SimRdbInfo::IS_MESSAGE_CARD, mainCardObj); - values.Put(SimRdbInfo::IS_CELLULAR_DATA_CARD, mainCardObj); + values.Put(SimData::IS_MAIN_CARD, mainCardObj); + values.Put(SimData::IS_VOICE_CARD, mainCardObj); + values.Put(SimData::IS_MESSAGE_CARD, mainCardObj); + values.Put(SimData::IS_CELLULAR_DATA_CARD, mainCardObj); } else { DataShare::DataShareValueObject notMainCardObj(NOT_MAIN); - values.Put(SimRdbInfo::IS_MAIN_CARD, notMainCardObj); - values.Put(SimRdbInfo::IS_VOICE_CARD, notMainCardObj); - values.Put(SimRdbInfo::IS_MESSAGE_CARD, notMainCardObj); - values.Put(SimRdbInfo::IS_CELLULAR_DATA_CARD, notMainCardObj); + values.Put(SimData::IS_MAIN_CARD, notMainCardObj); + values.Put(SimData::IS_VOICE_CARD, notMainCardObj); + values.Put(SimData::IS_MESSAGE_CARD, notMainCardObj); + values.Put(SimData::IS_CELLULAR_DATA_CARD, notMainCardObj); } int64_t id; return simDbHelper_->InsertData(id, values); @@ -435,7 +436,7 @@ int32_t MultiSimController::SetActiveSim(int32_t slotId, int32_t enable, bool fo std::lock_guard lock(mutex_); DataShare::DataShareValuesBucket values; DataShare::DataShareValueObject valueObj(enable); - values.Put(SimRdbInfo::IS_ACTIVE, valueObj); + values.Put(SimData::IS_ACTIVE, valueObj); int32_t result = simDbHelper_->UpdateDataBySlotId(slotId, values); if (result == INVALID_VALUE) { TELEPHONY_LOGE("MultiSimController::SetActiveSim failed by database"); @@ -780,7 +781,7 @@ int32_t MultiSimController::SetShowNumber(int32_t slotId, std::u16string number, std::lock_guard lock(mutex_); DataShare::DataShareValuesBucket values; DataShare::DataShareValueObject valueObj(Str16ToStr8(number)); - values.Put(SimRdbInfo::PHONE_NUMBER, valueObj); + values.Put(SimData::PHONE_NUMBER, valueObj); int32_t result = simDbHelper_->UpdateDataBySlotId(slotId, values); if (result == INVALID_VALUE) { TELEPHONY_LOGE("MultiSimController::SetShowNumber set Data Base failed"); @@ -822,7 +823,7 @@ int32_t MultiSimController::SetShowName(int32_t slotId, std::u16string name, boo std::lock_guard lock(mutex_); DataShare::DataShareValuesBucket values; DataShare::DataShareValueObject valueObj(Str16ToStr8(name)); - values.Put(SimRdbInfo::SHOW_NAME, valueObj); + values.Put(SimData::SHOW_NAME, valueObj); int32_t result = simDbHelper_->UpdateDataBySlotId(slotId, values); if (result == INVALID_VALUE) { TELEPHONY_LOGE("MultiSimController::SetShowName set Data Base failed"); @@ -855,8 +856,8 @@ bool MultiSimController::SetIccId(int32_t slotId, std::u16string iccId) } DataShare::DataShareValuesBucket values; DataShare::DataShareValueObject iccidObj(Str16ToStr8(iccId)); - values.Put(SimRdbInfo::ICC_ID, iccidObj); - values.Put(SimRdbInfo::CARD_ID, iccidObj); // iccId == cardId by now + values.Put(SimData::ICC_ID, iccidObj); + values.Put(SimData::CARD_ID, iccidObj); // iccId == cardId by now int32_t result = simDbHelper_->UpdateDataBySlotId(slotId, values); if (result == INVALID_VALUE) { TELEPHONY_LOGE("MultiSimController::SetIccId set Data Base failed"); @@ -930,7 +931,7 @@ int32_t MultiSimController::SaveImsSwitch(int32_t slotId, int32_t imsSwitchValue } DataShare::DataShareValuesBucket values; DataShare::DataShareValueObject valueObj(imsSwitchValue); - values.Put(SimRdbInfo::IMS_SWITCH, valueObj); + values.Put(SimData::IMS_SWITCH, valueObj); return simDbHelper_->UpdateDataByIccId(localCacheInfo_[slotId].iccId, values); } diff --git a/services/sim/src/sim_rdb_helper.cpp b/services/sim/src/sim_rdb_helper.cpp index d23bd442..5f5640f6 100755 --- a/services/sim/src/sim_rdb_helper.cpp +++ b/services/sim/src/sim_rdb_helper.cpp @@ -15,6 +15,7 @@ #include "sim_rdb_helper.h" +#include "sim_data.h" #include "telephony_errors.h" #include "telephony_types.h" @@ -37,7 +38,7 @@ std::shared_ptr SimRdbHelper::CreateDataAHelper() TELEPHONY_LOGE("SimRdbHelper GetSystemAbility Service Failed."); return nullptr; } - return DataShare::DataShareHelper::Creator(remoteObj, SimRdbInfo::SIM_RDB_URI); + return DataShare::DataShareHelper::Creator(remoteObj, SIM_URI); } int SimRdbHelper::Insert(const DataShare::DataShareValuesBucket &values) @@ -108,7 +109,7 @@ int32_t SimRdbHelper::GetDefaultMainCardSlotId() int32_t mainCardSlotId = 0; std::vector colume; DataShare::DataSharePredicates predicates; - predicates.EqualTo(SimRdbInfo::IS_MAIN_CARD, std::to_string(static_cast(MAIN_CARD))); + predicates.EqualTo(SimData::IS_MAIN_CARD, std::to_string(static_cast(MAIN_CARD))); std::shared_ptr result = Query(colume, predicates); if (result == nullptr) { TELEPHONY_LOGE("SimRdbHelper::get nothing"); @@ -120,7 +121,7 @@ int32_t SimRdbHelper::GetDefaultMainCardSlotId() return mainCardSlotId; } int index = 0; - result->GetColumnIndex(SimRdbInfo::SLOT_INDEX, index); + result->GetColumnIndex(SimData::SLOT_INDEX, index); result->GetInt(index, mainCardSlotId); result->Close(); return mainCardSlotId; @@ -132,7 +133,7 @@ int32_t SimRdbHelper::GetDefaultMessageCardSlotId() int32_t messageCardSlotId = 0; std::vector colume; DataShare::DataSharePredicates predicates; - predicates.EqualTo(SimRdbInfo::IS_MESSAGE_CARD, std::to_string(static_cast(MAIN_CARD))); + predicates.EqualTo(SimData::IS_MESSAGE_CARD, std::to_string(static_cast(MAIN_CARD))); std::shared_ptr result = Query(colume, predicates); if (result == nullptr) { TELEPHONY_LOGE("SimRdbHelper::get nothing"); @@ -144,7 +145,7 @@ int32_t SimRdbHelper::GetDefaultMessageCardSlotId() return messageCardSlotId; } int index = 0; - result->GetColumnIndex(SimRdbInfo::SLOT_INDEX, index); + result->GetColumnIndex(SimData::SLOT_INDEX, index); result->GetInt(index, messageCardSlotId); result->Close(); return messageCardSlotId; @@ -156,7 +157,7 @@ int32_t SimRdbHelper::GetDefaultCellularDataCardSlotId() int32_t cellularDataCardSlotId = 0; std::vector colume; DataShare::DataSharePredicates predicates; - predicates.EqualTo(SimRdbInfo::IS_CELLULAR_DATA_CARD, std::to_string(static_cast(MAIN_CARD))); + predicates.EqualTo(SimData::IS_CELLULAR_DATA_CARD, std::to_string(static_cast(MAIN_CARD))); std::shared_ptr result = Query(colume, predicates); if (result == nullptr) { TELEPHONY_LOGE("SimRdbHelper::get nothing"); @@ -168,7 +169,7 @@ int32_t SimRdbHelper::GetDefaultCellularDataCardSlotId() return cellularDataCardSlotId; } int index = 0; - result->GetColumnIndex(SimRdbInfo::SLOT_INDEX, index); + result->GetColumnIndex(SimData::SLOT_INDEX, index); result->GetInt(index, cellularDataCardSlotId); result->Close(); return cellularDataCardSlotId; @@ -179,7 +180,7 @@ int32_t SimRdbHelper::GetDefaultVoiceCardSlotId() int32_t voiceCardSlotId = INVALID_VALUE; std::vector colume; DataShare::DataSharePredicates predicates; - predicates.EqualTo(SimRdbInfo::IS_VOICE_CARD, std::to_string(static_cast(MAIN_CARD))); + predicates.EqualTo(SimData::IS_VOICE_CARD, std::to_string(static_cast(MAIN_CARD))); std::shared_ptr result = Query(colume, predicates); if (result == nullptr) { TELEPHONY_LOGE("SimRdbHelper::get nothing"); @@ -191,7 +192,7 @@ int32_t SimRdbHelper::GetDefaultVoiceCardSlotId() return voiceCardSlotId; } int index = 0; - result->GetColumnIndex(SimRdbInfo::SLOT_INDEX, index); + result->GetColumnIndex(SimData::SLOT_INDEX, index); result->GetInt(index, voiceCardSlotId); result->Close(); TELEPHONY_LOGI("SimRdbHelper::GetDefaultVoiceCardSlotId = %{public}d", voiceCardSlotId); @@ -205,8 +206,8 @@ int32_t SimRdbHelper::SetDefaultMainCard(int32_t slotId) DataShare::DataShareValuesBucket value; DataShare::DataShareValueObject slotObj(slotId); DataShare::DataShareValueObject valueObj(static_cast(DefaultCardType::MAIN)); - value.Put(SimRdbInfo::SLOT_INDEX, slotObj); - value.Put(SimRdbInfo::CARD_TYPE, valueObj); + value.Put(SimData::SLOT_INDEX, slotObj); + value.Put(SimData::CARD_TYPE, valueObj); std::shared_ptr dataShareHelper = CreateDataAHelper(); if (dataShareHelper == nullptr) { TELEPHONY_LOGE("SimRdbHelper::SetDefaultMainCard failed by nullptr"); @@ -226,8 +227,8 @@ int32_t SimRdbHelper::SetDefaultVoiceCard(int32_t slotId) DataShare::DataShareValuesBucket value; DataShare::DataShareValueObject slotObj(slotId); DataShare::DataShareValueObject valueObj(static_cast(DefaultCardType::VOICE)); - value.Put(SimRdbInfo::SLOT_INDEX, slotObj); - value.Put(SimRdbInfo::CARD_TYPE, valueObj); + value.Put(SimData::SLOT_INDEX, slotObj); + value.Put(SimData::CARD_TYPE, valueObj); std::shared_ptr dataShareHelper = CreateDataAHelper(); if (dataShareHelper == nullptr) { TELEPHONY_LOGE("SimRdbHelper::SetDefaultVoiceCard failed by nullptr"); @@ -247,8 +248,8 @@ int32_t SimRdbHelper::SetDefaultMessageCard(int32_t slotId) DataShare::DataShareValuesBucket value; DataShare::DataShareValueObject slotObj(slotId); DataShare::DataShareValueObject valueObj(static_cast(DefaultCardType::SMS)); - value.Put(SimRdbInfo::SLOT_INDEX, slotObj); - value.Put(SimRdbInfo::CARD_TYPE, valueObj); + value.Put(SimData::SLOT_INDEX, slotObj); + value.Put(SimData::CARD_TYPE, valueObj); std::shared_ptr dataShareHelper = CreateDataAHelper(); if (dataShareHelper == nullptr) { TELEPHONY_LOGE("SimRdbHelper::SetDefaultMessageCard failed by nullptr"); @@ -268,8 +269,8 @@ int32_t SimRdbHelper::SetDefaultCellularData(int32_t slotId) DataShare::DataShareValuesBucket value; DataShare::DataShareValueObject slotObj(slotId); DataShare::DataShareValueObject valueObj(static_cast(DefaultCardType::DATA)); - value.Put(SimRdbInfo::SLOT_INDEX, slotObj); - value.Put(SimRdbInfo::CARD_TYPE, valueObj); + value.Put(SimData::SLOT_INDEX, slotObj); + value.Put(SimData::CARD_TYPE, valueObj); std::shared_ptr dataShareHelper = CreateDataAHelper(); if (dataShareHelper == nullptr) { TELEPHONY_LOGE("SimRdbHelper::SetDefaultCellularData failed by nullptr"); @@ -292,37 +293,37 @@ void SimRdbHelper::SaveDataToBean(std::shared_ptr { TELEPHONY_LOGI("SimRdbHelper::SaveDataToBean"); int index = 0; - result->GetColumnIndex(SimRdbInfo::SIM_ID, index); + result->GetColumnIndex(SimData::SIM_ID, index); result->GetInt(index, simBean.simId); - result->GetColumnIndex(SimRdbInfo::ICC_ID, index); + result->GetColumnIndex(SimData::ICC_ID, index); result->GetString(index, simBean.iccId); - result->GetColumnIndex(SimRdbInfo::CARD_ID, index); + result->GetColumnIndex(SimData::CARD_ID, index); result->GetString(index, simBean.cardId); - result->GetColumnIndex(SimRdbInfo::IMS_SWITCH, index); + result->GetColumnIndex(SimData::IMS_SWITCH, index); result->GetInt(index, simBean.imsSwitch); - result->GetColumnIndex(SimRdbInfo::SLOT_INDEX, index); + result->GetColumnIndex(SimData::SLOT_INDEX, index); result->GetInt(index, simBean.slotIndex); - result->GetColumnIndex(SimRdbInfo::CARD_TYPE, index); + result->GetColumnIndex(SimData::CARD_TYPE, index); result->GetInt(index, simBean.cardType); - result->GetColumnIndex(SimRdbInfo::SHOW_NAME, index); + result->GetColumnIndex(SimData::SHOW_NAME, index); result->GetString(index, simBean.showName); - result->GetColumnIndex(SimRdbInfo::PHONE_NUMBER, index); + result->GetColumnIndex(SimData::PHONE_NUMBER, index); result->GetString(index, simBean.phoneNumber); - result->GetColumnIndex(SimRdbInfo::COUNTRY_CODE, index); + result->GetColumnIndex(SimData::COUNTRY_CODE, index); result->GetString(index, simBean.countryCode); - result->GetColumnIndex(SimRdbInfo::LANGUAGE, index); + result->GetColumnIndex(SimData::LANGUAGE, index); result->GetString(index, simBean.language); - result->GetColumnIndex(SimRdbInfo::IMSI, index); + result->GetColumnIndex(SimData::IMSI, index); result->GetString(index, simBean.imsi); - result->GetColumnIndex(SimRdbInfo::IS_MAIN_CARD, index); + result->GetColumnIndex(SimData::IS_MAIN_CARD, index); result->GetInt(index, simBean.isMainCard); - result->GetColumnIndex(SimRdbInfo::IS_VOICE_CARD, index); + result->GetColumnIndex(SimData::IS_VOICE_CARD, index); result->GetInt(index, simBean.isVoiceCard); - result->GetColumnIndex(SimRdbInfo::IS_MESSAGE_CARD, index); + result->GetColumnIndex(SimData::IS_MESSAGE_CARD, index); result->GetInt(index, simBean.isMessageCard); - result->GetColumnIndex(SimRdbInfo::IS_CELLULAR_DATA_CARD, index); + result->GetColumnIndex(SimData::IS_CELLULAR_DATA_CARD, index); result->GetInt(index, simBean.isCellularDataCard); - result->GetColumnIndex(SimRdbInfo::IS_ACTIVE, index); + result->GetColumnIndex(SimData::IS_ACTIVE, index); result->GetInt(index, simBean.isActive); } @@ -332,7 +333,7 @@ int32_t SimRdbHelper::QueryDataBySlotId(int32_t slotId, SimRdbInfo &simBean) std::string slot = std::to_string(slotId); std::vector colume; DataShare::DataSharePredicates predicates; - predicates.EqualTo(SimRdbInfo::SLOT_INDEX, slot); + predicates.EqualTo(SimData::SLOT_INDEX, slot); std::shared_ptr result = Query(colume, predicates); if (result == nullptr) { TELEPHONY_LOGE("SimRdbHelper::QueryDataBySlotId get nothing"); @@ -352,7 +353,7 @@ int32_t SimRdbHelper::QueryDataByIccId(std::string iccId, SimRdbInfo &simBean) TELEPHONY_LOGI("SimRdbHelper::QueryDataByIccId"); std::vector colume; DataShare::DataSharePredicates predicates; - predicates.EqualTo(SimRdbInfo::ICC_ID, iccId); + predicates.EqualTo(SimData::ICC_ID, iccId); std::shared_ptr result = Query(colume, predicates); if (result == nullptr) { TELEPHONY_LOGE("SimRdbHelper::QueryDataByIccId get nothing"); @@ -394,7 +395,7 @@ int32_t SimRdbHelper::QueryAllValidData(std::vector &vec) std::vector colume; std::string id = std::to_string(DEACTIVE); DataShare::DataSharePredicates predicates; - predicates.GreaterThan(SimRdbInfo::IS_ACTIVE, id); + predicates.GreaterThan(SimData::IS_ACTIVE, id); std::shared_ptr result = Query(colume, predicates); if (result == nullptr) { TELEPHONY_LOGE("SimRdbHelper::QueryAllValidData get nothing"); @@ -416,7 +417,7 @@ int32_t SimRdbHelper::UpdateDataBySlotId(int32_t slotId, const DataShare::DataSh TELEPHONY_LOGI("SimRdbHelper::UpdateDataBySlotId = %{public}d", slotId); std::string slot = std::to_string(slotId); DataShare::DataSharePredicates predicates; - predicates.EqualTo(SimRdbInfo::SLOT_INDEX, slot); + predicates.EqualTo(SimData::SLOT_INDEX, slot); return Update(values, predicates); } @@ -424,7 +425,7 @@ int32_t SimRdbHelper::UpdateDataByIccId(std::string iccId, const DataShare::Data { TELEPHONY_LOGI("SimRdbHelper::UpdateDataByIccId"); DataShare::DataSharePredicates predicates; - predicates.EqualTo(SimRdbInfo::ICC_ID, iccId); + predicates.EqualTo(SimData::ICC_ID, iccId); return Update(values, predicates); } @@ -434,7 +435,7 @@ int32_t SimRdbHelper::ForgetAllData() DataShare::DataSharePredicates predicates; DataShare::DataShareValuesBucket value; DataShare::DataShareValueObject valueObj(DEACTIVE); - value.Put(SimRdbInfo::IS_ACTIVE, valueObj); + value.Put(SimData::IS_ACTIVE, valueObj); return Update(value, predicates); } @@ -442,10 +443,10 @@ int32_t SimRdbHelper::ForgetAllData(int32_t slotId) { TELEPHONY_LOGI("SimRdbHelper::ForgetAllData slotId = %{public}d", slotId); DataShare::DataSharePredicates predicates; - predicates.EqualTo(SimRdbInfo::SLOT_INDEX, std::to_string(slotId)); + predicates.EqualTo(SimData::SLOT_INDEX, std::to_string(slotId)); DataShare::DataShareValuesBucket value; DataShare::DataShareValueObject valueObj(DEACTIVE); - value.Put(SimRdbInfo::IS_ACTIVE, valueObj); + value.Put(SimData::IS_ACTIVE, valueObj); return Update(value, predicates); } @@ -453,7 +454,7 @@ int32_t SimRdbHelper::ClearData() { std::string id = std::to_string(INVALID_VALUE); DataShare::DataSharePredicates predicates; - predicates.GreaterThan(SimRdbInfo::SIM_ID, id); + predicates.GreaterThan(SimData::SIM_ID, id); return Delete(predicates); } } // namespace Telephony diff --git a/services/sim/test/BUILD.gn b/services/sim/test/BUILD.gn index fb8a03af..3910e75b 100755 --- a/services/sim/test/BUILD.gn +++ b/services/sim/test/BUILD.gn @@ -10,15 +10,12 @@ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. -import("//base/telephony/core_service/core_service_aafwk.gni") -import("//base/telephony/core_service/telephony.gni") +SUBSYSTEM_DIR = "../../../.." import("//build/ohos.gni") -import("//drivers/hdf_core/adapter/uhdf2/uhdf.gni") -TELEPHONY_CORE_SERVICE_ROOT = "//base/telephony/core_service" -TELEPHONY_SIM_ROOT = "//base/telephony/core_service/services/sim" -HDF_FRAMEWORKS = "//drivers/hdf/frameworks" -TELEPHONY_FRAMEWORKS_ROOT = "//base/telephony/core_service/frameworks/native/" +TELEPHONY_CORE_SERVICE_ROOT = "$SUBSYSTEM_DIR/core_service" +TELEPHONY_SIM_ROOT = "$SUBSYSTEM_DIR/core_service/services/sim" +TELEPHONY_FRAMEWORKS_ROOT = "$SUBSYSTEM_DIR/core_service/frameworks/native/" ohos_executable("tel_sim_test") { install_enable = true @@ -31,40 +28,26 @@ ohos_executable("tel_sim_test") { ] include_dirs = [ - "//base/telephony/telephony_data/sim/include", - "//base/telephony/telephony_data/common/include", "$TELEPHONY_CORE_SERVICE_ROOT/base/include", "$TELEPHONY_CORE_SERVICE_ROOT/services/tel_ril/include", - "$TELEPHONY_CORE_SERVICE_ROOT/interfaces/innerkits/include", - "$TELEPHONY_CORE_SERVICE_ROOT/interfaces/innerkits/state_registry", - "$TELEPHONY_CORE_SERVICE_ROOT/interfaces/innerkits/telephony_data", "$TELEPHONY_SIM_ROOT/include", - - "$HDF_FRAMEWORKS/ability/sbuf/include", - "$HDF_FRAMEWORKS/core/shared/include", - "$HDF_FRAMEWORKS/core/host/include", - "$HDF_FRAMEWORKS/core/master/include", - "$HDF_FRAMEWORKS/include/core", - "$HDF_FRAMEWORKS/include/utils", - "$HDF_FRAMEWORKS/utils/include", - "$HDF_FRAMEWORKS/include/osal", ] - defines += [ + defines = [ "TELEPHONY_LOG_TAG = \"CoreServiceSimTest\"", "LOG_DOMAIN = 0xD000F00", ] - configs = [ "//base/telephony/core_service/utils:telephony_log_config" ] + configs = [ "$SUBSYSTEM_DIR/core_service/utils:telephony_log_config" ] deps = [ - "${ability_runtime_path}/frameworks/native/ability/native:abilitykit_native", - "//base/telephony/core_service:tel_core_service", - "//base/telephony/core_service/interfaces/innerkits:tel_core_service_api", + "$SUBSYSTEM_DIR/core_service:tel_core_service", + "$SUBSYSTEM_DIR/core_service/interfaces/innerkits:tel_core_service_api", ] external_deps = [ "ability_base:want", + "ability_runtime:abilitykit_native", "access_token:libaccesstoken_sdk", "access_token:libnativetoken", "access_token:libtoken_setproc", diff --git a/services/tel_ril/test/BUILD.gn b/services/tel_ril/test/BUILD.gn index 9ba3e1bc..c7b1c315 100644 --- a/services/tel_ril/test/BUILD.gn +++ b/services/tel_ril/test/BUILD.gn @@ -11,12 +11,9 @@ # See the License for the specific language governing permissions and # limitations under the License. -import("//base/telephony/core_service/telephony.gni") +TELEPHONY_CORE_SERVICE_ROOT = "../../.." import("//build/ohos.gni") -import("//drivers/hdf_core/adapter/uhdf2/uhdf.gni") - -TELEPHONY_CORE_SERVICE_ROOT = "//base/telephony/core_service" -TELEPHONY_SIM_ROOT = "//base/telephony/core_service/services/sim" +TELEPHONY_SIM_ROOT = "$TELEPHONY_CORE_SERVICE_ROOT/services/sim" ohos_executable("tel_ril_test") { install_enable = true @@ -30,17 +27,14 @@ ohos_executable("tel_ril_test") { "$TELEPHONY_SIM_ROOT/include", ] - defines += [ + defines = [ "TELEPHONY_LOG_TAG = \"CoreServiceRilTest\"", "LOG_DOMAIN = 0xD000F00", ] - configs = [ "//base/telephony/core_service/utils:telephony_log_config" ] + configs = [ "$TELEPHONY_CORE_SERVICE_ROOT/utils:telephony_log_config" ] - deps = [ - "$hdf_uhdf_path/hdi:libhdi", - "//base/telephony/core_service:tel_core_service", - ] + deps = [ "$TELEPHONY_CORE_SERVICE_ROOT:tel_core_service" ] external_deps = [ "c_utils:utils", @@ -48,6 +42,7 @@ ohos_executable("tel_ril_test") { "drivers_interface_ril:hril_innerkits", "drivers_interface_ril:ril_idl_headers", "eventhandler:libeventhandler", + "hdf_core:libhdi", "init:libbegetutil", "ipc:ipc_core", "power_manager:powermgr_client", diff --git a/telephony.gni b/telephony.gni deleted file mode 100755 index 1a3caf67..00000000 --- a/telephony.gni +++ /dev/null @@ -1,20 +0,0 @@ -# Copyright (c) 2021 Huawei Device Co., Ltd. -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -#declare build args - -if (!defined(defines)) { - defines = [] -} - -defines += [ "CELLULAR_SUPPORT = true" ] diff --git a/test/fuzztest/addiccdiallingnumbers_fuzzer/BUILD.gn b/test/fuzztest/addiccdiallingnumbers_fuzzer/BUILD.gn index e38549d9..6eb21d8c 100644 --- a/test/fuzztest/addiccdiallingnumbers_fuzzer/BUILD.gn +++ b/test/fuzztest/addiccdiallingnumbers_fuzzer/BUILD.gn @@ -12,7 +12,7 @@ # limitations under the License. #####################hydra-fuzz################### -import("//base/telephony/core_service/telephony.gni") +SUBSYSTEM_DIR = "../../../.." import("//build/config/features.gni") import("//build/ohos.gni") import("//build/test.gni") @@ -22,23 +22,22 @@ ohos_fuzztest("AddIccDiallingNumbersFuzzTest") { module_output_path = "core_service/AddIccDiallingNumbersFuzzTest" module_out_path = module_output_path fuzz_config_file = - "//base/telephony/core_service/test/fuzztest/addiccdiallingnumbers_fuzzer" + "$SUBSYSTEM_DIR/core_service/test/fuzztest/addiccdiallingnumbers_fuzzer" include_dirs = [ - "//base/telephony/core_service/frameworks/js/napi/include", - "//base/telephony/core_service/frameworks/js/napi", - "//base/telephony/core_service/services/sim/include", - "//base/telephony/core_service/services/core/include", - "//base/telephony/core_service/services/tel_ril/include", - "//base/telephony/core_service/test/fuzztest/common_fuzzer", + "$SUBSYSTEM_DIR/core_service/frameworks/js/napi/include", + "$SUBSYSTEM_DIR/core_service/frameworks/js/napi", + "$SUBSYSTEM_DIR/core_service/services/sim/include", + "$SUBSYSTEM_DIR/core_service/services/core/include", + "$SUBSYSTEM_DIR/core_service/services/tel_ril/include", + "$SUBSYSTEM_DIR/core_service/test/fuzztest/common_fuzzer", ] - configs = [ "//base/telephony/core_service/utils:telephony_log_config" ] + configs = [ "$SUBSYSTEM_DIR/core_service/utils:telephony_log_config" ] deps = [ - "//base/telephony/core_service:tel_core_service", - "//base/telephony/core_service/interfaces/innerkits:tel_core_service_api", - "//foundation/arkui/napi:ace_napi", + "$SUBSYSTEM_DIR/core_service:tel_core_service", + "$SUBSYSTEM_DIR/core_service/interfaces/innerkits:tel_core_service_api", ] external_deps = [ @@ -63,6 +62,7 @@ ohos_fuzztest("AddIccDiallingNumbersFuzzTest") { "i18n:zone_util", "init:libbegetutil", "ipc:ipc_core", + "napi:ace_napi", "netmanager_base:net_conn_manager_if", "netmanager_ext:net_tether_manager_if", "power_manager:powermgr_client", @@ -71,7 +71,7 @@ ohos_fuzztest("AddIccDiallingNumbersFuzzTest") { "safwk:system_ability_fwk", "samgr:samgr_proxy", ] - defines += [ + defines = [ "TELEPHONY_LOG_TAG = \"CoreServiceFuzzTest\"", "LOG_DOMAIN = 0xD000F00", ] @@ -88,8 +88,8 @@ ohos_fuzztest("AddIccDiallingNumbersFuzzTest") { "-fno-omit-frame-pointer", ] sources = [ - "//base/telephony/core_service/frameworks/js/napi/napi_util.cpp", - "//base/telephony/core_service/test/fuzztest/common_fuzzer/addcoreservicetoken_fuzzer.cpp", + "$SUBSYSTEM_DIR/core_service/frameworks/js/napi/napi_util.cpp", + "$SUBSYSTEM_DIR/core_service/test/fuzztest/common_fuzzer/addcoreservicetoken_fuzzer.cpp", "addiccdiallingnumbers_fuzzer.cpp", ] } diff --git a/test/fuzztest/addiccdiallingnumbers_fuzzer/addiccdiallingnumbers_fuzzer.cpp b/test/fuzztest/addiccdiallingnumbers_fuzzer/addiccdiallingnumbers_fuzzer.cpp index ae477d66..419622b6 100644 --- a/test/fuzztest/addiccdiallingnumbers_fuzzer/addiccdiallingnumbers_fuzzer.cpp +++ b/test/fuzztest/addiccdiallingnumbers_fuzzer/addiccdiallingnumbers_fuzzer.cpp @@ -39,6 +39,7 @@ bool IsServiceInited() if (!g_isInited) { auto onStart = [] { DelayedSingleton::GetInstance()->OnStart(); }; std::thread startThread(onStart); + pthread_setname_np(startThread.native_handle(), "addiccdiallingnumbers_fuzzer"); startThread.join(); sleep(SLEEP_TIME_SECONDS); diff --git a/test/fuzztest/getsimeons_fuzzer/BUILD.gn b/test/fuzztest/getsimeons_fuzzer/BUILD.gn index b7376c72..7fad7ccf 100644 --- a/test/fuzztest/getsimeons_fuzzer/BUILD.gn +++ b/test/fuzztest/getsimeons_fuzzer/BUILD.gn @@ -12,7 +12,7 @@ # limitations under the License. #####################hydra-fuzz################### -import("//base/telephony/core_service/telephony.gni") +SUBSYSTEM_DIR = "../../../.." import("//build/config/features.gni") import("//build/ohos.gni") import("//build/test.gni") @@ -22,24 +22,23 @@ ohos_fuzztest("GetSimEonsFuzzTest") { module_output_path = "core_service/GetSimEonsFuzzTest" module_out_path = module_output_path fuzz_config_file = - "//base/telephony/core_service/test/fuzztest/getsimeons_fuzzer" + "$SUBSYSTEM_DIR/core_service/test/fuzztest/getsimeons_fuzzer" include_dirs = [ - "//base/telephony/core_service/frameworks/js/napi/include", - "//base/telephony/core_service/frameworks/js/napi", - "//base/telephony/core_service/services/core/include", - "//base/telephony/core_service/services/network_search/include", - "//base/telephony/core_service/services/sim/include", - "//base/telephony/core_service/test/fuzztest/common_fuzzer", - "//base/telephony/core_service/services/tel_ril/include", + "$SUBSYSTEM_DIR/core_service/frameworks/js/napi/include", + "$SUBSYSTEM_DIR/core_service/frameworks/js/napi", + "$SUBSYSTEM_DIR/core_service/services/core/include", + "$SUBSYSTEM_DIR/core_service/services/network_search/include", + "$SUBSYSTEM_DIR/core_service/services/sim/include", + "$SUBSYSTEM_DIR/core_service/test/fuzztest/common_fuzzer", + "$SUBSYSTEM_DIR/core_service/services/tel_ril/include", ] - configs = [ "//base/telephony/core_service/utils:telephony_log_config" ] + configs = [ "$SUBSYSTEM_DIR/core_service/utils:telephony_log_config" ] deps = [ - "//base/telephony/core_service:tel_core_service", - "//base/telephony/core_service/interfaces/innerkits:tel_core_service_api", - "//foundation/arkui/napi:ace_napi", + "$SUBSYSTEM_DIR/core_service:tel_core_service", + "$SUBSYSTEM_DIR/core_service/interfaces/innerkits:tel_core_service_api", ] external_deps = [ @@ -54,13 +53,14 @@ ohos_fuzztest("GetSimEonsFuzzTest") { "hdf_core:libhdi", "init:libbegetutil", "ipc:ipc_core", + "napi:ace_napi", "netmanager_base:net_conn_manager_if", "netmanager_ext:net_tether_manager_if", "power_manager:powermgr_client", "relational_store:native_rdb", "samgr:samgr_proxy", ] - defines += [ + defines = [ "TELEPHONY_LOG_TAG = \"CoreServiceFuzzTest\"", "LOG_DOMAIN = 0xD000F00", ] @@ -77,8 +77,8 @@ ohos_fuzztest("GetSimEonsFuzzTest") { "-fno-omit-frame-pointer", ] sources = [ - "//base/telephony/core_service/frameworks/js/napi/napi_util.cpp", - "//base/telephony/core_service/test/fuzztest/common_fuzzer/addcoreservicetoken_fuzzer.cpp", + "$SUBSYSTEM_DIR/core_service/frameworks/js/napi/napi_util.cpp", + "$SUBSYSTEM_DIR/core_service/test/fuzztest/common_fuzzer/addcoreservicetoken_fuzzer.cpp", "getsimeons_fuzzer.cpp", ] } diff --git a/test/fuzztest/getsimeons_fuzzer/getsimeons_fuzzer.cpp b/test/fuzztest/getsimeons_fuzzer/getsimeons_fuzzer.cpp index 55cbdbb3..88e9e802 100644 --- a/test/fuzztest/getsimeons_fuzzer/getsimeons_fuzzer.cpp +++ b/test/fuzztest/getsimeons_fuzzer/getsimeons_fuzzer.cpp @@ -39,6 +39,7 @@ bool IsServiceInited() if (!g_isInited) { auto onStart = [] { DelayedSingleton::GetInstance()->OnStart(); }; std::thread startThread(onStart); + pthread_setname_np(startThread.native_handle(), "getsimeons_fuzzer"); startThread.join(); sleep(SLEEP_TIME_SECONDS); diff --git a/test/fuzztest/hexvectohexstr_fuzzer/BUILD.gn b/test/fuzztest/hexvectohexstr_fuzzer/BUILD.gn index 8f64d5fc..5a7feee0 100644 --- a/test/fuzztest/hexvectohexstr_fuzzer/BUILD.gn +++ b/test/fuzztest/hexvectohexstr_fuzzer/BUILD.gn @@ -12,7 +12,7 @@ # limitations under the License. #####################hydra-fuzz################### -import("//base/telephony/core_service/telephony.gni") +SUBSYSTEM_DIR = "../../../.." import("//build/config/features.gni") import("//build/ohos.gni") import("//build/test.gni") @@ -22,24 +22,23 @@ ohos_fuzztest("HexVecToHexStrFuzzTest") { module_output_path = "core_service/HexVecToHexStrFuzzTest" module_out_path = module_output_path fuzz_config_file = - "//base/telephony/core_service/test/fuzztest/hexvectohexstr_fuzzer" + "$SUBSYSTEM_DIR/core_service/test/fuzztest/hexvectohexstr_fuzzer" include_dirs = [ - "//base/telephony/core_service/frameworks/js/napi/include", - "//base/telephony/core_service/frameworks/js/napi", - "//base/telephony/core_service/services/core/include", - "//base/telephony/core_service/services/network_search/include", - "//base/telephony/core_service/services/sim/include", - "//base/telephony/core_service/test/fuzztest/common_fuzzer", - "//base/telephony/core_service/services/tel_ril/include", + "$SUBSYSTEM_DIR/core_service/frameworks/js/napi/include", + "$SUBSYSTEM_DIR/core_service/frameworks/js/napi", + "$SUBSYSTEM_DIR/core_service/services/core/include", + "$SUBSYSTEM_DIR/core_service/services/network_search/include", + "$SUBSYSTEM_DIR/core_service/services/sim/include", + "$SUBSYSTEM_DIR/core_service/test/fuzztest/common_fuzzer", + "$SUBSYSTEM_DIR/core_service/services/tel_ril/include", ] - configs = [ "//base/telephony/core_service/utils:telephony_log_config" ] + configs = [ "$SUBSYSTEM_DIR/core_service/utils:telephony_log_config" ] deps = [ - "//base/telephony/core_service:tel_core_service", - "//base/telephony/core_service/interfaces/innerkits:tel_core_service_api", - "//foundation/arkui/napi:ace_napi", + "$SUBSYSTEM_DIR/core_service:tel_core_service", + "$SUBSYSTEM_DIR/core_service/interfaces/innerkits:tel_core_service_api", ] external_deps = [ @@ -53,13 +52,14 @@ ohos_fuzztest("HexVecToHexStrFuzzTest") { "drivers_interface_ril:ril_idl_headers", "init:libbegetutil", "ipc:ipc_core", + "napi:ace_napi", "netmanager_base:net_conn_manager_if", "netmanager_ext:net_tether_manager_if", "power_manager:powermgr_client", "relational_store:native_rdb", "samgr:samgr_proxy", ] - defines += [ + defines = [ "TELEPHONY_LOG_TAG = \"CoreServiceFuzzTest\"", "LOG_DOMAIN = 0xD000F00", ] @@ -76,8 +76,8 @@ ohos_fuzztest("HexVecToHexStrFuzzTest") { "-fno-omit-frame-pointer", ] sources = [ - "//base/telephony/core_service/frameworks/js/napi/napi_util.cpp", - "//base/telephony/core_service/test/fuzztest/common_fuzzer/addcoreservicetoken_fuzzer.cpp", + "$SUBSYSTEM_DIR/core_service/frameworks/js/napi/napi_util.cpp", + "$SUBSYSTEM_DIR/core_service/test/fuzztest/common_fuzzer/addcoreservicetoken_fuzzer.cpp", "hexvectohexstr_fuzzer.cpp", ] } diff --git a/test/fuzztest/isshowableasciionly_fuzzer/BUILD.gn b/test/fuzztest/isshowableasciionly_fuzzer/BUILD.gn index c56ebd51..fb76f421 100644 --- a/test/fuzztest/isshowableasciionly_fuzzer/BUILD.gn +++ b/test/fuzztest/isshowableasciionly_fuzzer/BUILD.gn @@ -12,7 +12,7 @@ # limitations under the License. #####################hydra-fuzz################### -import("//base/telephony/core_service/telephony.gni") +SUBSYSTEM_DIR = "../../../.." import("//build/config/features.gni") import("//build/ohos.gni") import("//build/test.gni") @@ -22,24 +22,23 @@ ohos_fuzztest("IsShowableAsciiOnlyFuzzTest") { module_output_path = "core_service/IsShowableAsciiOnlyFuzzTest" module_out_path = module_output_path fuzz_config_file = - "//base/telephony/core_service/test/fuzztest/isshowableasciionly_fuzzer" + "$SUBSYSTEM_DIR/core_service/test/fuzztest/isshowableasciionly_fuzzer" include_dirs = [ - "//base/telephony/core_service/frameworks/js/napi/include", - "//base/telephony/core_service/frameworks/js/napi", - "//base/telephony/core_service/services/core/include", - "//base/telephony/core_service/services/network_search/include", - "//base/telephony/core_service/services/sim/include", - "//base/telephony/core_service/test/fuzztest/common_fuzzer", - "//base/telephony/core_service/services/tel_ril/include", + "$SUBSYSTEM_DIR/core_service/frameworks/js/napi/include", + "$SUBSYSTEM_DIR/core_service/frameworks/js/napi", + "$SUBSYSTEM_DIR/core_service/services/core/include", + "$SUBSYSTEM_DIR/core_service/services/network_search/include", + "$SUBSYSTEM_DIR/core_service/services/sim/include", + "$SUBSYSTEM_DIR/core_service/test/fuzztest/common_fuzzer", + "$SUBSYSTEM_DIR/core_service/services/tel_ril/include", ] - configs = [ "//base/telephony/core_service/utils:telephony_log_config" ] + configs = [ "$SUBSYSTEM_DIR/core_service/utils:telephony_log_config" ] deps = [ - "//base/telephony/core_service:tel_core_service", - "//base/telephony/core_service/interfaces/innerkits:tel_core_service_api", - "//foundation/arkui/napi:ace_napi", + "$SUBSYSTEM_DIR/core_service:tel_core_service", + "$SUBSYSTEM_DIR/core_service/interfaces/innerkits:tel_core_service_api", ] external_deps = [ @@ -53,13 +52,14 @@ ohos_fuzztest("IsShowableAsciiOnlyFuzzTest") { "drivers_interface_ril:ril_idl_headers", "init:libbegetutil", "ipc:ipc_core", + "napi:ace_napi", "netmanager_base:net_conn_manager_if", "netmanager_ext:net_tether_manager_if", "power_manager:powermgr_client", "relational_store:native_rdb", "samgr:samgr_proxy", ] - defines += [ + defines = [ "TELEPHONY_LOG_TAG = \"CoreServiceFuzzTest\"", "LOG_DOMAIN = 0xD000F00", ] @@ -76,8 +76,8 @@ ohos_fuzztest("IsShowableAsciiOnlyFuzzTest") { "-fno-omit-frame-pointer", ] sources = [ - "//base/telephony/core_service/frameworks/js/napi/napi_util.cpp", - "//base/telephony/core_service/test/fuzztest/common_fuzzer/addcoreservicetoken_fuzzer.cpp", + "$SUBSYSTEM_DIR/core_service/frameworks/js/napi/napi_util.cpp", + "$SUBSYSTEM_DIR/core_service/test/fuzztest/common_fuzzer/addcoreservicetoken_fuzzer.cpp", "isshowableasciionly_fuzzer.cpp", ] } diff --git a/test/fuzztest/isvalidnumberstring_fuzzer/BUILD.gn b/test/fuzztest/isvalidnumberstring_fuzzer/BUILD.gn index 03270519..03885f00 100644 --- a/test/fuzztest/isvalidnumberstring_fuzzer/BUILD.gn +++ b/test/fuzztest/isvalidnumberstring_fuzzer/BUILD.gn @@ -12,7 +12,7 @@ # limitations under the License. #####################hydra-fuzz################### -import("//base/telephony/core_service/telephony.gni") +SUBSYSTEM_DIR = "../../../.." import("//build/config/features.gni") import("//build/ohos.gni") import("//build/test.gni") @@ -22,24 +22,23 @@ ohos_fuzztest("IsValidNumberStringFuzzTest") { module_output_path = "core_service/IsValidNumberStringFuzzTest" module_out_path = module_output_path fuzz_config_file = - "//base/telephony/core_service/test/fuzztest/isvalidnumberstring_fuzzer" + "$SUBSYSTEM_DIR/core_service/test/fuzztest/isvalidnumberstring_fuzzer" include_dirs = [ - "//base/telephony/core_service/frameworks/js/napi/include", - "//base/telephony/core_service/frameworks/js/napi", - "//base/telephony/core_service/services/core/include", - "//base/telephony/core_service/services/network_search/include", - "//base/telephony/core_service/services/sim/include", - "//base/telephony/core_service/test/fuzztest/common_fuzzer", - "//base/telephony/core_service/services/tel_ril/include", + "$SUBSYSTEM_DIR/core_service/frameworks/js/napi/include", + "$SUBSYSTEM_DIR/core_service/frameworks/js/napi", + "$SUBSYSTEM_DIR/core_service/services/core/include", + "$SUBSYSTEM_DIR/core_service/services/network_search/include", + "$SUBSYSTEM_DIR/core_service/services/sim/include", + "$SUBSYSTEM_DIR/core_service/test/fuzztest/common_fuzzer", + "$SUBSYSTEM_DIR/core_service/services/tel_ril/include", ] - configs = [ "//base/telephony/core_service/utils:telephony_log_config" ] + configs = [ "$SUBSYSTEM_DIR/core_service/utils:telephony_log_config" ] deps = [ - "//base/telephony/core_service:tel_core_service", - "//base/telephony/core_service/interfaces/innerkits:tel_core_service_api", - "//foundation/arkui/napi:ace_napi", + "$SUBSYSTEM_DIR/core_service:tel_core_service", + "$SUBSYSTEM_DIR/core_service/interfaces/innerkits:tel_core_service_api", ] external_deps = [ @@ -53,13 +52,14 @@ ohos_fuzztest("IsValidNumberStringFuzzTest") { "drivers_interface_ril:ril_idl_headers", "init:libbegetutil", "ipc:ipc_core", + "napi:ace_napi", "netmanager_base:net_conn_manager_if", "netmanager_ext:net_tether_manager_if", "power_manager:powermgr_client", "relational_store:native_rdb", "samgr:samgr_proxy", ] - defines += [ + defines = [ "TELEPHONY_LOG_TAG = \"CoreServiceFuzzTest\"", "LOG_DOMAIN = 0xD000F00", ] @@ -76,8 +76,8 @@ ohos_fuzztest("IsValidNumberStringFuzzTest") { "-fno-omit-frame-pointer", ] sources = [ - "//base/telephony/core_service/frameworks/js/napi/napi_util.cpp", - "//base/telephony/core_service/test/fuzztest/common_fuzzer/addcoreservicetoken_fuzzer.cpp", + "$SUBSYSTEM_DIR/core_service/frameworks/js/napi/napi_util.cpp", + "$SUBSYSTEM_DIR/core_service/test/fuzztest/common_fuzzer/addcoreservicetoken_fuzzer.cpp", "isvalidnumberstring_fuzzer.cpp", ] } diff --git a/test/fuzztest/sendenvelopecmd_fuzzer/BUILD.gn b/test/fuzztest/sendenvelopecmd_fuzzer/BUILD.gn index be0ff921..05fe4c9e 100644 --- a/test/fuzztest/sendenvelopecmd_fuzzer/BUILD.gn +++ b/test/fuzztest/sendenvelopecmd_fuzzer/BUILD.gn @@ -12,7 +12,7 @@ # limitations under the License. #####################hydra-fuzz################### -import("//base/telephony/core_service/telephony.gni") +SUBSYSTEM_DIR = "../../../.." import("//build/config/features.gni") import("//build/ohos.gni") import("//build/test.gni") @@ -22,24 +22,23 @@ ohos_fuzztest("SendEnvelopeCmdFuzzTest") { module_output_path = "core_service/SendEnvelopeCmdFuzzTest" module_out_path = module_output_path fuzz_config_file = - "//base/telephony/core_service/test/fuzztest/sendenvelopecmd_fuzzer" + "$SUBSYSTEM_DIR/core_service/test/fuzztest/sendenvelopecmd_fuzzer" include_dirs = [ - "//base/telephony/core_service/frameworks/js/napi/include", - "//base/telephony/core_service/frameworks/js/napi", - "//base/telephony/core_service/services/core/include", - "//base/telephony/core_service/services/network_search/include", - "//base/telephony/core_service/services/sim/include", - "//base/telephony/core_service/test/fuzztest/common_fuzzer", - "//base/telephony/core_service/services/tel_ril/include", + "$SUBSYSTEM_DIR/core_service/frameworks/js/napi/include", + "$SUBSYSTEM_DIR/core_service/frameworks/js/napi", + "$SUBSYSTEM_DIR/core_service/services/core/include", + "$SUBSYSTEM_DIR/core_service/services/network_search/include", + "$SUBSYSTEM_DIR/core_service/services/sim/include", + "$SUBSYSTEM_DIR/core_service/test/fuzztest/common_fuzzer", + "$SUBSYSTEM_DIR/core_service/services/tel_ril/include", ] - configs = [ "//base/telephony/core_service/utils:telephony_log_config" ] + configs = [ "$SUBSYSTEM_DIR/core_service/utils:telephony_log_config" ] deps = [ - "//base/telephony/core_service:tel_core_service", - "//base/telephony/core_service/interfaces/innerkits:tel_core_service_api", - "//foundation/arkui/napi:ace_napi", + "$SUBSYSTEM_DIR/core_service:tel_core_service", + "$SUBSYSTEM_DIR/core_service/interfaces/innerkits:tel_core_service_api", ] external_deps = [ @@ -54,13 +53,14 @@ ohos_fuzztest("SendEnvelopeCmdFuzzTest") { "hdf_core:libhdi", "init:libbegetutil", "ipc:ipc_core", + "napi:ace_napi", "netmanager_base:net_conn_manager_if", "netmanager_ext:net_tether_manager_if", "power_manager:powermgr_client", "relational_store:native_rdb", "samgr:samgr_proxy", ] - defines += [ + defines = [ "TELEPHONY_LOG_TAG = \"CoreServiceFuzzTest\"", "LOG_DOMAIN = 0xD000F00", ] @@ -77,8 +77,8 @@ ohos_fuzztest("SendEnvelopeCmdFuzzTest") { "-fno-omit-frame-pointer", ] sources = [ - "//base/telephony/core_service/frameworks/js/napi/napi_util.cpp", - "//base/telephony/core_service/test/fuzztest/common_fuzzer/addcoreservicetoken_fuzzer.cpp", + "$SUBSYSTEM_DIR/core_service/frameworks/js/napi/napi_util.cpp", + "$SUBSYSTEM_DIR/core_service/test/fuzztest/common_fuzzer/addcoreservicetoken_fuzzer.cpp", "sendenvelopecmd_fuzzer.cpp", ] } diff --git a/test/fuzztest/sendenvelopecmd_fuzzer/sendenvelopecmd_fuzzer.cpp b/test/fuzztest/sendenvelopecmd_fuzzer/sendenvelopecmd_fuzzer.cpp index efa2b227..fb8313bb 100644 --- a/test/fuzztest/sendenvelopecmd_fuzzer/sendenvelopecmd_fuzzer.cpp +++ b/test/fuzztest/sendenvelopecmd_fuzzer/sendenvelopecmd_fuzzer.cpp @@ -38,6 +38,7 @@ bool IsServiceInited() if (!g_isInited) { auto onStart = [] { DelayedSingleton::GetInstance()->OnStart(); }; std::thread startThread(onStart); + pthread_setname_np(startThread.native_handle(), "sendenvelopecmd_fuzzer"); startThread.join(); sleep(SLEEP_TIME_SECONDS); diff --git a/test/fuzztest/sendsmsmoremode_fuzzer/BUILD.gn b/test/fuzztest/sendsmsmoremode_fuzzer/BUILD.gn index 6f3f2cf0..7901f845 100644 --- a/test/fuzztest/sendsmsmoremode_fuzzer/BUILD.gn +++ b/test/fuzztest/sendsmsmoremode_fuzzer/BUILD.gn @@ -12,7 +12,7 @@ # limitations under the License. #####################hydra-fuzz################### -import("//base/telephony/core_service/telephony.gni") +SUBSYSTEM_DIR = "../../../.." import("//build/config/features.gni") import("//build/ohos.gni") import("//build/test.gni") @@ -22,24 +22,23 @@ ohos_fuzztest("SendSmsMoreModeFuzzTest") { module_output_path = "core_service/SendSmsMoreModeFuzzTest" module_out_path = module_output_path fuzz_config_file = - "//base/telephony/core_service/test/fuzztest/sendsmsmoremode_fuzzer" + "$SUBSYSTEM_DIR/core_service/test/fuzztest/sendsmsmoremode_fuzzer" include_dirs = [ - "//base/telephony/core_service/frameworks/js/napi/include", - "//base/telephony/core_service/frameworks/js/napi", - "//base/telephony/core_service/services/core/include", - "//base/telephony/core_service/services/network_search/include", - "//base/telephony/core_service/services/sim/include", - "//base/telephony/core_service/test/fuzztest/common_fuzzer", - "//base/telephony/core_service/services/tel_ril/include", + "$SUBSYSTEM_DIR/core_service/frameworks/js/napi/include", + "$SUBSYSTEM_DIR/core_service/frameworks/js/napi", + "$SUBSYSTEM_DIR/core_service/services/core/include", + "$SUBSYSTEM_DIR/core_service/services/network_search/include", + "$SUBSYSTEM_DIR/core_service/services/sim/include", + "$SUBSYSTEM_DIR/core_service/test/fuzztest/common_fuzzer", + "$SUBSYSTEM_DIR/core_service/services/tel_ril/include", ] - configs = [ "//base/telephony/core_service/utils:telephony_log_config" ] + configs = [ "$SUBSYSTEM_DIR/core_service/utils:telephony_log_config" ] deps = [ - "//base/telephony/core_service:tel_core_service", - "//base/telephony/core_service/interfaces/innerkits:tel_core_service_api", - "//foundation/arkui/napi:ace_napi", + "$SUBSYSTEM_DIR/core_service:tel_core_service", + "$SUBSYSTEM_DIR/core_service/interfaces/innerkits:tel_core_service_api", ] external_deps = [ @@ -64,6 +63,7 @@ ohos_fuzztest("SendSmsMoreModeFuzzTest") { "i18n:zone_util", "init:libbegetutil", "ipc:ipc_core", + "napi:ace_napi", "netmanager_base:net_conn_manager_if", "netmanager_ext:net_tether_manager_if", "power_manager:powermgr_client", @@ -72,7 +72,7 @@ ohos_fuzztest("SendSmsMoreModeFuzzTest") { "safwk:system_ability_fwk", "samgr:samgr_proxy", ] - defines += [ + defines = [ "TELEPHONY_LOG_TAG = \"CoreServiceFuzzTest\"", "LOG_DOMAIN = 0xD000F00", ] @@ -89,8 +89,8 @@ ohos_fuzztest("SendSmsMoreModeFuzzTest") { "-fno-omit-frame-pointer", ] sources = [ - "//base/telephony/core_service/frameworks/js/napi/napi_util.cpp", - "//base/telephony/core_service/test/fuzztest/common_fuzzer/addcoreservicetoken_fuzzer.cpp", + "$SUBSYSTEM_DIR/core_service/frameworks/js/napi/napi_util.cpp", + "$SUBSYSTEM_DIR/core_service/test/fuzztest/common_fuzzer/addcoreservicetoken_fuzzer.cpp", "sendsmsmoremode_fuzzer.cpp", ] } diff --git a/test/fuzztest/sendterminalresponsecmd_fuzzer/BUILD.gn b/test/fuzztest/sendterminalresponsecmd_fuzzer/BUILD.gn index 118878c7..9254b10a 100644 --- a/test/fuzztest/sendterminalresponsecmd_fuzzer/BUILD.gn +++ b/test/fuzztest/sendterminalresponsecmd_fuzzer/BUILD.gn @@ -12,7 +12,7 @@ # limitations under the License. #####################hydra-fuzz################### -import("//base/telephony/core_service/telephony.gni") +SUBSYSTEM_DIR = "../../../.." import("//build/config/features.gni") import("//build/ohos.gni") import("//build/test.gni") @@ -21,23 +21,23 @@ import("//build/test.gni") ohos_fuzztest("SendTerminalResponseCmdFuzzTest") { module_output_path = "core_service/SendTerminalResponseCmdFuzzTest" module_out_path = module_output_path - fuzz_config_file = "//base/telephony/core_service/test/fuzztest/sendterminalresponsecmd_fuzzer" + fuzz_config_file = + "$SUBSYSTEM_DIR/core_service/test/fuzztest/sendterminalresponsecmd_fuzzer" include_dirs = [ - "//base/telephony/core_service/frameworks/js/napi/include", - "//base/telephony/core_service/frameworks/js/napi", - "//base/telephony/core_service/services/sim/include", - "//base/telephony/core_service/services/core/include", - "//base/telephony/core_service/services/tel_ril/include", - "//base/telephony/core_service/test/fuzztest/common_fuzzer", + "$SUBSYSTEM_DIR/core_service/frameworks/js/napi/include", + "$SUBSYSTEM_DIR/core_service/frameworks/js/napi", + "$SUBSYSTEM_DIR/core_service/services/sim/include", + "$SUBSYSTEM_DIR/core_service/services/core/include", + "$SUBSYSTEM_DIR/core_service/services/tel_ril/include", + "$SUBSYSTEM_DIR/core_service/test/fuzztest/common_fuzzer", ] - configs = [ "//base/telephony/core_service/utils:telephony_log_config" ] + configs = [ "$SUBSYSTEM_DIR/core_service/utils:telephony_log_config" ] deps = [ - "//base/telephony/core_service:tel_core_service", - "//base/telephony/core_service/interfaces/innerkits:tel_core_service_api", - "//foundation/arkui/napi:ace_napi", + "$SUBSYSTEM_DIR/core_service:tel_core_service", + "$SUBSYSTEM_DIR/core_service/interfaces/innerkits:tel_core_service_api", ] external_deps = [ @@ -62,6 +62,7 @@ ohos_fuzztest("SendTerminalResponseCmdFuzzTest") { "i18n:zone_util", "init:libbegetutil", "ipc:ipc_core", + "napi:ace_napi", "netmanager_base:net_conn_manager_if", "netmanager_ext:net_tether_manager_if", "power_manager:powermgr_client", @@ -70,7 +71,7 @@ ohos_fuzztest("SendTerminalResponseCmdFuzzTest") { "safwk:system_ability_fwk", "samgr:samgr_proxy", ] - defines += [ + defines = [ "TELEPHONY_LOG_TAG = \"CoreServiceFuzzTest\"", "LOG_DOMAIN = 0xD000F00", ] @@ -87,8 +88,8 @@ ohos_fuzztest("SendTerminalResponseCmdFuzzTest") { "-fno-omit-frame-pointer", ] sources = [ - "//base/telephony/core_service/frameworks/js/napi/napi_util.cpp", - "//base/telephony/core_service/test/fuzztest/common_fuzzer/addcoreservicetoken_fuzzer.cpp", + "$SUBSYSTEM_DIR/core_service/frameworks/js/napi/napi_util.cpp", + "$SUBSYSTEM_DIR/core_service/test/fuzztest/common_fuzzer/addcoreservicetoken_fuzzer.cpp", "sendterminalresponsecmd_fuzzer.cpp", ] } diff --git a/test/fuzztest/sendterminalresponsecmd_fuzzer/sendterminalresponsecmd_fuzzer.cpp b/test/fuzztest/sendterminalresponsecmd_fuzzer/sendterminalresponsecmd_fuzzer.cpp index 6e3f6f42..a4192a19 100644 --- a/test/fuzztest/sendterminalresponsecmd_fuzzer/sendterminalresponsecmd_fuzzer.cpp +++ b/test/fuzztest/sendterminalresponsecmd_fuzzer/sendterminalresponsecmd_fuzzer.cpp @@ -37,6 +37,7 @@ bool IsServiceInited() if (!g_isInited) { auto onStart = [] { DelayedSingleton::GetInstance()->OnStart(); }; std::thread startThread(onStart); + pthread_setname_np(startThread.native_handle(), "sendterminalresponsecmd_fuzzer"); startThread.join(); sleep(SLEEP_TIME_SECONDS); diff --git a/test/fuzztest/setaccesslimit_fuzzer/BUILD.gn b/test/fuzztest/setaccesslimit_fuzzer/BUILD.gn index f7f008dd..ee7758bf 100644 --- a/test/fuzztest/setaccesslimit_fuzzer/BUILD.gn +++ b/test/fuzztest/setaccesslimit_fuzzer/BUILD.gn @@ -12,7 +12,7 @@ # limitations under the License. #####################hydra-fuzz################### -import("//base/telephony/core_service/telephony.gni") +SUBSYSTEM_DIR = "../../../.." import("//build/config/features.gni") import("//build/ohos.gni") import("//build/test.gni") @@ -22,24 +22,23 @@ ohos_fuzztest("SetAccessLimitFuzzTest") { module_output_path = "core_service/SetAccessLimitFuzzTest" module_out_path = module_output_path fuzz_config_file = - "//base/telephony/core_service/test/fuzztest/setaccesslimit_fuzzer" + "$SUBSYSTEM_DIR/core_service/test/fuzztest/setaccesslimit_fuzzer" include_dirs = [ - "//base/telephony/core_service/frameworks/js/napi/include", - "//base/telephony/core_service/frameworks/js/napi", - "//base/telephony/core_service/services/core/include", - "//base/telephony/core_service/services/network_search/include", - "//base/telephony/core_service/services/sim/include", - "//base/telephony/core_service/test/fuzztest/common_fuzzer", - "//base/telephony/core_service/services/tel_ril/include", + "$SUBSYSTEM_DIR/core_service/frameworks/js/napi/include", + "$SUBSYSTEM_DIR/core_service/frameworks/js/napi", + "$SUBSYSTEM_DIR/core_service/services/core/include", + "$SUBSYSTEM_DIR/core_service/services/network_search/include", + "$SUBSYSTEM_DIR/core_service/services/sim/include", + "$SUBSYSTEM_DIR/core_service/test/fuzztest/common_fuzzer", + "$SUBSYSTEM_DIR/core_service/services/tel_ril/include", ] - configs = [ "//base/telephony/core_service/utils:telephony_log_config" ] + configs = [ "$SUBSYSTEM_DIR/core_service/utils:telephony_log_config" ] deps = [ - "//base/telephony/core_service:tel_core_service", - "//base/telephony/core_service/interfaces/innerkits:tel_core_service_api", - "//foundation/arkui/napi:ace_napi", + "$SUBSYSTEM_DIR/core_service:tel_core_service", + "$SUBSYSTEM_DIR/core_service/interfaces/innerkits:tel_core_service_api", ] external_deps = [ @@ -53,13 +52,14 @@ ohos_fuzztest("SetAccessLimitFuzzTest") { "drivers_interface_ril:ril_idl_headers", "init:libbegetutil", "ipc:ipc_core", + "napi:ace_napi", "netmanager_base:net_conn_manager_if", "netmanager_ext:net_tether_manager_if", "power_manager:powermgr_client", "relational_store:native_rdb", "samgr:samgr_proxy", ] - defines += [ + defines = [ "TELEPHONY_LOG_TAG = \"CoreServiceFuzzTest\"", "LOG_DOMAIN = 0xD000F00", ] @@ -76,8 +76,8 @@ ohos_fuzztest("SetAccessLimitFuzzTest") { "-fno-omit-frame-pointer", ] sources = [ - "//base/telephony/core_service/frameworks/js/napi/napi_util.cpp", - "//base/telephony/core_service/test/fuzztest/common_fuzzer/addcoreservicetoken_fuzzer.cpp", + "$SUBSYSTEM_DIR/core_service/frameworks/js/napi/napi_util.cpp", + "$SUBSYSTEM_DIR/core_service/test/fuzztest/common_fuzzer/addcoreservicetoken_fuzzer.cpp", "setaccesslimit_fuzzer.cpp", ] } diff --git a/test/fuzztest/setshowname_fuzzer/BUILD.gn b/test/fuzztest/setshowname_fuzzer/BUILD.gn index 7a49a76b..4c317aec 100644 --- a/test/fuzztest/setshowname_fuzzer/BUILD.gn +++ b/test/fuzztest/setshowname_fuzzer/BUILD.gn @@ -12,7 +12,7 @@ # limitations under the License. #####################hydra-fuzz################### -import("//base/telephony/core_service/telephony.gni") +SUBSYSTEM_DIR = "../../../.." import("//build/config/features.gni") import("//build/ohos.gni") import("//build/test.gni") @@ -22,25 +22,24 @@ ohos_fuzztest("SetShowNameFuzzTest") { module_output_path = "core_service/SetShowNameFuzzTest" module_out_path = module_output_path fuzz_config_file = - "//base/telephony/core_service/test/fuzztest/setshowname_fuzzer" + "$SUBSYSTEM_DIR/core_service/test/fuzztest/setshowname_fuzzer" include_dirs = [ - "//base/telephony/core_service/frameworks/js/napi/include", - "//base/telephony/core_service/frameworks/js/napi", - "//base/telephony/core_service/services/core/include", - "//base/telephony/core_service/services/network_search/include", - "//base/telephony/core_service/services/sim/include", - "//base/telephony/core_service/test/fuzztest/common_fuzzer", - "//base/telephony/core_service/services/tel_ril/include", + "$SUBSYSTEM_DIR/core_service/frameworks/js/napi/include", + "$SUBSYSTEM_DIR/core_service/frameworks/js/napi", + "$SUBSYSTEM_DIR/core_service/services/core/include", + "$SUBSYSTEM_DIR/core_service/services/network_search/include", + "$SUBSYSTEM_DIR/core_service/services/sim/include", + "$SUBSYSTEM_DIR/core_service/test/fuzztest/common_fuzzer", + "$SUBSYSTEM_DIR/core_service/services/tel_ril/include", "commonlibrary/c_utils/base/include", ] - configs = [ "//base/telephony/core_service/utils:telephony_log_config" ] + configs = [ "$SUBSYSTEM_DIR/core_service/utils:telephony_log_config" ] deps = [ - "//base/telephony/core_service:tel_core_service", - "//base/telephony/core_service/interfaces/innerkits:tel_core_service_api", - "//foundation/arkui/napi:ace_napi", + "$SUBSYSTEM_DIR/core_service:tel_core_service", + "$SUBSYSTEM_DIR/core_service/interfaces/innerkits:tel_core_service_api", ] external_deps = [ @@ -55,13 +54,14 @@ ohos_fuzztest("SetShowNameFuzzTest") { "hdf_core:libhdi", "init:libbegetutil", "ipc:ipc_core", + "napi:ace_napi", "netmanager_base:net_conn_manager_if", "netmanager_ext:net_tether_manager_if", "power_manager:powermgr_client", "relational_store:native_rdb", "samgr:samgr_proxy", ] - defines += [ + defines = [ "TELEPHONY_LOG_TAG = \"CoreServiceFuzzTest\"", "LOG_DOMAIN = 0xD000F00", ] @@ -78,8 +78,8 @@ ohos_fuzztest("SetShowNameFuzzTest") { "-fno-omit-frame-pointer", ] sources = [ - "//base/telephony/core_service/frameworks/js/napi/napi_util.cpp", - "//base/telephony/core_service/test/fuzztest/common_fuzzer/addcoreservicetoken_fuzzer.cpp", + "$SUBSYSTEM_DIR/core_service/frameworks/js/napi/napi_util.cpp", + "$SUBSYSTEM_DIR/core_service/test/fuzztest/common_fuzzer/addcoreservicetoken_fuzzer.cpp", "setshowname_fuzzer.cpp", ] } diff --git a/test/fuzztest/setshowname_fuzzer/setshowname_fuzzer.cpp b/test/fuzztest/setshowname_fuzzer/setshowname_fuzzer.cpp index dc14ee74..67731453 100644 --- a/test/fuzztest/setshowname_fuzzer/setshowname_fuzzer.cpp +++ b/test/fuzztest/setshowname_fuzzer/setshowname_fuzzer.cpp @@ -39,6 +39,7 @@ bool IsServiceInited() if (!g_isInited) { auto onStart = [] { DelayedSingleton::GetInstance()->OnStart(); }; std::thread startThread(onStart); + pthread_setname_np(startThread.native_handle(), "setshowname_fuzzer"); startThread.join(); sleep(SLEEP_TIME_SECONDS); diff --git a/test/fuzztest/setshownumber_fuzzer/BUILD.gn b/test/fuzztest/setshownumber_fuzzer/BUILD.gn index d810cdd0..32fdd0bd 100644 --- a/test/fuzztest/setshownumber_fuzzer/BUILD.gn +++ b/test/fuzztest/setshownumber_fuzzer/BUILD.gn @@ -12,7 +12,7 @@ # limitations under the License. #####################hydra-fuzz################### -import("//base/telephony/core_service/telephony.gni") +SUBSYSTEM_DIR = "../../../.." import("//build/config/features.gni") import("//build/ohos.gni") import("//build/test.gni") @@ -22,23 +22,22 @@ ohos_fuzztest("SetShowNumberFuzzTest") { module_output_path = "core_service/SetShowNumberFuzzTest" module_out_path = module_output_path fuzz_config_file = - "//base/telephony/core_service/test/fuzztest/setshownumber_fuzzer" + "$SUBSYSTEM_DIR/core_service/test/fuzztest/setshownumber_fuzzer" include_dirs = [ - "//base/telephony/core_service/frameworks/js/napi/include", - "//base/telephony/core_service/frameworks/js/napi", - "//base/telephony/core_service/services/sim/include", - "//base/telephony/core_service/services/core/include", - "//base/telephony/core_service/services/tel_ril/include", - "//base/telephony/core_service/test/fuzztest/common_fuzzer", + "$SUBSYSTEM_DIR/core_service/frameworks/js/napi/include", + "$SUBSYSTEM_DIR/core_service/frameworks/js/napi", + "$SUBSYSTEM_DIR/core_service/services/sim/include", + "$SUBSYSTEM_DIR/core_service/services/core/include", + "$SUBSYSTEM_DIR/core_service/services/tel_ril/include", + "$SUBSYSTEM_DIR/core_service/test/fuzztest/common_fuzzer", ] - configs = [ "//base/telephony/core_service/utils:telephony_log_config" ] + configs = [ "$SUBSYSTEM_DIR/core_service/utils:telephony_log_config" ] deps = [ - "//base/telephony/core_service:tel_core_service", - "//base/telephony/core_service/interfaces/innerkits:tel_core_service_api", - "//foundation/arkui/napi:ace_napi", + "$SUBSYSTEM_DIR/core_service:tel_core_service", + "$SUBSYSTEM_DIR/core_service/interfaces/innerkits:tel_core_service_api", ] external_deps = [ @@ -63,6 +62,7 @@ ohos_fuzztest("SetShowNumberFuzzTest") { "i18n:zone_util", "init:libbegetutil", "ipc:ipc_core", + "napi:ace_napi", "netmanager_base:net_conn_manager_if", "netmanager_ext:net_tether_manager_if", "power_manager:powermgr_client", @@ -71,7 +71,7 @@ ohos_fuzztest("SetShowNumberFuzzTest") { "safwk:system_ability_fwk", "samgr:samgr_proxy", ] - defines += [ + defines = [ "TELEPHONY_LOG_TAG = \"CoreServiceFuzzTest\"", "LOG_DOMAIN = 0xD000F00", ] @@ -88,8 +88,8 @@ ohos_fuzztest("SetShowNumberFuzzTest") { "-fno-omit-frame-pointer", ] sources = [ - "//base/telephony/core_service/frameworks/js/napi/napi_util.cpp", - "//base/telephony/core_service/test/fuzztest/common_fuzzer/addcoreservicetoken_fuzzer.cpp", + "$SUBSYSTEM_DIR/core_service/frameworks/js/napi/napi_util.cpp", + "$SUBSYSTEM_DIR/core_service/test/fuzztest/common_fuzzer/addcoreservicetoken_fuzzer.cpp", "setshownumber_fuzzer.cpp", ] } diff --git a/test/fuzztest/setshownumber_fuzzer/setshownumber_fuzzer.cpp b/test/fuzztest/setshownumber_fuzzer/setshownumber_fuzzer.cpp index b2f53655..8dae9bb4 100644 --- a/test/fuzztest/setshownumber_fuzzer/setshownumber_fuzzer.cpp +++ b/test/fuzztest/setshownumber_fuzzer/setshownumber_fuzzer.cpp @@ -38,6 +38,7 @@ bool IsServiceInited() if (!g_isInited) { auto onStart = [] { DelayedSingleton::GetInstance()->OnStart(); }; std::thread startThread(onStart); + pthread_setname_np(startThread.native_handle(), "setshownumber_fuzzer"); startThread.join(); sleep(SLEEP_TIME_SECONDS); diff --git a/test/fuzztest/setvoicemailinfo_fuzzer/BUILD.gn b/test/fuzztest/setvoicemailinfo_fuzzer/BUILD.gn index 83ffc8d6..d83e8698 100644 --- a/test/fuzztest/setvoicemailinfo_fuzzer/BUILD.gn +++ b/test/fuzztest/setvoicemailinfo_fuzzer/BUILD.gn @@ -12,7 +12,7 @@ # limitations under the License. #####################hydra-fuzz################### -import("//base/telephony/core_service/telephony.gni") +SUBSYSTEM_DIR = "../../../.." import("//build/config/features.gni") import("//build/ohos.gni") import("//build/test.gni") @@ -22,23 +22,22 @@ ohos_fuzztest("SetVoiceMailInfoFuzzTest") { module_output_path = "core_service/SetVoiceMailInfoFuzzTest" module_out_path = module_output_path fuzz_config_file = - "//base/telephony/core_service/test/fuzztest/setvoicemailinfo_fuzzer" + "$SUBSYSTEM_DIR/core_service/test/fuzztest/setvoicemailinfo_fuzzer" include_dirs = [ - "//base/telephony/core_service/frameworks/js/napi/include", - "//base/telephony/core_service/services/core/include", - "//base/telephony/core_service/services/sim/include", - "//base/telephony/core_service/services/tel_ril/include", - "//base/telephony/core_service/frameworks/js/napi", - "//base/telephony/core_service/test/fuzztest/common_fuzzer", + "$SUBSYSTEM_DIR/core_service/frameworks/js/napi/include", + "$SUBSYSTEM_DIR/core_service/services/core/include", + "$SUBSYSTEM_DIR/core_service/services/sim/include", + "$SUBSYSTEM_DIR/core_service/services/tel_ril/include", + "$SUBSYSTEM_DIR/core_service/frameworks/js/napi", + "$SUBSYSTEM_DIR/core_service/test/fuzztest/common_fuzzer", ] - configs = [ "//base/telephony/core_service/utils:telephony_log_config" ] + configs = [ "$SUBSYSTEM_DIR/core_service/utils:telephony_log_config" ] deps = [ - "//base/telephony/core_service:tel_core_service", - "//base/telephony/core_service/interfaces/innerkits:tel_core_service_api", - "//foundation/arkui/napi:ace_napi", + "$SUBSYSTEM_DIR/core_service:tel_core_service", + "$SUBSYSTEM_DIR/core_service/interfaces/innerkits:tel_core_service_api", ] external_deps = [ @@ -63,6 +62,7 @@ ohos_fuzztest("SetVoiceMailInfoFuzzTest") { "i18n:zone_util", "init:libbegetutil", "ipc:ipc_core", + "napi:ace_napi", "netmanager_base:net_conn_manager_if", "netmanager_ext:net_tether_manager_if", "power_manager:powermgr_client", @@ -71,7 +71,7 @@ ohos_fuzztest("SetVoiceMailInfoFuzzTest") { "safwk:system_ability_fwk", "samgr:samgr_proxy", ] - defines += [ + defines = [ "TELEPHONY_LOG_TAG = \"CoreServiceFuzzTest\"", "LOG_DOMAIN = 0xD000F00", ] @@ -88,8 +88,8 @@ ohos_fuzztest("SetVoiceMailInfoFuzzTest") { "-fno-omit-frame-pointer", ] sources = [ - "//base/telephony/core_service/frameworks/js/napi/napi_util.cpp", - "//base/telephony/core_service/test/fuzztest/common_fuzzer/addcoreservicetoken_fuzzer.cpp", + "$SUBSYSTEM_DIR/core_service/frameworks/js/napi/napi_util.cpp", + "$SUBSYSTEM_DIR/core_service/test/fuzztest/common_fuzzer/addcoreservicetoken_fuzzer.cpp", "setvoicemailinfo_fuzzer.cpp", ] } diff --git a/test/fuzztest/setvoicemailinfo_fuzzer/setvoicemailinfo_fuzzer.cpp b/test/fuzztest/setvoicemailinfo_fuzzer/setvoicemailinfo_fuzzer.cpp index 62ee5a78..5ccc7027 100644 --- a/test/fuzztest/setvoicemailinfo_fuzzer/setvoicemailinfo_fuzzer.cpp +++ b/test/fuzztest/setvoicemailinfo_fuzzer/setvoicemailinfo_fuzzer.cpp @@ -40,6 +40,7 @@ bool IsServiceInited() if (!g_isInited) { auto onStart = [] { DelayedSingleton::GetInstance()->OnStart(); }; std::thread startThread(onStart); + pthread_setname_np(startThread.native_handle(), "setvoicemailinfo_fuzzer"); startThread.join(); sleep(SLEEP_TIME_SECONDS); diff --git a/test/fuzztest/simauthentication_fuzzer/BUILD.gn b/test/fuzztest/simauthentication_fuzzer/BUILD.gn index 2d61dfb1..61e47cb6 100644 --- a/test/fuzztest/simauthentication_fuzzer/BUILD.gn +++ b/test/fuzztest/simauthentication_fuzzer/BUILD.gn @@ -12,7 +12,7 @@ # limitations under the License. #####################hydra-fuzz################### -import("//base/telephony/core_service/telephony.gni") +SUBSYSTEM_DIR = "../../../.." import("//build/config/features.gni") import("//build/ohos.gni") import("//build/test.gni") @@ -22,23 +22,22 @@ ohos_fuzztest("SimAuthenticationFuzzTest") { module_output_path = "core_service/SimAuthenticationFuzzTest" module_out_path = module_output_path fuzz_config_file = - "//base/telephony/core_service/test/fuzztest/simauthentication_fuzzer" + "$SUBSYSTEM_DIR/core_service/test/fuzztest/simauthentication_fuzzer" include_dirs = [ - "//base/telephony/core_service/frameworks/js/napi/include", - "//base/telephony/core_service/services/sim/include", - "//base/telephony/core_service/services/core/include", - "//base/telephony/core_service/services/tel_ril/include", - "//base/telephony/core_service/frameworks/js/napi", - "//base/telephony/core_service/test/fuzztest/common_fuzzer", + "$SUBSYSTEM_DIR/core_service/frameworks/js/napi/include", + "$SUBSYSTEM_DIR/core_service/services/sim/include", + "$SUBSYSTEM_DIR/core_service/services/core/include", + "$SUBSYSTEM_DIR/core_service/services/tel_ril/include", + "$SUBSYSTEM_DIR/core_service/frameworks/js/napi", + "$SUBSYSTEM_DIR/core_service/test/fuzztest/common_fuzzer", ] - configs = [ "//base/telephony/core_service/utils:telephony_log_config" ] + configs = [ "$SUBSYSTEM_DIR/core_service/utils:telephony_log_config" ] deps = [ - "//base/telephony/core_service:tel_core_service", - "//base/telephony/core_service/interfaces/innerkits:tel_core_service_api", - "//foundation/arkui/napi:ace_napi", + "$SUBSYSTEM_DIR/core_service:tel_core_service", + "$SUBSYSTEM_DIR/core_service/interfaces/innerkits:tel_core_service_api", ] external_deps = [ @@ -63,6 +62,7 @@ ohos_fuzztest("SimAuthenticationFuzzTest") { "i18n:zone_util", "init:libbegetutil", "ipc:ipc_core", + "napi:ace_napi", "netmanager_base:net_conn_manager_if", "netmanager_ext:net_tether_manager_if", "power_manager:powermgr_client", @@ -71,7 +71,7 @@ ohos_fuzztest("SimAuthenticationFuzzTest") { "safwk:system_ability_fwk", "samgr:samgr_proxy", ] - defines += [ + defines = [ "TELEPHONY_LOG_TAG = \"CoreServiceFuzzTest\"", "LOG_DOMAIN = 0xD000F00", ] @@ -88,8 +88,8 @@ ohos_fuzztest("SimAuthenticationFuzzTest") { "-fno-omit-frame-pointer", ] sources = [ - "//base/telephony/core_service/frameworks/js/napi/napi_util.cpp", - "//base/telephony/core_service/test/fuzztest/common_fuzzer/addcoreservicetoken_fuzzer.cpp", + "$SUBSYSTEM_DIR/core_service/frameworks/js/napi/napi_util.cpp", + "$SUBSYSTEM_DIR/core_service/test/fuzztest/common_fuzzer/addcoreservicetoken_fuzzer.cpp", "simauthentication_fuzzer.cpp", ] } diff --git a/test/fuzztest/simauthentication_fuzzer/simauthentication_fuzzer.cpp b/test/fuzztest/simauthentication_fuzzer/simauthentication_fuzzer.cpp index 5a2eddce..b8529000 100644 --- a/test/fuzztest/simauthentication_fuzzer/simauthentication_fuzzer.cpp +++ b/test/fuzztest/simauthentication_fuzzer/simauthentication_fuzzer.cpp @@ -39,6 +39,7 @@ bool IsServiceInited() if (!g_isInited) { auto onStart = [] { DelayedSingleton::GetInstance()->OnStart(); }; std::thread startThread(onStart); + pthread_setname_np(startThread.native_handle(), "simauthentication_fuzzer"); startThread.join(); sleep(SLEEP_TIME_SECONDS); diff --git a/test/fuzztest/unmarshalling_fuzzer/BUILD.gn b/test/fuzztest/unmarshalling_fuzzer/BUILD.gn index e63527e5..924e2552 100644 --- a/test/fuzztest/unmarshalling_fuzzer/BUILD.gn +++ b/test/fuzztest/unmarshalling_fuzzer/BUILD.gn @@ -12,7 +12,7 @@ # limitations under the License. #####################hydra-fuzz################### -import("//base/telephony/core_service/telephony.gni") +SUBSYSTEM_DIR = "../../../.." import("//build/config/features.gni") import("//build/ohos.gni") import("//build/test.gni") @@ -22,24 +22,23 @@ ohos_fuzztest("UnMarshallingFuzzTest") { module_output_path = "core_service/UnMarshallingFuzzTest" module_out_path = module_output_path fuzz_config_file = - "//base/telephony/core_service/test/fuzztest/unmarshalling_fuzzer" + "$SUBSYSTEM_DIR/core_service/test/fuzztest/unmarshalling_fuzzer" include_dirs = [ - "//base/telephony/core_service/frameworks/js/napi/include", - "//base/telephony/core_service/frameworks/js/napi", - "//base/telephony/core_service/services/core/include", - "//base/telephony/core_service/services/network_search/include", - "//base/telephony/core_service/services/sim/include", - "//base/telephony/core_service/test/fuzztest/common_fuzzer", - "//base/telephony/core_service/services/tel_ril/include", + "$SUBSYSTEM_DIR/core_service/frameworks/js/napi/include", + "$SUBSYSTEM_DIR/core_service/frameworks/js/napi", + "$SUBSYSTEM_DIR/core_service/services/core/include", + "$SUBSYSTEM_DIR/core_service/services/network_search/include", + "$SUBSYSTEM_DIR/core_service/services/sim/include", + "$SUBSYSTEM_DIR/core_service/test/fuzztest/common_fuzzer", + "$SUBSYSTEM_DIR/core_service/services/tel_ril/include", ] - configs = [ "//base/telephony/core_service/utils:telephony_log_config" ] + configs = [ "$SUBSYSTEM_DIR/core_service/utils:telephony_log_config" ] deps = [ - "//base/telephony/core_service:tel_core_service", - "//base/telephony/core_service/interfaces/innerkits:tel_core_service_api", - "//foundation/arkui/napi:ace_napi", + "$SUBSYSTEM_DIR/core_service:tel_core_service", + "$SUBSYSTEM_DIR/core_service/interfaces/innerkits:tel_core_service_api", ] external_deps = [ @@ -53,13 +52,14 @@ ohos_fuzztest("UnMarshallingFuzzTest") { "drivers_interface_ril:ril_idl_headers", "init:libbegetutil", "ipc:ipc_core", + "napi:ace_napi", "netmanager_base:net_conn_manager_if", "netmanager_ext:net_tether_manager_if", "power_manager:powermgr_client", "relational_store:native_rdb", "samgr:samgr_proxy", ] - defines += [ + defines = [ "TELEPHONY_LOG_TAG = \"CoreServiceFuzzTest\"", "LOG_DOMAIN = 0xD000F00", ] @@ -76,8 +76,8 @@ ohos_fuzztest("UnMarshallingFuzzTest") { "-fno-omit-frame-pointer", ] sources = [ - "//base/telephony/core_service/frameworks/js/napi/napi_util.cpp", - "//base/telephony/core_service/test/fuzztest/common_fuzzer/addcoreservicetoken_fuzzer.cpp", + "$SUBSYSTEM_DIR/core_service/frameworks/js/napi/napi_util.cpp", + "$SUBSYSTEM_DIR/core_service/test/fuzztest/common_fuzzer/addcoreservicetoken_fuzzer.cpp", "unmarshalling_fuzzer.cpp", ] } diff --git a/test/fuzztest/updateiccdiallingnumbers_fuzzer/BUILD.gn b/test/fuzztest/updateiccdiallingnumbers_fuzzer/BUILD.gn index 88646514..bbb9634e 100644 --- a/test/fuzztest/updateiccdiallingnumbers_fuzzer/BUILD.gn +++ b/test/fuzztest/updateiccdiallingnumbers_fuzzer/BUILD.gn @@ -12,7 +12,7 @@ # limitations under the License. #####################hydra-fuzz################### -import("//base/telephony/core_service/telephony.gni") +SUBSYSTEM_DIR = "../../../.." import("//build/config/features.gni") import("//build/ohos.gni") import("//build/test.gni") @@ -21,23 +21,22 @@ import("//build/test.gni") ohos_fuzztest("UpdateIccDiallingNumbersFuzzTest") { module_output_path = "core_service/UpdateIccDiallingNumbersFuzzTest" module_out_path = module_output_path - fuzz_config_file = "//base/telephony/core_service/test/fuzztest/updateiccdiallingnumbers_fuzzer" + fuzz_config_file = "$SUBSYSTEM_DIR/core_service/test/fuzztest/updateiccdiallingnumbers_fuzzer" include_dirs = [ - "//base/telephony/core_service/frameworks/js/napi/include", - "//base/telephony/core_service/frameworks/js/napi", - "//base/telephony/core_service/services/sim/include", - "//base/telephony/core_service/services/core/include", - "//base/telephony/core_service/services/tel_ril/include", - "//base/telephony/core_service/test/fuzztest/common_fuzzer", + "$SUBSYSTEM_DIR/core_service/frameworks/js/napi/include", + "$SUBSYSTEM_DIR/core_service/frameworks/js/napi", + "$SUBSYSTEM_DIR/core_service/services/sim/include", + "$SUBSYSTEM_DIR/core_service/services/core/include", + "$SUBSYSTEM_DIR/core_service/services/tel_ril/include", + "$SUBSYSTEM_DIR/core_service/test/fuzztest/common_fuzzer", ] - configs = [ "//base/telephony/core_service/utils:telephony_log_config" ] + configs = [ "$SUBSYSTEM_DIR/core_service/utils:telephony_log_config" ] deps = [ - "//base/telephony/core_service:tel_core_service", - "//base/telephony/core_service/interfaces/innerkits:tel_core_service_api", - "//foundation/arkui/napi:ace_napi", + "$SUBSYSTEM_DIR/core_service:tel_core_service", + "$SUBSYSTEM_DIR/core_service/interfaces/innerkits:tel_core_service_api", ] external_deps = [ @@ -62,6 +61,7 @@ ohos_fuzztest("UpdateIccDiallingNumbersFuzzTest") { "i18n:zone_util", "init:libbegetutil", "ipc:ipc_core", + "napi:ace_napi", "netmanager_base:net_conn_manager_if", "netmanager_ext:net_tether_manager_if", "power_manager:powermgr_client", @@ -70,7 +70,7 @@ ohos_fuzztest("UpdateIccDiallingNumbersFuzzTest") { "safwk:system_ability_fwk", "samgr:samgr_proxy", ] - defines += [ + defines = [ "TELEPHONY_LOG_TAG = \"CoreServiceFuzzTest\"", "LOG_DOMAIN = 0xD000F00", ] @@ -87,8 +87,8 @@ ohos_fuzztest("UpdateIccDiallingNumbersFuzzTest") { "-fno-omit-frame-pointer", ] sources = [ - "//base/telephony/core_service/frameworks/js/napi/napi_util.cpp", - "//base/telephony/core_service/test/fuzztest/common_fuzzer/addcoreservicetoken_fuzzer.cpp", + "$SUBSYSTEM_DIR/core_service/frameworks/js/napi/napi_util.cpp", + "$SUBSYSTEM_DIR/core_service/test/fuzztest/common_fuzzer/addcoreservicetoken_fuzzer.cpp", "updateiccdiallingnumbers_fuzzer.cpp", ] } diff --git a/test/fuzztest/updateiccdiallingnumbers_fuzzer/updateiccdiallingnumbers_fuzzer.cpp b/test/fuzztest/updateiccdiallingnumbers_fuzzer/updateiccdiallingnumbers_fuzzer.cpp index 030fe983..d70bfd26 100644 --- a/test/fuzztest/updateiccdiallingnumbers_fuzzer/updateiccdiallingnumbers_fuzzer.cpp +++ b/test/fuzztest/updateiccdiallingnumbers_fuzzer/updateiccdiallingnumbers_fuzzer.cpp @@ -40,6 +40,7 @@ bool IsServiceInited() if (!g_isInited) { auto onStart = [] { DelayedSingleton::GetInstance()->OnStart(); }; std::thread startThread(onStart); + pthread_setname_np(startThread.native_handle(), "updateiccdiallingnumbers_fuzzer"); startThread.join(); sleep(SLEEP_TIME_SECONDS); diff --git a/test/fuzztest/updatesmsicc_fuzzer/BUILD.gn b/test/fuzztest/updatesmsicc_fuzzer/BUILD.gn index 873a4b89..ed8d9a13 100644 --- a/test/fuzztest/updatesmsicc_fuzzer/BUILD.gn +++ b/test/fuzztest/updatesmsicc_fuzzer/BUILD.gn @@ -12,7 +12,7 @@ # limitations under the License. #####################hydra-fuzz################### -import("//base/telephony/core_service/telephony.gni") +SUBSYSTEM_DIR = "../../../.." import("//build/config/features.gni") import("//build/ohos.gni") import("//build/test.gni") @@ -22,23 +22,22 @@ ohos_fuzztest("UpdateSmsIccFuzzTest") { module_output_path = "core_service/UpdateSmsIccFuzzTest" module_out_path = module_output_path fuzz_config_file = - "//base/telephony/core_service/test/fuzztest/updatesmsicc_fuzzer" + "$SUBSYSTEM_DIR/core_service/test/fuzztest/updatesmsicc_fuzzer" include_dirs = [ - "//base/telephony/core_service/frameworks/js/napi/include", - "//base/telephony/core_service/frameworks/js/napi", - "//base/telephony/core_service/services/sim/include", - "//base/telephony/core_service/services/core/include", - "//base/telephony/core_service/services/tel_ril/include", - "//base/telephony/core_service/test/fuzztest/common_fuzzer", + "$SUBSYSTEM_DIR/core_service/frameworks/js/napi/include", + "$SUBSYSTEM_DIR/core_service/frameworks/js/napi", + "$SUBSYSTEM_DIR/core_service/services/sim/include", + "$SUBSYSTEM_DIR/core_service/services/core/include", + "$SUBSYSTEM_DIR/core_service/services/tel_ril/include", + "$SUBSYSTEM_DIR/core_service/test/fuzztest/common_fuzzer", ] - configs = [ "//base/telephony/core_service/utils:telephony_log_config" ] + configs = [ "$SUBSYSTEM_DIR/core_service/utils:telephony_log_config" ] deps = [ - "//base/telephony/core_service:tel_core_service", - "//base/telephony/core_service/interfaces/innerkits:tel_core_service_api", - "//foundation/arkui/napi:ace_napi", + "$SUBSYSTEM_DIR/core_service:tel_core_service", + "$SUBSYSTEM_DIR/core_service/interfaces/innerkits:tel_core_service_api", ] external_deps = [ @@ -63,6 +62,7 @@ ohos_fuzztest("UpdateSmsIccFuzzTest") { "i18n:zone_util", "init:libbegetutil", "ipc:ipc_core", + "napi:ace_napi", "netmanager_base:net_conn_manager_if", "netmanager_ext:net_tether_manager_if", "power_manager:powermgr_client", @@ -71,7 +71,7 @@ ohos_fuzztest("UpdateSmsIccFuzzTest") { "safwk:system_ability_fwk", "samgr:samgr_proxy", ] - defines += [ + defines = [ "TELEPHONY_LOG_TAG = \"CoreServiceFuzzTest\"", "LOG_DOMAIN = 0xD000F00", ] @@ -88,8 +88,8 @@ ohos_fuzztest("UpdateSmsIccFuzzTest") { "-fno-omit-frame-pointer", ] sources = [ - "//base/telephony/core_service/frameworks/js/napi/napi_util.cpp", - "//base/telephony/core_service/test/fuzztest/common_fuzzer/addcoreservicetoken_fuzzer.cpp", + "$SUBSYSTEM_DIR/core_service/frameworks/js/napi/napi_util.cpp", + "$SUBSYSTEM_DIR/core_service/test/fuzztest/common_fuzzer/addcoreservicetoken_fuzzer.cpp", "updatesmsicc_fuzzer.cpp", ] } diff --git a/test/fuzztest/updatevoicemail_fuzzer/BUILD.gn b/test/fuzztest/updatevoicemail_fuzzer/BUILD.gn index cb80c0e0..4659d94b 100644 --- a/test/fuzztest/updatevoicemail_fuzzer/BUILD.gn +++ b/test/fuzztest/updatevoicemail_fuzzer/BUILD.gn @@ -12,7 +12,7 @@ # limitations under the License. #####################hydra-fuzz################### -import("//base/telephony/core_service/telephony.gni") +SUBSYSTEM_DIR = "../../../.." import("//build/config/features.gni") import("//build/ohos.gni") import("//build/test.gni") @@ -22,24 +22,23 @@ ohos_fuzztest("UpdateVoiceMailFuzzTest") { module_output_path = "core_service/UpdateVoiceMailFuzzTest" module_out_path = module_output_path fuzz_config_file = - "//base/telephony/core_service/test/fuzztest/updatevoicemail_fuzzer" + "$SUBSYSTEM_DIR/core_service/test/fuzztest/updatevoicemail_fuzzer" include_dirs = [ - "//base/telephony/core_service/frameworks/js/napi/include", - "//base/telephony/core_service/frameworks/js/napi", - "//base/telephony/core_service/services/core/include", - "//base/telephony/core_service/services/network_search/include", - "//base/telephony/core_service/services/sim/include", - "//base/telephony/core_service/test/fuzztest/common_fuzzer", - "//base/telephony/core_service/services/tel_ril/include", + "$SUBSYSTEM_DIR/core_service/frameworks/js/napi/include", + "$SUBSYSTEM_DIR/core_service/frameworks/js/napi", + "$SUBSYSTEM_DIR/core_service/services/core/include", + "$SUBSYSTEM_DIR/core_service/services/network_search/include", + "$SUBSYSTEM_DIR/core_service/services/sim/include", + "$SUBSYSTEM_DIR/core_service/test/fuzztest/common_fuzzer", + "$SUBSYSTEM_DIR/core_service/services/tel_ril/include", ] - configs = [ "//base/telephony/core_service/utils:telephony_log_config" ] + configs = [ "$SUBSYSTEM_DIR/core_service/utils:telephony_log_config" ] deps = [ - "//base/telephony/core_service:tel_core_service", - "//base/telephony/core_service/interfaces/innerkits:tel_core_service_api", - "//foundation/arkui/napi:ace_napi", + "$SUBSYSTEM_DIR/core_service:tel_core_service", + "$SUBSYSTEM_DIR/core_service/interfaces/innerkits:tel_core_service_api", ] external_deps = [ @@ -64,6 +63,7 @@ ohos_fuzztest("UpdateVoiceMailFuzzTest") { "i18n:zone_util", "init:libbegetutil", "ipc:ipc_core", + "napi:ace_napi", "netmanager_base:net_conn_manager_if", "netmanager_ext:net_tether_manager_if", "power_manager:powermgr_client", @@ -72,7 +72,7 @@ ohos_fuzztest("UpdateVoiceMailFuzzTest") { "safwk:system_ability_fwk", "samgr:samgr_proxy", ] - defines += [ + defines = [ "TELEPHONY_LOG_TAG = \"CoreServiceFuzzTest\"", "LOG_DOMAIN = 0xD000F00", ] @@ -89,8 +89,8 @@ ohos_fuzztest("UpdateVoiceMailFuzzTest") { "-fno-omit-frame-pointer", ] sources = [ - "//base/telephony/core_service/frameworks/js/napi/napi_util.cpp", - "//base/telephony/core_service/test/fuzztest/common_fuzzer/addcoreservicetoken_fuzzer.cpp", + "$SUBSYSTEM_DIR/core_service/frameworks/js/napi/napi_util.cpp", + "$SUBSYSTEM_DIR/core_service/test/fuzztest/common_fuzzer/addcoreservicetoken_fuzzer.cpp", "updatevoicemail_fuzzer.cpp", ] } diff --git a/test/unittest/core_service_gtest/BUILD.gn b/test/unittest/core_service_gtest/BUILD.gn index db13f80e..03915c8a 100755 --- a/test/unittest/core_service_gtest/BUILD.gn +++ b/test/unittest/core_service_gtest/BUILD.gn @@ -12,6 +12,7 @@ # limitations under the License. import("//build/test.gni") +SOURCE_DIR = "../../../" ohos_unittest("tel_core_service_gtest") { install_enable = true @@ -21,7 +22,7 @@ ohos_unittest("tel_core_service_gtest") { module_out_path = part_name + "/" + test_module sources = [ - "//base/telephony/core_service/frameworks/native/src/i_network_search_callback_stub.cpp", + "$SOURCE_DIR/frameworks/native/src/i_network_search_callback_stub.cpp", "core_service_test_helper.cpp", "ims_reg_info_callback_gtest.cpp", "network_search_test.cpp", @@ -32,27 +33,20 @@ ohos_unittest("tel_core_service_gtest") { ] include_dirs = [ - "//base/telephony/telephony_data/sim/include", - "//base/telephony/telephony_data/common/include", - "//base/telephony/core_service/services/core/include", - "//base/telephony/core_service/utils/log/include", - "//base/telephony/core_service/utils/preferences/include", - "//base/telephony/core_service/common/sim", - "//base/telephony/core_service/services/sim/include", - "//base/telephony/core_service/services/network_search/include", - "//base/telephony/core_service/common/network_search", - "//base/telephony/core_service/common/core", - "//commonlibrary/c_utils/base/include", - "//base/telephony/core_service/services/tel_ril/include", - "//drivers/hdf_core/adapter/uhdf2/include/hdi", + "$SOURCE_DIR/services/core/include", + "$SOURCE_DIR/utils/log/include", + "$SOURCE_DIR/utils/preferences/include", + "$SOURCE_DIR/services/sim/include", + "$SOURCE_DIR/services/network_search/include", + "$SOURCE_DIR/services/tel_ril/include", ] - configs = [ "//base/telephony/core_service/utils:telephony_log_config" ] + configs = [ "$SOURCE_DIR/utils:telephony_log_config" ] deps = [ - "//base/telephony/core_service:tel_core_service", - "//base/telephony/core_service/interfaces/innerkits:tel_core_service_api", - "//base/telephony/core_service/utils:libtel_common", + "$SOURCE_DIR:tel_core_service", + "$SOURCE_DIR/interfaces/innerkits:tel_core_service_api", + "$SOURCE_DIR/utils:libtel_common", "//third_party/googletest:gtest_main", "//third_party/jsoncpp:jsoncpp", ] diff --git a/test/unittest/core_service_gtest/core_service_test_helper.cpp b/test/unittest/core_service_gtest/core_service_test_helper.cpp index 8b2cb786..e4002564 100755 --- a/test/unittest/core_service_gtest/core_service_test_helper.cpp +++ b/test/unittest/core_service_gtest/core_service_test_helper.cpp @@ -24,10 +24,11 @@ constexpr static const int32_t WAIT_TIME_SECOND = 5; bool CoreServiceTestHelper::Run(void (*func)(CoreServiceTestHelper &), CoreServiceTestHelper &helper) { std::thread t(func, std::ref(helper)); + pthread_setname_np(t.native_handle(), "core_service_test_helper"); t.detach(); return WaitForResult(WAIT_TIME_SECOND); } - + void CoreServiceTestHelper::NotifyAll() { std::unique_lock lock(mtx_); diff --git a/test/unittest/tel_ril_gtest/BUILD.gn b/test/unittest/tel_ril_gtest/BUILD.gn index 91634804..56d908eb 100644 --- a/test/unittest/tel_ril_gtest/BUILD.gn +++ b/test/unittest/tel_ril_gtest/BUILD.gn @@ -12,6 +12,7 @@ # limitations under the License. import("//build/test.gni") +SOURCE_DIR = "../../../" ohos_unittest("tel_ril_gtest") { install_enable = true @@ -21,26 +22,20 @@ ohos_unittest("tel_ril_gtest") { module_out_path = part_name + "/" + test_module sources = [ - "//base/telephony/core_service/frameworks/native/src/i_network_search_callback_stub.cpp", + "$SOURCE_DIR/frameworks/native/src/i_network_search_callback_stub.cpp", "tel_ril_test.cpp", ] include_dirs = [ - "//base/telephony/core_service/utils/common/include", - "//base/telephony/core_service/utils/log/include", - "//base/telephony/core_service/common/sim", - "//base/telephony/core_service/common/network_search", - "//base/telephony/core_service/common/core", - "//base/telephony/core_service/services/tel_ril/include", - "//base/telephony/core_service/services/sim/include", - "//drivers/hdf_core/adapter/uhdf2/include/hdi", - "//commonlibrary/c_utils/base/include", + "$SOURCE_DIR/utils/common/include", + "$SOURCE_DIR/utils/log/include", + "$SOURCE_DIR/services/tel_ril/include", + "$SOURCE_DIR/services/sim/include", ] deps = [ - "//base/telephony/core_service:tel_core_service", - "//base/telephony/core_service/interfaces/innerkits:tel_core_service_api", - "//drivers/hdf_core/adapter/uhdf2/hdi:libhdi", + "$SOURCE_DIR:tel_core_service", + "$SOURCE_DIR/interfaces/innerkits:tel_core_service_api", "//third_party/googletest:gtest_main", ] @@ -52,6 +47,7 @@ ohos_unittest("tel_ril_gtest") { "drivers_interface_ril:hril_innerkits", "drivers_interface_ril:ril_idl_headers", "eventhandler:libeventhandler", + "hdf_core:libhdi", "init:libbegetutil", "ipc:ipc_core", "power_manager:powermgr_client", diff --git a/utils/BUILD.gn b/utils/BUILD.gn index 26ac7e1d..01900977 100755 --- a/utils/BUILD.gn +++ b/utils/BUILD.gn @@ -12,7 +12,6 @@ # limitations under the License. import("//build/ohos.gni") -import("//foundation/distributeddatamgr/preferences/preferences.gni") group("common_target") { deps = [ ":libtel_common" ] @@ -22,6 +21,14 @@ config("telephony_log_config") { include_dirs = [ "log/include" ] } +config("tel_napi_config") { + include_dirs = [ + "../frameworks/js/napi/", + "../frameworks/js/network_search/include/", + "../interfaces/innerkits/include/", + ] +} + config("tel_utils_config") { include_dirs = [ "common/include", @@ -31,9 +38,8 @@ config("tel_utils_config") { } ohos_shared_library("libtel_common") { - include_dirs = [ "//base/hiviewdfx/hisysevent/interfaces/native/innerkits/hisysevent/include" ] - sources = [ + "../frameworks/js/napi/napi_util.cpp", "common/src/enum_convert.cpp", "common/src/str_convert.cpp", "common/src/telephony_common_utils.cpp", @@ -50,11 +56,12 @@ ohos_shared_library("libtel_common") { defines += [ "STANDARD_SYSTEM_ENABLE" ] } - configs = [ "//base/telephony/core_service/utils:telephony_log_config" ] + configs = [ "../utils:telephony_log_config" ] - public_configs = [ ":tel_utils_config" ] - - public_deps = [ "//commonlibrary/c_utils/base:utils" ] + public_configs = [ + ":tel_napi_config", + ":tel_utils_config", + ] if (is_double_framework) { cflags_cc = [ "-DCONFIG_DUAL_FRAMEWORK" ] @@ -72,7 +79,10 @@ ohos_shared_library("libtel_common") { "access_token:libtokenid_sdk", "bundle_framework:appexecfwk_base", "bundle_framework:appexecfwk_core", + "c_utils:utils", + "hisysevent_native:libhisysevent", "ipc:ipc_single", + "napi:ace_napi", "preferences:native_preferences", "samgr:samgr_proxy", ] diff --git a/utils/log/test/unittest/common_telephony_log_test/BUILD.gn b/utils/log/test/unittest/common_telephony_log_test/BUILD.gn index 299f7cd2..5ee068a0 100755 --- a/utils/log/test/unittest/common_telephony_log_test/BUILD.gn +++ b/utils/log/test/unittest/common_telephony_log_test/BUILD.gn @@ -13,18 +13,18 @@ import("//build/ohos.gni") import("//build/test.gni") -module_output_path = "//base/telephony/core_service/utils/telephonydfx" +SOURCE_DIR = "../../../../../.." +module_output_path = "$SOURCE_DIR/core_service/utils/telephonydfx" ohos_unittest("TelephonySALogTest") { module_out_path = module_output_path - sources = [ - "//base/telephony/core_service/utils/log/src/telephony_log_wrapper.cpp", - ] + sources = + [ "$SOURCE_DIR/core_service/utils/log/src/telephony_log_wrapper.cpp" ] configs = [ - "//base/telephony/core_service/utils:telephony_log_config", - "//base/telephony/core_service/utils/test:common_test_config", + "$SOURCE_DIR/core_service/utils:telephony_log_config", + "$SOURCE_DIR/core_service/utils/test:common_test_config", ] deps = [ "//third_party/googletest:gtest_main" ]