From 67b7c204931bf3d6db9f43b36e9f9a1414b7c000 Mon Sep 17 00:00:00 2001 From: zhoujie223 Date: Sun, 7 Apr 2024 10:34:35 +0800 Subject: [PATCH] =?UTF-8?q?IssueNo:=20=E8=8E=B7=E5=8F=96IMEISVN=E6=96=B9?= =?UTF-8?q?=E5=BC=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Description: 获取IMEISVN方式 Sig:SIG_Telephony Feature or Bugfix: Feature Binary Source: No Signed-off-by: zhoujie223 --- BUILD.gn | 1 + .../js/network_search/include/napi_radio.h | 5 ++ .../js/network_search/src/napi_radio.cpp | 72 +++++++++++++++++++ frameworks/native/src/core_manager_inner.cpp | 9 +++ frameworks/native/src/core_service_client.cpp | 10 +++ frameworks/native/src/core_service_proxy.cpp | 27 +++++++ frameworks/native/src/resource_utils.cpp | 3 + .../innerkits/include/core_manager_inner.h | 1 + .../innerkits/include/core_service_client.h | 9 +++ .../include/core_service_ipc_interface_code.h | 1 + .../innerkits/include/core_service_proxy.h | 1 + interfaces/innerkits/include/i_core_service.h | 1 + .../innerkits/include/i_network_search.h | 1 + .../innerkits/include/i_tel_ril_manager.h | 2 + interfaces/innerkits/include/radio_event.h | 1 + interfaces/innerkits/include/resource_utils.h | 2 + interfaces/kits/js/@ohos.telephony.radio.d.ts | 19 +++++ services/core/include/core_service.h | 2 + services/core/include/core_service_stub.h | 1 + services/core/src/core_service.cpp | 17 +++++ services/core/src/core_service_stub.cpp | 20 ++++++ .../include/network_search_handler.h | 1 + .../include/network_search_manager.h | 3 + services/network_search/include/radio_info.h | 1 + .../src/network_search_handler.cpp | 15 ++++ .../src/network_search_manager.cpp | 25 +++++++ services/network_search/src/network_utils.cpp | 1 + services/network_search/src/radio_info.cpp | 25 +++++++ services/network_search/test/test.cpp | 19 +++++ services/tel_ril/include/tel_ril_base.h | 8 +-- services/tel_ril/include/tel_ril_call.h | 2 +- services/tel_ril/include/tel_ril_callback.h | 6 +- services/tel_ril/include/tel_ril_data.h | 2 +- services/tel_ril/include/tel_ril_manager.h | 6 +- services/tel_ril/include/tel_ril_modem.h | 4 +- services/tel_ril/include/tel_ril_network.h | 2 +- services/tel_ril/include/tel_ril_sim.h | 2 +- services/tel_ril/include/tel_ril_sms.h | 2 +- services/tel_ril/src/tel_ril_base.cpp | 4 +- services/tel_ril/src/tel_ril_call.cpp | 2 +- services/tel_ril/src/tel_ril_callback.cpp | 6 ++ services/tel_ril/src/tel_ril_data.cpp | 2 +- services/tel_ril/src/tel_ril_manager.cpp | 9 ++- services/tel_ril/src/tel_ril_modem.cpp | 14 +++- services/tel_ril/src/tel_ril_network.cpp | 2 +- services/tel_ril/src/tel_ril_sim.cpp | 2 +- services/tel_ril/src/tel_ril_sms.cpp | 2 +- services/tel_ril/test/tel_ril_test.cpp | 13 ++++ services/tel_ril/test/tel_ril_test.h | 1 + .../main/resources/base/element/string.json | 8 +++ test/fuzztest/sendsmsmoremode_fuzzer/BUILD.gn | 1 + .../sendsmsmoremode_fuzzer.cpp | 12 ++-- .../sendterminalresponsecmd_fuzzer.cpp | 16 +++++ .../network_search_test.cpp | 57 +++++++++++++++ .../sim_core_service_test.cpp | 2 + .../core_service_gtest/zero_branch_test.cpp | 8 +++ .../zero_branch_test_core_service.cpp | 1 + test/unittest/tel_ril_gtest/BUILD.gn | 1 + .../tel_ril_gtest/tel_ril_network_test.cpp | 22 ++++++ .../tel_ril_gtest/tel_ril_test_util.cpp | 20 ++++++ .../tel_ril_gtest/tel_ril_test_util.h | 2 + .../zero_branch_test_tel_ril.cpp | 14 ++-- 62 files changed, 513 insertions(+), 37 deletions(-) mode change 100755 => 100644 frameworks/js/network_search/include/napi_radio.h mode change 100755 => 100644 frameworks/native/src/core_manager_inner.cpp mode change 100755 => 100644 frameworks/native/src/core_service_client.cpp mode change 100755 => 100644 frameworks/native/src/core_service_proxy.cpp mode change 100755 => 100644 interfaces/innerkits/include/core_manager_inner.h mode change 100755 => 100644 interfaces/innerkits/include/core_service_client.h mode change 100755 => 100644 interfaces/innerkits/include/core_service_proxy.h mode change 100755 => 100644 interfaces/innerkits/include/i_core_service.h mode change 100755 => 100644 interfaces/innerkits/include/i_network_search.h mode change 100755 => 100644 interfaces/innerkits/include/i_tel_ril_manager.h mode change 100755 => 100644 interfaces/innerkits/include/radio_event.h mode change 100755 => 100644 interfaces/kits/js/@ohos.telephony.radio.d.ts mode change 100755 => 100644 services/core/include/core_service.h mode change 100755 => 100644 services/core/include/core_service_stub.h mode change 100755 => 100644 services/network_search/src/network_utils.cpp mode change 100755 => 100644 services/network_search/test/test.cpp mode change 100755 => 100644 services/tel_ril/test/tel_ril_test.cpp mode change 100755 => 100644 telephonyres/main/resources/base/element/string.json mode change 100755 => 100644 test/unittest/core_service_gtest/network_search_test.cpp mode change 100755 => 100644 test/unittest/tel_ril_gtest/tel_ril_test_util.cpp mode change 100755 => 100644 test/unittest/tel_ril_gtest/tel_ril_test_util.h diff --git a/BUILD.gn b/BUILD.gn index 1178df8d8..86481f747 100644 --- a/BUILD.gn +++ b/BUILD.gn @@ -168,6 +168,7 @@ ohos_shared_library("tel_core_service") { "drivers_interface_ril:hril_innerkits", "drivers_interface_ril:libril_proxy_1.1", "drivers_interface_ril:libril_proxy_1.2", + "drivers_interface_ril:libril_proxy_1.3", "eventhandler:libeventhandler", "hdf_core:libhdi", "hdf_core:libpub_utils", diff --git a/frameworks/js/network_search/include/napi_radio.h b/frameworks/js/network_search/include/napi_radio.h old mode 100755 new mode 100644 index 5e743cd20..c2b04a044 --- a/frameworks/js/network_search/include/napi_radio.h +++ b/frameworks/js/network_search/include/napi_radio.h @@ -235,6 +235,11 @@ struct GetIMEIContext : BaseContext { std::string getIMEIResult = ""; }; +struct GetIMEISVContext : BaseContext { + int32_t slotId = DEFAULT_SIM_SLOT_ID; + std::string getIMEISVResult = ""; +}; + struct GetMEIDContext : BaseContext { int32_t slotId = DEFAULT_SIM_SLOT_ID; std::string getMEIDResult = ""; diff --git a/frameworks/js/network_search/src/napi_radio.cpp b/frameworks/js/network_search/src/napi_radio.cpp index 03bc4024c..f68064d2d 100644 --- a/frameworks/js/network_search/src/napi_radio.cpp +++ b/frameworks/js/network_search/src/napi_radio.cpp @@ -1803,6 +1803,77 @@ static napi_value GetIMEI(napi_env env, napi_callback_info info) return NapiUtil::HandleAsyncWork(env, asyncContext.release(), "GetIMEI", NativeGetIMEI, GetIMEICallback); } +void NativeGetIMEISV(napi_env env, void *data) +{ + auto context = static_cast(data); + if (!IsValidSlotId(context->slotId)) { + TELEPHONY_LOGE("NativeGetIMEISV slotId is invalid"); + context->errorCode = ERROR_SLOT_ID_INVALID; + return; + } + std::u16string imeiSv = u""; + context->errorCode = DelayedRefSingleton::GetInstance().GetImeiSv(context->slotId, imeiSv); + if (context->errorCode == TELEPHONY_SUCCESS) { + context->resolved = true; + context->getIMEISVResult = NapiUtil::ToUtf8(imeiSv); + TELEPHONY_LOGI( + "NativeGetIMEISV len = %{public}lu", static_cast(context->getIMEISVResult.length())); + } +} + +void GetIMEISVCallback(napi_env env, napi_status status, void *data) +{ + auto context = static_cast(data); + napi_value callbackValue = nullptr; + if (context->resolved) { + napi_create_string_utf8(env, context->getIMEISVResult.c_str(), context->getIMEISVResult.size(), &callbackValue); + } else { + JsError error = + NapiUtil::ConverErrorMessageWithPermissionForJs(context->errorCode, "getIMEISV", GET_TELEPHONY_STATE); + callbackValue = NapiUtil::CreateErrorMessage(env, error.errorMessage, error.errorCode); + } + NapiUtil::Handle2ValueCallback(env, context, callbackValue); +} + +static napi_value GetIMEISV(napi_env env, napi_callback_info info) +{ + size_t parameterCount = PARAMETER_COUNT_TWO; + napi_value parameters[PARAMETER_COUNT_TWO] = { 0 }; + napi_value thisVar = nullptr; + void *data = nullptr; + NAPI_CALL(env, napi_get_cb_info(env, info, ¶meterCount, parameters, &thisVar, &data)); + if (!MatchGetIMEIParameter(env, parameters, parameterCount)) { + TELEPHONY_LOGE("parameter matching failed."); + NapiUtil::ThrowParameterError(env); + return nullptr; + } + auto asyncContext = std::make_unique(); + if (asyncContext == nullptr) { + TELEPHONY_LOGE("asyncContext is nullptr."); + NapiUtil::ThrowParameterError(env); + return nullptr; + } + if (parameterCount == PARAMETER_COUNT_ZERO) { + asyncContext->slotId = GetDefaultSlotId(); + } else if (parameterCount == PARAMETER_COUNT_ONE) { + napi_valuetype valueType = napi_undefined; + NAPI_CALL(env, napi_typeof(env, parameters[0], &valueType)); + if (valueType == napi_undefined || valueType == napi_null) { + TELEPHONY_LOGI("undefined or null parameter detected, treating as no parameter input."); + asyncContext->slotId = GetDefaultSlotId(); + } else if (valueType == napi_number) { + NAPI_CALL(env, napi_get_value_int32(env, parameters[0], &asyncContext->slotId)); + } else { + asyncContext->slotId = GetDefaultSlotId(); + NAPI_CALL(env, napi_create_reference(env, parameters[0], DEFAULT_REF_COUNT, &asyncContext->callbackRef)); + } + } else { + NAPI_CALL(env, napi_get_value_int32(env, parameters[0], &asyncContext->slotId)); + NAPI_CALL(env, napi_create_reference(env, parameters[1], DEFAULT_REF_COUNT, &asyncContext->callbackRef)); + } + return NapiUtil::HandleAsyncWork(env, asyncContext.release(), "GetIMEISV", NativeGetIMEISV, GetIMEISVCallback); +} + void NativeGetMEID(napi_env env, void *data) { auto context = static_cast(data); @@ -3525,6 +3596,7 @@ static napi_value CreateFunctions(napi_env env, napi_value exports) DECLARE_NAPI_FUNCTION("setNetworkCapability", SetNetworkCapability), DECLARE_NAPI_FUNCTION("getNetworkCapability", GetNetworkCapability), DECLARE_NAPI_FUNCTION("getIMEI", GetIMEI), + DECLARE_NAPI_FUNCTION("getIMEISV", GetIMEISV), DECLARE_NAPI_FUNCTION("getMEID", GetMEID), DECLARE_NAPI_FUNCTION("sendUpdateCellLocationRequest", SendUpdateCellLocationRequest), DECLARE_NAPI_FUNCTION("getCellInformation", GetCellInformation), diff --git a/frameworks/native/src/core_manager_inner.cpp b/frameworks/native/src/core_manager_inner.cpp old mode 100755 new mode 100644 index 2c22df4e9..815d70f28 --- a/frameworks/native/src/core_manager_inner.cpp +++ b/frameworks/native/src/core_manager_inner.cpp @@ -1495,6 +1495,15 @@ int32_t CoreManagerInner::GetImei(int32_t slotId, std::u16string &imei) return networkSearchManager_->GetImei(slotId, imei); } +int32_t CoreManagerInner::GetImeiSv(int32_t slotId, std::u16string &imeiSv) +{ + if (networkSearchManager_ == nullptr) { + TELEPHONY_LOGE("networkSearchManager is null!"); + return TELEPHONY_ERR_LOCAL_PTR_NULL; + } + return networkSearchManager_->GetImeiSv(slotId, imeiSv); +} + int32_t CoreManagerInner::GetMeid(int32_t slotId, std::u16string &meid) { if (networkSearchManager_ == nullptr) { diff --git a/frameworks/native/src/core_service_client.cpp b/frameworks/native/src/core_service_client.cpp old mode 100755 new mode 100644 index e9e7d4c75..abe42c283 --- a/frameworks/native/src/core_service_client.cpp +++ b/frameworks/native/src/core_service_client.cpp @@ -247,6 +247,16 @@ int32_t CoreServiceClient::GetImei(int32_t slotId, std::u16string &imei) return proxy->GetImei(slotId, imei); } +int32_t CoreServiceClient::GetImeiSv(int32_t slotId, std::u16string &imeiSv) +{ + auto proxy = GetProxy(); + if (proxy == nullptr) { + TELEPHONY_LOGE("proxy is null!"); + return TELEPHONY_ERR_IPC_CONNECT_STUB_FAIL; + } + return proxy->GetImeiSv(slotId, imeiSv); +} + int32_t CoreServiceClient::HasSimCard(int32_t slotId, bool &hasSimCard) { auto proxy = GetProxy(); diff --git a/frameworks/native/src/core_service_proxy.cpp b/frameworks/native/src/core_service_proxy.cpp old mode 100755 new mode 100644 index 50d5c0e25..cd8839fa9 --- a/frameworks/native/src/core_service_proxy.cpp +++ b/frameworks/native/src/core_service_proxy.cpp @@ -485,6 +485,33 @@ int32_t CoreServiceProxy::GetImei(int32_t slotId, std::u16string &imei) return result; } +int32_t CoreServiceProxy::GetImeiSv(int32_t slotId, std::u16string &imeiSv) +{ + MessageParcel data; + MessageParcel reply; + MessageOption option; + if (!WriteInterfaceToken(data)) { + TELEPHONY_LOGE("GetImeiSv WriteInterfaceToken is false"); + return TELEPHONY_ERR_WRITE_DESCRIPTOR_TOKEN_FAIL; + } + data.WriteInt32(slotId); + auto remote = Remote(); + if (remote == nullptr) { + TELEPHONY_LOGE("GetImeiSv Remote is null"); + return TELEPHONY_ERR_IPC_CONNECT_STUB_FAIL; + } + int32_t error = remote->SendRequest(uint32_t(CoreServiceInterfaceCode::GET_IMEISV), data, reply, option); + if (error != ERR_NONE) { + TELEPHONY_LOGE("GetImeiSv failed, error code is %{public}d", error); + return TELEPHONY_ERR_IPC_CONNECT_STUB_FAIL; + } + int32_t result = reply.ReadInt32(); + if (result == TELEPHONY_ERR_SUCCESS) { + imeiSv = reply.ReadString16(); + } + return result; +} + int32_t CoreServiceProxy::GetMeid(int32_t slotId, std::u16string &meid) { MessageParcel data; diff --git a/frameworks/native/src/resource_utils.cpp b/frameworks/native/src/resource_utils.cpp index 3ef8a0f0c..40b4463bd 100644 --- a/frameworks/native/src/resource_utils.cpp +++ b/frameworks/native/src/resource_utils.cpp @@ -113,6 +113,7 @@ const std::string ResourceUtils::CALL_FAILED_CALL_BARRED = "call_failed_call_bar const std::string ResourceUtils::CALL_FAILED_FDN_BLOCKED = "call_failed_fdn_blocked"; const std::string ResourceUtils::CALL_FAILED_IMSI_UNKNOWN_IN_VLR = "call_failed_imsi_unknow"; const std::string ResourceUtils::CALL_FAILED_IMEI_NOT_ACCEPTED = "call_failed_imei_not_accepted"; +const std::string ResourceUtils::CALL_FAILED_IMEISV_NOT_ACCEPTED = "call_failed_imeisv_not_accepted"; const std::string ResourceUtils::CALL_FAILED_DIAL_MODIFIED_TO_USSD = "call_failed_dial_modify_to_ussd"; const std::string ResourceUtils::CALL_FAILED_DIAL_MODIFIED_TO_SS = "call_failed_dial_modify_to_ss"; const std::string ResourceUtils::CALL_FAILED_DIAL_MODIFIED_TO_DIAL = "call_failed_dial_modify_to_dial"; @@ -213,6 +214,7 @@ const std::map ResourceUtils::mapResou { ResourceUtils::CALL_FAILED_FDN_BLOCKED, ResourceUtils::ResourceType::ResourceTypeString }, { ResourceUtils::CALL_FAILED_IMSI_UNKNOWN_IN_VLR, ResourceUtils::ResourceType::ResourceTypeString }, { ResourceUtils::CALL_FAILED_IMEI_NOT_ACCEPTED, ResourceUtils::ResourceType::ResourceTypeString }, + { ResourceUtils::CALL_FAILED_IMEISV_NOT_ACCEPTED, ResourceUtils::ResourceType::ResourceTypeString }, { ResourceUtils::CALL_FAILED_DIAL_MODIFIED_TO_USSD, ResourceUtils::ResourceType::ResourceTypeString }, { ResourceUtils::CALL_FAILED_DIAL_MODIFIED_TO_SS, ResourceUtils::ResourceType::ResourceTypeString }, { ResourceUtils::CALL_FAILED_DIAL_MODIFIED_TO_DIAL, ResourceUtils::ResourceType::ResourceTypeString }, @@ -312,6 +314,7 @@ const std::map ResourceUtils::callFailedResourceName_ = { { DisconnectedReasons::FDN_BLOCKED, ResourceUtils::CALL_FAILED_FDN_BLOCKED }, { DisconnectedReasons::IMSI_UNKNOWN_IN_VLR, ResourceUtils::CALL_FAILED_IMSI_UNKNOWN_IN_VLR }, { DisconnectedReasons::IMEI_NOT_ACCEPTED, ResourceUtils::CALL_FAILED_IMEI_NOT_ACCEPTED }, + { DisconnectedReasons::IMEISV_NOT_ACCEPTED, ResourceUtils::CALL_FAILED_IMEISV_NOT_ACCEPTED }, { DisconnectedReasons::DIAL_MODIFIED_TO_USSD, ResourceUtils::CALL_FAILED_DIAL_MODIFIED_TO_USSD }, { DisconnectedReasons::DIAL_MODIFIED_TO_SS, ResourceUtils::CALL_FAILED_DIAL_MODIFIED_TO_SS }, { DisconnectedReasons::DIAL_MODIFIED_TO_DIAL, ResourceUtils::CALL_FAILED_DIAL_MODIFIED_TO_DIAL }, diff --git a/interfaces/innerkits/include/core_manager_inner.h b/interfaces/innerkits/include/core_manager_inner.h old mode 100755 new mode 100644 index c42d8f3f5..fe96f1dfb --- a/interfaces/innerkits/include/core_manager_inner.h +++ b/interfaces/innerkits/include/core_manager_inner.h @@ -208,6 +208,7 @@ public: int32_t GetRadioState(int32_t slotId, const sptr &callback); int32_t GetIsoCountryCodeForNetwork(int32_t slotId, std::u16string &countryCode); int32_t GetImei(int32_t slotId, std::u16string &imei); + int32_t GetImeiSv(int32_t slotId, std::u16string &imeiSv); int32_t GetMeid(int32_t slotId, std::u16string &meid); int32_t GetUniqueDeviceId(int32_t slotId, std::u16string &deviceId); PhoneType GetPhoneType(int32_t slotId); diff --git a/interfaces/innerkits/include/core_service_client.h b/interfaces/innerkits/include/core_service_client.h old mode 100755 new mode 100644 index 65a5d60c7..cd2794464 --- a/interfaces/innerkits/include/core_service_client.h +++ b/interfaces/innerkits/include/core_service_client.h @@ -166,6 +166,15 @@ public: */ int32_t GetImei(int32_t slotId, std::u16string &imei); + /** + * @brief Obtains the software version number of a specified card slot of the device + * + * @param slotId[in], sim slot id + * @param imeiSv[out], the International Mobile Equipment Identification Number of the SIM card + * @return int32_t TELEPHONY_SUCCESS on success, others on failure. + */ + int32_t GetImeiSv(int32_t slotId, std::u16string &imeiSv); + /** * @brief Checks whether a SIM card is inserted in a specified slot. * diff --git a/interfaces/innerkits/include/core_service_ipc_interface_code.h b/interfaces/innerkits/include/core_service_ipc_interface_code.h index fb85e3639..9bc7092c7 100644 --- a/interfaces/innerkits/include/core_service_ipc_interface_code.h +++ b/interfaces/innerkits/include/core_service_ipc_interface_code.h @@ -30,6 +30,7 @@ enum class CoreServiceInterfaceCode { SET_RADIO_STATE, GET_RADIO_STATE, GET_IMEI, + GET_IMEISV, GET_MEID, GET_UNIQUE_DEVICE_ID, HAS_SIM_CARD, diff --git a/interfaces/innerkits/include/core_service_proxy.h b/interfaces/innerkits/include/core_service_proxy.h old mode 100755 new mode 100644 index 303f40b61..522941abb --- a/interfaces/innerkits/include/core_service_proxy.h +++ b/interfaces/innerkits/include/core_service_proxy.h @@ -38,6 +38,7 @@ public: int32_t SetNrOptionMode(int32_t slotId, int32_t mode, const sptr &callback) override; int32_t GetNrOptionMode(int32_t slotId, const sptr &callback) override; int32_t GetImei(int32_t slotId, std::u16string &imei) override; + int32_t GetImeiSv(int32_t slotId, std::u16string &imeiSv) override; int32_t GetMeid(int32_t slotId, std::u16string &meid) override; int32_t GetUniqueDeviceId(int32_t slotId, std::u16string &deviceId) override; int32_t GetNetworkSearchInformation(int32_t slotId, const sptr &callback) override; diff --git a/interfaces/innerkits/include/i_core_service.h b/interfaces/innerkits/include/i_core_service.h old mode 100755 new mode 100644 index c6f302266..1053643b2 --- a/interfaces/innerkits/include/i_core_service.h +++ b/interfaces/innerkits/include/i_core_service.h @@ -45,6 +45,7 @@ public: virtual int32_t SetRadioState(int32_t slotId, bool isOn, const sptr &callback) = 0; virtual int32_t GetRadioState(int32_t slotId, const sptr &callback) = 0; virtual int32_t GetImei(int32_t slotId, std::u16string &imei) = 0; + virtual int32_t GetImeiSv(int32_t slotId, std::u16string &imeiSv) = 0; virtual int32_t GetMeid(int32_t slotId, std::u16string &meid) = 0; virtual int32_t GetUniqueDeviceId(int32_t slotId, std::u16string &deviceId) = 0; virtual bool IsNrSupported(int32_t slotId) = 0; diff --git a/interfaces/innerkits/include/i_network_search.h b/interfaces/innerkits/include/i_network_search.h old mode 100755 new mode 100644 index a475471b5..c73969ebd --- a/interfaces/innerkits/include/i_network_search.h +++ b/interfaces/innerkits/include/i_network_search.h @@ -95,6 +95,7 @@ public: */ virtual int32_t GetPsRoamingState(int32_t slotId) = 0; virtual int32_t GetImei(int32_t slotId, std::u16string &imei) = 0; + virtual int32_t GetImeiSv(int32_t slotId, std::u16string &imeiSv) = 0; virtual int32_t GetImsRegStatus(int32_t slotId, ImsServiceType imsSrvType, ImsRegInfo &info) = 0; virtual int32_t GetCellInfoList(int32_t slotId, std::vector> &cellInfo) = 0; virtual int32_t SendUpdateCellLocationRequest(int32_t slotId) = 0; diff --git a/interfaces/innerkits/include/i_tel_ril_manager.h b/interfaces/innerkits/include/i_tel_ril_manager.h old mode 100755 new mode 100644 index f9755a1b3..8023766f6 --- a/interfaces/innerkits/include/i_tel_ril_manager.h +++ b/interfaces/innerkits/include/i_tel_ril_manager.h @@ -121,6 +121,8 @@ public: virtual int32_t GetImei(int32_t slotId, const AppExecFwk::InnerEvent::Pointer &response) = 0; + virtual int32_t GetImeiSv(int32_t slotId, const AppExecFwk::InnerEvent::Pointer &response) = 0; + virtual int32_t GetMeid(int32_t slotId, const AppExecFwk::InnerEvent::Pointer &response) = 0; virtual int32_t GetVoiceRadioTechnology(int32_t slotId, const AppExecFwk::InnerEvent::Pointer &response) = 0; diff --git a/interfaces/innerkits/include/radio_event.h b/interfaces/innerkits/include/radio_event.h old mode 100755 new mode 100644 index 4453a67f5..1a39126fa --- a/interfaces/innerkits/include/radio_event.h +++ b/interfaces/innerkits/include/radio_event.h @@ -135,6 +135,7 @@ enum RadioEvent { RADIO_NITZ_UPDATE, RADIO_GET_IMS_REG_STATUS, RADIO_GET_IMEI, + RADIO_GET_IMEISV, RADIO_SET_PS_ATTACH_STATUS, RADIO_GET_MEID, RADIO_CHANNEL_CONFIG_UPDATE, diff --git a/interfaces/innerkits/include/resource_utils.h b/interfaces/innerkits/include/resource_utils.h index 12238ec66..9b61403e7 100644 --- a/interfaces/innerkits/include/resource_utils.h +++ b/interfaces/innerkits/include/resource_utils.h @@ -107,6 +107,7 @@ enum DisconnectedReasons { RADIO_RELEASE_ABNORMAL = 259, // RRC connection release, abnormal ACCESS_CLASS_BLOCKED = 260, // Access class barring NETWORK_DETACH = 261, // Explicit network detach + IMEISV_NOT_ACCEPTED = 262, // ImeiSv not accepted FAILED_INVALID_PARAMETER = 1025, SIM_NOT_EXIT = 1026, SIM_PIN_NEED = 1027, @@ -180,6 +181,7 @@ public: static const std::string CALL_FAILED_FDN_BLOCKED; static const std::string CALL_FAILED_IMSI_UNKNOWN_IN_VLR; static const std::string CALL_FAILED_IMEI_NOT_ACCEPTED; + static const std::string CALL_FAILED_IMEISV_NOT_ACCEPTED; static const std::string CALL_FAILED_DIAL_MODIFIED_TO_USSD; static const std::string CALL_FAILED_DIAL_MODIFIED_TO_SS; static const std::string CALL_FAILED_DIAL_MODIFIED_TO_DIAL; diff --git a/interfaces/kits/js/@ohos.telephony.radio.d.ts b/interfaces/kits/js/@ohos.telephony.radio.d.ts old mode 100755 new mode 100644 index 3562a9357..dc3a3946e --- a/interfaces/kits/js/@ohos.telephony.radio.d.ts +++ b/interfaces/kits/js/@ohos.telephony.radio.d.ts @@ -617,6 +617,25 @@ declare namespace radio { */ function getIMEI(callback: AsyncCallback): void; + /** + * Obtains the software version number of a specified card slot of the device. + * + * @permission ohos.permission.GET_TELEPHONY_STATE + * @param { number } slotId - Indicates the card slot index number, ranging from 0 to the maximum card slot + * index number supported by the device. + * @returns { Promise } Returns the IMEISV. Returns an empty string if the IMEISV does not exist. + * @throws { BusinessError } 201 - Permission denied. + * @throws { BusinessError } 202 - Non-system applications use system APIs. + * @throws { BusinessError } 401 - Parameter error. + * @throws { BusinessError } 8300001 - Invalid parameter value. + * @throws { BusinessError } 8300002 - Operation failed. Cannot connect to service. + * @throws { BusinessError } 8300003 - System internal error. + * @throws { BusinessError } 8300999 - Unknown error code. + * @systemapi Hide this for inner system use. + * @since 12 + */ + function getIMEISV(slotId?: number): Promise; + /** * Obtains the MEID of a specified card slot of the device. * diff --git a/services/core/include/core_service.h b/services/core/include/core_service.h old mode 100755 new mode 100644 index 69f4c23ca..6601f7802 --- a/services/core/include/core_service.h +++ b/services/core/include/core_service.h @@ -58,6 +58,8 @@ public: int32_t GetImei(int32_t slotId, std::u16string &imei) override; + int32_t GetImeiSv(int32_t slotId, std::u16string &imeiSv) override; + int32_t GetMeid(int32_t slotId, std::u16string &meid) override; int32_t GetUniqueDeviceId(int32_t slotId, std::u16string &deviceId) override; diff --git a/services/core/include/core_service_stub.h b/services/core/include/core_service_stub.h old mode 100755 new mode 100644 index b4759a7c4..366023eb5 --- a/services/core/include/core_service_stub.h +++ b/services/core/include/core_service_stub.h @@ -51,6 +51,7 @@ private: int32_t OnGetNetworkSelectionMode(MessageParcel &data, MessageParcel &reply); int32_t OnGetIsoCountryCodeForNetwork(MessageParcel &data, MessageParcel &reply); int32_t OnGetImei(MessageParcel &data, MessageParcel &reply); + int32_t OnGetImeiSv(MessageParcel &data, MessageParcel &reply); int32_t OnGetMeid(MessageParcel &data, MessageParcel &reply); int32_t OnGetUniqueDeviceId(MessageParcel &data, MessageParcel &reply); int32_t OnIsNrSupported(MessageParcel &data, MessageParcel &reply); diff --git a/services/core/src/core_service.cpp b/services/core/src/core_service.cpp index 4a0b99433..5634ca476 100644 --- a/services/core/src/core_service.cpp +++ b/services/core/src/core_service.cpp @@ -279,6 +279,23 @@ int32_t CoreService::GetImei(int32_t slotId, std::u16string &imei) return networkSearchManager_->GetImei(slotId, imei); } +int32_t CoreService::GetImeiSv(int32_t slotId, std::u16string &imeiSv) +{ + if (!TelephonyPermission::CheckCallerIsSystemApp()) { + TELEPHONY_LOGE("Non-system applications use system APIs!"); + return TELEPHONY_ERR_ILLEGAL_USE_OF_SYSTEM_API; + } + if (!TelephonyPermission::CheckPermission(Permission::GET_TELEPHONY_STATE)) { + TELEPHONY_LOGE("permission denied!"); + return TELEPHONY_ERR_PERMISSION_ERR; + } + if (networkSearchManager_ == nullptr) { + TELEPHONY_LOGE("networkSearchManager_ is null"); + return TELEPHONY_ERR_LOCAL_PTR_NULL; + } + return networkSearchManager_->GetImeiSv(slotId, imeiSv); +} + int32_t CoreService::GetMeid(int32_t slotId, std::u16string &meid) { if (!TelephonyPermission::CheckCallerIsSystemApp()) { diff --git a/services/core/src/core_service_stub.cpp b/services/core/src/core_service_stub.cpp index 6b1777396..eed39694d 100644 --- a/services/core/src/core_service_stub.cpp +++ b/services/core/src/core_service_stub.cpp @@ -52,6 +52,7 @@ void CoreServiceStub::AddHandlerNetWorkToMap() memberFuncMap_[uint32_t(CoreServiceInterfaceCode::GET_ISO_COUNTRY_CODE_FOR_NETWORK)] = &CoreServiceStub::OnGetIsoCountryCodeForNetwork; memberFuncMap_[uint32_t(CoreServiceInterfaceCode::GET_IMEI)] = &CoreServiceStub::OnGetImei; + memberFuncMap_[uint32_t(CoreServiceInterfaceCode::GET_IMEISV)] = &CoreServiceStub::OnGetImeiSv; memberFuncMap_[uint32_t(CoreServiceInterfaceCode::GET_MEID)] = &CoreServiceStub::OnGetMeid; memberFuncMap_[uint32_t(CoreServiceInterfaceCode::GET_UNIQUE_DEVICE_ID)] = &CoreServiceStub::OnGetUniqueDeviceId; memberFuncMap_[uint32_t(CoreServiceInterfaceCode::GET_IMS_REG_STATUS)] = &CoreServiceStub::OnGetImsRegStatus; @@ -354,6 +355,25 @@ int32_t CoreServiceStub::OnGetImei(MessageParcel &data, MessageParcel &reply) return result; } +int32_t CoreServiceStub::OnGetImeiSv(MessageParcel &data, MessageParcel &reply) +{ + int32_t slotId = data.ReadInt32(); + std::u16string imeiSv = u""; + int32_t result = GetImeiSv(slotId, imeiSv); + if (!reply.WriteInt32(result)) { + TELEPHONY_LOGE("OnRemoteRequest::OnGetImeiSv write reply failed."); + return TELEPHONY_ERR_WRITE_REPLY_FAIL; + } + if (result != TELEPHONY_ERR_SUCCESS) { + return result; + } + if (!reply.WriteString16(imeiSv)) { + TELEPHONY_LOGE("OnRemoteRequest::OnGetImeiSv write reply failed."); + return TELEPHONY_ERR_WRITE_REPLY_FAIL; + } + return result; +} + int32_t CoreServiceStub::OnGetMeid(MessageParcel &data, MessageParcel &reply) { int32_t slotId = data.ReadInt32(); diff --git a/services/network_search/include/network_search_handler.h b/services/network_search/include/network_search_handler.h index dbcc43ee6..acd885724 100644 --- a/services/network_search/include/network_search_handler.h +++ b/services/network_search/include/network_search_handler.h @@ -124,6 +124,7 @@ private: void SetPreferredNetworkResponse(const AppExecFwk::InnerEvent::Pointer &event); void RadioNitzUpdate(const AppExecFwk::InnerEvent::Pointer &event); void RadioGetImei(const AppExecFwk::InnerEvent::Pointer &event); + void RadioGetImeiSv(const AppExecFwk::InnerEvent::Pointer &event); void RadioGetMeid(const AppExecFwk::InnerEvent::Pointer &event); void RadioGetNeighboringCellInfo(const AppExecFwk::InnerEvent::Pointer &event); void RadioGetCurrentCellInfo(const AppExecFwk::InnerEvent::Pointer &event); diff --git a/services/network_search/include/network_search_manager.h b/services/network_search/include/network_search_manager.h index 152b5178b..35a52f64d 100644 --- a/services/network_search/include/network_search_manager.h +++ b/services/network_search/include/network_search_manager.h @@ -66,6 +66,7 @@ struct NetworkSearchManagerInner { SelectionMode selection_ = SelectionMode::MODE_TYPE_UNKNOWN; ModemPowerState radioState_ = ModemPowerState::CORE_SERVICE_POWER_OFF; std::u16string imei_ = u""; + std::u16string imeiSv_ = u""; std::u16string meid_ = u""; std::string residentNetworkNumeric_ = ""; std::string basebandVersion_ = ""; @@ -174,6 +175,7 @@ public: int32_t SetPreferredNetwork(int32_t slotId, int32_t networkMode, NSCALLBACK &callback) override; int32_t GetIsoCountryCodeForNetwork(int32_t slotId, std::u16string &countryCode) override; int32_t GetImei(int32_t slotId, std::u16string &imei) override; + int32_t GetImeiSv(int32_t slotId, std::u16string &imeiSv) override; int32_t GetPsRegState(int32_t slotId) override; int32_t GetCsRegState(int32_t slotId) override; int32_t GetPsRoamingState(int32_t slotId) override; @@ -235,6 +237,7 @@ public: int32_t GetPreferredNetworkValue(int32_t slotId) const; void UpdatePhone(int32_t slotId, RadioTech csRadioTech, const RadioTech &psRadioTech); void SetImei(int32_t slotId, std::u16string imei); + void SetImeiSv(int32_t slotId, std::u16string imeiSv); void UpdateCellLocation(int32_t slotId, int32_t techType, int32_t cellId, int32_t lac); void SetMeid(int32_t slotId, std::u16string meid); void SetFrequencyType(int32_t slotId, FrequencyType type); diff --git a/services/network_search/include/radio_info.h b/services/network_search/include/radio_info.h index 266566dad..b583ab1c1 100644 --- a/services/network_search/include/radio_info.h +++ b/services/network_search/include/radio_info.h @@ -36,6 +36,7 @@ public: void ProcessSetRadioState(const AppExecFwk::InnerEvent::Pointer &event) const; void RadioFirstPowerOn(std::shared_ptr &nsm, ModemPowerState radioState) const; void ProcessGetImei(const AppExecFwk::InnerEvent::Pointer &event) const; + void ProcessGetImeiSv(const AppExecFwk::InnerEvent::Pointer &event) const; void ProcessGetMeid(const AppExecFwk::InnerEvent::Pointer &event) const; void UpdatePhone(RadioTech csRadioTech, const RadioTech &psRadioTech); void SetPhoneType(PhoneType phoneType); diff --git a/services/network_search/src/network_search_handler.cpp b/services/network_search/src/network_search_handler.cpp index 3191336a6..9a0a75769 100644 --- a/services/network_search/src/network_search_handler.cpp +++ b/services/network_search/src/network_search_handler.cpp @@ -54,6 +54,7 @@ const std::map NetworkSearchHandl { RadioEvent::RADIO_IMS_SERVICE_STATUS_UPDATE, &NetworkSearchHandler::UpdateImsServiceStatus }, { RadioEvent::RADIO_IMS_REGISTER_STATE_UPDATE, &NetworkSearchHandler::UpdateImsRegisterState }, { RadioEvent::RADIO_GET_IMEI, &NetworkSearchHandler::RadioGetImei }, + { RadioEvent::RADIO_GET_IMEISV, &NetworkSearchHandler::RadioGetImeiSv }, { RadioEvent::RADIO_GET_MEID, &NetworkSearchHandler::RadioGetMeid }, { RadioEvent::RADIO_GET_NEIGHBORING_CELL_INFO, &NetworkSearchHandler::RadioGetNeighboringCellInfo }, { RadioEvent::RADIO_GET_CURRENT_CELL_INFO, &NetworkSearchHandler::RadioGetCurrentCellInfo }, @@ -779,6 +780,20 @@ void NetworkSearchHandler::RadioGetImei(const AppExecFwk::InnerEvent::Pointer &e } } +void NetworkSearchHandler::RadioGetImeiSv(const AppExecFwk::InnerEvent::Pointer &event) +{ + if (event == nullptr) { + TELEPHONY_LOGE("NetworkSearchHandler::RadioGetImeiSv event is nullptr!"); + return; + } + TELEPHONY_LOGD("NetworkSearchHandler::RadioGetImeiSv start slotId:%{public}d", slotId_); + if (radioInfo_ != nullptr) { + radioInfo_->ProcessGetImeiSv(event); + } else { + TELEPHONY_LOGE("RadioGetImeiSv radioInfo_ is null slotId:%{public}d", slotId_); + } +} + void NetworkSearchHandler::RadioGetMeid(const AppExecFwk::InnerEvent::Pointer &event) { TELEPHONY_LOGD("NetworkSearchHandler::RadioGetMeid start slotId:%{public}d", slotId_); diff --git a/services/network_search/src/network_search_manager.cpp b/services/network_search/src/network_search_manager.cpp index 346d1ec4b..7ebd1b3ce 100644 --- a/services/network_search/src/network_search_manager.cpp +++ b/services/network_search/src/network_search_manager.cpp @@ -966,6 +966,14 @@ void NetworkSearchManager::SetImei(int32_t slotId, std::u16string imei) } } +void NetworkSearchManager::SetImeiSv(int32_t slotId, std::u16string imeiSv) +{ + auto inner = FindManagerInner(slotId); + if (inner != nullptr) { + inner->imeiSv_ = imeiSv; + } +} + int32_t NetworkSearchManager::GetImei(int32_t slotId, std::u16string &imei) { TELEPHONY_LOGD("NetworkSearchManager::GetImei start slotId:%{public}d", slotId); @@ -988,6 +996,23 @@ int32_t NetworkSearchManager::GetImei(int32_t slotId, std::u16string &imei) return TELEPHONY_ERR_SUCCESS; } +int32_t NetworkSearchManager::GetImeiSv(int32_t slotId, std::u16string &imeiSv) +{ + TELEPHONY_LOGD("NetworkSearchManager::GetImeiSv start slotId:%{public}d", slotId); + imeiSv = u""; + auto inner = FindManagerInner(slotId); + if (inner == nullptr || eventSender_ == nullptr) { + TELEPHONY_LOGE("slotId:%{public}d inner or eventSender_ is null", slotId); + return TELEPHONY_ERR_LOCAL_PTR_NULL; + } + if (inner->imeiSv_.empty()) { + eventSender_->SendBase(slotId, RadioEvent::RADIO_GET_IMEISV); + return TELEPHONY_ERR_LOCAL_PTR_NULL; + } + imeiSv = inner->imeiSv_; + return TELEPHONY_ERR_SUCCESS; +} + int32_t NetworkSearchManager::GetCellInfoList(int32_t slotId, std::vector> &cellInfo) { auto inner = FindManagerInner(slotId); diff --git a/services/network_search/src/network_utils.cpp b/services/network_search/src/network_utils.cpp old mode 100755 new mode 100644 index d6a782625..2830663c4 --- a/services/network_search/src/network_utils.cpp +++ b/services/network_search/src/network_utils.cpp @@ -227,6 +227,7 @@ const std::map EventSender::mapFunctions_ = { { RadioEvent::RADIO_SET_STATUS, &ITelRilManager::SetRadioState }, { RadioEvent::RADIO_GET_STATUS, &ITelRilManager::GetRadioState }, { RadioEvent::RADIO_GET_IMEI, &ITelRilManager::GetImei }, + { RadioEvent::RADIO_GET_IMEISV, &ITelRilManager::GetImeiSv }, { RadioEvent::RADIO_GET_MEID, &ITelRilManager::GetMeid }, { RadioEvent::RADIO_NETWORK_SEARCH_RESULT, &ITelRilManager::GetNetworkSearchInformation }, { RadioEvent::RADIO_GET_VOICE_TECH, &ITelRilManager::GetVoiceRadioTechnology }, diff --git a/services/network_search/src/radio_info.cpp b/services/network_search/src/radio_info.cpp index ecfcf7125..623744bcd 100644 --- a/services/network_search/src/radio_info.cpp +++ b/services/network_search/src/radio_info.cpp @@ -149,6 +149,29 @@ void RadioInfo::ProcessGetImei(const AppExecFwk::InnerEvent::Pointer &event) con nsm->SetImei(slotId_, Str8ToStr16(imeiID->data)); } +void RadioInfo::ProcessGetImeiSv(const AppExecFwk::InnerEvent::Pointer &event) const +{ + std::shared_ptr nsm = networkSearchManager_.lock(); + TELEPHONY_LOGI("RadioInfo::ProcessGetImeiSv slotId:%{public}d", slotId_); + if (event == nullptr) { + TELEPHONY_LOGE("RadioInfo::ProcessGetImeiSv event is nullptr slotId:%{public}d", slotId_); + return; + } + if (nsm == nullptr) { + TELEPHONY_LOGE("RadioInfo::ProcessGetImeiSv nsm is nullptr slotId:%{public}d", slotId_); + return; + } + + std::shared_ptr imeiSvID = event->GetSharedObject(); + if (imeiSvID == nullptr) { + TELEPHONY_LOGE("RadioInfo::ProcessGetImeiSv imeiSv is nullptr slotId:%{public}d", slotId_); + nsm->SetImeiSv(slotId_, u""); + return; + } + TELEPHONY_LOGI("RadioInfo::ProcessGetImeiSv get imeiSv success"); + nsm->SetImeiSv(slotId_, Str8ToStr16(imeiSvID->data)); +} + void RadioInfo::ProcessGetMeid(const AppExecFwk::InnerEvent::Pointer &event) const { std::shared_ptr nsm = networkSearchManager_.lock(); @@ -207,8 +230,10 @@ void RadioInfo::UpdatePhone(RadioTech csRadioTech, const RadioTech &psRadioTech) networkSearchManager->InitSimRadioProtocol(slotId_); std::u16string meid = u""; std::u16string imei = u""; + std::u16string imeiSv = u""; std::string basebandVersion = ""; networkSearchManager->GetImei(slotId_, imei); + networkSearchManager->GetImeiSv(slotId_, imeiSv); networkSearchManager->GetMeid(slotId_, meid); networkSearchManager->GetBasebandVersion(slotId_, basebandVersion); if (static_cast(radioState) == CORE_SERVICE_POWER_ON) { diff --git a/services/network_search/test/test.cpp b/services/network_search/test/test.cpp old mode 100755 new mode 100644 index 3f4ae4b79..8ec75dc32 --- a/services/network_search/test/test.cpp +++ b/services/network_search/test/test.cpp @@ -71,6 +71,7 @@ const int32_t INPUT_SET_NR_OPTION_MODE = 33; const int32_t INPUT_FACTORY_RESET = 34; const int32_t INPUT_GET_NR_SSBID = 35; const int32_t INPUT_GET_RESIDENT_NETWORK_NUMERIC = 36; +const int32_t INPUT_GET_IMEISV = 37; const int32_t INPUT_INIT_TIME = 99; const int32_t INPUT_QUIT = 100; const int32_t SLEEP_TIME = 5; @@ -613,6 +614,22 @@ void TestGetImei() std::cout << "imei:" << str << std::endl; } +void TestGetImeiSv() +{ + AccessToken token; + if (g_telephonyService == nullptr) { + std::cout << "TestGetImeiSv g_telephonyService is nullptr." << std::endl; + return; + } + std::u16string imeiSv = u""; + int32_t result = g_telephonyService->GetImeiSv(InputSlotId(), imeiSv); + if (result != TELEPHONY_ERR_SUCCESS) { + std::cout << "error:" << result << std::endl; + } + std::string str = Str16ToStr8(imeiSv); + std::cout << "imeiSv:" << str << std::endl; +} + void TestGetMeid() { AccessToken token; @@ -773,6 +790,7 @@ void Prompt() "34:FactoryReset\n" "35:GetNrSsbId\n" "36:GetResidentNetworkNumeric\n" + "37:GetImeiSv\n" "99:InitTimeAndTimeZone\n" "100:exit \n"); } @@ -849,6 +867,7 @@ void Init() memberFuncMap_[INPUT_SET_NR_OPTION_MODE] = TestSetNrOptionMode; memberFuncMap_[INPUT_GET_NR_SSBID] = TestGetNrSsbId; memberFuncMap_[INPUT_GET_RESIDENT_NETWORK_NUMERIC] = TestGetResidentNetworkNumeric; + memberFuncMap_[INPUT_GET_IMEISV] = TestGetImeiSv; memberFuncMap_[INPUT_FACTORY_RESET] = TestFactoryReset; } diff --git a/services/tel_ril/include/tel_ril_base.h b/services/tel_ril/include/tel_ril_base.h index dda02e236..a5e3de1e8 100644 --- a/services/tel_ril/include/tel_ril_base.h +++ b/services/tel_ril/include/tel_ril_base.h @@ -32,7 +32,7 @@ #include "telephony_errors.h" #include "telephony_log_wrapper.h" #include "telephony_types.h" -#include "v1_2/iril.h" +#include "v1_3/iril.h" namespace OHOS { namespace Telephony { @@ -53,13 +53,13 @@ private: class TelRilBase { public: - TelRilBase(int32_t slotId, sptr rilInterface, + TelRilBase(int32_t slotId, sptr rilInterface, std::shared_ptr observerHandler, std::shared_ptr handler); virtual ~TelRilBase() = default; static std::shared_ptr CreateTelRilRequest( int32_t request, const AppExecFwk::InnerEvent::Pointer &result); - void ResetRilInterface(sptr rilInterface); + void ResetRilInterface(sptr rilInterface); static std::shared_ptr FindTelRilRequest(const HRilRadioResponseInfo &responseInfo); int32_t ErrorResponse(std::shared_ptr telRilRequest, const HRilRadioResponseInfo &responseInfo); @@ -91,7 +91,7 @@ protected: protected: std::shared_ptr observerHandler_; - sptr rilInterface_; + sptr rilInterface_; int32_t slotId_; private: diff --git a/services/tel_ril/include/tel_ril_call.h b/services/tel_ril/include/tel_ril_call.h index a02bd2ada..0e6598dad 100644 --- a/services/tel_ril/include/tel_ril_call.h +++ b/services/tel_ril/include/tel_ril_call.h @@ -23,7 +23,7 @@ namespace OHOS { namespace Telephony { class TelRilCall : public TelRilBase { public: - TelRilCall(int32_t slotId, sptr rilInterface, + TelRilCall(int32_t slotId, sptr rilInterface, std::shared_ptr observerHandler, std::shared_ptr handler); ~TelRilCall() = default; diff --git a/services/tel_ril/include/tel_ril_callback.h b/services/tel_ril/include/tel_ril_callback.h index 2a0a5d89b..96506abc6 100644 --- a/services/tel_ril/include/tel_ril_callback.h +++ b/services/tel_ril/include/tel_ril_callback.h @@ -16,13 +16,13 @@ #ifndef TEL_RIL_CALLBACK_H #define TEL_RIL_CALLBACK_H -#include +#include #include "tel_ril_manager.h" namespace OHOS { namespace Telephony { -class TelRilCallback : public HDI::Ril::V1_2::IRilCallback { +class TelRilCallback : public HDI::Ril::V1_3::IRilCallback { public: explicit TelRilCallback(std::shared_ptr telRilManager); ~TelRilCallback() = default; @@ -115,6 +115,8 @@ public: int32_t SetRadioStateResponse(const HDI::Ril::V1_1::RilRadioResponseInfo &responseInfo) override; int32_t GetRadioStateResponse(const HDI::Ril::V1_1::RilRadioResponseInfo &responseInfo, int32_t state) override; int32_t GetImeiResponse(const HDI::Ril::V1_1::RilRadioResponseInfo &responseInfo, const std::string &imei) override; + int32_t GetImeiSvResponse( + const HDI::Ril::V1_1::RilRadioResponseInfo &responseInfo, const std::string &imeiSv) override; int32_t GetMeidResponse(const HDI::Ril::V1_1::RilRadioResponseInfo &responseInfo, const std::string &meid) override; int32_t GetVoiceRadioTechnologyResponse(const HDI::Ril::V1_1::RilRadioResponseInfo &responseInfo, const HDI::Ril::V1_1::VoiceRadioTechnology &voiceRadioTechnology) override; diff --git a/services/tel_ril/include/tel_ril_data.h b/services/tel_ril/include/tel_ril_data.h index df7cd089b..32af5d86f 100644 --- a/services/tel_ril/include/tel_ril_data.h +++ b/services/tel_ril/include/tel_ril_data.h @@ -24,7 +24,7 @@ namespace OHOS { namespace Telephony { class TelRilData : public TelRilBase { public: - TelRilData(int32_t slotId, sptr rilInterface, + TelRilData(int32_t slotId, sptr rilInterface, std::shared_ptr observerHandler, std::shared_ptr handler); ~TelRilData() = default; diff --git a/services/tel_ril/include/tel_ril_manager.h b/services/tel_ril/include/tel_ril_manager.h index af42cd51a..28288ef69 100644 --- a/services/tel_ril/include/tel_ril_manager.h +++ b/services/tel_ril/include/tel_ril_manager.h @@ -17,7 +17,7 @@ #define TEL_RIL_MANAGER_H #include -#include +#include #include "hdf_service_status_listener.h" #include "i_tel_ril_manager.h" @@ -125,6 +125,8 @@ public: int32_t GetImei(int32_t slotId, const AppExecFwk::InnerEvent::Pointer &response) override; + int32_t GetImeiSv(int32_t slotId, const AppExecFwk::InnerEvent::Pointer &response) override; + int32_t GetMeid(int32_t slotId, const AppExecFwk::InnerEvent::Pointer &response) override; int32_t GetVoiceRadioTechnology(int32_t slotId, const AppExecFwk::InnerEvent::Pointer &response) override; @@ -363,7 +365,7 @@ private: std::shared_ptr handler_ = nullptr; sptr servMgr_ = nullptr; sptr hdfListener_ = nullptr; - sptr rilInterface_ = nullptr; + sptr rilInterface_ = nullptr; }; } // namespace Telephony } // namespace OHOS diff --git a/services/tel_ril/include/tel_ril_modem.h b/services/tel_ril/include/tel_ril_modem.h index c4bbf686c..fee8e052d 100644 --- a/services/tel_ril/include/tel_ril_modem.h +++ b/services/tel_ril/include/tel_ril_modem.h @@ -24,7 +24,7 @@ namespace OHOS { namespace Telephony { class TelRilModem : public TelRilBase { public: - TelRilModem(int32_t slotId, sptr rilInterface, + TelRilModem(int32_t slotId, sptr rilInterface, std::shared_ptr observerHandler, std::shared_ptr handler); ~TelRilModem() = default; @@ -38,10 +38,12 @@ public: int32_t SetRadioState(int32_t fun, int32_t rst, const AppExecFwk::InnerEvent::Pointer &response); int32_t GetRadioState(const AppExecFwk::InnerEvent::Pointer &response); int32_t GetImei(const AppExecFwk::InnerEvent::Pointer &response); + int32_t GetImeiSv(const AppExecFwk::InnerEvent::Pointer &response); int32_t GetMeid(const AppExecFwk::InnerEvent::Pointer &response); int32_t GetVoiceRadioTechnology(const AppExecFwk::InnerEvent::Pointer &response); int32_t GetBasebandVersion(const AppExecFwk::InnerEvent::Pointer &response); int32_t GetImeiResponse(const HDI::Ril::V1_1::RilRadioResponseInfo &responseInfo, const std::string &imei); + int32_t GetImeiSvResponse(const HDI::Ril::V1_1::RilRadioResponseInfo &responseInfo, const std::string &imeiSv); int32_t GetMeidResponse(const HDI::Ril::V1_1::RilRadioResponseInfo &responseInfo, const std::string &meid); int32_t GetVoiceRadioTechnologyResponse(const HDI::Ril::V1_1::RilRadioResponseInfo &responseInfo, const HDI::Ril::V1_1::VoiceRadioTechnology &voiceRadioTechnology); diff --git a/services/tel_ril/include/tel_ril_network.h b/services/tel_ril/include/tel_ril_network.h index a350b8de5..6f115cb63 100644 --- a/services/tel_ril/include/tel_ril_network.h +++ b/services/tel_ril/include/tel_ril_network.h @@ -23,7 +23,7 @@ namespace OHOS { namespace Telephony { class TelRilNetwork : public TelRilBase { public: - TelRilNetwork(int32_t slotId, sptr rilInterface, + TelRilNetwork(int32_t slotId, sptr rilInterface, std::shared_ptr observerHandler, std::shared_ptr handler); ~TelRilNetwork() = default; diff --git a/services/tel_ril/include/tel_ril_sim.h b/services/tel_ril/include/tel_ril_sim.h index 6414ff43f..2bbe75f4b 100644 --- a/services/tel_ril/include/tel_ril_sim.h +++ b/services/tel_ril/include/tel_ril_sim.h @@ -24,7 +24,7 @@ namespace OHOS { namespace Telephony { class TelRilSim : public TelRilBase { public: - TelRilSim(int32_t slotId, sptr rilInterface, std::shared_ptr observerHandler, + TelRilSim(int32_t slotId, sptr rilInterface, std::shared_ptr observerHandler, std::shared_ptr handler); ~TelRilSim() = default; diff --git a/services/tel_ril/include/tel_ril_sms.h b/services/tel_ril/include/tel_ril_sms.h index 1d3592bcc..0cba369a8 100644 --- a/services/tel_ril/include/tel_ril_sms.h +++ b/services/tel_ril/include/tel_ril_sms.h @@ -23,7 +23,7 @@ namespace OHOS { namespace Telephony { class TelRilSms : public TelRilBase { public: - TelRilSms(int32_t slotId, sptr rilInterface, std::shared_ptr observerHandler, + TelRilSms(int32_t slotId, sptr rilInterface, std::shared_ptr observerHandler, std::shared_ptr handler); ~TelRilSms() = default; diff --git a/services/tel_ril/src/tel_ril_base.cpp b/services/tel_ril/src/tel_ril_base.cpp index 402052403..62a50bf07 100644 --- a/services/tel_ril/src/tel_ril_base.cpp +++ b/services/tel_ril/src/tel_ril_base.cpp @@ -24,14 +24,14 @@ std::unordered_map> TelRilBase::requestM std::mutex TelRilBase::requestLock_; std::shared_ptr TelRilBase::handler_; -TelRilBase::TelRilBase(int32_t slotId, sptr rilInterface, +TelRilBase::TelRilBase(int32_t slotId, sptr rilInterface, std::shared_ptr observerHandler, std::shared_ptr handler) : observerHandler_(observerHandler), rilInterface_(rilInterface), slotId_(slotId) { handler_ = handler; } -void TelRilBase::ResetRilInterface(sptr rilInterface) +void TelRilBase::ResetRilInterface(sptr rilInterface) { rilInterface_ = rilInterface; } diff --git a/services/tel_ril/src/tel_ril_call.cpp b/services/tel_ril/src/tel_ril_call.cpp index 582fbf7b6..d26722f66 100644 --- a/services/tel_ril/src/tel_ril_call.cpp +++ b/services/tel_ril/src/tel_ril_call.cpp @@ -28,7 +28,7 @@ static const int32_t DTMF_ON_LENGTH = 150; static const int32_t DTMF_OFF_LENGTH = 70; static const int32_t DTMF_STRING_LENGTH = 1; -TelRilCall::TelRilCall(int32_t slotId, sptr rilInterface, +TelRilCall::TelRilCall(int32_t slotId, sptr rilInterface, std::shared_ptr observerHandler, std::shared_ptr handler) : TelRilBase(slotId, rilInterface, observerHandler, handler) {} diff --git a/services/tel_ril/src/tel_ril_callback.cpp b/services/tel_ril/src/tel_ril_callback.cpp index b3a016335..944410af5 100644 --- a/services/tel_ril/src/tel_ril_callback.cpp +++ b/services/tel_ril/src/tel_ril_callback.cpp @@ -355,6 +355,12 @@ int32_t TelRilCallback::GetImeiResponse( return Response(responseInfo, &TelRilManager::GetTelRilModem, &TelRilModem::GetImeiResponse, imei); } +int32_t TelRilCallback::GetImeiSvResponse( + const HDI::Ril::V1_1::RilRadioResponseInfo &responseInfo, const std::string &imeiSv) +{ + return Response(responseInfo, &TelRilManager::GetTelRilModem, &TelRilModem::GetImeiSvResponse, imeiSv); +} + int32_t TelRilCallback::GetMeidResponse( const HDI::Ril::V1_1::RilRadioResponseInfo &responseInfo, const std::string &meid) { diff --git a/services/tel_ril/src/tel_ril_data.cpp b/services/tel_ril/src/tel_ril_data.cpp index 4ed1533f5..e545e68f0 100644 --- a/services/tel_ril/src/tel_ril_data.cpp +++ b/services/tel_ril/src/tel_ril_data.cpp @@ -23,7 +23,7 @@ namespace OHOS { namespace Telephony { -TelRilData::TelRilData(int32_t slotId, sptr rilInterface, +TelRilData::TelRilData(int32_t slotId, sptr rilInterface, std::shared_ptr observerHandler, std::shared_ptr handler) : TelRilBase(slotId, rilInterface, observerHandler, handler) {} diff --git a/services/tel_ril/src/tel_ril_manager.cpp b/services/tel_ril/src/tel_ril_manager.cpp index 621045712..410dbaf33 100644 --- a/services/tel_ril/src/tel_ril_manager.cpp +++ b/services/tel_ril/src/tel_ril_manager.cpp @@ -60,12 +60,12 @@ bool TelRilManager::DeInit() bool TelRilManager::ConnectRilInterface() { std::lock_guard lock_l(mutex_); - rilInterface_ = HDI::Ril::V1_2::IRil::Get(); + rilInterface_ = HDI::Ril::V1_3::IRil::Get(); if (rilInterface_ == nullptr) { TELEPHONY_LOGE("TelRilManager not find RilInterfaceService"); return false; } - rilInterface_->SetCallback1_2(new TelRilCallback(shared_from_this())); + rilInterface_->SetCallback1_3(new TelRilCallback(shared_from_this())); return true; } @@ -295,6 +295,11 @@ int32_t TelRilManager::GetImei(int32_t slotId, const AppExecFwk::InnerEvent::Poi return TaskSchedule(response, "TelRilModem", GetTelRilModem(slotId), &TelRilModem::GetImei); } +int32_t TelRilManager::GetImeiSv(int32_t slotId, const AppExecFwk::InnerEvent::Pointer &response) +{ + return TaskSchedule(response, "TelRilModem", GetTelRilModem(slotId), &TelRilModem::GetImeiSv); +} + int32_t TelRilManager::GetMeid(int32_t slotId, const AppExecFwk::InnerEvent::Pointer &response) { return TaskSchedule(response, "TelRilModem", GetTelRilModem(slotId), &TelRilModem::GetMeid); diff --git a/services/tel_ril/src/tel_ril_modem.cpp b/services/tel_ril/src/tel_ril_modem.cpp index ae798a885..f41d92e18 100644 --- a/services/tel_ril/src/tel_ril_modem.cpp +++ b/services/tel_ril/src/tel_ril_modem.cpp @@ -24,7 +24,7 @@ namespace OHOS { namespace Telephony { -TelRilModem::TelRilModem(int32_t slotId, sptr rilInterface, +TelRilModem::TelRilModem(int32_t slotId, sptr rilInterface, std::shared_ptr observerHandler, std::shared_ptr handler) : TelRilBase(slotId, rilInterface, observerHandler, handler) {} @@ -73,6 +73,11 @@ int32_t TelRilModem::GetImei(const AppExecFwk::InnerEvent::Pointer &response) return Request(TELEPHONY_LOG_FUNC_NAME, response, HREQ_MODEM_GET_IMEI, &HDI::Ril::V1_1::IRil::GetImei); } +int32_t TelRilModem::GetImeiSv(const AppExecFwk::InnerEvent::Pointer &response) +{ + return Request(TELEPHONY_LOG_FUNC_NAME, response, HREQ_MODEM_GET_IMEISV, &HDI::Ril::V1_3::IRil::GetImeiSv); +} + int32_t TelRilModem::GetMeid(const AppExecFwk::InnerEvent::Pointer &response) { return Request(TELEPHONY_LOG_FUNC_NAME, response, HREQ_MODEM_GET_MEID, &HDI::Ril::V1_1::IRil::GetMeid); @@ -100,6 +105,13 @@ int32_t TelRilModem::GetImeiResponse(const HDI::Ril::V1_1::RilRadioResponseInfo return Response(TELEPHONY_LOG_FUNC_NAME, responseInfo, std::make_shared(imei)); } +int32_t TelRilModem::GetImeiSvResponse( + const HDI::Ril::V1_1::RilRadioResponseInfo &responseInfo, const std::string &imeiSv) +{ + return Response( + TELEPHONY_LOG_FUNC_NAME, responseInfo, std::make_shared(imeiSv)); +} + int32_t TelRilModem::GetMeidResponse(const HDI::Ril::V1_1::RilRadioResponseInfo &responseInfo, const std::string &meid) { return Response(TELEPHONY_LOG_FUNC_NAME, responseInfo, std::make_shared(meid)); diff --git a/services/tel_ril/src/tel_ril_network.cpp b/services/tel_ril/src/tel_ril_network.cpp index b0ca479b9..dd51f2389 100644 --- a/services/tel_ril/src/tel_ril_network.cpp +++ b/services/tel_ril/src/tel_ril_network.cpp @@ -26,7 +26,7 @@ using OHOS::IRemoteObject; using OHOS::sptr; namespace OHOS { namespace Telephony { -TelRilNetwork::TelRilNetwork(int32_t slotId, sptr rilInterface, +TelRilNetwork::TelRilNetwork(int32_t slotId, sptr rilInterface, std::shared_ptr observerHandler, std::shared_ptr handler) : TelRilBase(slotId, rilInterface, observerHandler, handler) {} diff --git a/services/tel_ril/src/tel_ril_sim.cpp b/services/tel_ril/src/tel_ril_sim.cpp index dd68f0898..d8dfe1890 100644 --- a/services/tel_ril/src/tel_ril_sim.cpp +++ b/services/tel_ril/src/tel_ril_sim.cpp @@ -23,7 +23,7 @@ namespace OHOS { namespace Telephony { -TelRilSim::TelRilSim(int32_t slotId, sptr rilInterface, +TelRilSim::TelRilSim(int32_t slotId, sptr rilInterface, std::shared_ptr observerHandler, std::shared_ptr handler) : TelRilBase(slotId, rilInterface, observerHandler, handler) {} diff --git a/services/tel_ril/src/tel_ril_sms.cpp b/services/tel_ril/src/tel_ril_sms.cpp index 20b8cd157..b73d23015 100644 --- a/services/tel_ril/src/tel_ril_sms.cpp +++ b/services/tel_ril/src/tel_ril_sms.cpp @@ -22,7 +22,7 @@ namespace OHOS { namespace Telephony { -TelRilSms::TelRilSms(int32_t slotId, sptr rilInterface, +TelRilSms::TelRilSms(int32_t slotId, sptr rilInterface, std::shared_ptr observerHandler, std::shared_ptr handler) : TelRilBase(slotId, rilInterface, observerHandler, handler) {} diff --git a/services/tel_ril/test/tel_ril_test.cpp b/services/tel_ril/test/tel_ril_test.cpp old mode 100755 new mode 100644 index 847f278be..a0f06038f --- a/services/tel_ril/test/tel_ril_test.cpp +++ b/services/tel_ril/test/tel_ril_test.cpp @@ -177,6 +177,7 @@ void TelRilTest::OnInitNetwork() memberFuncMap_[DiffInterfaceId::TEST_GET_PREFERRED_NETWORK_TYPE] = &TelRilTest::OnRequestGetPreferredNetworkTest; memberFuncMap_[DiffInterfaceId::TEST_SET_PREFERRED_NETWORK_TYPE] = &TelRilTest::OnRequestSetPreferredNetworkTest; memberFuncMap_[DiffInterfaceId::TEST_GET_IMEI] = &TelRilTest::OnRequestGetImeiTest; + memberFuncMap_[DiffInterfaceId::TEST_GET_IMEISV] = &TelRilTest::OnRequestGetImeiSvTest; memberFuncMap_[DiffInterfaceId::TEST_GET_BASEBAND_VERSION] = &TelRilTest::OnRequestGetBasebandVersionTest; memberFuncMap_[DiffInterfaceId::TEST_GET_MEID] = &TelRilTest::OnRequestGetMeidTest; memberFuncMap_[DiffInterfaceId::TEST_GET_CS_REG_STATUS] = &TelRilTest::OnRequestGetCsRegStatusTest; @@ -1431,6 +1432,17 @@ void TelRilTest::OnRequestGetImeiTest(int32_t slotId, const std::shared_ptr &handler) +{ + auto event = AppExecFwk::InnerEvent::Get(TYPESBITMAP); + if (event != nullptr && telRilManager_ != nullptr) { + event->SetOwner(handler); + TELEPHONY_LOGI("TelRilTest::OnRequestGetImeiSvTest -->"); + telRilManager_->GetImeiSv(slotId, event); + TELEPHONY_LOGI("OnRequestGetImeiSvTest finished"); + } +} + void TelRilTest::OnRequestGetBasebandVersionTest(int32_t slotId, const std::shared_ptr &handler) { @@ -2144,6 +2156,7 @@ void Promote() cout << static_cast(DiffInterfaceId::TEST_SET_POWER_STATE) << " --> OnRequestSetRadioStateTest" << endl; cout << static_cast(DiffInterfaceId::TEST_GET_POWER_STATE) << " --> OnRequestGetRadioStateTest" << endl; cout << static_cast(DiffInterfaceId::TEST_GET_IMEI) << "--> OnRequestGetImeiTest" << endl; + cout << static_cast(DiffInterfaceId::TEST_GET_IMEISV) << "--> OnRequestGetImeiSvTest" << endl; cout << static_cast(DiffInterfaceId::TEST_GET_BASEBAND_VERSION) << "--> OnRequestGetBasebandVersionTest" << endl; cout << static_cast(DiffInterfaceId::TEST_GET_MEID) << "--> OnRequestGetMeidTest" << endl; diff --git a/services/tel_ril/test/tel_ril_test.h b/services/tel_ril/test/tel_ril_test.h index 7559b9d92..d72b5ef3d 100644 --- a/services/tel_ril/test/tel_ril_test.h +++ b/services/tel_ril/test/tel_ril_test.h @@ -113,6 +113,7 @@ enum class DiffInterfaceId { TEST_GET_PREFERRED_NETWORK_TYPE, TEST_SET_PREFERRED_NETWORK_TYPE, TEST_GET_IMEI, + TEST_GET_IMEISV, TEST_GET_BASEBAND_VERSION, TEST_GET_MEID, TEST_SET_CALL_PREFERENCE_MODE, diff --git a/telephonyres/main/resources/base/element/string.json b/telephonyres/main/resources/base/element/string.json old mode 100755 new mode 100644 index 40c73b0f5..fc203f428 --- a/telephonyres/main/resources/base/element/string.json +++ b/telephonyres/main/resources/base/element/string.json @@ -240,6 +240,14 @@ "name": "call_failed_imei_not_accepted", "value": "IMSI unavailable, please insert a valid SIM card" }, + { + "name": "call_failed_imsiSv_unknow", + "value": "IMEISV unkown, please insert a valid SIM card" + }, + { + "name": "call_failed_imeiSv_not_accepted", + "value": "IMSISV unavailable, please insert a valid SIM card" + }, { "name": "call_failed_dial_modify_to_ussd", "value": "Call modified to USSD request" diff --git a/test/fuzztest/sendsmsmoremode_fuzzer/BUILD.gn b/test/fuzztest/sendsmsmoremode_fuzzer/BUILD.gn index f7e2537c2..e1e29b3dc 100644 --- a/test/fuzztest/sendsmsmoremode_fuzzer/BUILD.gn +++ b/test/fuzztest/sendsmsmoremode_fuzzer/BUILD.gn @@ -58,6 +58,7 @@ ohos_fuzztest("SendSmsMoreModeFuzzTest") { "drivers_interface_ril:hril_innerkits", "drivers_interface_ril:libril_proxy_1.1", "drivers_interface_ril:libril_proxy_1.2", + "drivers_interface_ril:libril_proxy_1.3", "eventhandler:libeventhandler", "hdf_core:libhdi", "hdf_core:libpub_utils", diff --git a/test/fuzztest/sendsmsmoremode_fuzzer/sendsmsmoremode_fuzzer.cpp b/test/fuzztest/sendsmsmoremode_fuzzer/sendsmsmoremode_fuzzer.cpp index 10cc77e76..276df7cd3 100644 --- a/test/fuzztest/sendsmsmoremode_fuzzer/sendsmsmoremode_fuzzer.cpp +++ b/test/fuzztest/sendsmsmoremode_fuzzer/sendsmsmoremode_fuzzer.cpp @@ -50,7 +50,7 @@ void SendSmsMoreMode(const uint8_t *data, size_t size) std::string address(reinterpret_cast(data), size); std::unique_ptr object = std::make_unique(*data); AppExecFwk::InnerEvent::Pointer response = AppExecFwk::InnerEvent::Get(responseId, object); - auto rilInterface_ = HDI::Ril::V1_2::IRil::Get(); + auto rilInterface_ = HDI::Ril::V1_3::IRil::Get(); std::shared_ptr observerHandler = std::make_shared(); auto telRilSms = std::make_shared(slotId, rilInterface_, observerHandler, nullptr); telRilSms->SendSmsMoreMode(smscPdu, pdu, response); @@ -85,7 +85,7 @@ void GetCallList(const uint8_t *data, size_t size) std::string newPassword(reinterpret_cast(data), size); std::unique_ptr object = std::make_unique(*data); AppExecFwk::InnerEvent::Pointer result = AppExecFwk::InnerEvent::Get(resultId, object); - auto rilInterface_ = HDI::Ril::V1_2::IRil::Get(); + auto rilInterface_ = HDI::Ril::V1_3::IRil::Get(); std::shared_ptr observerHandler = std::make_shared(); auto telRilCall = std::make_shared(slotId, rilInterface_, observerHandler, nullptr); telRilCall->GetCallList(result); @@ -120,7 +120,7 @@ void AnswerResponse(const uint8_t *data, size_t size) AppExecFwk::InnerEvent::Pointer result = AppExecFwk::InnerEvent::Get(resultId, object); HDI::Ril::V1_1::RilRadioResponseInfo responseInfo; responseInfo.slotId = slotId; - auto rilInterface_ = HDI::Ril::V1_2::IRil::Get(); + auto rilInterface_ = HDI::Ril::V1_3::IRil::Get(); std::shared_ptr observerHandler = std::make_shared(); auto telRilCall = std::make_shared(slotId, rilInterface_, observerHandler, nullptr); telRilCall->HoldCall(result); @@ -161,7 +161,7 @@ void DeactivatePdpContext(const uint8_t *data, size_t size) dataProfile.userName = userName; dataProfile.password = password; dataProfile.roamingProtocol = roamingProtocol; - auto rilInterface_ = HDI::Ril::V1_2::IRil::Get(); + auto rilInterface_ = HDI::Ril::V1_3::IRil::Get(); std::shared_ptr observerHandler = std::make_shared(); auto telRilData = std::make_shared(slotId, rilInterface_, observerHandler, nullptr); telRilData->DeactivatePdpContext(cid, reason, response); @@ -187,7 +187,7 @@ void SimStkProactiveNotify(const uint8_t *data, size_t size) std::string response(reinterpret_cast(data), size); HDI::Ril::V1_1::RilRadioResponseInfo responseInfo; responseInfo.slotId = slotId; - auto rilInterface_ = HDI::Ril::V1_2::IRil::Get(); + auto rilInterface_ = HDI::Ril::V1_3::IRil::Get(); std::shared_ptr observerHandler = std::make_shared(); auto telRilSim = std::make_shared(slotId, rilInterface_, observerHandler, nullptr); telRilSim->SimStkProactiveNotify(response); @@ -228,7 +228,7 @@ void GetSimStatus(const uint8_t *data, size_t size) simIoInfo.aid = aid; std::unique_ptr object = std::make_unique(*data); AppExecFwk::InnerEvent::Pointer result = AppExecFwk::InnerEvent::Get(resultId, object); - auto rilInterface_ = HDI::Ril::V1_2::IRil::Get(); + auto rilInterface_ = HDI::Ril::V1_3::IRil::Get(); std::shared_ptr observerHandler = std::make_shared(); auto telRilSim = std::make_shared(slotId, rilInterface_, observerHandler, nullptr); telRilSim->GetSimStatus(result); diff --git a/test/fuzztest/sendterminalresponsecmd_fuzzer/sendterminalresponsecmd_fuzzer.cpp b/test/fuzztest/sendterminalresponsecmd_fuzzer/sendterminalresponsecmd_fuzzer.cpp index 5403bdcb7..353edbbef 100644 --- a/test/fuzztest/sendterminalresponsecmd_fuzzer/sendterminalresponsecmd_fuzzer.cpp +++ b/test/fuzztest/sendterminalresponsecmd_fuzzer/sendterminalresponsecmd_fuzzer.cpp @@ -79,6 +79,21 @@ void GetImei(const uint8_t *data, size_t size) DelayedSingleton::GetInstance()->OnGetImei(dataMessageParcel, reply); } +void GetImeiSv(const uint8_t *data, size_t size) +{ + if (!IsServiceInited()) { + return; + } + + int32_t slotId = static_cast(size % SLOT_NUM); + MessageParcel dataMessageParcel; + dataMessageParcel.WriteInt32(slotId); + dataMessageParcel.WriteBuffer(data, size); + dataMessageParcel.RewindRead(0); + MessageParcel reply; + DelayedSingleton::GetInstance()->OnGetImeiSv(dataMessageParcel, reply); +} + void GetSimOperatorNumeric(const uint8_t *data, size_t size) { if (!IsServiceInited()) { @@ -133,6 +148,7 @@ void DoSomethingInterestingWithMyAPI(const uint8_t *data, size_t size) GetNetworkState(data, size); GetImei(data, size); + GetImeiSv(data, size); GetNetworkState(data, size); GetISOCountryCodeForSim(data, size); SendTerminalResponseCmd(data, size); diff --git a/test/unittest/core_service_gtest/network_search_test.cpp b/test/unittest/core_service_gtest/network_search_test.cpp old mode 100755 new mode 100644 index 44b9a339a..88201b78e --- a/test/unittest/core_service_gtest/network_search_test.cpp +++ b/test/unittest/core_service_gtest/network_search_test.cpp @@ -1621,6 +1621,63 @@ HWTEST_F(NetworkSearchTest, Telephony_NetworkSearch_GetImei_0300, Function | Med EXPECT_EQ(ret, TELEPHONY_ERR_PERMISSION_ERR); } +/** + * @tc.number Telephony_NetworkSearch_GetImeiSv_0100 + * @tc.name Get ImeiSv + * @tc.desc Function test + */ +HWTEST_F(NetworkSearchTest, Telephony_NetworkSearch_GetImeiSv_0100, Function | MediumTest | Level2) +{ + AccessToken token; + if (NetworkSearchTest::telephonyService_ == nullptr || !(NetworkSearchTest::HasSimCard(SLOT_ID))) { + TELEPHONY_LOGI("TelephonyTestService Remote service is null"); + NetworkSearchTest::telephonyService_ = GetProxy(); + } else { + std::u16string result = u""; + int32_t ret = CoreServiceClient::GetInstance().GetImeiSv(SLOT_ID, result); + EXPECT_EQ(ret, TELEPHONY_ERR_SUCCESS); + std::string imei = Str16ToStr8(result); + EXPECT_STRNE(imei.c_str(), ""); + } +} + +/** + * @tc.number Telephony_NetworkSearch_GetImeiSv_0200 + * @tc.name Get ImeiSv + * @tc.desc Function test + */ +HWTEST_F(NetworkSearchTest, Telephony_NetworkSearch_GetImeiSv_0200, Function | MediumTest | Level2) +{ + AccessToken token; + if (NetworkSearchTest::telephonyService_ == nullptr || !(NetworkSearchTest::HasSimCard(SLOT_ID1))) { + TELEPHONY_LOGI("TelephonyTestService Remote service is null"); + NetworkSearchTest::telephonyService_ = GetProxy(); + } else { + std::u16string result = u""; + int32_t ret = CoreServiceClient::GetInstance().GetImeiSv(SLOT_ID1, result); + EXPECT_EQ(ret, TELEPHONY_ERR_SUCCESS); + std::string imei = Str16ToStr8(result); + EXPECT_STRNE(imei.c_str(), ""); + } +} + +/** + * @tc.number Telephony_NetworkSearch_GetImeiSv_0300 + * @tc.name Get ImeiSv without permission + * @tc.desc Function test + */ +HWTEST_F(NetworkSearchTest, Telephony_NetworkSearch_GetImeiSv_0300, Function | MediumTest | Level2) +{ + if (NetworkSearchTest::telephonyService_ == nullptr || !(NetworkSearchTest::HasSimCard(SLOT_ID))) { + TELEPHONY_LOGI("TelephonyTestService Remote service is null"); + NetworkSearchTest::telephonyService_ = GetProxy(); + return; + } + std::u16string result = u""; + int32_t ret = CoreServiceClient::GetInstance().GetImeiSv(SLOT_ID, result); + EXPECT_EQ(ret, TELEPHONY_ERR_PERMISSION_ERR); +} + /** * @tc.number Telephony_NetworkSearch_GetMeid_0100 * @tc.name Get Meid diff --git a/test/unittest/core_service_gtest/sim_core_service_test.cpp b/test/unittest/core_service_gtest/sim_core_service_test.cpp index e1eecd124..60c773d6d 100644 --- a/test/unittest/core_service_gtest/sim_core_service_test.cpp +++ b/test/unittest/core_service_gtest/sim_core_service_test.cpp @@ -46,6 +46,7 @@ HWTEST_F(SimTest, Telephony_Sim_CoreService_0100, Function | MediumTest | Level3 mCoreService->SetRadioState(0, true, callback); std::u16string testU16Str = u""; EXPECT_NE(mCoreService->GetImei(0, testU16Str), TELEPHONY_ERR_SUCCESS); + EXPECT_NE(mCoreService->GetImeiSv(0, testU16Str), TELEPHONY_ERR_SUCCESS); EXPECT_NE(mCoreService->GetMeid(0, testU16Str), TELEPHONY_ERR_SUCCESS); EXPECT_NE(mCoreService->GetUniqueDeviceId(0, testU16Str), TELEPHONY_ERR_SUCCESS); EXPECT_NE(mCoreService->GetNrOptionMode(0, callback), TELEPHONY_ERR_SUCCESS); @@ -192,6 +193,7 @@ HWTEST_F(SimTest, Telephony_Sim_CoreService_0400, Function | MediumTest | Level3 mCoreService->SetRadioState(0, true, callback); std::u16string testU16Str = u""; EXPECT_NE(mCoreService->GetImei(0, testU16Str), TELEPHONY_ERR_SUCCESS); + EXPECT_NE(mCoreService->GetImeiSv(0, testU16Str), TELEPHONY_ERR_SUCCESS); EXPECT_NE(mCoreService->GetMeid(0, testU16Str), TELEPHONY_ERR_SUCCESS); EXPECT_NE(mCoreService->GetUniqueDeviceId(0, testU16Str), TELEPHONY_ERR_SUCCESS); EXPECT_NE(mCoreService->GetNrOptionMode(0, callback), 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 bd7fb16b1..2a3af5f3d 100644 --- a/test/unittest/core_service_gtest/zero_branch_test.cpp +++ b/test/unittest/core_service_gtest/zero_branch_test.cpp @@ -974,6 +974,8 @@ HWTEST_F(BranchTest, Telephony_CoreManagerInner_003, Function | MediumTest | Lev std::u16string result = u""; EXPECT_NE(mInner.GetImei(0, result), TELEPHONY_ERR_SUCCESS); EXPECT_EQ(result, std::u16string()); + EXPECT_NE(mInner.GetImeiSv(0, result), TELEPHONY_ERR_SUCCESS); + EXPECT_EQ(result, std::u16string()); EXPECT_NE(mInner.GetMeid(0, result), TELEPHONY_ERR_SUCCESS); EXPECT_EQ(result, std::u16string()); EXPECT_NE(mInner.GetUniqueDeviceId(0, result), TELEPHONY_ERR_SUCCESS); @@ -1941,6 +1943,8 @@ HWTEST_F(BranchTest, Telephony_NetworkSearchManager_001, Function | MediumTest | EXPECT_EQ(result, testStr); EXPECT_NE(networkSearchManager->GetImei(INVALID_SLOTID, result), TELEPHONY_ERR_SUCCESS); EXPECT_EQ(result, testStr); + EXPECT_NE(networkSearchManager->GetImeiSv(INVALID_SLOTID, result), TELEPHONY_ERR_SUCCESS); + EXPECT_EQ(result, testStr); EXPECT_EQ(networkSearchManager->GetImsRegStatus(INVALID_SLOTID, ImsServiceType::TYPE_SMS, info), TELEPHONY_ERR_LOCAL_PTR_NULL); EXPECT_NE(networkSearchManager->GetUniqueDeviceId(INVALID_SLOTID, result), TELEPHONY_ERR_SUCCESS); @@ -1970,6 +1974,7 @@ HWTEST_F(BranchTest, Telephony_NetworkSearchManager_002, Function | MediumTest | inner->networkSearchHandler_ = networkSearchHandler; std::string bundleName = "qwe"; std::u16string imei = u""; + std::u16string imeiSv = u""; sptr callback = nullptr; networkSearchManager->SetLocateUpdate(INVALID_SLOTID); networkSearchManager->GetVoiceTech(INVALID_SLOTID); @@ -1989,6 +1994,7 @@ HWTEST_F(BranchTest, Telephony_NetworkSearchManager_002, Function | MediumTest | networkSearchManager->SetRadioStateValue(INVALID_SLOTID, ModemPowerState::CORE_SERVICE_POWER_NOT_AVAILABLE); networkSearchManager->SetNetworkSelectionValue(INVALID_SLOTID, SelectionMode::MODE_TYPE_UNKNOWN); networkSearchManager->SetImei(INVALID_SLOTID, imei); + networkSearchManager->SetImeiSv(INVALID_SLOTID, imeiSv); networkSearchManager->UpdateCellLocation(INVALID_SLOTID, 1, 1, 1); networkSearchManager->SetMeid(INVALID_SLOTID, imei); networkSearchManager->SetFrequencyType(INVALID_SLOTID, FrequencyType::FREQ_TYPE_MMWAVE); @@ -2246,6 +2252,7 @@ HWTEST_F(BranchTest, Telephony_NetworkSearchHandler_001, Function | MediumTest | networkSearchHandler->GetPreferredNetworkResponse(event); networkSearchHandler->SetPreferredNetworkResponse(event); networkSearchHandler->RadioGetImei(event); + networkSearchHandler->RadioGetImeiSv(event); networkSearchHandler->RadioGetMeid(event); event = nullptr; networkSearchHandler->ProcessEvent(event); @@ -2347,6 +2354,7 @@ HWTEST_F(BranchTest, Telephony_NetworkSearchHandler_003, Function | MediumTest | networkSearchHandler->HandleDelayNotifyEvent(event); networkSearchHandler->NetworkSearchResult(event); networkSearchHandler->RadioGetNeighboringCellInfo(event); + networkSearchHandler->RadioGetImeiSv(event); EXPECT_EQ(networkSearchHandler->GetRegServiceState(regState), TELEPHONY_ERR_LOCAL_PTR_NULL); EXPECT_EQ(networkSearchHandler->HandleRrcStateChanged(status), TELEPHONY_ERR_LOCAL_PTR_NULL); EXPECT_EQ(networkSearchHandler->RevertLastTechnology(), TELEPHONY_ERR_LOCAL_PTR_NULL); diff --git a/test/unittest/core_service_gtest/zero_branch_test_core_service.cpp b/test/unittest/core_service_gtest/zero_branch_test_core_service.cpp index bd63a2699..8440047ec 100644 --- a/test/unittest/core_service_gtest/zero_branch_test_core_service.cpp +++ b/test/unittest/core_service_gtest/zero_branch_test_core_service.cpp @@ -146,6 +146,7 @@ HWTEST_F(CoreServiceBranchTest, Telephony_CoreService_NetWork_002, Function | Me std::u16string u16Ret = u""; DelayedSingleton::GetInstance()->GetIsoCountryCodeForNetwork(SLOT_ID, u16Ret); DelayedSingleton::GetInstance()->GetImei(SLOT_ID, u16Ret); + DelayedSingleton::GetInstance()->GetImeiSv(SLOT_ID, u16Ret); DelayedSingleton::GetInstance()->GetMeid(SLOT_ID, u16Ret); DelayedSingleton::GetInstance()->GetUniqueDeviceId(SLOT_ID, u16Ret); DelayedSingleton::GetInstance()->IsNrSupported(SLOT_ID); diff --git a/test/unittest/tel_ril_gtest/BUILD.gn b/test/unittest/tel_ril_gtest/BUILD.gn index 67ce90765..259944825 100644 --- a/test/unittest/tel_ril_gtest/BUILD.gn +++ b/test/unittest/tel_ril_gtest/BUILD.gn @@ -54,6 +54,7 @@ ohos_unittest("tel_ril_gtest") { "drivers_interface_ril:hril_innerkits", "drivers_interface_ril:libril_proxy_1.1", "drivers_interface_ril:libril_proxy_1.2", + "drivers_interface_ril:libril_proxy_1.3", "drivers_interface_ril:ril_idl_headers", "eventhandler:libeventhandler", "hdf_core:libhdi", diff --git a/test/unittest/tel_ril_gtest/tel_ril_network_test.cpp b/test/unittest/tel_ril_gtest/tel_ril_network_test.cpp index e37dab0f1..85af3f82b 100644 --- a/test/unittest/tel_ril_gtest/tel_ril_network_test.cpp +++ b/test/unittest/tel_ril_gtest/tel_ril_network_test.cpp @@ -259,6 +259,28 @@ HWTEST_F(TelRilTest, Telephony_TelRil_GetImeiTest_0201, Function | MediumTest | return; } +/** + * @tc.number Telephony_TelRil_GetImeiSvTest_0101 to do ... + * @tc.name Get ImeiSv information of the card 1 + * @tc.desc Function test + */ +HWTEST_F(TelRilTest, Telephony_TelRil_GetImeiSvTest_0101, Function | MediumTest | Level3) +{ + ASSERT_TRUE(ProcessTest(static_cast(DiffInterfaceId::TEST_GET_IMEISV), SLOT_ID_0, GetHandler())); + return; +} + +/** + * @tc.number Telephony_TelRil_GetImeiSvTest_0201 to do ... + * @tc.name Get ImeiSv information of the card 2 + * @tc.desc Function test + */ +HWTEST_F(TelRilTest, Telephony_TelRil_GetImeiSvTest_0201, Function | MediumTest | Level3) +{ + ASSERT_TRUE(ProcessTest(static_cast(DiffInterfaceId::TEST_GET_IMEISV), SLOT_ID_1, GetHandler())); + return; +} + /** * @tc.number Telephony_TelRil_GetMeidTest_0101 to do ... * @tc.name Get Meid information of the card 1 diff --git a/test/unittest/tel_ril_gtest/tel_ril_test_util.cpp b/test/unittest/tel_ril_gtest/tel_ril_test_util.cpp old mode 100755 new mode 100644 index 73a2f2146..730a10df5 --- a/test/unittest/tel_ril_gtest/tel_ril_test_util.cpp +++ b/test/unittest/tel_ril_gtest/tel_ril_test_util.cpp @@ -273,6 +273,7 @@ void TelRilTest::InitNetwork() memberFuncMap_[DiffInterfaceId::TEST_GET_PREFERRED_NETWORK_TYPE] = &TelRilTest::GetPreferredNetworkParaTest; memberFuncMap_[DiffInterfaceId::TEST_SET_PREFERRED_NETWORK_TYPE] = &TelRilTest::SetPreferredNetworkParaTest; memberFuncMap_[DiffInterfaceId::TEST_GET_IMEI] = &TelRilTest::GetImeiTest; + memberFuncMap_[DiffInterfaceId::TEST_GET_IMEISV] = &TelRilTest::GetImeiSvTest; memberFuncMap_[DiffInterfaceId::TEST_GET_MEID] = &TelRilTest::GetMeidTest; memberFuncMap_[DiffInterfaceId::TEST_GET_VOICE_RADIO_INFO] = &TelRilTest::GetVoiceRadioTechnologyTest; memberFuncMap_[DiffInterfaceId::TEST_GET_PHYSICAL_CHANNEL_CONFIG] = &TelRilTest::GetPhysicalChannelConfigTest; @@ -1675,6 +1676,25 @@ void TelRilTest::GetImeiTest(int32_t slotId, std::shared_ptr handler) +{ + int32_t eventId = static_cast(DiffInterfaceId::TEST_GET_IMEISV); + auto event = AppExecFwk::InnerEvent::Get(eventId); + if (event != nullptr && telRilManager_ != nullptr) { + event->SetOwner(handler); + TELEPHONY_LOGI("TelRilTest::GetImeisVTest -->"); + telRilManager_->GetImeiSv(slotId, event); + TELEPHONY_LOGI("TelRilTest::GetImeiSvTest --> finished"); + bool syncResult = WaitGetResult(eventId, handler, WAIT_TIME_SECOND); + ASSERT_TRUE(syncResult); + } +} + /** * @brief Get MEID * diff --git a/test/unittest/tel_ril_gtest/tel_ril_test_util.h b/test/unittest/tel_ril_gtest/tel_ril_test_util.h old mode 100755 new mode 100644 index ffddc5f1b..eccaab6f4 --- a/test/unittest/tel_ril_gtest/tel_ril_test_util.h +++ b/test/unittest/tel_ril_gtest/tel_ril_test_util.h @@ -113,6 +113,7 @@ enum class DiffInterfaceId { TEST_GET_PREFERRED_NETWORK_TYPE, TEST_SET_PREFERRED_NETWORK_TYPE, TEST_GET_IMEI, + TEST_GET_IMEISV, TEST_GET_MEID, TEST_GET_RADIO_PROTOCOL, TEST_SET_RADIO_PROTOCOL, @@ -267,6 +268,7 @@ private: void SetPreferredNetworkParaTest(int32_t slotId, std::shared_ptr handler); void GetPreferredNetworkParaTest(int32_t slotId, std::shared_ptr handler); void GetImeiTest(int32_t slotId, std::shared_ptr handler); + void GetImeiSvTest(int32_t slotId, std::shared_ptr handler); void GetMeidTest(int32_t slotId, std::shared_ptr handler); void GetVoiceRadioTechnologyTest(int32_t slotId, std::shared_ptr handler); void GetPhysicalChannelConfigTest(int32_t slotId, std::shared_ptr handler); diff --git a/test/unittest/tel_ril_gtest/zero_branch_test_tel_ril.cpp b/test/unittest/tel_ril_gtest/zero_branch_test_tel_ril.cpp index e61f6cdce..52baf0e22 100644 --- a/test/unittest/tel_ril_gtest/zero_branch_test_tel_ril.cpp +++ b/test/unittest/tel_ril_gtest/zero_branch_test_tel_ril.cpp @@ -107,7 +107,7 @@ HWTEST_F(TelRilBranchTest, Telephony_tel_ril_Callback_001, Function | MediumTest HWTEST_F(TelRilBranchTest, Telephony_tel_ril_Base_001, Function | MediumTest | Level1) { TELEPHONY_LOGI("Telephony_tel_ril_Base_001 entry"); - auto rilInterface = HDI::Ril::V1_2::IRil::Get(); + auto rilInterface = HDI::Ril::V1_3::IRil::Get(); std::shared_ptr observerHandler = std::make_shared(); auto telRilBase = std::make_shared(SLOT_ID, rilInterface, observerHandler, nullptr); AppExecFwk::InnerEvent::Pointer event = AppExecFwk::InnerEvent::Get(1, 1); @@ -151,7 +151,7 @@ HWTEST_F(TelRilBranchTest, Telephony_tel_ril_Base_001, Function | MediumTest | L HWTEST_F(TelRilBranchTest, Telephony_tel_ril_Network_001, Function | MediumTest | Level1) { TELEPHONY_LOGI("Telephony_tel_ril_Network_001 entry"); - auto rilInterface = HDI::Ril::V1_2::IRil::Get(); + auto rilInterface = HDI::Ril::V1_3::IRil::Get(); std::shared_ptr observerHandler = std::make_shared(); auto telRilNetwork = std::make_shared(SLOT_ID, rilInterface, observerHandler, nullptr); @@ -182,7 +182,7 @@ HWTEST_F(TelRilBranchTest, Telephony_tel_ril_Network_001, Function | MediumTest HWTEST_F(TelRilBranchTest, Telephony_tel_ril_Sms_001, Function | MediumTest | Level1) { TELEPHONY_LOGI("Telephony_tel_ril_Sms_001 entry"); - auto rilInterface = HDI::Ril::V1_2::IRil::Get(); + auto rilInterface = HDI::Ril::V1_3::IRil::Get(); std::shared_ptr observerHandler = std::make_shared(); auto telRilSms = std::make_shared(SLOT_ID, rilInterface, observerHandler, nullptr); @@ -251,7 +251,7 @@ HWTEST_F(TelRilBranchTest, Telephony_observerhandler_001, Function | MediumTest HWTEST_F(TelRilBranchTest, Telephony_tel_ril_Modem_001, Function | MediumTest | Level1) { TELEPHONY_LOGI("Telephony_tel_ril_Modem_001 entry"); - auto rilInterface = HDI::Ril::V1_2::IRil::Get(); + auto rilInterface = HDI::Ril::V1_3::IRil::Get(); std::shared_ptr observerHandler = std::make_shared(); auto telRilModem = std::make_shared(SLOT_ID, rilInterface, observerHandler, nullptr); HDI::Ril::V1_1::VoiceRadioTechnology voiceRadioTechnology; @@ -268,7 +268,7 @@ HWTEST_F(TelRilBranchTest, Telephony_tel_ril_Modem_001, Function | MediumTest | HWTEST_F(TelRilBranchTest, Telephony_tel_ril_Data_001, Function | MediumTest | Level1) { TELEPHONY_LOGI("Telephony_tel_ril_Data_001 entry"); - auto rilInterface = HDI::Ril::V1_2::IRil::Get(); + auto rilInterface = HDI::Ril::V1_3::IRil::Get(); std::shared_ptr observerHandler = std::make_shared(); auto telRilData = std::make_shared(SLOT_ID, rilInterface, observerHandler, nullptr); HDI::Ril::V1_1::DataCallResultList iDataCallResultList; @@ -289,7 +289,7 @@ HWTEST_F(TelRilBranchTest, Telephony_tel_ril_Data_001, Function | MediumTest | L HWTEST_F(TelRilBranchTest, Telephony_tel_ril_Sim_001, Function | MediumTest | Level1) { TELEPHONY_LOGI("Telephony_tel_ril_Sim_001 entry"); - auto rilInterface = HDI::Ril::V1_2::IRil::Get(); + auto rilInterface = HDI::Ril::V1_3::IRil::Get(); std::shared_ptr observerHandler = std::make_shared(); auto telRilSim = std::make_shared(SLOT_ID, rilInterface, observerHandler, nullptr); @@ -326,7 +326,7 @@ HWTEST_F(TelRilBranchTest, Telephony_tel_ril_Sim_001, Function | MediumTest | Le HWTEST_F(TelRilBranchTest, Telephony_tel_ril_Call_001, Function | MediumTest | Level1) { TELEPHONY_LOGI("Telephony_tel_ril_Call_001 entry"); - auto rilInterface = HDI::Ril::V1_2::IRil::Get(); + auto rilInterface = HDI::Ril::V1_3::IRil::Get(); std::shared_ptr observerHandler = std::make_shared(); auto telRilCall = std::make_shared(SLOT_ID, rilInterface, observerHandler, nullptr);