From e8c72f673454439445a3600eceee2079dce7e804 Mon Sep 17 00:00:00 2001 From: zhangwuling1 Date: Wed, 19 Mar 2025 17:45:30 +0800 Subject: [PATCH 001/145] networkslice_for_cellulardata Signed-off-by: zhangwuling1 --- BUILD.gn | 1 + bundle.json | 3 +- frameworks/native/cellular_data_client.cpp | 62 +++++++- .../native/cellular_data_service_proxy.cpp | 150 ++++++++++++++++++ .../native/cellular_data_service_proxy.h | 10 ++ interfaces/innerkits/cellular_data_client.h | 45 ++++++ .../cellular_data_ipc_interface_code.h | 5 + .../innerkits/i_cellular_data_manager.h | 10 ++ services/include/apn_manager/apn_item.h | 6 + services/include/cellular_data_service.h | 5 + services/include/cellular_data_service_stub.h | 17 +- .../include/common/cellular_data_constant.h | 28 +++- .../include/common/cellular_data_event_code.h | 6 + services/include/data_connection_manager.h | 3 + .../cellular_data_state_machine.h | 2 + services/src/apn_manager/apn_holder.cpp | 6 + services/src/apn_manager/apn_item.cpp | 2 +- services/src/apn_manager/apn_manager.cpp | 68 +++++++- services/src/cellular_data_service.cpp | 39 ++++- services/src/cellular_data_service_stub.cpp | 84 ++++++++++ services/src/data_connection_manager.cpp | 58 +++++++ .../cellular_data_state_machine.cpp | 97 ++++++++++- .../src/utils/cellular_data_net_agent.cpp | 3 +- test/apn_manager_test.cpp | 78 +++++++++ test/cellular_data_client_test.cpp | 60 +++++++ test/cellular_data_service_test.cpp | 7 + 26 files changed, 836 insertions(+), 19 deletions(-) diff --git a/BUILD.gn b/BUILD.gn index ef84a838..4b4a285d 100644 --- a/BUILD.gn +++ b/BUILD.gn @@ -103,6 +103,7 @@ ohos_shared_library("tel_cellular_data") { "safwk:system_ability_fwk", "samgr:samgr_proxy", "telephony_data:tel_telephony_data", + "netmanager_ext:networkslice_manager_if", ] defines = [ diff --git a/bundle.json b/bundle.json index a3b55ab9..31ab5182 100644 --- a/bundle.json +++ b/bundle.json @@ -52,7 +52,8 @@ "safwk", "samgr", "telephony_data", - "power_manager" + "power_manager", + "netmanager_ext" ] }, "build": { diff --git a/frameworks/native/cellular_data_client.cpp b/frameworks/native/cellular_data_client.cpp index e2c81b90..c5c493c2 100644 --- a/frameworks/native/cellular_data_client.cpp +++ b/frameworks/native/cellular_data_client.cpp @@ -470,7 +470,7 @@ int32_t CellularDataClient::GetDefaultActReportInfo(int32_t slotId, ApnActivateR } return proxy->GetDefaultActReportInfo(slotId, info); } - + int32_t CellularDataClient::GetInternalActReportInfo(int32_t slotId, ApnActivateReportInfo &info) { sptr proxy = GetProxy(); @@ -513,5 +513,65 @@ int32_t CellularDataClient::QueryAllApnInfo(std::vector &apnInfoList) TELEPHONY_LOGI("QueryAllApnInfo"); return proxy->QueryAllApnInfo(apnInfoList); } + +int32_t CellularDataClient::SendUrspDecodeResult(int32_t slotId, std::vector buffer) +{ + TELEPHONY_LOGI("CellularDataClient::SendUrspDecodeResult"); + sptr proxy = GetProxy(); + if (proxy == nullptr) { + TELEPHONY_LOGE("proxy is null"); + return TELEPHONY_ERR_IPC_CONNECT_STUB_FAIL; + } + int32_t result = proxy->SendUrspDecodeResult(slotId, buffer); + return result; +} + +int32_t CellularDataClient::SendUePolicySectionIdentifier(int32_t slotId, std::vector buffer) +{ + TELEPHONY_LOGI("CellularDataClient::SendUePolicySectionIdentifier"); + sptr proxy = GetProxy(); + if (proxy == nullptr) { + TELEPHONY_LOGE("proxy is null"); + return TELEPHONY_ERR_IPC_CONNECT_STUB_FAIL; + } + int32_t result = proxy->SendUePolicySectionIdentifier(slotId, buffer); + return result; +} + +int32_t CellularDataClient::SendImsRsdList(int32_t slotId, std::vector buffer) +{ + TELEPHONY_LOGI("CellularDataClient::SendImsRsdList"); + sptr proxy = GetProxy(); + if (proxy == nullptr) { + TELEPHONY_LOGE("proxy is null"); + return TELEPHONY_ERR_IPC_CONNECT_STUB_FAIL; + } + int32_t result = proxy->SendImsRsdList(slotId, buffer); + return result; +} + +int32_t CellularDataClient::GetNetworkSliceAllowedNssai(int32_t slotId, std::vector buffer) +{ + TELEPHONY_LOGI("CellularDataClient::GetNetworkSliceAllowedNssai"); + sptr proxy = GetProxy(); + if (proxy == nullptr) { + TELEPHONY_LOGE("proxy is null"); + return TELEPHONY_ERR_IPC_CONNECT_STUB_FAIL; + } + int32_t result = proxy->GetNetworkSliceAllowedNssai(slotId, buffer); + return result; +} + +int32_t CellularDataClient::GetNetworkSliceEhplmn(int32_t slotId) +{ + TELEPHONY_LOGI("CellularDataClient::GetNetworkSliceEhplmn"); + sptr proxy = GetProxy(); + if (proxy == nullptr) { + TELEPHONY_LOGE("proxy is null"); + return TELEPHONY_ERR_IPC_CONNECT_STUB_FAIL; + } + int32_t result = proxy->GetNetworkSliceEhplmn(slotId); + return result; +} } // namespace Telephony } // namespace OHOS diff --git a/frameworks/native/cellular_data_service_proxy.cpp b/frameworks/native/cellular_data_service_proxy.cpp index c9d16005..5b8050e9 100644 --- a/frameworks/native/cellular_data_service_proxy.cpp +++ b/frameworks/native/cellular_data_service_proxy.cpp @@ -909,5 +909,155 @@ int32_t CellularDataServiceProxy::QueryAllApnInfo(std::vector &apnInfoL return result; } +int32_t CellularDataServiceProxy::SendUrspDecodeResult(int32_t slotId, std::vector buffer) +{ + TELEPHONY_LOGI("CellularDataServiceProxy::SendUrspDecodeResult"); + MessageParcel data; + MessageParcel reply; + MessageOption option; + if (!data.WriteInterfaceToken(CellularDataServiceProxy::GetDescriptor())) { + TELEPHONY_LOGE("write interface token failed!"); + return TELEPHONY_ERR_WRITE_DESCRIPTOR_TOKEN_FAIL; + } + data.WriteInt32(slotId); + int32_t bufferlen = (int32_t)buffer.size(); + data.WriteInt32(bufferlen); + for (size_t i = 0; i < buffer.size(); ++i) { + data.WriteInt32(buffer[i]); + } + if (Remote() == nullptr) { + TELEPHONY_LOGE("remote is null"); + return TELEPHONY_ERR_IPC_CONNECT_STUB_FAIL; + } + + int32_t error = Remote()->SendRequest((uint32_t)CellularDataInterfaceCode::SEND_MANAGE_UEPOLICY_DECODE_RESULT, + data, reply, option); + if (error != TELEPHONY_SUCCESS) { + TELEPHONY_LOGE("SendUrspDecodeResult fail! errCode: %{public}d", error); + return TELEPHONY_ERR_IPC_CONNECT_STUB_FAIL; + } + int32_t result = reply.ReadInt32(); + return result; +} + +int32_t CellularDataServiceProxy::SendUePolicySectionIdentifier(int32_t slotId, std::vector buffer) +{ + TELEPHONY_LOGI("CellularDataServiceProxy::SendUePolicySectionIdentifier"); + MessageParcel data; + MessageParcel reply; + MessageOption option; + if (!data.WriteInterfaceToken(CellularDataServiceProxy::GetDescriptor())) { + TELEPHONY_LOGE("write interface token failed!"); + return TELEPHONY_ERR_WRITE_DESCRIPTOR_TOKEN_FAIL; + } + data.WriteInt32(slotId); + int32_t bufferlen = (int32_t)buffer.size(); + data.WriteInt32(bufferlen); + for (size_t i = 0; i < buffer.size(); ++i) { + data.WriteInt32(buffer[i]); + } + if (Remote() == nullptr) { + TELEPHONY_LOGE("remote is null"); + return TELEPHONY_ERR_IPC_CONNECT_STUB_FAIL; + } + + int32_t error = Remote()->SendRequest((uint32_t)CellularDataInterfaceCode::SEND_UE_STATE_INDICATION, + data, reply, option); + if (error != TELEPHONY_SUCCESS) { + TELEPHONY_LOGE("SendUePolicySectionIdentifier fail! errCode: %{public}d", error); + return TELEPHONY_ERR_IPC_CONNECT_STUB_FAIL; + } + int32_t result = reply.ReadInt32(); + return result; +} + +int32_t CellularDataServiceProxy::SendImsRsdList(int32_t slotId, std::vector buffer) +{ + TELEPHONY_LOGI("CellularDataServiceProxy::SendImsRsdList"); + MessageParcel data; + MessageParcel reply; + MessageOption option; + if (!data.WriteInterfaceToken(CellularDataServiceProxy::GetDescriptor())) { + TELEPHONY_LOGE("write interface token failed!"); + return TELEPHONY_ERR_WRITE_DESCRIPTOR_TOKEN_FAIL; + } + data.WriteInt32(slotId); + int32_t bufferlen = (int32_t)buffer.size(); + data.WriteInt32(bufferlen); + for (size_t i = 0; i < buffer.size(); ++i) { + data.WriteInt32(buffer[i]); + } + if (Remote() == nullptr) { + TELEPHONY_LOGE("remote is null"); + return TELEPHONY_ERR_IPC_CONNECT_STUB_FAIL; + } + + int32_t error = Remote()->SendRequest((uint32_t)CellularDataInterfaceCode::SEND_IMS_RSDLIST, + data, reply, option); + if (error != TELEPHONY_SUCCESS) { + TELEPHONY_LOGE("SendImsRsdList fail! errCode: %{public}d", error); + return TELEPHONY_ERR_IPC_CONNECT_STUB_FAIL; + } + int32_t result = reply.ReadInt32(); + return result; +} + +int32_t CellularDataServiceProxy::GetNetworkSliceAllowedNssai(int32_t slotId, std::vector buffer) +{ + TELEPHONY_LOGI("CellularDataServiceProxy::GetNetworkSliceAllowedNssai"); + MessageParcel data; + MessageParcel reply; + MessageOption option; + if (!data.WriteInterfaceToken(CellularDataServiceProxy::GetDescriptor())) { + TELEPHONY_LOGE("write interface token failed!"); + return TELEPHONY_ERR_WRITE_DESCRIPTOR_TOKEN_FAIL; + } + data.WriteInt32(slotId); + int32_t bufferlen = (int32_t)buffer.size(); + data.WriteInt32(bufferlen); + for (size_t i = 0; i < buffer.size(); ++i) { + data.WriteInt32(buffer[i]); + } + if (Remote() == nullptr) { + TELEPHONY_LOGE("remote is null"); + return TELEPHONY_ERR_IPC_CONNECT_STUB_FAIL; + } + + int32_t error = Remote()->SendRequest((uint32_t)CellularDataInterfaceCode::SYNC_ALLOWED_NSSAI_WITH_MODEM, + data, reply, option); + if (error != TELEPHONY_SUCCESS) { + TELEPHONY_LOGE("GetNetworkSliceAllowedNssai fail! errCode: %{public}d", error); + return TELEPHONY_ERR_IPC_CONNECT_STUB_FAIL; + } + int32_t result = reply.ReadInt32(); + return result; +} + +int32_t CellularDataServiceProxy::GetNetworkSliceEhplmn(int32_t slotId) +{ + TELEPHONY_LOGI("CellularDataServiceProxy::GetNetworkSliceEhplmn"); + MessageParcel data; + MessageParcel reply; + MessageOption option; + if (!data.WriteInterfaceToken(CellularDataServiceProxy::GetDescriptor())) { + TELEPHONY_LOGE("write interface token failed!"); + return TELEPHONY_ERR_WRITE_DESCRIPTOR_TOKEN_FAIL; + } + data.WriteInt32(slotId); + if (Remote() == nullptr) { + TELEPHONY_LOGE("remote is null"); + return TELEPHONY_ERR_IPC_CONNECT_STUB_FAIL; + } + + int32_t error = Remote()->SendRequest((uint32_t)CellularDataInterfaceCode::SYNC_EHPLMN_WITH_MODEM, + data, reply, option); + if (error != TELEPHONY_SUCCESS) { + TELEPHONY_LOGE("GetNetworkSliceEhplmn fail! errCode: %{public}d", error); + return TELEPHONY_ERR_IPC_CONNECT_STUB_FAIL; + } + int32_t result = reply.ReadInt32(); + return result; +} + } // namespace Telephony } // namespace OHOS diff --git a/frameworks/native/cellular_data_service_proxy.h b/frameworks/native/cellular_data_service_proxy.h index 33aaaa22..72b7e375 100644 --- a/frameworks/native/cellular_data_service_proxy.h +++ b/frameworks/native/cellular_data_service_proxy.h @@ -176,6 +176,16 @@ public: int32_t CorrectNetSupplierNoAvailable(int32_t slotId); int32_t GetSupplierRegisterState(uint32_t supplierId, int32_t ®State); + + int32_t SendUrspDecodeResult(int32_t slotId, std::vector buffer); + + int32_t SendUePolicySectionIdentifier(int32_t slotId, std::vector buffer); + + int32_t SendImsRsdList(int32_t slotId, std::vector buffer); + + int32_t GetNetworkSliceAllowedNssai(int32_t slotId, std::vector buffer); + + int32_t GetNetworkSliceEhplmn(int32_t slotId); int32_t GetIfSupportDunApn(bool &isSupportDun); diff --git a/interfaces/innerkits/cellular_data_client.h b/interfaces/innerkits/cellular_data_client.h index 8c88be4a..8b139529 100644 --- a/interfaces/innerkits/cellular_data_client.h +++ b/interfaces/innerkits/cellular_data_client.h @@ -296,6 +296,51 @@ public: */ int32_t QueryAllApnInfo(std::vector &apnInfoList); + /** + * @brief Snd Ursp Decode Result + * + * @param slotId Card slot identification. + * @param buffer msginfo + * @return 0 set success, others set fail + */ + int32_t SendUrspDecodeResult(int32_t slotId, std::vector buffer); + + /** + * @brief Snd Ue Policy Section Identifier + * + * @param slotId Card slot identification. + * @param buffer msginfo + * @return 0 set success, others set fail + */ + int32_t SendUePolicySectionIdentifier(int32_t slotId, std::vector buffer); + + /** + * @brief Snd ImsRsdList + * + * @param slotId Card slot identification. + * @param buffer msginfo + * @return 0 set success, others set fail + */ + int32_t SendImsRsdList(int32_t slotId, std::vector buffer); + + /** + * @brief Sync AllowedNssai With Modem + * + * @param slotId Card slot identification. + * @param buffer msginfo + * @return 0 set success, others set fail + */ + int32_t GetNetworkSliceAllowedNssai(int32_t slotId, std::vector buffer); + + /** + * @brief Sync Ehplmn With Modem + * + * @param slotId Card slot identification. + * @param buffer msginfo + * @return 0 set success, others set fail + */ + int32_t GetNetworkSliceEhplmn(int32_t slotId); + private: class CellularDataDeathRecipient : public IRemoteObject::DeathRecipient { public: diff --git a/interfaces/innerkits/cellular_data_ipc_interface_code.h b/interfaces/innerkits/cellular_data_ipc_interface_code.h index cef061a8..bededf75 100644 --- a/interfaces/innerkits/cellular_data_ipc_interface_code.h +++ b/interfaces/innerkits/cellular_data_ipc_interface_code.h @@ -54,6 +54,11 @@ enum class CellularDataInterfaceCode { QUERY_APN_INFO, SET_PREFER_APN, QUERY_ALL_APN_INFO, + SEND_MANAGE_UEPOLICY_DECODE_RESULT, + SEND_UE_STATE_INDICATION, + SEND_IMS_RSDLIST, + SYNC_ALLOWED_NSSAI_WITH_MODEM, + SYNC_EHPLMN_WITH_MODEM, }; } // namespace Telephony } // namespace OHOS diff --git a/interfaces/innerkits/i_cellular_data_manager.h b/interfaces/innerkits/i_cellular_data_manager.h index ed30e041..de5ec728 100644 --- a/interfaces/innerkits/i_cellular_data_manager.h +++ b/interfaces/innerkits/i_cellular_data_manager.h @@ -173,6 +173,16 @@ public: virtual int32_t QueryAllApnInfo(std::vector &apnInfoList) = 0; + virtual int32_t SendUrspDecodeResult(int32_t slotId, std::vector buffer) = 0; + + virtual int32_t SendUePolicySectionIdentifier(int32_t slotId, std::vector buffer) = 0; + + virtual int32_t SendImsRsdList(int32_t slotId, std::vector buffer) = 0; + + virtual int32_t GetNetworkSliceAllowedNssai(int32_t slotId, std::vector buffer) = 0; + + virtual int32_t GetNetworkSliceEhplmn(int32_t slotId) = 0; + public: DECLARE_INTERFACE_DESCRIPTOR(u"ohos.telephony.ICellularDataManager"); }; diff --git a/services/include/apn_manager/apn_item.h b/services/include/apn_manager/apn_item.h index 4456a6b8..69d383d9 100644 --- a/services/include/apn_manager/apn_item.h +++ b/services/include/apn_manager/apn_item.h @@ -78,6 +78,12 @@ public: char proxyIpAddress_[ALL_APN_ITEM_CHAR_LENGTH] = { 0 }; char mmsIpAddress_[ALL_APN_ITEM_CHAR_LENGTH] = { 0 }; bool isEdited_ = false; + /* For networkslice*/ + char snssai_[ALL_APN_ITEM_CHAR_LENGTH] = { 0 }; + uint8_t sscMode_ = 0; + char dnn_[ALL_APN_ITEM_CHAR_LENGTH] = { 0 }; + int32_t PduSessionType_ = 0; + uint8_t RouteBitmap_ = 0; } attr_; private: diff --git a/services/include/cellular_data_service.h b/services/include/cellular_data_service.h index 30430dbb..0c44c861 100644 --- a/services/include/cellular_data_service.h +++ b/services/include/cellular_data_service.h @@ -96,6 +96,11 @@ public: int32_t QueryApnIds(ApnInfo apnInfo, std::vector &apnIdList) override; int32_t SetPreferApn(int32_t apnId) override; int32_t QueryAllApnInfo(std::vector &apnInfoList) override; + int32_t SendUrspDecodeResult(int32_t slotId, std::vector buffer) override; + int32_t SendUePolicySectionIdentifier(int32_t slotId, std::vector buffer) override; + int32_t SendImsRsdList(int32_t slotId, std::vector buffer) override; + int32_t GetNetworkSliceAllowedNssai(int32_t slotId, std::vector buffer) override; + int32_t GetNetworkSliceEhplmn(int32_t slotId) override; private: bool Init(); diff --git a/services/include/cellular_data_service_stub.h b/services/include/cellular_data_service_stub.h index 3eb5c2c0..44b456a1 100644 --- a/services/include/cellular_data_service_stub.h +++ b/services/include/cellular_data_service_stub.h @@ -70,6 +70,11 @@ private: int32_t OnQueryApnInfo(MessageParcel &data, MessageParcel &reply); int32_t OnSetPreferApn(MessageParcel &data, MessageParcel &reply); int32_t OnQueryAllApnInfo(MessageParcel &data, MessageParcel &reply); + int32_t OnSendUrspDecodeResult(MessageParcel &data, MessageParcel &reply); + int32_t OnSendUePolicySectionIdentifier(MessageParcel &data, MessageParcel &reply); + int32_t OnSendImsRsdList(MessageParcel &data, MessageParcel &reply); + int32_t OnGetNetworkSliceAllowedNssai(MessageParcel &data, MessageParcel &reply); + int32_t OnGetNetworkSliceEhplmn(MessageParcel &data, MessageParcel &reply); private: using Fun = std::function; @@ -143,7 +148,17 @@ private: { (uint32_t)CellularDataInterfaceCode::SET_PREFER_APN, [this](MessageParcel &data, MessageParcel &reply) { return OnSetPreferApn(data, reply); } }, { (uint32_t)CellularDataInterfaceCode::QUERY_ALL_APN_INFO, - [this](MessageParcel &data, MessageParcel &reply) { return OnQueryAllApnInfo(data, reply); } } + [this](MessageParcel &data, MessageParcel &reply) { return OnQueryAllApnInfo(data, reply); } }, + { (uint32_t)CellularDataInterfaceCode::SEND_MANAGE_UEPOLICY_DECODE_RESULT, + [this](MessageParcel &data, MessageParcel &reply) { return OnSendUrspDecodeResult(data, reply); } }, + { (uint32_t)CellularDataInterfaceCode::SEND_UE_STATE_INDICATION, + [this](MessageParcel &data, MessageParcel &reply) { return OnSendUePolicySectionIdentifier(data, reply); }}, + { (uint32_t)CellularDataInterfaceCode::SEND_IMS_RSDLIST, + [this](MessageParcel &data, MessageParcel &reply) { return OnSendImsRsdList(data, reply); } }, + { (uint32_t)CellularDataInterfaceCode::SYNC_ALLOWED_NSSAI_WITH_MODEM, + [this](MessageParcel &data, MessageParcel &reply) { return OnGetNetworkSliceAllowedNssai(data, reply); } }, + { (uint32_t)CellularDataInterfaceCode::SYNC_EHPLMN_WITH_MODEM, + [this](MessageParcel &data, MessageParcel &reply) { return OnGetNetworkSliceEhplmn(data, reply); } } }; std::map collieCodeStringMap_ = { { uint32_t(CellularDataInterfaceCode::GET_CELLULAR_DATA_STATE), "GET_CELLULAR_DATA_STATE" }, diff --git a/services/include/common/cellular_data_constant.h b/services/include/common/cellular_data_constant.h index 75023200..85441562 100644 --- a/services/include/common/cellular_data_constant.h +++ b/services/include/common/cellular_data_constant.h @@ -132,7 +132,13 @@ enum DataContextRolesId { DATA_CONTEXT_ROLE_EMERGENCY_ID = 7, DATA_CONTEXT_ROLE_INTERNAL_DEFAULT_ID = 8, DATA_CONTEXT_ROLE_XCAP_ID = 9, - DATA_CONTEXT_ROLE_BIP_ID = 10 + DATA_CONTEXT_ROLE_BIP_ID = 10, + DATA_CONTEXT_ROLE_SNSSAI1_ID = 11, + DATA_CONTEXT_ROLE_SNSSAI2_ID = 12, + DATA_CONTEXT_ROLE_SNSSAI3_ID = 13, + DATA_CONTEXT_ROLE_SNSSAI4_ID = 14, + DATA_CONTEXT_ROLE_SNSSAI5_ID = 15, + DATA_CONTEXT_ROLE_SNSSAI6_ID = 16 }; enum class DataContextPriority : int32_t { PRIORITY_NONE, PRIORITY_LOW, PRIORITY_NORMAL, PRIORITY_HIGH }; @@ -175,7 +181,13 @@ enum class ApnTypes : int32_t { XCAP = 2048, INTERNAL_DEFAULT = 4096, BIP = 8192, - ALL = 16383 + SNSSAI1 = 16384, + SNSSAI2 = 32768, + SNSSAI3 = 65536, + SNSSAI4 = 131072, + SNSSAI5 = 262144, + SNSSAI6 = 524288, + ALL = 1048575 }; enum class RetryScene : int32_t { @@ -195,6 +207,12 @@ static constexpr const char *DATA_CONTEXT_ROLE_IA = "ia"; static constexpr const char *DATA_CONTEXT_ROLE_EMERGENCY = "emergency"; static constexpr const char *DATA_CONTEXT_ROLE_INTERNAL_DEFAULT = "internal_default"; static constexpr const char *DATA_CONTEXT_ROLE_XCAP = "xcap"; +static constexpr const char *DATA_CONTEXT_ROLE_SNSSAI1 = "snssai1"; +static constexpr const char *DATA_CONTEXT_ROLE_SNSSAI2 = "snssai2"; +static constexpr const char *DATA_CONTEXT_ROLE_SNSSAI3 = "snssai3"; +static constexpr const char *DATA_CONTEXT_ROLE_SNSSAI4 = "snssai4"; +static constexpr const char *DATA_CONTEXT_ROLE_SNSSAI5 = "snssai5"; +static constexpr const char *DATA_CONTEXT_ROLE_SNSSAI6 = "snssai6"; static const int32_t DATA_PROFILE_DEFAULT = 0; static const int32_t DATA_PROFILE_MMS = 1; static const int32_t DATA_PROFILE_INTERNAL_DEFAULT = 2; @@ -203,6 +221,12 @@ static const int32_t DATA_PROFILE_DUN = 4; static const int32_t DATA_PROFILE_IA = 5; static const int32_t DATA_PROFILE_XCAP = 6; static const int32_t DATA_PROFILE_BIP = 7; +static const int32_t DATA_PROFILE_SNSSAI1 = 8; +static const int32_t DATA_PROFILE_SNSSAI2 = 9; +static const int32_t DATA_PROFILE_SNSSAI3 = 10; +static const int32_t DATA_PROFILE_SNSSAI4 = 11; +static const int32_t DATA_PROFILE_SNSSAI5 = 12; +static const int32_t DATA_PROFILE_SNSSAI6 = 13; static const int32_t CMCC_MCC_MNC = 46002; static const int32_t DEFAULT_AUTH_TYPE = 0; static const int32_t DEFAULT_MTU = 1500; diff --git a/services/include/common/cellular_data_event_code.h b/services/include/common/cellular_data_event_code.h index 394f8ac5..797d0065 100644 --- a/services/include/common/cellular_data_event_code.h +++ b/services/include/common/cellular_data_event_code.h @@ -71,6 +71,12 @@ public: static const uint32_t MSG_SM_UPDATE_NETWORK_INFO = BASE + 44; static const uint32_t MSG_ESTABLISH_ALL_APNS_IF_CONNECTABLE = BASE + 45; static const uint32_t MSG_RESUME_DATA_PERMITTED_TIMEOUT = BASE + 46; + static const uint32_t MSG_SEND_UEPOLICY_COMPLETE = BASE + 47; + static const uint32_t MSG_SEND_UEPOLICY_COMMAND_REJECT = BASE + 48; + static const uint32_t MSG_SEND_UE_STATE_INDICATION = BASE + 49; + static const uint32_t MSG_SEND_IMS_RSDLIST = BASE + 50; + static const uint32_t MSG_SYNC_ALLOWED_NSSAI_WITH_MODEM = BASE + 51; + static const uint32_t MSG_SYNC_EHPLMN_WITH_MODEM = BASE + 52; }; } // namespace Telephony } // namespace OHOS diff --git a/services/include/data_connection_manager.h b/services/include/data_connection_manager.h index 9c9af809..0a40a9e0 100644 --- a/services/include/data_connection_manager.h +++ b/services/include/data_connection_manager.h @@ -91,6 +91,9 @@ protected: void RadioDataCallListChanged(const AppExecFwk::InnerEvent::Pointer &event); void RadioLinkCapabilityChanged(const AppExecFwk::InnerEvent::Pointer &event); void UpdateNetworkInfo(const AppExecFwk::InnerEvent::Pointer &event); + void RadioNetworkSliceUrspRpt(const AppExecFwk::InnerEvent::Pointer &event); + void RadioNetworkSliceAllowedNssaiRpt(const AppExecFwk::InnerEvent::Pointer &event); + void RadioNetworkSliceEhplmnRpt(const AppExecFwk::InnerEvent::Pointer &event); private: DataConnectionManager &connectManager_; diff --git a/services/include/state_machine/cellular_data_state_machine.h b/services/include/state_machine/cellular_data_state_machine.h index cc4660c4..92817864 100644 --- a/services/include/state_machine/cellular_data_state_machine.h +++ b/services/include/state_machine/cellular_data_state_machine.h @@ -97,6 +97,8 @@ private: std::string GetIpType(std::vector ipInfoArray); bool HasMatchedIpTypeAddrs(uint8_t ipType, uint8_t ipInfoArraySize, std::vector ipInfoArray); int32_t GetNetScoreBySlotId(int32_t slotId); + void GetNetworkSlicePara(const DataConnectionParams& connectionParams, sptr apn); + void FillRSDFromNetCap(std::map networkSliceParas, sptr apn); private: friend class Active; diff --git a/services/src/apn_manager/apn_holder.cpp b/services/src/apn_manager/apn_holder.cpp index 6ac6e89b..0264cb73 100644 --- a/services/src/apn_manager/apn_holder.cpp +++ b/services/src/apn_manager/apn_holder.cpp @@ -34,6 +34,12 @@ const std::map ApnHolder::apnTypeDataProfileMap_ { {DATA_CONTEXT_ROLE_IA, DATA_PROFILE_IA}, {DATA_CONTEXT_ROLE_XCAP, DATA_PROFILE_XCAP}, {DATA_CONTEXT_ROLE_BIP, DATA_PROFILE_BIP}, + {DATA_CONTEXT_ROLE_SNSSAI1, DATA_PROFILE_SNSSAI1}, + {DATA_CONTEXT_ROLE_SNSSAI2, DATA_PROFILE_SNSSAI2}, + {DATA_CONTEXT_ROLE_SNSSAI3, DATA_PROFILE_SNSSAI3}, + {DATA_CONTEXT_ROLE_SNSSAI4, DATA_PROFILE_SNSSAI4}, + {DATA_CONTEXT_ROLE_SNSSAI5, DATA_PROFILE_SNSSAI5}, + {DATA_CONTEXT_ROLE_SNSSAI6, DATA_PROFILE_SNSSAI6}, }; ApnHolder::ApnHolder(const std::string &apnType, const int32_t priority) : apnType_(apnType), priority_(priority) {} diff --git a/services/src/apn_manager/apn_item.cpp b/services/src/apn_manager/apn_item.cpp index 1d1e9e95..9a4dff63 100644 --- a/services/src/apn_manager/apn_item.cpp +++ b/services/src/apn_manager/apn_item.cpp @@ -70,7 +70,7 @@ sptr ApnItem::MakeDefaultApn(const std::string &apnType) return nullptr; } Attribute attr = {"", "46002", DATA_PROFILE_DEFAULT, "IPV4V6", "IPV4V6", - DEFAULT_AUTH_TYPE, "cmnet", "CMNET", "", "", false, "", "", "", false}; + DEFAULT_AUTH_TYPE, "cmnet", "CMNET", "", "", false, "", "", "", false, "", 0, "", 0, 0}; apnItem->apnTypes_ = CellularDataUtils::Split(apnType, ","); apnItem->attr_ = attr; if (strcpy_s(apnItem->attr_.types_, ALL_APN_ITEM_CHAR_LENGTH, apnType.c_str()) != EOK) { diff --git a/services/src/apn_manager/apn_manager.cpp b/services/src/apn_manager/apn_manager.cpp index 60ef103e..11571a1a 100644 --- a/services/src/apn_manager/apn_manager.cpp +++ b/services/src/apn_manager/apn_manager.cpp @@ -37,7 +37,13 @@ const std::map ApnManager::apnIdApnNameMap_ { {DATA_CONTEXT_ROLE_EMERGENCY, DATA_CONTEXT_ROLE_EMERGENCY_ID}, {DATA_CONTEXT_ROLE_INTERNAL_DEFAULT, DATA_CONTEXT_ROLE_INTERNAL_DEFAULT_ID}, {DATA_CONTEXT_ROLE_XCAP, DATA_CONTEXT_ROLE_XCAP_ID}, - {DATA_CONTEXT_ROLE_BIP, DATA_CONTEXT_ROLE_BIP_ID} + {DATA_CONTEXT_ROLE_BIP, DATA_CONTEXT_ROLE_BIP_ID}, + {DATA_CONTEXT_ROLE_SNSSAI1, DATA_CONTEXT_ROLE_SNSSAI1_ID}, + {DATA_CONTEXT_ROLE_SNSSAI2, DATA_CONTEXT_ROLE_SNSSAI2_ID}, + {DATA_CONTEXT_ROLE_SNSSAI3, DATA_CONTEXT_ROLE_SNSSAI3_ID}, + {DATA_CONTEXT_ROLE_SNSSAI4, DATA_CONTEXT_ROLE_SNSSAI4_ID}, + {DATA_CONTEXT_ROLE_SNSSAI5, DATA_CONTEXT_ROLE_SNSSAI5_ID}, + {DATA_CONTEXT_ROLE_SNSSAI6, DATA_CONTEXT_ROLE_SNSSAI6_ID} }; const std::map ApnManager::apnNameApnTypeMap_ { {DATA_CONTEXT_ROLE_ALL, ApnTypes::ALL}, @@ -50,7 +56,13 @@ const std::map ApnManager::apnNameApnTypeMap_ { {DATA_CONTEXT_ROLE_EMERGENCY, ApnTypes::EMERGENCY}, {DATA_CONTEXT_ROLE_XCAP, ApnTypes::XCAP}, {DATA_CONTEXT_ROLE_BIP, ApnTypes::BIP}, - {DATA_CONTEXT_ROLE_INTERNAL_DEFAULT, ApnTypes::INTERNAL_DEFAULT} + {DATA_CONTEXT_ROLE_INTERNAL_DEFAULT, ApnTypes::INTERNAL_DEFAULT}, + {DATA_CONTEXT_ROLE_SNSSAI1, ApnTypes::SNSSAI1}, + {DATA_CONTEXT_ROLE_SNSSAI2, ApnTypes::SNSSAI2}, + {DATA_CONTEXT_ROLE_SNSSAI3, ApnTypes::SNSSAI3}, + {DATA_CONTEXT_ROLE_SNSSAI4, ApnTypes::SNSSAI4}, + {DATA_CONTEXT_ROLE_SNSSAI5, ApnTypes::SNSSAI5}, + {DATA_CONTEXT_ROLE_SNSSAI6, ApnTypes::SNSSAI6} }; const std::vector ApnManager::apnStateArr_ = { PROFILE_STATE_CONNECTED, @@ -84,6 +96,12 @@ void ApnManager::InitApnHolders() AddApnHolder(DATA_CONTEXT_ROLE_IA, static_cast(DataContextPriority::PRIORITY_HIGH)); AddApnHolder(DATA_CONTEXT_ROLE_SUPL, static_cast(DataContextPriority::PRIORITY_NORMAL)); AddApnHolder(DATA_CONTEXT_ROLE_BIP, static_cast(DataContextPriority::PRIORITY_NORMAL)); + AddApnHolder(DATA_CONTEXT_ROLE_SNSSAI1, static_cast(DataContextPriority::PRIORITY_NORMAL)); + AddApnHolder(DATA_CONTEXT_ROLE_SNSSAI2, static_cast(DataContextPriority::PRIORITY_NORMAL)); + AddApnHolder(DATA_CONTEXT_ROLE_SNSSAI3, static_cast(DataContextPriority::PRIORITY_NORMAL)); + AddApnHolder(DATA_CONTEXT_ROLE_SNSSAI4, static_cast(DataContextPriority::PRIORITY_NORMAL)); + AddApnHolder(DATA_CONTEXT_ROLE_SNSSAI5, static_cast(DataContextPriority::PRIORITY_NORMAL)); + AddApnHolder(DATA_CONTEXT_ROLE_SNSSAI6, static_cast(DataContextPriority::PRIORITY_NORMAL)); } sptr ApnManager::FindApnHolderById(const int32_t id) const @@ -153,6 +171,18 @@ int32_t ApnManager::FindApnIdByCapability(const uint64_t capability) return DATA_CONTEXT_ROLE_DUN_ID; case NetManagerStandard::NetCap::NET_CAPABILITY_BIP: return DATA_CONTEXT_ROLE_BIP_ID; + case NetManagerStandard::NetCap::NET_CAPABILITY_SNSSAI1: + return DATA_CONTEXT_ROLE_SNSSAI1_ID; + case NetManagerStandard::NetCap::NET_CAPABILITY_SNSSAI2: + return DATA_CONTEXT_ROLE_SNSSAI2_ID; + case NetManagerStandard::NetCap::NET_CAPABILITY_SNSSAI3: + return DATA_CONTEXT_ROLE_SNSSAI3_ID; + case NetManagerStandard::NetCap::NET_CAPABILITY_SNSSAI4: + return DATA_CONTEXT_ROLE_SNSSAI4_ID; + case NetManagerStandard::NetCap::NET_CAPABILITY_SNSSAI5: + return DATA_CONTEXT_ROLE_SNSSAI5_ID; + case NetManagerStandard::NetCap::NET_CAPABILITY_SNSSAI6: + return DATA_CONTEXT_ROLE_SNSSAI6_ID; default: return DATA_CONTEXT_ROLE_INVALID_ID; } @@ -190,6 +220,24 @@ NetManagerStandard::NetCap ApnManager::FindBestCapability(const uint64_t capabil if (HasNetCap(capabilities, NetManagerStandard::NetCap::NET_CAPABILITY_BIP)) { netCap = NetManagerStandard::NetCap::NET_CAPABILITY_BIP; } + if (HasNetCap(capabilities, NetManagerStandard::NetCap::NET_CAPABILITY_SNSSAI1)) { + netCap = NetManagerStandard::NetCap::NET_CAPABILITY_SNSSAI1; + } + if (HasNetCap(capabilities, NetManagerStandard::NetCap::NET_CAPABILITY_SNSSAI2)) { + netCap = NetManagerStandard::NetCap::NET_CAPABILITY_SNSSAI2; + } + if (HasNetCap(capabilities, NetManagerStandard::NetCap::NET_CAPABILITY_SNSSAI3)) { + netCap = NetManagerStandard::NetCap::NET_CAPABILITY_SNSSAI3; + } + if (HasNetCap(capabilities, NetManagerStandard::NetCap::NET_CAPABILITY_SNSSAI4)) { + netCap = NetManagerStandard::NetCap::NET_CAPABILITY_SNSSAI4; + } + if (HasNetCap(capabilities, NetManagerStandard::NetCap::NET_CAPABILITY_SNSSAI5)) { + netCap = NetManagerStandard::NetCap::NET_CAPABILITY_SNSSAI5; + } + if (HasNetCap(capabilities, NetManagerStandard::NetCap::NET_CAPABILITY_SNSSAI6)) { + netCap = NetManagerStandard::NetCap::NET_CAPABILITY_SNSSAI6; + } return netCap; } @@ -246,6 +294,7 @@ std::vector> ApnManager::GetSortApnHolder() const int32_t ApnManager::CreateAllApnItemByDatabase(int32_t slotId) { + TELEPHONY_LOGI("CreateAllApnItemByDatabase"); int32_t count = 0; if (TELEPHONY_EXT_WRAPPER.createAllApnItemExt_) { sptr extraApnItem = ApnItem::MakeDefaultApn("default"); @@ -320,6 +369,7 @@ void ApnManager::GetCTOperator(int32_t slotId, std::string &numeric) int32_t ApnManager::CreateMvnoApnItems(int32_t slotId, const std::string &mcc, const std::string &mnc) { + TELEPHONY_LOGI("CreateMvnoApnItems"); int32_t count = 0; auto helper = CellularDataRdbHelper::GetInstance(); if (helper == nullptr) { @@ -367,6 +417,7 @@ void ApnManager::ReportApnInfo(int32_t slotId, PdpProfile &apnData) int32_t ApnManager::MakeSpecificApnItem(std::vector &apnVec, int32_t slotId) { + TELEPHONY_LOGI("MakeSpecificApnItem"); std::lock_guard lock(mutex_); allApnItem_.clear(); TryMergeSimilarPdpProfile(apnVec); @@ -406,7 +457,6 @@ std::vector> ApnManager::FilterMatchedApns(const std::string &requ FetchBipApns(matchApnItemList); return matchApnItemList; } - for (const sptr &apnItem : allApnItem_) { if (apnItem->CanDealWithType(requestApnType)) { matchApnItemList.push_back(apnItem); @@ -686,6 +736,18 @@ uint64_t ApnManager::FindCapabilityByApnId(int32_t apnId) return NetManagerStandard::NetCap::NET_CAPABILITY_DUN; case DATA_CONTEXT_ROLE_BIP_ID: return NetManagerStandard::NetCap::NET_CAPABILITY_BIP; + case DATA_CONTEXT_ROLE_SNSSAI1_ID: + return NetManagerStandard::NetCap::NET_CAPABILITY_SNSSAI1; + case DATA_CONTEXT_ROLE_SNSSAI2_ID: + return NetManagerStandard::NetCap::NET_CAPABILITY_SNSSAI2; + case DATA_CONTEXT_ROLE_SNSSAI3_ID: + return NetManagerStandard::NetCap::NET_CAPABILITY_SNSSAI3; + case DATA_CONTEXT_ROLE_SNSSAI4_ID: + return NetManagerStandard::NetCap::NET_CAPABILITY_SNSSAI4; + case DATA_CONTEXT_ROLE_SNSSAI5_ID: + return NetManagerStandard::NetCap::NET_CAPABILITY_SNSSAI5; + case DATA_CONTEXT_ROLE_SNSSAI6_ID: + return NetManagerStandard::NetCap::NET_CAPABILITY_SNSSAI6; default: return NetManagerStandard::NetCap::NET_CAPABILITY_END; } diff --git a/services/src/cellular_data_service.cpp b/services/src/cellular_data_service.cpp index 70ea8b1b..c9bafdd7 100644 --- a/services/src/cellular_data_service.cpp +++ b/services/src/cellular_data_service.cpp @@ -304,6 +304,12 @@ void CellularDataService::InitModule() netCapabilities.push_back(NetCap::NET_CAPABILITY_IA); netCapabilities.push_back(NetCap::NET_CAPABILITY_XCAP); netCapabilities.push_back(NetCap::NET_CAPABILITY_BIP); + netCapabilities.push_back(NetCap::NET_CAPABILITY_SNSSAI1); + netCapabilities.push_back(NetCap::NET_CAPABILITY_SNSSAI2); + netCapabilities.push_back(NetCap::NET_CAPABILITY_SNSSAI3); + netCapabilities.push_back(NetCap::NET_CAPABILITY_SNSSAI4); + netCapabilities.push_back(NetCap::NET_CAPABILITY_SNSSAI5); + netCapabilities.push_back(NetCap::NET_CAPABILITY_SNSSAI6); int32_t simNum = CoreManagerInner::GetInstance().GetMaxSimCount(); for (int32_t i = 0; i < simNum; ++i) { AddNetSupplier(i, netAgent, netCapabilities); @@ -785,7 +791,7 @@ int32_t CellularDataService::GetCellularDataSupplierId(int32_t slotId, uint64_t TELEPHONY_LOGE("Permission denied!"); return TELEPHONY_ERR_PERMISSION_ERR; } - if (capability < NetCap::NET_CAPABILITY_MMS || capability > NetCap::NET_CAPABILITY_INTERNAL_DEFAULT) { + if (capability < NetCap::NET_CAPABILITY_MMS || capability > NetCap::NET_CAPABILITY_SNSSAI6) { TELEPHONY_LOGE("Invalid capability = (%{public}" PRIu64 ")", capability); return CELLULAR_DATA_INVALID_PARAM; } @@ -840,7 +846,6 @@ int32_t CellularDataService::GetIfSupportDunApn(bool &isSupportDun) return TELEPHONY_ERR_SUCCESS; } - int32_t CellularDataService::GetDefaultActReportInfo(int32_t slotId, ApnActivateReportInfo &info) { if (!TelephonyPermission::CheckPermission(Permission::GET_TELEPHONY_STATE)) { @@ -917,5 +922,35 @@ int32_t CellularDataService::QueryAllApnInfo(std::vector &allApnInfoLis helper->QueryAllApnInfo(allApnInfoList); return 0; } + +int32_t CellularDataService::SendUrspDecodeResult(int32_t slotId, std::vector buffer) +{ + int32_t eventid = static_cast(CellularDataEventCode::MSG_SEND_UEPOLICY_COMMAND_REJECT); + return CoreManagerInner::GetInstance().SendUrspDecodeResult(slotId, buffer, eventid); +} + +int32_t CellularDataService::SendUePolicySectionIdentifier(int32_t slotId, std::vector buffer) +{ + int32_t eventid = static_cast(CellularDataEventCode::MSG_SEND_UE_STATE_INDICATION); + return CoreManagerInner::GetInstance().SendUePolicySectionIdentifier(slotId, buffer, eventid); +} + +int32_t CellularDataService::SendImsRsdList(int32_t slotId, std::vector buffer) +{ + int32_t eventid = static_cast(CellularDataEventCode::MSG_SEND_IMS_RSDLIST); + return CoreManagerInner::GetInstance().SendImsRsdList(slotId, buffer, eventid); +} + +int32_t CellularDataService::GetNetworkSliceAllowedNssai(int32_t slotId, std::vector buffer) +{ + int32_t eventid = static_cast(CellularDataEventCode::MSG_SYNC_ALLOWED_NSSAI_WITH_MODEM); + return CoreManagerInner::GetInstance().GetNetworkSliceAllowedNssai(slotId, buffer, eventid); +} + +int32_t CellularDataService::GetNetworkSliceEhplmn(int32_t slotId) +{ + int32_t eventid = static_cast(CellularDataEventCode::MSG_SYNC_EHPLMN_WITH_MODEM); + return CoreManagerInner::GetInstance().GetNetworkSliceEhplmn(slotId, eventid); +} } // namespace Telephony } // namespace OHOS diff --git a/services/src/cellular_data_service_stub.cpp b/services/src/cellular_data_service_stub.cpp index 4a616802..3137c154 100644 --- a/services/src/cellular_data_service_stub.cpp +++ b/services/src/cellular_data_service_stub.cpp @@ -578,5 +578,89 @@ int32_t CellularDataServiceStub::OnQueryAllApnInfo(MessageParcel &data, MessageP } return 0; } + +int32_t CellularDataServiceStub::OnSendUrspDecodeResult(MessageParcel &data, MessageParcel &reply) +{ + TELEPHONY_LOGI("CellularDataServiceStub::OnSendUrspDecodeResult"); + int32_t slotId = data.ReadInt32(); + int32_t buffer_len = data.ReadInt32(); + std::vector buffer; + for (int i = 0; i < buffer_len; ++i) + { + buffer.push_back(data.ReadUint8()); + } + int32_t result = SendUrspDecodeResult(slotId, buffer); + if (result != TELEPHONY_ERR_SUCCESS) + { + return result; + } + return TELEPHONY_SUCCESS; +} + +int32_t CellularDataServiceStub::OnSendUePolicySectionIdentifier(MessageParcel &data, MessageParcel &reply) +{ + TELEPHONY_LOGI("CellularDataServiceStub::OnSendUePolicySectionIdentifier"); + int32_t slotId = data.ReadInt32(); + int32_t buffer_len = data.ReadInt32(); + std::vector buffer; + for (int i = 0; i < buffer_len; ++i) + { + buffer.push_back(data.ReadUint8()); + } + int32_t result = SendUePolicySectionIdentifier(slotId, buffer); + if (result != TELEPHONY_ERR_SUCCESS) + { + return result; + } + return TELEPHONY_SUCCESS; +} + +int32_t CellularDataServiceStub::OnSendImsRsdList(MessageParcel &data, MessageParcel &reply) +{ + TELEPHONY_LOGI("CellularDataServiceStub::OnSendImsRsdList"); + int32_t slotId = data.ReadInt32(); + int32_t buffer_len = data.ReadInt32(); + std::vector buffer; + for (int i = 0; i < buffer_len; ++i) + { + buffer.push_back(data.ReadUint8()); + } + int32_t result = SendImsRsdList(slotId, buffer); + if (result != TELEPHONY_ERR_SUCCESS) + { + return result; + } + return TELEPHONY_SUCCESS; +} + +int32_t CellularDataServiceStub::OnGetNetworkSliceAllowedNssai(MessageParcel &data, MessageParcel &reply) +{ + TELEPHONY_LOGI("CellularDataServiceStub::OnGetNetworkSliceAllowedNssai"); + int32_t slotId = data.ReadInt32(); + int32_t buffer_len = data.ReadInt32(); + std::vector buffer; + for (int i = 0; i < buffer_len; ++i) + { + buffer.push_back(data.ReadUint8()); + } + int32_t result = GetNetworkSliceAllowedNssai(slotId, buffer); + if (result != TELEPHONY_ERR_SUCCESS) + { + return result; + } + return TELEPHONY_SUCCESS; +} + +int32_t CellularDataServiceStub::OnGetNetworkSliceEhplmn(MessageParcel &data, MessageParcel &reply) +{ + TELEPHONY_LOGI("CellularDataServiceStub::OnGetNetworkSliceEhplmn"); + int32_t slotId = data.ReadInt32(); + int32_t result = GetNetworkSliceEhplmn(slotId); + if (result != TELEPHONY_ERR_SUCCESS) + { + return result; + } + return TELEPHONY_SUCCESS; +} } // namespace Telephony } // namespace OHOS \ No newline at end of file diff --git a/services/src/data_connection_manager.cpp b/services/src/data_connection_manager.cpp index a889bbe6..c66f0700 100644 --- a/services/src/data_connection_manager.cpp +++ b/services/src/data_connection_manager.cpp @@ -24,6 +24,8 @@ #include "operator_config_types.h" #include "radio_event.h" #include "telephony_log_wrapper.h" +#include "networkslice_client.h" +#include "singleton.h" namespace OHOS { namespace Telephony { @@ -155,6 +157,11 @@ void DataConnectionManager::RegisterRadioObserver() coreInner.RegisterCoreNotify(slotId_, stateMachineEventHandler_, RadioEvent::RADIO_DATA_CALL_LIST_CHANGED, nullptr); coreInner.RegisterCoreNotify( slotId_, stateMachineEventHandler_, RadioEvent::RADIO_LINK_CAPABILITY_CHANGED, nullptr); + coreInner.RegisterCoreNotify(slotId_, stateMachineEventHandler_, RadioEvent::RADIO_NETWORKSLICE_URSP_RPT, nullptr); + coreInner.RegisterCoreNotify(slotId_, stateMachineEventHandler_, + RadioEvent::RADIO_NETWORKSLICE_ALLOWEDNSSAI_RPT, nullptr); + coreInner.RegisterCoreNotify(slotId_, stateMachineEventHandler_, + RadioEvent::RADIO_NETWORKSLICE_EHPLMN_RPT, nullptr); } void DataConnectionManager::UnRegisterRadioObserver() const @@ -167,6 +174,9 @@ void DataConnectionManager::UnRegisterRadioObserver() const coreInner.UnRegisterCoreNotify(slotId_, stateMachineEventHandler_, RadioEvent::RADIO_CONNECTED); coreInner.UnRegisterCoreNotify(slotId_, stateMachineEventHandler_, RadioEvent::RADIO_DATA_CALL_LIST_CHANGED); coreInner.UnRegisterCoreNotify(slotId_, stateMachineEventHandler_, RadioEvent::RADIO_LINK_CAPABILITY_CHANGED); + coreInner.UnRegisterCoreNotify(slotId_, stateMachineEventHandler_, RadioEvent::RADIO_NETWORKSLICE_URSP_RPT); + coreInner.UnRegisterCoreNotify(slotId_, stateMachineEventHandler_, RadioEvent::RADIO_NETWORKSLICE_ALLOWEDNSSAI_RPT); + coreInner.UnRegisterCoreNotify(slotId_, stateMachineEventHandler_, RadioEvent::RADIO_NETWORKSLICE_EHPLMN_RPT); } void CcmDefaultState::StateBegin() @@ -196,6 +206,15 @@ bool CcmDefaultState::StateProcess(const AppExecFwk::InnerEvent::Pointer &event) case RadioEvent::RADIO_LINK_CAPABILITY_CHANGED: RadioLinkCapabilityChanged(event); break; + case RadioEvent::RADIO_NETWORKSLICE_URSP_RPT: + RadioNetworkSliceUrspRpt(event); + break; + case RadioEvent::RADIO_NETWORKSLICE_ALLOWEDNSSAI_RPT: + RadioNetworkSliceAllowedNssaiRpt(event); + break; + case RadioEvent::RADIO_NETWORKSLICE_EHPLMN_RPT: + RadioNetworkSliceEhplmnRpt(event); + break; default: TELEPHONY_LOGE("handle nothing!"); return false; @@ -464,5 +483,44 @@ void DataConnectionManager::HandleScreenStateChanged(bool isScreenOn) const } connectionMonitor_->HandleScreenStateChanged(isScreenOn); } + +void CcmDefaultState::RadioNetworkSliceUrspRpt(const AppExecFwk::InnerEvent::Pointer &event) +{ + TELEPHONY_LOGI("CcmDefaultState::RadioNetworkSliceUrspRpt"); + std::shared_ptr networkSliceUrspInfo = event->GetSharedObject(); + if (networkSliceUrspInfo == nullptr) { + TELEPHONY_LOGE("networkSliceClient is null"); + return; + } + std::vector buffer = networkSliceUrspInfo->urspInfo; + DelayedSingleton::GetInstance()->SetNetworkSliceUePolicy(buffer); +} + +void CcmDefaultState::RadioNetworkSliceAllowedNssaiRpt(const AppExecFwk::InnerEvent::Pointer &event) +{ + TELEPHONY_LOGI("CcmDefaultState::RadioNetworkSliceAllowedNssaiRpt"); + std::shared_ptr networkSliceAllowedNssaiInfo + = event->GetSharedObject(); + if (networkSliceAllowedNssaiInfo == nullptr) { + TELEPHONY_LOGE("networkSliceClient is null"); + return; + } + std::vector buffer = networkSliceAllowedNssaiInfo->allowednssaiInfo; + DelayedSingleton::GetInstance()->NetworkSliceAllowedNssaiRpt(buffer); +} + +void CcmDefaultState::RadioNetworkSliceEhplmnRpt(const AppExecFwk::InnerEvent::Pointer &event) +{ + TELEPHONY_LOGI("CcmDefaultState::RadioNetworkSliceEhplmnRpt"); + std::shared_ptr networkSliceEhplmnInfo + = event->GetSharedObject(); + if (networkSliceEhplmnInfo == nullptr) { + TELEPHONY_LOGE("networkSliceClient is null"); + return; + } + std::vector buffer = networkSliceEhplmnInfo->ehplmnInfo; + DelayedSingleton::GetInstance()->NetworkSliceEhplmnRpt(buffer); +} + } // namespace Telephony } // namespace OHOS diff --git a/services/src/state_machine/cellular_data_state_machine.cpp b/services/src/state_machine/cellular_data_state_machine.cpp index 6c736099..4e410850 100644 --- a/services/src/state_machine/cellular_data_state_machine.cpp +++ b/services/src/state_machine/cellular_data_state_machine.cpp @@ -30,11 +30,13 @@ #include "radio_event.h" #include "telephony_common_utils.h" #include "telephony_log_wrapper.h" +#include "networkslice_client.h" namespace OHOS { using namespace NetManagerStandard; namespace Telephony { static const int32_t INVALID_MTU_VALUE = -1; +static const bool IS_SUPPORT_NR_SLICE = system::GetBoolParameter("persist.netmgr_ext.networkslice", false); bool CellularDataStateMachine::IsInactiveState() const { return currentState_ == inActiveState_; @@ -94,6 +96,17 @@ sptr CellularDataStateMachine::GetApnItem() const return apnItem_; } +static void FillActivateDataParam(ActivateDataParam& activeDataParam, sptr apn) +{ + activeDataParam.dataProfile.profileId = apn->attr_.profileId_; + activeDataParam.dataProfile.apn = apn->attr_.apn_; + activeDataParam.dataProfile.protocol = apn->attr_.protocol_; + activeDataParam.dataProfile.verType = apn->attr_.authType_; + activeDataParam.dataProfile.userName = apn->attr_.user_; + activeDataParam.dataProfile.password = apn->attr_.password_; + activeDataParam.dataProfile.roamingProtocol = apn->attr_.roamingProtocol_; +} + void CellularDataStateMachine::DoConnect(const DataConnectionParams &connectionParams) { if (connectionParams.GetApnHolder() == nullptr) { @@ -115,13 +128,14 @@ void CellularDataStateMachine::DoConnect(const DataConnectionParams &connectionP activeDataParam.radioTechnology = radioTech; activeDataParam.allowRoaming = connectionParams.GetRoamingState(); activeDataParam.isRoaming = connectionParams.GetUserDataRoaming(); - activeDataParam.dataProfile.profileId = apn->attr_.profileId_; - activeDataParam.dataProfile.apn = apn->attr_.apn_; - activeDataParam.dataProfile.protocol = apn->attr_.protocol_; - activeDataParam.dataProfile.verType = apn->attr_.authType_; - activeDataParam.dataProfile.userName = apn->attr_.user_; - activeDataParam.dataProfile.password = apn->attr_.password_; - activeDataParam.dataProfile.roamingProtocol = apn->attr_.roamingProtocol_; + FillActivateDataParam(activeDataParam, apn); + if (IS_SUPPORT_NR_SLICE) { + GetNetworkSlicePara(connectionParams, apn); + activeDataParam.dataProfile.snssai = apn->attr_.snssai_; + activeDataParam.dataProfile.sscMode = apn->attr_.sscMode_; + activeDataParam.dataProfile.apn = apn->attr_.apn_; + activeDataParam.dataProfile.protocol = apn->attr_.protocol_; + } int32_t bitMap = ApnManager::FindApnTypeByApnName(connectionParams.GetApnHolder()->GetApnType()); activeDataParam.dataProfile.supportedApnTypesBitmap = bitMap; TELEPHONY_LOGI("Slot%{public}d: Activate PDP context (%{public}d, %{public}s, %{public}s, %{public}s, %{public}d)", @@ -485,5 +499,74 @@ uint64_t CellularDataStateMachine::GetReuseApnCap() const { return reuseApnCap_; } + +void CellularDataStateMachine::GetNetworkSlicePara(const DataConnectionParams& connectionParams, sptr apn) +{ + std::string apnType = connectionParams.GetApnHolder()->GetApnType(); + bool isNr_Sa = false; + int slotId = 0; + sptr networkState(new NetworkState()); + CoreManagerInner::GetInstance().GetNetworkStatus(slotId, networkState); + if (networkState->GetPsRadioTech() == RadioTech::RADIO_TECHNOLOGY_NR && + networkState->GetNrState() == NrState::NR_NSA_STATE_SA_ATTACHED) { + isNr_Sa = true; + } + if (!isNr_Sa) { + return; + } + std::string dnn = apn->attr_.apn_; + TELEPHONY_LOGI("GetNetworkSlicePara apnType = %{public}s, dnn = %{public}s", + apnType.c_str(), dnn.c_str()); + if (apnType.find("snssai") != std::string::npos) { + int32_t apnId = ApnManager::FindApnIdByApnName(apnType); + int32_t netcap = ApnManager::FindCapabilityByApnId(apnId); + std::map networkSliceParas; + DelayedSingleton::GetInstance()->GetRSDByNetCap( + netcap, networkSliceParas); + FillRSDFromNetCap(networkSliceParas, apn); + } else if (!dnn.empty()) { + std::string snssai; + uint8_t sscMode = 0; + DelayedSingleton::GetInstance()->GetRouteSelectionDescriptorByDNN( + dnn, snssai, sscMode); + apn->attr_.sscMode_ = sscMode; + if (!snssai.empty()) { + std::fill(apn->attr_.snssai_, apn->attr_.snssai_ + ApnItem::ALL_APN_ITEM_CHAR_LENGTH, '\0'); + std::copy(snssai.begin(), snssai.end(), apn->attr_.snssai_); + apn->attr_.snssai_[std::min((int)snssai.size(), ApnItem::ALL_APN_ITEM_CHAR_LENGTH - 1)] = '\0'; + } + TELEPHONY_LOGI("GetRouteSelectionDescriptorByDNN snssai = %{public}s, sscmode = %{public}d", + snssai.c_str(), sscMode); + } +} + +void CellularDataStateMachine::FillRSDFromNetCap( + std::map networkSliceParas, sptr apn) +{ + if (networkSliceParas["sscmode"] != "0") { + apn->attr_.sscMode_ = std::stoi(networkSliceParas["sscmode"]); + } + if (networkSliceParas["snssai"] != "") { + std::string snssai = networkSliceParas["snssai"]; + std::fill(apn->attr_.snssai_, apn->attr_.snssai_ + ApnItem::ALL_APN_ITEM_CHAR_LENGTH, '\0'); + std::copy(snssai.begin(), snssai.end(), apn->attr_.snssai_); + apn->attr_.snssai_[std::min((int)snssai.size(), ApnItem::ALL_APN_ITEM_CHAR_LENGTH - 1)] = '\0'; + } + if (networkSliceParas["dnn"] != "") { + std::string dnn = networkSliceParas["dnn"]; + std::fill(apn->attr_.apn_, apn->attr_.apn_ + ApnItem::ALL_APN_ITEM_CHAR_LENGTH, '\0'); + std::copy(dnn.begin(), dnn.end(), apn->attr_.apn_); + apn->attr_.apn_[std::min((int)dnn.size(), ApnItem::ALL_APN_ITEM_CHAR_LENGTH - 1)] = '\0'; + } + if (networkSliceParas["pdusessiontype"] != "0") { + std::string pdusessiontype = networkSliceParas["pdusessiontype"]; + std::fill(apn->attr_.protocol_, apn->attr_.protocol_ + ApnItem::ALL_APN_ITEM_CHAR_LENGTH, '\0'); + std::copy(pdusessiontype.begin(), pdusessiontype.end(), apn->attr_.protocol_); + apn->attr_.apn_[std::min((int)pdusessiontype.size(), ApnItem::ALL_APN_ITEM_CHAR_LENGTH - 1)] = '\0'; + } + TELEPHONY_LOGI("FillRSD: snssai = %{public}s, sscmode = %{public}s, dnn = %{public}s, pdusession = %{public}s", + networkSliceParas["snssai"].c_str(), networkSliceParas["sscmode"].c_str(), networkSliceParas["dnn"].c_str(), + networkSliceParas["pdusessiontype"].c_str()); +} } // namespace Telephony } // namespace OHOS diff --git a/services/src/utils/cellular_data_net_agent.cpp b/services/src/utils/cellular_data_net_agent.cpp index d3806da4..711ad1b7 100644 --- a/services/src/utils/cellular_data_net_agent.cpp +++ b/services/src/utils/cellular_data_net_agent.cpp @@ -44,13 +44,14 @@ CellularDataNetAgent::~CellularDataNetAgent() = default; bool CellularDataNetAgent::RegisterNetSupplier(const int32_t slotId) { + TELEPHONY_LOGI("RegisterNetSupplier, slotId = %{public}d", slotId); bool flag = false; for (NetSupplier &netSupplier : netSuppliers_) { if (netSupplier.slotId != slotId) { continue; } auto& netManager = NetConnClient::GetInstance(); - if (netSupplier.capability > NetCap::NET_CAPABILITY_INTERNAL_DEFAULT) { + if (netSupplier.capability > NetCap::NET_CAPABILITY_SNSSAI6) { TELEPHONY_LOGE("capabilities(%{public}" PRIu64 ") not support", netSupplier.capability); continue; } diff --git a/test/apn_manager_test.cpp b/test/apn_manager_test.cpp index 05be7001..964f35b0 100644 --- a/test/apn_manager_test.cpp +++ b/test/apn_manager_test.cpp @@ -228,6 +228,84 @@ HWTEST_F(ApnManagerTest, FindApnIdByCapability_009, Function | MediumTest | Leve ASSERT_EQ(actual, expected); } +/** + * @tc.number FindApnIdByCapability_009 + * @tc.name test function branch + * @tc.desc Function test + */ +HWTEST_F(ApnManagerTest, FindApnIdByCapability_010, Function | MediumTest | Level1) +{ + uint64_t capability = NetManagerStandard::NetCap::NET_CAPABILITY_SNSSAI1; + int32_t expected = DATA_CONTEXT_ROLE_SNSSAI1_ID; + int32_t actual = apnManager->FindApnIdByCapability(capability); + ASSERT_EQ(actual, expected); +} + +/** + * @tc.number FindApnIdByCapability_009 + * @tc.name test function branch + * @tc.desc Function test + */ +HWTEST_F(ApnManagerTest, FindApnIdByCapability_011, Function | MediumTest | Level1) +{ + uint64_t capability = NetManagerStandard::NetCap::NET_CAPABILITY_SNSSAI2; + int32_t expected = DATA_CONTEXT_ROLE_SNSSAI2_ID; + int32_t actual = apnManager->FindApnIdByCapability(capability); + ASSERT_EQ(actual, expected); +} + +/** + * @tc.number FindApnIdByCapability_009 + * @tc.name test function branch + * @tc.desc Function test + */ +HWTEST_F(ApnManagerTest, FindApnIdByCapability_012, Function | MediumTest | Level1) +{ + uint64_t capability = NetManagerStandard::NetCap::NET_CAPABILITY_SNSSAI3; + int32_t expected = DATA_CONTEXT_ROLE_SNSSAI3_ID; + int32_t actual = apnManager->FindApnIdByCapability(capability); + ASSERT_EQ(actual, expected); +} + +/** + * @tc.number FindApnIdByCapability_009 + * @tc.name test function branch + * @tc.desc Function test + */ +HWTEST_F(ApnManagerTest, FindApnIdByCapability_013, Function | MediumTest | Level1) +{ + uint64_t capability = NetManagerStandard::NetCap::NET_CAPABILITY_SNSSAI4; + int32_t expected = DATA_CONTEXT_ROLE_SNSSAI4_ID; + int32_t actual = apnManager->FindApnIdByCapability(capability); + ASSERT_EQ(actual, expected); +} + +/** + * @tc.number FindApnIdByCapability_009 + * @tc.name test function branch + * @tc.desc Function test + */ +HWTEST_F(ApnManagerTest, FindApnIdByCapability_014, Function | MediumTest | Level1) +{ + uint64_t capability = NetManagerStandard::NetCap::NET_CAPABILITY_SNSSAI5; + int32_t expected = DATA_CONTEXT_ROLE_SNSSAI5_ID; + int32_t actual = apnManager->FindApnIdByCapability(capability); + ASSERT_EQ(actual, expected); +} + +/** + * @tc.number FindApnIdByCapability_009 + * @tc.name test function branch + * @tc.desc Function test + */ +HWTEST_F(ApnManagerTest, FindApnIdByCapability_015, Function | MediumTest | Level1) +{ + uint64_t capability = NetManagerStandard::NetCap::NET_CAPABILITY_SNSSAI6; + int32_t expected = DATA_CONTEXT_ROLE_SNSSAI6_ID; + int32_t actual = apnManager->FindApnIdByCapability(capability); + ASSERT_EQ(actual, expected); +} + /** * @tc.number FindBestCapability_001 * @tc.name test function branch diff --git a/test/cellular_data_client_test.cpp b/test/cellular_data_client_test.cpp index ab7e240b..4205a2b0 100644 --- a/test/cellular_data_client_test.cpp +++ b/test/cellular_data_client_test.cpp @@ -281,5 +281,65 @@ HWTEST_F(CellularDataClientTest, GetInternalActReportInfo_001, TestSize.Level0) int32_t result = CellularDataClient::GetInstance().GetInternalActReportInfo(0, info); EXPECT_EQ(result, TELEPHONY_ERR_PERMISSION_ERR); } + +/** + * @tc.number SendUrspDecodeResult_001 + * @tc.name test function branch + * @tc.desc Function test + */ +HWTEST_F(CellularDataClientTest, SendUrspDecodeResult_001, TestSize.Level0) +{ + std::vector buffer = {}; + int32_t result = CellularDataClient::GetInstance().SendUrspDecodeResult(0, buffer); + EXPECT_EQ(result, 0); +} + +/** + * @tc.number SendUePolicySectionIdentifier_001 + * @tc.name test function branch + * @tc.desc Function test + */ +HWTEST_F(CellularDataClientTest, SendUePolicySectionIdentifier_001, TestSize.Level0) +{ + std::vector buffer = {}; + int32_t result = CellularDataClient::GetInstance().SendUePolicySectionIdentifier(0, buffer); + EXPECT_EQ(result, 0); +} + +/** + * @tc.number SendImsRsdList_001 + * @tc.name test function branch + * @tc.desc Function test + */ +HWTEST_F(CellularDataClientTest, SendImsRsdList_001, TestSize.Level0) +{ + std::vector buffer = {}; + int32_t result = CellularDataClient::GetInstance().SendImsRsdList(0, buffer); + EXPECT_EQ(result, 0); +} + +/** + * @tc.number GetNetworkSliceAllowedNssai_001 + * @tc.name test function branch + * @tc.desc Function test + */ +HWTEST_F(CellularDataClientTest, GetNetworkSliceAllowedNssai_001, TestSize.Level0) +{ + std::vector buffer = {}; + int32_t result = CellularDataClient::GetInstance().GetNetworkSliceAllowedNssai(0, buffer); + EXPECT_EQ(result, 0); +} + +/** + * @tc.number GetNetworkSliceEhplmn_001 + * @tc.name test function branch + * @tc.desc Function test + */ +HWTEST_F(CellularDataClientTest, GetNetworkSliceEhplmn_001, TestSize.Level0) +{ + int32_t result = CellularDataClient::GetInstance().GetNetworkSliceEhplmn(0); + EXPECT_EQ(result, 0); +} + } // namespace Telephony } // namespace OHOS \ No newline at end of file diff --git a/test/cellular_data_service_test.cpp b/test/cellular_data_service_test.cpp index 14370537..0ed9dec7 100644 --- a/test/cellular_data_service_test.cpp +++ b/test/cellular_data_service_test.cpp @@ -108,6 +108,13 @@ HWTEST_F(CellularDataServiceTest, CellularDataService_002, TestSize.Level0) service->GetCellularDataSupplierId(DEFAULT_SIM_SLOT_ID, NetCap::NET_CAPABILITY_END, supplierId)); service->CorrectNetSupplierNoAvailable(DEFAULT_SIM_SLOT_ID); ASSERT_EQ(TELEPHONY_ERR_PERMISSION_ERR, service->EstablishAllApnsIfConnectable(DEFAULT_SIM_SLOT_ID)); + int32_t slotId = 0; + std::vector buffer = {}; + ASSERT_EQ(TELEPHONY_ERR_LOCAL_PTR_NULL, service->SendUrspDecodeResult(slotId, buffer)); + ASSERT_EQ(TELEPHONY_ERR_LOCAL_PTR_NULL, service->SendUePolicySectionIdentifier(slotId, buffer)); + ASSERT_EQ(TELEPHONY_ERR_LOCAL_PTR_NULL, service->SndImsRsdList(slotId, buffer)); + ASSERT_EQ(TELEPHONY_ERR_LOCAL_PTR_NULL, service->GetNetworkSliceAllowedNssai(slotId, buffer)); + ASSERT_EQ(TELEPHONY_ERR_LOCAL_PTR_NULL, service->GetNetworkSliceEhplmn(slotId)); int32_t regState = -1; service->GetSupplierRegisterState(supplierId, regState); bool isSupportDun = false; -- Gitee From 65efdc8ddc95a3381943ca8c816371f9027ebe69 Mon Sep 17 00:00:00 2001 From: zhangwuling1 Date: Wed, 19 Mar 2025 11:50:50 +0000 Subject: [PATCH 002/145] update services/src/cellular_data_service_stub.cpp. Signed-off-by: zhangwuling1 --- services/src/cellular_data_service_stub.cpp | 27 +++++++-------------- 1 file changed, 9 insertions(+), 18 deletions(-) diff --git a/services/src/cellular_data_service_stub.cpp b/services/src/cellular_data_service_stub.cpp index 3137c154..fcde23ed 100644 --- a/services/src/cellular_data_service_stub.cpp +++ b/services/src/cellular_data_service_stub.cpp @@ -585,13 +585,11 @@ int32_t CellularDataServiceStub::OnSendUrspDecodeResult(MessageParcel &data, Mes int32_t slotId = data.ReadInt32(); int32_t buffer_len = data.ReadInt32(); std::vector buffer; - for (int i = 0; i < buffer_len; ++i) - { + for (int i = 0; i < buffer_len; ++i) { buffer.push_back(data.ReadUint8()); } int32_t result = SendUrspDecodeResult(slotId, buffer); - if (result != TELEPHONY_ERR_SUCCESS) - { + if (result != TELEPHONY_ERR_SUCCESS) { return result; } return TELEPHONY_SUCCESS; @@ -603,13 +601,11 @@ int32_t CellularDataServiceStub::OnSendUePolicySectionIdentifier(MessageParcel & int32_t slotId = data.ReadInt32(); int32_t buffer_len = data.ReadInt32(); std::vector buffer; - for (int i = 0; i < buffer_len; ++i) - { + for (int i = 0; i < buffer_len; ++i) { buffer.push_back(data.ReadUint8()); } int32_t result = SendUePolicySectionIdentifier(slotId, buffer); - if (result != TELEPHONY_ERR_SUCCESS) - { + if (result != TELEPHONY_ERR_SUCCESS) { return result; } return TELEPHONY_SUCCESS; @@ -621,13 +617,11 @@ int32_t CellularDataServiceStub::OnSendImsRsdList(MessageParcel &data, MessagePa int32_t slotId = data.ReadInt32(); int32_t buffer_len = data.ReadInt32(); std::vector buffer; - for (int i = 0; i < buffer_len; ++i) - { + for (int i = 0; i < buffer_len; ++i) { buffer.push_back(data.ReadUint8()); } int32_t result = SendImsRsdList(slotId, buffer); - if (result != TELEPHONY_ERR_SUCCESS) - { + if (result != TELEPHONY_ERR_SUCCESS) { return result; } return TELEPHONY_SUCCESS; @@ -639,13 +633,11 @@ int32_t CellularDataServiceStub::OnGetNetworkSliceAllowedNssai(MessageParcel &da int32_t slotId = data.ReadInt32(); int32_t buffer_len = data.ReadInt32(); std::vector buffer; - for (int i = 0; i < buffer_len; ++i) - { + for (int i = 0; i < buffer_len; ++i) { buffer.push_back(data.ReadUint8()); } int32_t result = GetNetworkSliceAllowedNssai(slotId, buffer); - if (result != TELEPHONY_ERR_SUCCESS) - { + if (result != TELEPHONY_ERR_SUCCESS) { return result; } return TELEPHONY_SUCCESS; @@ -656,8 +648,7 @@ int32_t CellularDataServiceStub::OnGetNetworkSliceEhplmn(MessageParcel &data, Me TELEPHONY_LOGI("CellularDataServiceStub::OnGetNetworkSliceEhplmn"); int32_t slotId = data.ReadInt32(); int32_t result = GetNetworkSliceEhplmn(slotId); - if (result != TELEPHONY_ERR_SUCCESS) - { + if (result != TELEPHONY_ERR_SUCCESS) { return result; } return TELEPHONY_SUCCESS; -- Gitee From ee942d07052904560e0bc8c889c91c0107dbe0cb Mon Sep 17 00:00:00 2001 From: zhangwuling1 Date: Wed, 19 Mar 2025 11:52:58 +0000 Subject: [PATCH 003/145] update BUILD.gn. Signed-off-by: zhangwuling1 --- BUILD.gn | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/BUILD.gn b/BUILD.gn index 4b4a285d..19543f4b 100644 --- a/BUILD.gn +++ b/BUILD.gn @@ -97,13 +97,13 @@ ohos_shared_library("tel_cellular_data") { "netmanager_base:net_conn_manager_if", "netmanager_base:net_policy_manager_if", "netmanager_base:net_stats_manager_if", + "netmanager_ext:networkslice_manager_if", "preferences:native_preferences", "relational_store:native_dataability", "relational_store:native_rdb", "safwk:system_ability_fwk", "samgr:samgr_proxy", "telephony_data:tel_telephony_data", - "netmanager_ext:networkslice_manager_if", ] defines = [ -- Gitee From a83eacb6f53de79ce1f52cb7b36eb776deccd86f Mon Sep 17 00:00:00 2001 From: zhangwuling1 Date: Thu, 20 Mar 2025 09:45:40 +0000 Subject: [PATCH 004/145] update services/src/cellular_data_service_stub.cpp. Signed-off-by: zhangwuling1 --- services/src/cellular_data_service_stub.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/services/src/cellular_data_service_stub.cpp b/services/src/cellular_data_service_stub.cpp index fcde23ed..7174f294 100644 --- a/services/src/cellular_data_service_stub.cpp +++ b/services/src/cellular_data_service_stub.cpp @@ -586,7 +586,7 @@ int32_t CellularDataServiceStub::OnSendUrspDecodeResult(MessageParcel &data, Mes int32_t buffer_len = data.ReadInt32(); std::vector buffer; for (int i = 0; i < buffer_len; ++i) { - buffer.push_back(data.ReadUint8()); + buffer.push_back(data.ReadUint8()); } int32_t result = SendUrspDecodeResult(slotId, buffer); if (result != TELEPHONY_ERR_SUCCESS) { -- Gitee From 8f4ab0c2d17c7ef38a2ffefe2853a3f849616139 Mon Sep 17 00:00:00 2001 From: HuangHaitao Date: Thu, 20 Mar 2025 11:24:05 +0000 Subject: [PATCH 005/145] =?UTF-8?q?=E6=97=A0=E6=9D=83=E9=99=90=E6=97=B6?= =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E5=BC=82=E5=B8=B8=E6=8A=9B=E5=87=BA=EF=BC=8C?= =?UTF-8?q?=E5=8E=9F=E6=9D=A5=E8=BF=94=E5=9B=9Eundefined=EF=BC=8C=E4=B8=8D?= =?UTF-8?q?=E7=AC=A6=E5=90=88=E6=96=87=E6=A1=A3=E6=8F=8F=E8=BF=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: HuangHaitao --- frameworks/js/napi/src/napi_cellular_data.cpp | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/frameworks/js/napi/src/napi_cellular_data.cpp b/frameworks/js/napi/src/napi_cellular_data.cpp index 42f3761d..2535f3e4 100644 --- a/frameworks/js/napi/src/napi_cellular_data.cpp +++ b/frameworks/js/napi/src/napi_cellular_data.cpp @@ -265,6 +265,9 @@ static napi_value IsCellularDataEnabledSync(napi_env env, napi_callback_info inf if (IsCellularDataManagerInited()) { auto errorCode = CellularDataClient::GetInstance().IsCellularDataEnabled(isEnabled); if (errorCode != TELEPHONY_SUCCESS) { + JsError error = NapiUtil::ConverErrorMessageWithPermissionForJs( + errorCode, "isCellularDataEnabledSync", GET_NETWORK_INFO); + NapiUtil::ThrowError(env, error.errorCode, error.errorMessage); return value; } } else { @@ -632,12 +635,16 @@ static napi_value IsCellularDataRoamingEnabledSync(napi_env env, napi_callback_i napi_get_value_int32(env, parameters[0], &slotId); if (!IsValidSlotId(slotId)) { TELEPHONY_LOGE("IsCellularDataRoamingEnabledSync slotId is invalid"); + NapiUtil::ThrowParameterError(env); return value; } if (IsCellularDataManagerInited()) { auto &dataManager = CellularDataClient::GetInstance(); auto errorCode = dataManager.IsCellularDataRoamingEnabled(slotId, dataRoamingEnabled); if (errorCode != TELEPHONY_SUCCESS) { + JsError error = NapiUtil::ConverErrorMessageWithPermissionForJs( + errorCode, "isCellularDataRoamingEnabledSync", GET_NETWORK_INFO); + NapiUtil::ThrowError(env, error.errorCode, error.errorMessage); return value; } } else { -- Gitee From 7e313c37d7ccaf7c835fcb9352a2137eb1dc0f1f Mon Sep 17 00:00:00 2001 From: HuangHaitao Date: Thu, 20 Mar 2025 11:29:54 +0000 Subject: [PATCH 006/145] fix typo Signed-off-by: HuangHaitao --- frameworks/js/napi/src/napi_cellular_data.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/frameworks/js/napi/src/napi_cellular_data.cpp b/frameworks/js/napi/src/napi_cellular_data.cpp index 2535f3e4..4d761c45 100644 --- a/frameworks/js/napi/src/napi_cellular_data.cpp +++ b/frameworks/js/napi/src/napi_cellular_data.cpp @@ -644,7 +644,7 @@ static napi_value IsCellularDataRoamingEnabledSync(napi_env env, napi_callback_i if (errorCode != TELEPHONY_SUCCESS) { JsError error = NapiUtil::ConverErrorMessageWithPermissionForJs( errorCode, "isCellularDataRoamingEnabledSync", GET_NETWORK_INFO); - NapiUtil::ThrowError(env, error.errorCode, error.errorMessage); + NapiUtil::ThrowError(env, error.errorCode, error.errorMessage); return value; } } else { -- Gitee From cd85f86f820ae316c9b1932c62eefca046035517 Mon Sep 17 00:00:00 2001 From: zhangwuling1 Date: Fri, 21 Mar 2025 02:17:23 +0000 Subject: [PATCH 007/145] update BUILD.gn. Signed-off-by: zhangwuling1 --- BUILD.gn | 1 + 1 file changed, 1 insertion(+) diff --git a/BUILD.gn b/BUILD.gn index 19543f4b..67d967d9 100644 --- a/BUILD.gn +++ b/BUILD.gn @@ -214,6 +214,7 @@ ohos_static_library("tel_cellular_data_static") { "netmanager_base:net_conn_manager_if", "netmanager_base:net_policy_manager_if", "netmanager_base:net_stats_manager_if", + "netmanager_ext:networkslice_manager_if", "preferences:native_preferences", "relational_store:native_dataability", "relational_store:native_rdb", -- Gitee From 3e0d546c5f79338b2c87767a70797bf8b4629504 Mon Sep 17 00:00:00 2001 From: zhangwuling1 Date: Fri, 21 Mar 2025 02:43:01 +0000 Subject: [PATCH 008/145] update test/cellular_data_service_test.cpp. Signed-off-by: zhangwuling1 --- test/cellular_data_service_test.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/cellular_data_service_test.cpp b/test/cellular_data_service_test.cpp index 0ed9dec7..9347c29c 100644 --- a/test/cellular_data_service_test.cpp +++ b/test/cellular_data_service_test.cpp @@ -112,7 +112,7 @@ HWTEST_F(CellularDataServiceTest, CellularDataService_002, TestSize.Level0) std::vector buffer = {}; ASSERT_EQ(TELEPHONY_ERR_LOCAL_PTR_NULL, service->SendUrspDecodeResult(slotId, buffer)); ASSERT_EQ(TELEPHONY_ERR_LOCAL_PTR_NULL, service->SendUePolicySectionIdentifier(slotId, buffer)); - ASSERT_EQ(TELEPHONY_ERR_LOCAL_PTR_NULL, service->SndImsRsdList(slotId, buffer)); + ASSERT_EQ(TELEPHONY_ERR_LOCAL_PTR_NULL, service->SendImsRsdList(slotId, buffer)); ASSERT_EQ(TELEPHONY_ERR_LOCAL_PTR_NULL, service->GetNetworkSliceAllowedNssai(slotId, buffer)); ASSERT_EQ(TELEPHONY_ERR_LOCAL_PTR_NULL, service->GetNetworkSliceEhplmn(slotId)); int32_t regState = -1; -- Gitee From 9b9a978ee7a467841015dc950d0ee9ac8645809b Mon Sep 17 00:00:00 2001 From: HuangHaitao Date: Fri, 21 Mar 2025 02:47:57 +0000 Subject: [PATCH 009/145] fix typo Signed-off-by: HuangHaitao --- frameworks/js/napi/src/napi_cellular_data.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/frameworks/js/napi/src/napi_cellular_data.cpp b/frameworks/js/napi/src/napi_cellular_data.cpp index 4d761c45..b2919cbc 100644 --- a/frameworks/js/napi/src/napi_cellular_data.cpp +++ b/frameworks/js/napi/src/napi_cellular_data.cpp @@ -266,7 +266,7 @@ static napi_value IsCellularDataEnabledSync(napi_env env, napi_callback_info inf auto errorCode = CellularDataClient::GetInstance().IsCellularDataEnabled(isEnabled); if (errorCode != TELEPHONY_SUCCESS) { JsError error = NapiUtil::ConverErrorMessageWithPermissionForJs( - errorCode, "isCellularDataEnabledSync", GET_NETWORK_INFO); + errorCode, "isCellularDataEnabledSync", GET_NETWORK_INFO); NapiUtil::ThrowError(env, error.errorCode, error.errorMessage); return value; } -- Gitee From c1f60218964f712684107b83140de9b5e9823a8e Mon Sep 17 00:00:00 2001 From: zhangwuling1 Date: Fri, 21 Mar 2025 02:50:39 +0000 Subject: [PATCH 010/145] update frameworks/native/cellular_data_client.cpp. Signed-off-by: zhangwuling1 --- frameworks/native/cellular_data_client.cpp | 5 ----- 1 file changed, 5 deletions(-) diff --git a/frameworks/native/cellular_data_client.cpp b/frameworks/native/cellular_data_client.cpp index c5c493c2..7c4411f6 100644 --- a/frameworks/native/cellular_data_client.cpp +++ b/frameworks/native/cellular_data_client.cpp @@ -516,7 +516,6 @@ int32_t CellularDataClient::QueryAllApnInfo(std::vector &apnInfoList) int32_t CellularDataClient::SendUrspDecodeResult(int32_t slotId, std::vector buffer) { - TELEPHONY_LOGI("CellularDataClient::SendUrspDecodeResult"); sptr proxy = GetProxy(); if (proxy == nullptr) { TELEPHONY_LOGE("proxy is null"); @@ -528,7 +527,6 @@ int32_t CellularDataClient::SendUrspDecodeResult(int32_t slotId, std::vector buffer) { - TELEPHONY_LOGI("CellularDataClient::SendUePolicySectionIdentifier"); sptr proxy = GetProxy(); if (proxy == nullptr) { TELEPHONY_LOGE("proxy is null"); @@ -540,7 +538,6 @@ int32_t CellularDataClient::SendUePolicySectionIdentifier(int32_t slotId, std::v int32_t CellularDataClient::SendImsRsdList(int32_t slotId, std::vector buffer) { - TELEPHONY_LOGI("CellularDataClient::SendImsRsdList"); sptr proxy = GetProxy(); if (proxy == nullptr) { TELEPHONY_LOGE("proxy is null"); @@ -552,7 +549,6 @@ int32_t CellularDataClient::SendImsRsdList(int32_t slotId, std::vector int32_t CellularDataClient::GetNetworkSliceAllowedNssai(int32_t slotId, std::vector buffer) { - TELEPHONY_LOGI("CellularDataClient::GetNetworkSliceAllowedNssai"); sptr proxy = GetProxy(); if (proxy == nullptr) { TELEPHONY_LOGE("proxy is null"); @@ -564,7 +560,6 @@ int32_t CellularDataClient::GetNetworkSliceAllowedNssai(int32_t slotId, std::vec int32_t CellularDataClient::GetNetworkSliceEhplmn(int32_t slotId) { - TELEPHONY_LOGI("CellularDataClient::GetNetworkSliceEhplmn"); sptr proxy = GetProxy(); if (proxy == nullptr) { TELEPHONY_LOGE("proxy is null"); -- Gitee From f47d690e5e8daf2e31d6b0336493cedc46c203e0 Mon Sep 17 00:00:00 2001 From: zhangwuling1 Date: Fri, 21 Mar 2025 02:51:40 +0000 Subject: [PATCH 011/145] update frameworks/native/cellular_data_service_proxy.cpp. Signed-off-by: zhangwuling1 --- frameworks/native/cellular_data_service_proxy.cpp | 5 ----- 1 file changed, 5 deletions(-) diff --git a/frameworks/native/cellular_data_service_proxy.cpp b/frameworks/native/cellular_data_service_proxy.cpp index 5b8050e9..83362770 100644 --- a/frameworks/native/cellular_data_service_proxy.cpp +++ b/frameworks/native/cellular_data_service_proxy.cpp @@ -911,7 +911,6 @@ int32_t CellularDataServiceProxy::QueryAllApnInfo(std::vector &apnInfoL int32_t CellularDataServiceProxy::SendUrspDecodeResult(int32_t slotId, std::vector buffer) { - TELEPHONY_LOGI("CellularDataServiceProxy::SendUrspDecodeResult"); MessageParcel data; MessageParcel reply; MessageOption option; @@ -942,7 +941,6 @@ int32_t CellularDataServiceProxy::SendUrspDecodeResult(int32_t slotId, std::vect int32_t CellularDataServiceProxy::SendUePolicySectionIdentifier(int32_t slotId, std::vector buffer) { - TELEPHONY_LOGI("CellularDataServiceProxy::SendUePolicySectionIdentifier"); MessageParcel data; MessageParcel reply; MessageOption option; @@ -973,7 +971,6 @@ int32_t CellularDataServiceProxy::SendUePolicySectionIdentifier(int32_t slotId, int32_t CellularDataServiceProxy::SendImsRsdList(int32_t slotId, std::vector buffer) { - TELEPHONY_LOGI("CellularDataServiceProxy::SendImsRsdList"); MessageParcel data; MessageParcel reply; MessageOption option; @@ -1004,7 +1001,6 @@ int32_t CellularDataServiceProxy::SendImsRsdList(int32_t slotId, std::vector buffer) { - TELEPHONY_LOGI("CellularDataServiceProxy::GetNetworkSliceAllowedNssai"); MessageParcel data; MessageParcel reply; MessageOption option; @@ -1035,7 +1031,6 @@ int32_t CellularDataServiceProxy::GetNetworkSliceAllowedNssai(int32_t slotId, st int32_t CellularDataServiceProxy::GetNetworkSliceEhplmn(int32_t slotId) { - TELEPHONY_LOGI("CellularDataServiceProxy::GetNetworkSliceEhplmn"); MessageParcel data; MessageParcel reply; MessageOption option; -- Gitee From 7bea76356e418bfbc9e5c3b491f83d896336788a Mon Sep 17 00:00:00 2001 From: zhangwuling1 Date: Fri, 21 Mar 2025 02:55:13 +0000 Subject: [PATCH 012/145] update services/src/apn_manager/apn_manager.cpp. Signed-off-by: zhangwuling1 --- services/src/apn_manager/apn_manager.cpp | 3 --- 1 file changed, 3 deletions(-) diff --git a/services/src/apn_manager/apn_manager.cpp b/services/src/apn_manager/apn_manager.cpp index 11571a1a..12b1f5c8 100644 --- a/services/src/apn_manager/apn_manager.cpp +++ b/services/src/apn_manager/apn_manager.cpp @@ -294,7 +294,6 @@ std::vector> ApnManager::GetSortApnHolder() const int32_t ApnManager::CreateAllApnItemByDatabase(int32_t slotId) { - TELEPHONY_LOGI("CreateAllApnItemByDatabase"); int32_t count = 0; if (TELEPHONY_EXT_WRAPPER.createAllApnItemExt_) { sptr extraApnItem = ApnItem::MakeDefaultApn("default"); @@ -369,7 +368,6 @@ void ApnManager::GetCTOperator(int32_t slotId, std::string &numeric) int32_t ApnManager::CreateMvnoApnItems(int32_t slotId, const std::string &mcc, const std::string &mnc) { - TELEPHONY_LOGI("CreateMvnoApnItems"); int32_t count = 0; auto helper = CellularDataRdbHelper::GetInstance(); if (helper == nullptr) { @@ -417,7 +415,6 @@ void ApnManager::ReportApnInfo(int32_t slotId, PdpProfile &apnData) int32_t ApnManager::MakeSpecificApnItem(std::vector &apnVec, int32_t slotId) { - TELEPHONY_LOGI("MakeSpecificApnItem"); std::lock_guard lock(mutex_); allApnItem_.clear(); TryMergeSimilarPdpProfile(apnVec); -- Gitee From f4d48b4999cfaede9bfd81e42f752d3d461b035f Mon Sep 17 00:00:00 2001 From: zhangwuling1 Date: Fri, 21 Mar 2025 02:55:44 +0000 Subject: [PATCH 013/145] update services/src/cellular_data_service_stub.cpp. Signed-off-by: zhangwuling1 --- services/src/cellular_data_service_stub.cpp | 5 ----- 1 file changed, 5 deletions(-) diff --git a/services/src/cellular_data_service_stub.cpp b/services/src/cellular_data_service_stub.cpp index 7174f294..6dd377da 100644 --- a/services/src/cellular_data_service_stub.cpp +++ b/services/src/cellular_data_service_stub.cpp @@ -581,7 +581,6 @@ int32_t CellularDataServiceStub::OnQueryAllApnInfo(MessageParcel &data, MessageP int32_t CellularDataServiceStub::OnSendUrspDecodeResult(MessageParcel &data, MessageParcel &reply) { - TELEPHONY_LOGI("CellularDataServiceStub::OnSendUrspDecodeResult"); int32_t slotId = data.ReadInt32(); int32_t buffer_len = data.ReadInt32(); std::vector buffer; @@ -597,7 +596,6 @@ int32_t CellularDataServiceStub::OnSendUrspDecodeResult(MessageParcel &data, Mes int32_t CellularDataServiceStub::OnSendUePolicySectionIdentifier(MessageParcel &data, MessageParcel &reply) { - TELEPHONY_LOGI("CellularDataServiceStub::OnSendUePolicySectionIdentifier"); int32_t slotId = data.ReadInt32(); int32_t buffer_len = data.ReadInt32(); std::vector buffer; @@ -613,7 +611,6 @@ int32_t CellularDataServiceStub::OnSendUePolicySectionIdentifier(MessageParcel & int32_t CellularDataServiceStub::OnSendImsRsdList(MessageParcel &data, MessageParcel &reply) { - TELEPHONY_LOGI("CellularDataServiceStub::OnSendImsRsdList"); int32_t slotId = data.ReadInt32(); int32_t buffer_len = data.ReadInt32(); std::vector buffer; @@ -629,7 +626,6 @@ int32_t CellularDataServiceStub::OnSendImsRsdList(MessageParcel &data, MessagePa int32_t CellularDataServiceStub::OnGetNetworkSliceAllowedNssai(MessageParcel &data, MessageParcel &reply) { - TELEPHONY_LOGI("CellularDataServiceStub::OnGetNetworkSliceAllowedNssai"); int32_t slotId = data.ReadInt32(); int32_t buffer_len = data.ReadInt32(); std::vector buffer; @@ -645,7 +641,6 @@ int32_t CellularDataServiceStub::OnGetNetworkSliceAllowedNssai(MessageParcel &da int32_t CellularDataServiceStub::OnGetNetworkSliceEhplmn(MessageParcel &data, MessageParcel &reply) { - TELEPHONY_LOGI("CellularDataServiceStub::OnGetNetworkSliceEhplmn"); int32_t slotId = data.ReadInt32(); int32_t result = GetNetworkSliceEhplmn(slotId); if (result != TELEPHONY_ERR_SUCCESS) { -- Gitee From a6286bf0ee7d280d13a45d979abb9e06aa49c2ec Mon Sep 17 00:00:00 2001 From: zhangwuling1 Date: Fri, 21 Mar 2025 02:57:34 +0000 Subject: [PATCH 014/145] update services/src/data_connection_manager.cpp. Signed-off-by: zhangwuling1 --- services/src/data_connection_manager.cpp | 3 --- 1 file changed, 3 deletions(-) diff --git a/services/src/data_connection_manager.cpp b/services/src/data_connection_manager.cpp index c66f0700..f7b8c106 100644 --- a/services/src/data_connection_manager.cpp +++ b/services/src/data_connection_manager.cpp @@ -486,7 +486,6 @@ void DataConnectionManager::HandleScreenStateChanged(bool isScreenOn) const void CcmDefaultState::RadioNetworkSliceUrspRpt(const AppExecFwk::InnerEvent::Pointer &event) { - TELEPHONY_LOGI("CcmDefaultState::RadioNetworkSliceUrspRpt"); std::shared_ptr networkSliceUrspInfo = event->GetSharedObject(); if (networkSliceUrspInfo == nullptr) { TELEPHONY_LOGE("networkSliceClient is null"); @@ -498,7 +497,6 @@ void CcmDefaultState::RadioNetworkSliceUrspRpt(const AppExecFwk::InnerEvent::Poi void CcmDefaultState::RadioNetworkSliceAllowedNssaiRpt(const AppExecFwk::InnerEvent::Pointer &event) { - TELEPHONY_LOGI("CcmDefaultState::RadioNetworkSliceAllowedNssaiRpt"); std::shared_ptr networkSliceAllowedNssaiInfo = event->GetSharedObject(); if (networkSliceAllowedNssaiInfo == nullptr) { @@ -511,7 +509,6 @@ void CcmDefaultState::RadioNetworkSliceAllowedNssaiRpt(const AppExecFwk::InnerEv void CcmDefaultState::RadioNetworkSliceEhplmnRpt(const AppExecFwk::InnerEvent::Pointer &event) { - TELEPHONY_LOGI("CcmDefaultState::RadioNetworkSliceEhplmnRpt"); std::shared_ptr networkSliceEhplmnInfo = event->GetSharedObject(); if (networkSliceEhplmnInfo == nullptr) { -- Gitee From 2fa7f162bc6ab873fc5761570712c27378252952 Mon Sep 17 00:00:00 2001 From: zhangwuling1 Date: Fri, 21 Mar 2025 02:58:49 +0000 Subject: [PATCH 015/145] update services/src/utils/cellular_data_net_agent.cpp. Signed-off-by: zhangwuling1 --- services/src/utils/cellular_data_net_agent.cpp | 1 - 1 file changed, 1 deletion(-) diff --git a/services/src/utils/cellular_data_net_agent.cpp b/services/src/utils/cellular_data_net_agent.cpp index 711ad1b7..45c985ea 100644 --- a/services/src/utils/cellular_data_net_agent.cpp +++ b/services/src/utils/cellular_data_net_agent.cpp @@ -44,7 +44,6 @@ CellularDataNetAgent::~CellularDataNetAgent() = default; bool CellularDataNetAgent::RegisterNetSupplier(const int32_t slotId) { - TELEPHONY_LOGI("RegisterNetSupplier, slotId = %{public}d", slotId); bool flag = false; for (NetSupplier &netSupplier : netSuppliers_) { if (netSupplier.slotId != slotId) { -- Gitee From f5f0f9754a770e8445e83d2811a3f2f2046e5a0e Mon Sep 17 00:00:00 2001 From: zhangwuling1 Date: Fri, 21 Mar 2025 06:27:22 +0000 Subject: [PATCH 016/145] update frameworks/native/cellular_data_client.cpp. Signed-off-by: zhangwuling1 --- frameworks/native/cellular_data_client.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/frameworks/native/cellular_data_client.cpp b/frameworks/native/cellular_data_client.cpp index 7c4411f6..d5b61571 100644 --- a/frameworks/native/cellular_data_client.cpp +++ b/frameworks/native/cellular_data_client.cpp @@ -470,7 +470,7 @@ int32_t CellularDataClient::GetDefaultActReportInfo(int32_t slotId, ApnActivateR } return proxy->GetDefaultActReportInfo(slotId, info); } - + int32_t CellularDataClient::GetInternalActReportInfo(int32_t slotId, ApnActivateReportInfo &info) { sptr proxy = GetProxy(); -- Gitee From 5acd1763f851143d0f1f5aeb9963c1ef375607d0 Mon Sep 17 00:00:00 2001 From: zhangwuling1 Date: Fri, 21 Mar 2025 08:00:03 +0000 Subject: [PATCH 017/145] update frameworks/native/cellular_data_service_proxy.cpp. Signed-off-by: zhangwuling1 --- .../native/cellular_data_service_proxy.cpp | 25 ++++++++++++++++--- 1 file changed, 21 insertions(+), 4 deletions(-) diff --git a/frameworks/native/cellular_data_service_proxy.cpp b/frameworks/native/cellular_data_service_proxy.cpp index 83362770..0ec2a3dd 100644 --- a/frameworks/native/cellular_data_service_proxy.cpp +++ b/frameworks/native/cellular_data_service_proxy.cpp @@ -12,7 +12,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ - +#include #include "cellular_data_service_proxy.h" #include "iremote_object.h" @@ -25,6 +25,7 @@ namespace OHOS { namespace Telephony { +constexpr int32_t INT32_MAX = std::numeric_limits::max(); int32_t CellularDataServiceProxy::IsCellularDataEnabled(bool &dataEnabled) { MessageParcel data; @@ -920,8 +921,12 @@ int32_t CellularDataServiceProxy::SendUrspDecodeResult(int32_t slotId, std::vect } data.WriteInt32(slotId); int32_t bufferlen = (int32_t)buffer.size(); + if (bufferlen <= 0 || bufferlen > INT32_MAX) { + TELEPHONY_LOGE("buffer length is invalid: %{public}d", bufferlen); + return TELEPHONY_ERR_ARGUMENT_INVALID; + } data.WriteInt32(bufferlen); - for (size_t i = 0; i < buffer.size(); ++i) { + for (int i = 0; i < bufferlen; ++i) { data.WriteInt32(buffer[i]); } if (Remote() == nullptr) { @@ -950,8 +955,12 @@ int32_t CellularDataServiceProxy::SendUePolicySectionIdentifier(int32_t slotId, } data.WriteInt32(slotId); int32_t bufferlen = (int32_t)buffer.size(); + if (bufferlen <= 0 || bufferlen > INT32_MAX) { + TELEPHONY_LOGE("buffer length is invalid: %{public}d", bufferlen); + return TELEPHONY_ERR_ARGUMENT_INVALID; + } data.WriteInt32(bufferlen); - for (size_t i = 0; i < buffer.size(); ++i) { + for (int i = 0; i < bufferlen; ++i) { data.WriteInt32(buffer[i]); } if (Remote() == nullptr) { @@ -980,8 +989,12 @@ int32_t CellularDataServiceProxy::SendImsRsdList(int32_t slotId, std::vector INT32_MAX) { + TELEPHONY_LOGE("buffer length is invalid: %{public}d", bufferlen); + return TELEPHONY_ERR_ARGUMENT_INVALID; + } data.WriteInt32(bufferlen); - for (size_t i = 0; i < buffer.size(); ++i) { + for (int i = 0; i < bufferlen; ++i) { data.WriteInt32(buffer[i]); } if (Remote() == nullptr) { @@ -1010,6 +1023,10 @@ int32_t CellularDataServiceProxy::GetNetworkSliceAllowedNssai(int32_t slotId, st } data.WriteInt32(slotId); int32_t bufferlen = (int32_t)buffer.size(); + if (bufferlen <= 0 || bufferlen > INT32_MAX) { + TELEPHONY_LOGE("buffer length is invalid: %{public}d", bufferlen); + return TELEPHONY_ERR_ARGUMENT_INVALID; + } data.WriteInt32(bufferlen); for (size_t i = 0; i < buffer.size(); ++i) { data.WriteInt32(buffer[i]); -- Gitee From 5f46d8e9159015f494a1eec73b1f6d6021b9a2cb Mon Sep 17 00:00:00 2001 From: zhangwuling1 Date: Fri, 21 Mar 2025 08:03:35 +0000 Subject: [PATCH 018/145] update frameworks/native/cellular_data_service_proxy.cpp. Signed-off-by: zhangwuling1 --- frameworks/native/cellular_data_service_proxy.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/frameworks/native/cellular_data_service_proxy.cpp b/frameworks/native/cellular_data_service_proxy.cpp index 0ec2a3dd..2a485714 100644 --- a/frameworks/native/cellular_data_service_proxy.cpp +++ b/frameworks/native/cellular_data_service_proxy.cpp @@ -1028,7 +1028,7 @@ int32_t CellularDataServiceProxy::GetNetworkSliceAllowedNssai(int32_t slotId, st return TELEPHONY_ERR_ARGUMENT_INVALID; } data.WriteInt32(bufferlen); - for (size_t i = 0; i < buffer.size(); ++i) { + for (int i = 0; i < bufferlen; ++i) { data.WriteInt32(buffer[i]); } if (Remote() == nullptr) { -- Gitee From a609ca6e081ba958db2239361093a468d00f2305 Mon Sep 17 00:00:00 2001 From: zhangwuling1 Date: Fri, 21 Mar 2025 08:23:35 +0000 Subject: [PATCH 019/145] update interfaces/innerkits/cellular_data_client.h. Signed-off-by: zhangwuling1 --- interfaces/innerkits/cellular_data_client.h | 1 - 1 file changed, 1 deletion(-) diff --git a/interfaces/innerkits/cellular_data_client.h b/interfaces/innerkits/cellular_data_client.h index 8b139529..bf199cde 100644 --- a/interfaces/innerkits/cellular_data_client.h +++ b/interfaces/innerkits/cellular_data_client.h @@ -336,7 +336,6 @@ public: * @brief Sync Ehplmn With Modem * * @param slotId Card slot identification. - * @param buffer msginfo * @return 0 set success, others set fail */ int32_t GetNetworkSliceEhplmn(int32_t slotId); -- Gitee From 6eb5385ce2229a1c6f83afb446b9e37715631a35 Mon Sep 17 00:00:00 2001 From: zhangwuling1 Date: Fri, 21 Mar 2025 08:37:27 +0000 Subject: [PATCH 020/145] update services/src/cellular_data_service_stub.cpp. Signed-off-by: zhangwuling1 --- services/src/cellular_data_service_stub.cpp | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/services/src/cellular_data_service_stub.cpp b/services/src/cellular_data_service_stub.cpp index 6dd377da..6ae36f70 100644 --- a/services/src/cellular_data_service_stub.cpp +++ b/services/src/cellular_data_service_stub.cpp @@ -585,6 +585,11 @@ int32_t CellularDataServiceStub::OnSendUrspDecodeResult(MessageParcel &data, Mes int32_t buffer_len = data.ReadInt32(); std::vector buffer; for (int i = 0; i < buffer_len; ++i) { + uint8_t temp; + if (!data.ReadUint8(temp)) { + TELEPHONY_LOGE("write Uint8 buffer failed."); + return TELEPHONY_ERR_READ_DATA_FAIL; + } buffer.push_back(data.ReadUint8()); } int32_t result = SendUrspDecodeResult(slotId, buffer); @@ -600,6 +605,11 @@ int32_t CellularDataServiceStub::OnSendUePolicySectionIdentifier(MessageParcel & int32_t buffer_len = data.ReadInt32(); std::vector buffer; for (int i = 0; i < buffer_len; ++i) { + uint8_t temp; + if (!data.ReadUint8(temp)) { + TELEPHONY_LOGE("write Uint8 buffer failed."); + return TELEPHONY_ERR_READ_DATA_FAIL; + } buffer.push_back(data.ReadUint8()); } int32_t result = SendUePolicySectionIdentifier(slotId, buffer); @@ -615,6 +625,11 @@ int32_t CellularDataServiceStub::OnSendImsRsdList(MessageParcel &data, MessagePa int32_t buffer_len = data.ReadInt32(); std::vector buffer; for (int i = 0; i < buffer_len; ++i) { + uint8_t temp; + if (!data.ReadUint8(temp)) { + TELEPHONY_LOGE("write Uint8 buffer failed."); + return TELEPHONY_ERR_READ_DATA_FAIL; + } buffer.push_back(data.ReadUint8()); } int32_t result = SendImsRsdList(slotId, buffer); @@ -630,6 +645,11 @@ int32_t CellularDataServiceStub::OnGetNetworkSliceAllowedNssai(MessageParcel &da int32_t buffer_len = data.ReadInt32(); std::vector buffer; for (int i = 0; i < buffer_len; ++i) { + uint8_t temp; + if (!data.ReadUint8(temp)) { + TELEPHONY_LOGE("write Uint8 buffer failed."); + return TELEPHONY_ERR_READ_DATA_FAIL; + } buffer.push_back(data.ReadUint8()); } int32_t result = GetNetworkSliceAllowedNssai(slotId, buffer); -- Gitee From af341711bff3bacb87c8153774de987362e9ba38 Mon Sep 17 00:00:00 2001 From: zhangwuling1 Date: Fri, 21 Mar 2025 08:39:24 +0000 Subject: [PATCH 021/145] update services/src/state_machine/cellular_data_state_machine.cpp. Signed-off-by: zhangwuling1 --- services/src/state_machine/cellular_data_state_machine.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/services/src/state_machine/cellular_data_state_machine.cpp b/services/src/state_machine/cellular_data_state_machine.cpp index 4e410850..8058b336 100644 --- a/services/src/state_machine/cellular_data_state_machine.cpp +++ b/services/src/state_machine/cellular_data_state_machine.cpp @@ -503,15 +503,15 @@ uint64_t CellularDataStateMachine::GetReuseApnCap() const void CellularDataStateMachine::GetNetworkSlicePara(const DataConnectionParams& connectionParams, sptr apn) { std::string apnType = connectionParams.GetApnHolder()->GetApnType(); - bool isNr_Sa = false; + bool isNrSa = false; int slotId = 0; sptr networkState(new NetworkState()); CoreManagerInner::GetInstance().GetNetworkStatus(slotId, networkState); if (networkState->GetPsRadioTech() == RadioTech::RADIO_TECHNOLOGY_NR && networkState->GetNrState() == NrState::NR_NSA_STATE_SA_ATTACHED) { - isNr_Sa = true; + isNrSa = true; } - if (!isNr_Sa) { + if (!isNrSa) { return; } std::string dnn = apn->attr_.apn_; -- Gitee From d66a9a391c7ff30afaf70abde34cf564ae079a96 Mon Sep 17 00:00:00 2001 From: zhangwuling1 Date: Fri, 21 Mar 2025 08:42:20 +0000 Subject: [PATCH 022/145] update services/src/cellular_data_service_stub.cpp. Signed-off-by: zhangwuling1 --- services/src/cellular_data_service_stub.cpp | 27 +++++++++++++-------- 1 file changed, 17 insertions(+), 10 deletions(-) diff --git a/services/src/cellular_data_service_stub.cpp b/services/src/cellular_data_service_stub.cpp index 6ae36f70..152dce93 100644 --- a/services/src/cellular_data_service_stub.cpp +++ b/services/src/cellular_data_service_stub.cpp @@ -32,6 +32,7 @@ namespace OHOS { namespace Telephony { +constexpr int32_t INT32_MAX = std::numeric_limits::max(); CellularDataServiceStub::CellularDataServiceStub() = default; CellularDataServiceStub::~CellularDataServiceStub() = default; @@ -583,13 +584,12 @@ int32_t CellularDataServiceStub::OnSendUrspDecodeResult(MessageParcel &data, Mes { int32_t slotId = data.ReadInt32(); int32_t buffer_len = data.ReadInt32(); + if (buffer_len <= 0 || buffer_len > INT32_MAX) { + TELEPHONY_LOGE("buffer length is invalid: %{public}d", buffer_len); + return TELEPHONY_ERR_ARGUMENT_INVALID; + } std::vector buffer; for (int i = 0; i < buffer_len; ++i) { - uint8_t temp; - if (!data.ReadUint8(temp)) { - TELEPHONY_LOGE("write Uint8 buffer failed."); - return TELEPHONY_ERR_READ_DATA_FAIL; - } buffer.push_back(data.ReadUint8()); } int32_t result = SendUrspDecodeResult(slotId, buffer); @@ -603,13 +603,12 @@ int32_t CellularDataServiceStub::OnSendUePolicySectionIdentifier(MessageParcel & { int32_t slotId = data.ReadInt32(); int32_t buffer_len = data.ReadInt32(); + if (buffer_len <= 0 || buffer_len > INT32_MAX) { + TELEPHONY_LOGE("buffer length is invalid: %{public}d", buffer_len); + return TELEPHONY_ERR_ARGUMENT_INVALID; + } std::vector buffer; for (int i = 0; i < buffer_len; ++i) { - uint8_t temp; - if (!data.ReadUint8(temp)) { - TELEPHONY_LOGE("write Uint8 buffer failed."); - return TELEPHONY_ERR_READ_DATA_FAIL; - } buffer.push_back(data.ReadUint8()); } int32_t result = SendUePolicySectionIdentifier(slotId, buffer); @@ -623,6 +622,10 @@ int32_t CellularDataServiceStub::OnSendImsRsdList(MessageParcel &data, MessagePa { int32_t slotId = data.ReadInt32(); int32_t buffer_len = data.ReadInt32(); + if (buffer_len <= 0 || buffer_len > INT32_MAX) { + TELEPHONY_LOGE("buffer length is invalid: %{public}d", buffer_len); + return TELEPHONY_ERR_ARGUMENT_INVALID; + } std::vector buffer; for (int i = 0; i < buffer_len; ++i) { uint8_t temp; @@ -643,6 +646,10 @@ int32_t CellularDataServiceStub::OnGetNetworkSliceAllowedNssai(MessageParcel &da { int32_t slotId = data.ReadInt32(); int32_t buffer_len = data.ReadInt32(); + if (buffer_len <= 0 || buffer_len > INT32_MAX) { + TELEPHONY_LOGE("buffer length is invalid: %{public}d", buffer_len); + return TELEPHONY_ERR_ARGUMENT_INVALID; + } std::vector buffer; for (int i = 0; i < buffer_len; ++i) { uint8_t temp; -- Gitee From 7123a4e14fadbf249b08e79fc770a916e919a807 Mon Sep 17 00:00:00 2001 From: zhangwuling1 Date: Fri, 21 Mar 2025 08:50:26 +0000 Subject: [PATCH 023/145] update frameworks/native/cellular_data_service_proxy.cpp. Signed-off-by: zhangwuling1 --- frameworks/native/cellular_data_service_proxy.cpp | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/frameworks/native/cellular_data_service_proxy.cpp b/frameworks/native/cellular_data_service_proxy.cpp index 2a485714..b8c1de5e 100644 --- a/frameworks/native/cellular_data_service_proxy.cpp +++ b/frameworks/native/cellular_data_service_proxy.cpp @@ -25,7 +25,7 @@ namespace OHOS { namespace Telephony { -constexpr int32_t INT32_MAX = std::numeric_limits::max(); +constexpr int32_t BUFFER_MAX = 65538; int32_t CellularDataServiceProxy::IsCellularDataEnabled(bool &dataEnabled) { MessageParcel data; @@ -921,7 +921,7 @@ int32_t CellularDataServiceProxy::SendUrspDecodeResult(int32_t slotId, std::vect } data.WriteInt32(slotId); int32_t bufferlen = (int32_t)buffer.size(); - if (bufferlen <= 0 || bufferlen > INT32_MAX) { + if (bufferlen <= 0 || bufferlen > BUFFER_MAX) { TELEPHONY_LOGE("buffer length is invalid: %{public}d", bufferlen); return TELEPHONY_ERR_ARGUMENT_INVALID; } @@ -955,7 +955,7 @@ int32_t CellularDataServiceProxy::SendUePolicySectionIdentifier(int32_t slotId, } data.WriteInt32(slotId); int32_t bufferlen = (int32_t)buffer.size(); - if (bufferlen <= 0 || bufferlen > INT32_MAX) { + if (bufferlen <= 0 || bufferlen > BUFFER_MAX) { TELEPHONY_LOGE("buffer length is invalid: %{public}d", bufferlen); return TELEPHONY_ERR_ARGUMENT_INVALID; } @@ -989,7 +989,7 @@ int32_t CellularDataServiceProxy::SendImsRsdList(int32_t slotId, std::vector INT32_MAX) { + if (bufferlen <= 0 || bufferlen > BUFFER_MAX) { TELEPHONY_LOGE("buffer length is invalid: %{public}d", bufferlen); return TELEPHONY_ERR_ARGUMENT_INVALID; } @@ -1023,7 +1023,7 @@ int32_t CellularDataServiceProxy::GetNetworkSliceAllowedNssai(int32_t slotId, st } data.WriteInt32(slotId); int32_t bufferlen = (int32_t)buffer.size(); - if (bufferlen <= 0 || bufferlen > INT32_MAX) { + if (bufferlen <= 0 || bufferlen > BUFFER_MAX) { TELEPHONY_LOGE("buffer length is invalid: %{public}d", bufferlen); return TELEPHONY_ERR_ARGUMENT_INVALID; } -- Gitee From 06f1b742fa63ee0ff0166945515f1c0bb324a381 Mon Sep 17 00:00:00 2001 From: zhangwuling1 Date: Fri, 21 Mar 2025 08:50:49 +0000 Subject: [PATCH 024/145] update frameworks/native/cellular_data_service_proxy.cpp. Signed-off-by: zhangwuling1 --- frameworks/native/cellular_data_service_proxy.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/frameworks/native/cellular_data_service_proxy.cpp b/frameworks/native/cellular_data_service_proxy.cpp index b8c1de5e..d216b96b 100644 --- a/frameworks/native/cellular_data_service_proxy.cpp +++ b/frameworks/native/cellular_data_service_proxy.cpp @@ -12,7 +12,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -#include + #include "cellular_data_service_proxy.h" #include "iremote_object.h" -- Gitee From b527dc51da6fad5223e8f3e298850582fe68ba54 Mon Sep 17 00:00:00 2001 From: zhangwuling1 Date: Fri, 21 Mar 2025 08:51:33 +0000 Subject: [PATCH 025/145] update services/src/cellular_data_service_stub.cpp. Signed-off-by: zhangwuling1 --- services/src/cellular_data_service_stub.cpp | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/services/src/cellular_data_service_stub.cpp b/services/src/cellular_data_service_stub.cpp index 152dce93..5bddccf7 100644 --- a/services/src/cellular_data_service_stub.cpp +++ b/services/src/cellular_data_service_stub.cpp @@ -32,7 +32,7 @@ namespace OHOS { namespace Telephony { -constexpr int32_t INT32_MAX = std::numeric_limits::max(); +constexpr int32_t BUFFER_MAX = 65538; CellularDataServiceStub::CellularDataServiceStub() = default; CellularDataServiceStub::~CellularDataServiceStub() = default; @@ -584,7 +584,7 @@ int32_t CellularDataServiceStub::OnSendUrspDecodeResult(MessageParcel &data, Mes { int32_t slotId = data.ReadInt32(); int32_t buffer_len = data.ReadInt32(); - if (buffer_len <= 0 || buffer_len > INT32_MAX) { + if (buffer_len <= 0 || buffer_len > BUFFER_MAX) { TELEPHONY_LOGE("buffer length is invalid: %{public}d", buffer_len); return TELEPHONY_ERR_ARGUMENT_INVALID; } @@ -603,7 +603,7 @@ int32_t CellularDataServiceStub::OnSendUePolicySectionIdentifier(MessageParcel & { int32_t slotId = data.ReadInt32(); int32_t buffer_len = data.ReadInt32(); - if (buffer_len <= 0 || buffer_len > INT32_MAX) { + if (buffer_len <= 0 || buffer_len > BUFFER_MAX) { TELEPHONY_LOGE("buffer length is invalid: %{public}d", buffer_len); return TELEPHONY_ERR_ARGUMENT_INVALID; } @@ -622,7 +622,7 @@ int32_t CellularDataServiceStub::OnSendImsRsdList(MessageParcel &data, MessagePa { int32_t slotId = data.ReadInt32(); int32_t buffer_len = data.ReadInt32(); - if (buffer_len <= 0 || buffer_len > INT32_MAX) { + if (buffer_len <= 0 || buffer_len > BUFFER_MAX) { TELEPHONY_LOGE("buffer length is invalid: %{public}d", buffer_len); return TELEPHONY_ERR_ARGUMENT_INVALID; } @@ -646,7 +646,7 @@ int32_t CellularDataServiceStub::OnGetNetworkSliceAllowedNssai(MessageParcel &da { int32_t slotId = data.ReadInt32(); int32_t buffer_len = data.ReadInt32(); - if (buffer_len <= 0 || buffer_len > INT32_MAX) { + if (buffer_len <= 0 || buffer_len > BUFFER_MAX) { TELEPHONY_LOGE("buffer length is invalid: %{public}d", buffer_len); return TELEPHONY_ERR_ARGUMENT_INVALID; } -- Gitee From 58562fe3788e8cafab2001e5ed6e8f0e7aabfba0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=BD=AD=E6=B6=9B?= Date: Mon, 24 Mar 2025 08:54:28 +0000 Subject: [PATCH 026/145] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E9=87=8D=E5=90=AF?= =?UTF-8?q?=E6=97=B6preferapn=E8=8E=B7=E5=8F=96=E5=A4=B1=E8=B4=A5=E6=97=B6?= =?UTF-8?q?=EF=BC=8C=E5=88=9B=E5=BB=BAAPNlist=E4=B8=8D=E6=AD=A3=E7=A1=AE?= =?UTF-8?q?=EF=BC=9B=20=E4=BF=AE=E5=A4=8DAPN=E8=BD=AE=E8=AF=A2=E5=90=8E?= =?UTF-8?q?=EF=BC=8CAPNlist=E5=8F=98=E5=8C=96=E6=97=B6=EF=BC=8C=E6=BF=80?= =?UTF-8?q?=E6=B4=BB=E9=80=89=E6=8B=A9APN=E4=B8=8D=E5=AF=B9=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 彭涛 --- services/include/apn_manager/apn_manager.h | 1 + services/src/apn_manager/apn_manager.cpp | 37 ++++++++++++++++--- .../apn_manager/connection_retry_policy.cpp | 12 ++++++ .../src/utils/cellular_data_rdb_helper.cpp | 10 ++--- 4 files changed, 49 insertions(+), 11 deletions(-) diff --git a/services/include/apn_manager/apn_manager.h b/services/include/apn_manager/apn_manager.h index 09df0254..c3b138f3 100644 --- a/services/include/apn_manager/apn_manager.h +++ b/services/include/apn_manager/apn_manager.h @@ -65,6 +65,7 @@ private: void GetCTOperator(int32_t slotId, std::string &numeric); void TryMergeSimilarPdpProfile(std::vector &apnVec); void MergePdpProfile(PdpProfile &newProfile, PdpProfile &oldProfile); + bool GetPreferId(int32_t slotId); private: static const std::map apnIdApnNameMap_; diff --git a/services/src/apn_manager/apn_manager.cpp b/services/src/apn_manager/apn_manager.cpp index 12b1f5c8..c706f569 100644 --- a/services/src/apn_manager/apn_manager.cpp +++ b/services/src/apn_manager/apn_manager.cpp @@ -313,17 +313,16 @@ int32_t ApnManager::CreateAllApnItemByDatabase(int32_t slotId) return count; } TELEPHONY_LOGI("current slotId = %{public}d, numeric = %{public}s", slotId, numeric.c_str()); + preferId_ = INVALID_PROFILE_ID; + if (!GetPreferId(slotId)) { + TELEPHONY_LOGE("query prefer apn fail"); + return count; + } auto helper = CellularDataRdbHelper::GetInstance(); if (helper == nullptr) { TELEPHONY_LOGE("get cellularDataRdbHelper failed"); return count; } - preferId_ = INVALID_PROFILE_ID; - std::vector preferApnVec; - if (helper->QueryPreferApn(slotId, preferApnVec)) { - preferId_ = preferApnVec[0].profileId; - TELEPHONY_LOGI("query preferId_ = %{public}d", preferId_); - } std::string mcc = numeric.substr(0, DEFAULT_MCC_SIZE); std::string mnc = numeric.substr(mcc.size(), numeric.size() - mcc.size()); int32_t mvnoCount = CreateMvnoApnItems(slotId, mcc, mnc); @@ -761,5 +760,31 @@ void ApnManager::GetBipApnItem(sptr &bipApn) } } } + +bool ApnManager::GetPreferId(int32_t slotId) +{ + int32_t simId = CoreManagerInner::GetInstance().GetSimId(slotId); + if (simId <= INVALID_SIM_ID) { + TELEPHONY_LOGE("Slot%{public}d: failed due to invalid sim id %{public}d", slotId, simId); + return false; + } + auto helper = CellularDataRdbHelper::GetInstance(); + if (helper == nullptr) { + TELEPHONY_LOGE("get cellularDataRdbHelper failed"); + return false; + } + std::vector preferApnVec; + if (helper->QueryPreferApn(slotId, preferApnVec)) { + if (preferApnVec.size() > 0) { + preferId_ = preferApnVec[0].profileId; + TELEPHONY_LOGI("query preferId_ = %{public}d", preferId_); + } else { + TELEPHONY_LOGI("query prefer apn is null"); + } + return true; + } + TELEPHONY_LOGE("query prefer apn fail"); + return false; +} } // namespace Telephony } // namespace OHOS diff --git a/services/src/apn_manager/connection_retry_policy.cpp b/services/src/apn_manager/connection_retry_policy.cpp index ee7bab92..5b17ec02 100644 --- a/services/src/apn_manager/connection_retry_policy.cpp +++ b/services/src/apn_manager/connection_retry_policy.cpp @@ -81,6 +81,18 @@ sptr ConnectionRetryPolicy::GetNextRetryApnItem() const void ConnectionRetryPolicy::SetMatchedApns(std::vector> &apns) { + if (matchedApns_.size() != apns.size()) { + TELEPHONY_LOGI("reset currentApnIndex"); + currentApnIndex_ = 0; + } else { + for (int32_t i = 0; i < apns.size(); i++) { + if (apns[i]->attr_.profileId_ != matchedApns_[i]->attr_.profileId_) { + TELEPHONY_LOGI("reset currentApnIndex"); + currentApnIndex_ = 0; + break; + } + } + } matchedApns_ = apns; } diff --git a/services/src/utils/cellular_data_rdb_helper.cpp b/services/src/utils/cellular_data_rdb_helper.cpp index 35fb2584..9711a483 100644 --- a/services/src/utils/cellular_data_rdb_helper.cpp +++ b/services/src/utils/cellular_data_rdb_helper.cpp @@ -170,12 +170,12 @@ bool CellularDataRdbHelper::QueryPreferApn(int32_t slotId, std::vectorClose(); dataShareHelper->Release(); - if (apnVec.size() > 0) { - return true; + if (apnVec.size() <= 0) { + TELEPHONY_LOGI("simid no set prefer apn"); + CellularDataHiSysEvent::WriteDataActivateFaultEvent(slotId, SWITCH_ON, + CellularDataErrorCode::DATA_ERROR_APN_FOUND_EMPTY, "Apn list is empty"); } - CellularDataHiSysEvent::WriteDataActivateFaultEvent(slotId, SWITCH_ON, - CellularDataErrorCode::DATA_ERROR_APN_FOUND_EMPTY, "Apn list is empty"); - return false; + return true; } void CellularDataRdbHelper::ReadApnResult( -- Gitee From 5c58d399787d85bca9850c0a91c38d606909f2f8 Mon Sep 17 00:00:00 2001 From: cavalier Date: Mon, 24 Mar 2025 17:16:11 +0800 Subject: [PATCH 027/145] Description:return err when query db failed Signed-off-by: cavalier --- services/src/cellular_data_handler.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/services/src/cellular_data_handler.cpp b/services/src/cellular_data_handler.cpp index 41aa42b0..68472639 100644 --- a/services/src/cellular_data_handler.cpp +++ b/services/src/cellular_data_handler.cpp @@ -157,6 +157,7 @@ int32_t CellularDataHandler::SetCellularDataEnable(bool userDataOn) int32_t result = dataSwitchSettings_->QueryUserDataStatus(dataEnabled); if (result != TELEPHONY_ERR_SUCCESS) { TELEPHONY_LOGE("Slot%{public}d: Query result: %{public}d", slotId_, result); + return result; } if (dataEnabled == userDataOn) { TELEPHONY_LOGI("Slot%{public}d: The status of the cellular data switch has not changed", slotId_); -- Gitee From 2f78d77d5ca6dfa6d130522480fee35e552786f6 Mon Sep 17 00:00:00 2001 From: heqianmo Date: Tue, 25 Mar 2025 13:39:11 +0000 Subject: [PATCH 028/145] update test/mock/mock_net_conn_service.h. Signed-off-by: heqianmo --- test/mock/mock_net_conn_service.h | 2 ++ 1 file changed, 2 insertions(+) diff --git a/test/mock/mock_net_conn_service.h b/test/mock/mock_net_conn_service.h index dafb5cdb..3db4a4e0 100644 --- a/test/mock/mock_net_conn_service.h +++ b/test/mock/mock_net_conn_service.h @@ -114,6 +114,8 @@ public: MOCK_METHOD(int32_t, GetPacUrl, (std::string &pacUrl)); MOCK_METHOD(int32_t, SetAppIsFrozened, (uint32_t uid, bool isFrozened)); MOCK_METHOD(int32_t, EnableAppFrozenedCallbackLimitation, (bool flag)); + MOCK_METHOD(int32_t, UpdateSupplierScore, + (NetBearType bearerType, const std::string &ident, uint32_t detectionStatus, uint32_t &supplierId)); }; } // namespace NetManagerStandard -- Gitee From 5825930397c7c38e84c62342136bc8ce545f9583 Mon Sep 17 00:00:00 2001 From: l30045243 Date: Thu, 27 Mar 2025 21:14:31 +0800 Subject: [PATCH 029/145] =?UTF-8?q?spn=20show=20error=20in=20roaming=20Sig?= =?UTF-8?q?ned-off-by:=20=E6=9D=8E=E6=B1=9F=E5=BD=A4=20<1332187805@qq.com>?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- test/mock/mock_net_conn_service.h | 2 ++ test/mock/mock_sim_manager.h | 2 ++ 2 files changed, 4 insertions(+) diff --git a/test/mock/mock_net_conn_service.h b/test/mock/mock_net_conn_service.h index dafb5cdb..3db4a4e0 100644 --- a/test/mock/mock_net_conn_service.h +++ b/test/mock/mock_net_conn_service.h @@ -114,6 +114,8 @@ public: MOCK_METHOD(int32_t, GetPacUrl, (std::string &pacUrl)); MOCK_METHOD(int32_t, SetAppIsFrozened, (uint32_t uid, bool isFrozened)); MOCK_METHOD(int32_t, EnableAppFrozenedCallbackLimitation, (bool flag)); + MOCK_METHOD(int32_t, UpdateSupplierScore, + (NetBearType bearerType, const std::string &ident, uint32_t detectionStatus, uint32_t &supplierId)); }; } // namespace NetManagerStandard diff --git a/test/mock/mock_sim_manager.h b/test/mock/mock_sim_manager.h index 6a538d7f..64223e40 100644 --- a/test/mock/mock_sim_manager.h +++ b/test/mock/mock_sim_manager.h @@ -100,6 +100,8 @@ public: MOCK_METHOD2(SendTerminalResponseCmd, int32_t(int32_t, const std::string &)); MOCK_METHOD2(RegisterSimAccountCallback, int32_t(const int32_t, const sptr &)); MOCK_METHOD2(UpdateImsCapFromChip, void(int32_t, const ImsCapFromChip &)); + MOCK_METHOD2(GetSpdiPlmns, int32_t(int32_t, std::set &)); + MOCK_METHOD2(GetEhPlmns, int32_t(int32_t, std::set &)); MOCK_METHOD3(GetLockState, int32_t(int32_t, LockType, LockState &)); MOCK_METHOD3(GetSimAccountInfo, int32_t(int32_t, bool, IccAccountInfo &)); MOCK_METHOD3(ObtainSpnCondition, int(int32_t, bool, std::string)); -- Gitee From 3b22c127190f6c1e4e67dbf97b1ca9f7f6213095 Mon Sep 17 00:00:00 2001 From: zhengsiwen960323 Date: Tue, 1 Apr 2025 06:28:49 +0000 Subject: [PATCH 030/145] update test/BUILD.gn. Signed-off-by: zhengsiwen960323 --- test/BUILD.gn | 25 +++++++++++++++---------- 1 file changed, 15 insertions(+), 10 deletions(-) diff --git a/test/BUILD.gn b/test/BUILD.gn index 34f4dddb..3fdb01a0 100644 --- a/test/BUILD.gn +++ b/test/BUILD.gn @@ -16,8 +16,9 @@ SOURCE_DIR = ".." ohos_unittest("tel_cellular_data_test") { subsystem_name = "telephony" part_name = "cellular_data" - test_module = "tel_cellular_data_test" - module_out_path = part_name + "/" + test_module + test_module = "cellular_data" + test_suite = "tel_cellular_data_test" + module_out_path = part_name + "/" + test_module + "/" + test_suite sources = [ "$SOURCE_DIR/test/apn_manager_test.cpp", @@ -82,8 +83,9 @@ ohos_unittest("tel_cellular_data_test") { ohos_unittest("tel_cellular_state_machine_test") { subsystem_name = "telephony" part_name = "cellular_data" - test_module = "tel_cellular_data_test" - module_out_path = part_name + "/" + test_module + test_module = "cellular_data" + test_suite = "tel_cellular_state_machine_test" + module_out_path = part_name + "/" + test_module + "/" + test_suite sources = [ "$SOURCE_DIR/test/cellular_state_machine_test.cpp", @@ -145,8 +147,9 @@ ohos_unittest("tel_cellular_state_machine_test") { ohos_unittest("tel_cellular_state_branch_test") { subsystem_name = "telephony" part_name = "cellular_data" - test_module = "tel_cellular_data_test" - module_out_path = part_name + "/" + test_module + test_module = "cellular_data" + test_suite = "tel_cellular_state_branch_test" + module_out_path = part_name + "/" + test_module + "/" + test_suite sources = [ "$SOURCE_DIR/test/cellualr_data_branch_test.cpp", @@ -207,8 +210,9 @@ ohos_unittest("tel_cellular_state_branch_test") { ohos_unittest("tel_cellular_data_client_test") { subsystem_name = "telephony" part_name = "cellular_data" - test_module = "tel_cellular_data_test" - module_out_path = part_name + "/" + test_module + test_module = "cellular_data" + test_suite = "tel_cellular_data_client_test" + module_out_path = part_name + "/" + test_module + "/" + test_suite sources = [ "$SOURCE_DIR/test/cellular_data_client_test.cpp", @@ -270,8 +274,9 @@ ohos_unittest("tel_cellular_data_client_test") { ohos_unittest("tel_cellular_data_traffic_test") { subsystem_name = "telephony" part_name = "cellular_data" - test_module = "tel_cellular_data_test" - module_out_path = part_name + "/" + test_module + test_module = "cellular_data" + test_suite = "tel_cellular_data_traffic_test" + module_out_path = part_name + "/" + test_module + "/" + test_suite sources = [ "$SOURCE_DIR/test/cellular_data_dump_helper_test.cpp", -- Gitee From 18b9deb489feabd0cacef7edfe3f1aa7a805215f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=BD=AD=E6=B6=9B?= Date: Tue, 1 Apr 2025 07:26:59 +0000 Subject: [PATCH 031/145] =?UTF-8?q?=E7=BC=96=E8=AF=91=E5=91=8A=E8=AD=A6?= =?UTF-8?q?=E5=A4=84=E7=90=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 彭涛 --- services/src/apn_manager/connection_retry_policy.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/services/src/apn_manager/connection_retry_policy.cpp b/services/src/apn_manager/connection_retry_policy.cpp index 5b17ec02..6bcbceb7 100644 --- a/services/src/apn_manager/connection_retry_policy.cpp +++ b/services/src/apn_manager/connection_retry_policy.cpp @@ -85,7 +85,7 @@ void ConnectionRetryPolicy::SetMatchedApns(std::vector> &apns) TELEPHONY_LOGI("reset currentApnIndex"); currentApnIndex_ = 0; } else { - for (int32_t i = 0; i < apns.size(); i++) { + for (int32_t i = 0; i < static_cast(apns.size()); i++) { if (apns[i]->attr_.profileId_ != matchedApns_[i]->attr_.profileId_) { TELEPHONY_LOGI("reset currentApnIndex"); currentApnIndex_ = 0; -- Gitee From b0851085967d231a2526858b630adb6b9a6e3fb4 Mon Sep 17 00:00:00 2001 From: zhengsiwen960323 Date: Wed, 2 Apr 2025 08:19:44 +0000 Subject: [PATCH 032/145] update test/apn_manager_test.cpp. Signed-off-by: zhengsiwen960323 --- test/apn_manager_test.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/apn_manager_test.cpp b/test/apn_manager_test.cpp index 964f35b0..a162d159 100644 --- a/test/apn_manager_test.cpp +++ b/test/apn_manager_test.cpp @@ -1371,7 +1371,7 @@ HWTEST_F(ApnManagerTest, ApnManager_TryMergeSimilarPdpProfile_001, TestSize.Leve * @tc.name : ApnManager_TryMergeSimilarPdpProfile_002 * @tc.number: ApnManagerTest_005 */ -HWTEST_F(ApnManagerTest, ApnManager_TryMergeSimilarPdpProfile_002, TestSize.Level0) +HWTEST_F(ApnManagerTest, ApnManager_TryMergeSimilarPdpProfile_002, TestSize.Level1) { uint64_t expected = NetManagerStandard::NetCap::NET_CAPABILITY_INTERNET; int32_t apnId = DATA_CONTEXT_ROLE_DEFAULT_ID; -- Gitee From 2da08876767e481a18c1b8f03436f7c9985f47c1 Mon Sep 17 00:00:00 2001 From: zhengsiwen960323 Date: Wed, 2 Apr 2025 08:43:45 +0000 Subject: [PATCH 033/145] update test/cellular_data_client_test.cpp. Signed-off-by: zhengsiwen960323 --- test/cellular_data_client_test.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/test/cellular_data_client_test.cpp b/test/cellular_data_client_test.cpp index 4205a2b0..d5109966 100644 --- a/test/cellular_data_client_test.cpp +++ b/test/cellular_data_client_test.cpp @@ -287,7 +287,7 @@ HWTEST_F(CellularDataClientTest, GetInternalActReportInfo_001, TestSize.Level0) * @tc.name test function branch * @tc.desc Function test */ -HWTEST_F(CellularDataClientTest, SendUrspDecodeResult_001, TestSize.Level0) +HWTEST_F(CellularDataClientTest, SendUrspDecodeResult_001, TestSize.Level1) { std::vector buffer = {}; int32_t result = CellularDataClient::GetInstance().SendUrspDecodeResult(0, buffer); @@ -299,7 +299,7 @@ HWTEST_F(CellularDataClientTest, SendUrspDecodeResult_001, TestSize.Level0) * @tc.name test function branch * @tc.desc Function test */ -HWTEST_F(CellularDataClientTest, SendUePolicySectionIdentifier_001, TestSize.Level0) +HWTEST_F(CellularDataClientTest, SendUePolicySectionIdentifier_001, TestSize.Level1) { std::vector buffer = {}; int32_t result = CellularDataClient::GetInstance().SendUePolicySectionIdentifier(0, buffer); @@ -311,7 +311,7 @@ HWTEST_F(CellularDataClientTest, SendUePolicySectionIdentifier_001, TestSize.Lev * @tc.name test function branch * @tc.desc Function test */ -HWTEST_F(CellularDataClientTest, SendImsRsdList_001, TestSize.Level0) +HWTEST_F(CellularDataClientTest, SendImsRsdList_001, TestSize.Level1) { std::vector buffer = {}; int32_t result = CellularDataClient::GetInstance().SendImsRsdList(0, buffer); @@ -323,7 +323,7 @@ HWTEST_F(CellularDataClientTest, SendImsRsdList_001, TestSize.Level0) * @tc.name test function branch * @tc.desc Function test */ -HWTEST_F(CellularDataClientTest, GetNetworkSliceAllowedNssai_001, TestSize.Level0) +HWTEST_F(CellularDataClientTest, GetNetworkSliceAllowedNssai_001, TestSize.Level1) { std::vector buffer = {}; int32_t result = CellularDataClient::GetInstance().GetNetworkSliceAllowedNssai(0, buffer); -- Gitee From 0a448341072db7c759594df727f83b7cbef5a11c Mon Sep 17 00:00:00 2001 From: zhengsiwen960323 Date: Wed, 2 Apr 2025 08:48:24 +0000 Subject: [PATCH 034/145] update test/cellular_data_service_test.cpp. Signed-off-by: zhengsiwen960323 --- test/cellular_data_service_test.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/cellular_data_service_test.cpp b/test/cellular_data_service_test.cpp index 9347c29c..30251d78 100644 --- a/test/cellular_data_service_test.cpp +++ b/test/cellular_data_service_test.cpp @@ -53,7 +53,7 @@ void CellularDataServiceTest::TearDown() {} * @tc.name test function branch * @tc.desc Function test */ -HWTEST_F(CellularDataServiceTest, CellularDataService_001, TestSize.Level0) +HWTEST_F(CellularDataServiceTest, CellularDataService_001, TestSize.Level1) { DataAccessToken token; service->OnStart(); -- Gitee From cad2661d15e6e534107e524f2d3971fadfe58eae Mon Sep 17 00:00:00 2001 From: zhengsiwen960323 Date: Wed, 2 Apr 2025 09:06:10 +0000 Subject: [PATCH 035/145] update test/cellular_data_service_test.cpp. Signed-off-by: zhengsiwen960323 --- test/cellular_data_service_test.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/test/cellular_data_service_test.cpp b/test/cellular_data_service_test.cpp index 30251d78..c0dfd68d 100644 --- a/test/cellular_data_service_test.cpp +++ b/test/cellular_data_service_test.cpp @@ -85,7 +85,7 @@ HWTEST_F(CellularDataServiceTest, CellularDataService_001, TestSize.Level1) * @tc.name test function branch * @tc.desc Function test */ -HWTEST_F(CellularDataServiceTest, CellularDataService_002, TestSize.Level0) +HWTEST_F(CellularDataServiceTest, CellularDataService_002, TestSize.Level1) { ASSERT_NE(TELEPHONY_ERR_SUCCESS, service->GetCellularDataFlowType()); ASSERT_EQ("default slotId: -1", service->GetStateMachineCurrentStatusDump()); @@ -143,7 +143,7 @@ HWTEST_F(CellularDataServiceTest, DataConnectionMonitor_HandleScreenStateChanged * @tc.name test function branch * @tc.desc Function test */ -HWTEST_F(CellularDataServiceTest, DataConnectionMonitor_OnStallDetectionTimer_001, TestSize.Level0) +HWTEST_F(CellularDataServiceTest, DataConnectionMonitor_OnStallDetectionTimer_001, TestSize.Level1) { std::shared_ptr dataConnectionMonitor = std::make_shared(0); dataConnectionMonitor->noRecvPackets_ = 20; -- Gitee From 91345e03b9d656c4655bdd2a797479b677447326 Mon Sep 17 00:00:00 2001 From: liuleimin_hw Date: Mon, 7 Apr 2025 19:38:48 +0800 Subject: [PATCH 036/145] =?UTF-8?q?APN=E5=AF=86=E7=A0=81=E9=97=AE=E9=A2=98?= =?UTF-8?q?=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: liuleimin_hw --- services/include/utils/cellular_data_rdb_helper.h | 2 ++ services/src/cellular_data_handler.cpp | 2 +- services/src/utils/cellular_data_rdb_helper.cpp | 10 +++++----- 3 files changed, 8 insertions(+), 6 deletions(-) diff --git a/services/include/utils/cellular_data_rdb_helper.h b/services/include/utils/cellular_data_rdb_helper.h index 00464d60..d38c159e 100644 --- a/services/include/utils/cellular_data_rdb_helper.h +++ b/services/include/utils/cellular_data_rdb_helper.h @@ -35,6 +35,8 @@ namespace OHOS { namespace Telephony { +static constexpr int SETUP_DATA_AUTH_NONE = 0; +static constexpr int SETUP_DATA_AUTH_PAP_CHAP = 3; class CellularDataRdbHelper : public DelayedSingleton { DECLARE_DELAYED_SINGLETON(CellularDataRdbHelper); diff --git a/services/src/cellular_data_handler.cpp b/services/src/cellular_data_handler.cpp index 434510ab..4df737fe 100644 --- a/services/src/cellular_data_handler.cpp +++ b/services/src/cellular_data_handler.cpp @@ -907,7 +907,7 @@ std::shared_ptr CellularDataHandler::CreatorDataShar bool CellularDataHandler::GetCurrentDataShareApnInfo(std::shared_ptr dataShareHelper, const int32_t simId, int32_t &profileIdValue) { - Uri preferApnUri(std::string(CELLULAR_DATA_RDB_PREFER) + "?Proxy=true&simId=" + std::to_string(simId)); + Uri preferApnUri(std::string(CELLULAR_DATA_RDB_PREFER) + "?simId=" + std::to_string(simId)); DataShare::DataSharePredicates predicates; std::vector columns; std::shared_ptr resultSet = diff --git a/services/src/utils/cellular_data_rdb_helper.cpp b/services/src/utils/cellular_data_rdb_helper.cpp index 9711a483..09a9f638 100644 --- a/services/src/utils/cellular_data_rdb_helper.cpp +++ b/services/src/utils/cellular_data_rdb_helper.cpp @@ -100,7 +100,7 @@ bool CellularDataRdbHelper::QueryApns( DataShare::DataSharePredicates predicates; predicates.EqualTo(PdpProfileData::MCCMNC, mcc + mnc); int32_t simId = CoreManagerInner::GetInstance().GetSimId(slotId); - Uri cellularDataUri(std::string(CELLULAR_DATA_RDB_SELECTION) + "?Proxy=true&simId=" + std::to_string(simId)); + Uri cellularDataUri(std::string(CELLULAR_DATA_RDB_SELECTION) + "?simId=" + std::to_string(simId)); std::shared_ptr result = dataShareHelper->Query(cellularDataUri, predicates, columns); if (result == nullptr) { @@ -132,7 +132,7 @@ bool CellularDataRdbHelper::QueryMvnoApnsByType(const std::string &mcc, const st predicates.EqualTo(PdpProfileData::MVNO_TYPE, mvnoType) ->EqualTo(PdpProfileData::MCCMNC, mcc + mnc); int32_t simId = CoreManagerInner::GetInstance().GetSimId(slotId); - Uri cellularDataUri(std::string(CELLULAR_DATA_RDB_SELECTION) + "?Proxy=true&simId=" + std::to_string(simId)); + Uri cellularDataUri(std::string(CELLULAR_DATA_RDB_SELECTION) + "?simId=" + std::to_string(simId)); std::shared_ptr result = dataShareHelper->Query(cellularDataUri, predicates, columns); if (result == nullptr) { @@ -158,7 +158,7 @@ bool CellularDataRdbHelper::QueryPreferApn(int32_t slotId, std::vector columns; DataShare::DataSharePredicates predicates; int32_t simId = CoreManagerInner::GetInstance().GetSimId(slotId); - Uri preferApnUri(std::string(CELLULAR_DATA_RDB_PREFER) + "?Proxy=true&simId=" + std::to_string(simId)); + Uri preferApnUri(std::string(CELLULAR_DATA_RDB_PREFER) + "?simId=" + std::to_string(simId)); std::shared_ptr result = dataShareHelper->Query(preferApnUri, predicates, columns); if (result == nullptr) { TELEPHONY_LOGE("query prefer apns error"); @@ -371,7 +371,7 @@ void CellularDataRdbHelper::QueryApnIds(const ApnInfo &apnInfo, std::vector &apnInfoList) DataShare::DataSharePredicates predicates; std::string opkey = GetOpKey(CoreManagerInner::GetInstance().GetDefaultCellularDataSlotId()); predicates.EqualTo(Telephony::PdpProfileData::OPKEY, opkey); - Uri cellularDataUri(std::string(CELLULAR_DATA_RDB_SELECTION) + "?Proxy=true&simId=" + std::to_string(GetSimId())); + Uri cellularDataUri(std::string(CELLULAR_DATA_RDB_SELECTION) + "?simId=" + std::to_string(GetSimId())); std::shared_ptr result = dataShareHelper->Query(cellularDataUri, predicates, columns); if (result == nullptr) { -- Gitee From 3f9b434206e1649cc8262b8bb35b77833900da32 Mon Sep 17 00:00:00 2001 From: liuleimin_hw Date: Mon, 7 Apr 2025 19:47:09 +0800 Subject: [PATCH 037/145] =?UTF-8?q?APN=E5=AF=86=E7=A0=81=E5=8A=A0=E5=AF=86?= =?UTF-8?q?=E9=97=AE=E9=A2=98=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: liuleimin_hw --- services/src/utils/cellular_data_rdb_helper.cpp | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/services/src/utils/cellular_data_rdb_helper.cpp b/services/src/utils/cellular_data_rdb_helper.cpp index 09a9f638..3bafeb46 100644 --- a/services/src/utils/cellular_data_rdb_helper.cpp +++ b/services/src/utils/cellular_data_rdb_helper.cpp @@ -231,10 +231,16 @@ void CellularDataRdbHelper::MakePdpProfile( result->GetString(index, apnBean.mnc); result->GetColumnIndex(PdpProfileData::APN, index); result->GetString(index, apnBean.apn); - result->GetColumnIndex(PdpProfileData::AUTH_TYPE, index); - result->GetInt(index, apnBean.authType); result->GetColumnIndex(PdpProfileData::AUTH_USER, index); result->GetString(index, apnBean.authUser); + int32_t authType; + result->GetColumnIndex(PdpProfileData::AUTH_TYPE, index); + result->GetInt(index, authType); + if (authType == -1) { + apnBean.authType = (apnBean.authUser.empty()) ? SETUP_DATA_AUTH_NONE : SETUP_DATA_AUTH_PAP_CHAP; + } else { + apnBean.authType = authType; + } result->GetColumnIndex(PdpProfileData::AUTH_PWD, index); result->GetString(index, apnBean.authPwd); result->GetColumnIndex(PdpProfileData::APN_TYPES, index); -- Gitee From ded01d86b3529639072a347f0f03a47e31254052 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=B1=AA=E5=B0=91=E4=BF=8A?= Date: Mon, 7 Apr 2025 22:38:03 +0800 Subject: [PATCH 038/145] inner add SetNrOptionMode MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 汪少俊 --- test/mock/mock_network_search.h | 1 + 1 file changed, 1 insertion(+) diff --git a/test/mock/mock_network_search.h b/test/mock/mock_network_search.h index 08357ce7..ae9c4e76 100644 --- a/test/mock/mock_network_search.h +++ b/test/mock/mock_network_search.h @@ -68,6 +68,7 @@ public: MOCK_METHOD2(GetMeid, int32_t(int32_t slotId, std::u16string &meid)); MOCK_METHOD2(GetUniqueDeviceId, int32_t(int32_t slotId, std::u16string &deviceId)); MOCK_METHOD1(GetPhoneType, PhoneType(int32_t slotId)); + MOCK_METHOD2(SetNrOptionMode, int32_t(int32_t slotId, int32_t mode)); MOCK_METHOD3(SetNrOptionMode, int32_t(int32_t slotId, int32_t mode, NSCALLBACK &callback)); MOCK_METHOD2(GetNrOptionMode, int32_t(int32_t slotId, NrMode &mode)); MOCK_METHOD2(GetNrOptionMode, int32_t(int32_t slotId, NSCALLBACK &callback)); -- Gitee From 4f5c3cd1286e14cd90ba1cb6ff064c052f3c0213 Mon Sep 17 00:00:00 2001 From: benlau Date: Tue, 8 Apr 2025 23:47:43 +0800 Subject: [PATCH 039/145] merge similar apn bug Signed-off-by: benlau --- services/src/apn_manager/apn_item.cpp | 7 +++++-- services/src/apn_manager/apn_manager.cpp | 3 +++ test/apn_manager_test.cpp | 11 +++++++++++ 3 files changed, 19 insertions(+), 2 deletions(-) diff --git a/services/src/apn_manager/apn_item.cpp b/services/src/apn_manager/apn_item.cpp index 9a4dff63..0e8d62ca 100644 --- a/services/src/apn_manager/apn_item.cpp +++ b/services/src/apn_manager/apn_item.cpp @@ -158,14 +158,17 @@ sptr ApnItem::BuildOtherApnAttributes(sptr &apnItem, const Pdp bool ApnItem::IsSimilarPdpProfile(const PdpProfile &newPdpProfile, const PdpProfile &oldPdpProfile) { - return (newPdpProfile.apn == oldPdpProfile.apn) && (newPdpProfile.authType == oldPdpProfile.authType) && + return (newPdpProfile.apn == oldPdpProfile.apn) && (newPdpProfile.authUser == oldPdpProfile.authUser) && (newPdpProfile.authPwd == oldPdpProfile.authPwd) && (newPdpProfile.proxyIpAddress == oldPdpProfile.proxyIpAddress) && (newPdpProfile.mmsIpAddress == oldPdpProfile.mmsIpAddress) && IsSimilarProtocol(newPdpProfile.pdpProtocol, oldPdpProfile.pdpProtocol) && IsSimilarProtocol(newPdpProfile.roamPdpProtocol, oldPdpProfile.roamPdpProtocol) && IsSimilarProperty(newPdpProfile.homeUrl, oldPdpProfile.homeUrl) && - IsSimilarProperty(newPdpProfile.mmsIpAddress, oldPdpProfile.mmsIpAddress); + IsSimilarProperty(newPdpProfile.mmsIpAddress, oldPdpProfile.mmsIpAddress) && + (newPdpProfile.authType == oldPdpProfile.authType || + newPdpProfile.authType == static_cast(ApnAuthType::NONE) || + oldPdpProfile.authType == static_cast(ApnAuthType::NONE)); } bool ApnItem::IsSimilarProtocol(const std::string &newProtocol, const std::string &oldProtocol) diff --git a/services/src/apn_manager/apn_manager.cpp b/services/src/apn_manager/apn_manager.cpp index c706f569..563db38b 100644 --- a/services/src/apn_manager/apn_manager.cpp +++ b/services/src/apn_manager/apn_manager.cpp @@ -698,6 +698,9 @@ void ApnManager::TryMergeSimilarPdpProfile(std::vector &apnVec) void ApnManager::MergePdpProfile(PdpProfile &newProfile, PdpProfile &oldProfile) { + if (oldProfile.apnTypes.find(DATA_CONTEXT_ROLE_DEFAULT) != std::string::npos) { + newProfile.authType = oldProfile.authType; + } newProfile.apnTypes = newProfile.apnTypes + ',' + oldProfile.apnTypes; newProfile.pdpProtocol = (newProfile.pdpProtocol == PROTOCOL_IPV4V6) ? newProfile.pdpProtocol : oldProfile.pdpProtocol; diff --git a/test/apn_manager_test.cpp b/test/apn_manager_test.cpp index a162d159..dacbcbb9 100644 --- a/test/apn_manager_test.cpp +++ b/test/apn_manager_test.cpp @@ -1308,6 +1308,12 @@ HWTEST_F(ApnManagerTest, ApnItem_IsSimilarPdpProfile_001, TestSize.Level0) p1.authType = 1; p2.authType = 2; EXPECT_FALSE(ApnItem::IsSimilarPdpProfile(p1, p2)); + p1.authType = 0; + p2.authType = 1; + EXPECT_TRUE(ApnItem::IsSimilarPdpProfile(p1, p2)); + p1.authType = 1; + p2.authType = 0; + EXPECT_TRUE(ApnItem::IsSimilarPdpProfile(p1, p2)); p1.authType = 1; p2.authType = 1; p1.authUser = "1"; @@ -1365,6 +1371,11 @@ HWTEST_F(ApnManagerTest, ApnManager_TryMergeSimilarPdpProfile_001, TestSize.Leve apnVec.push_back(pdpProfile2); apnManager->TryMergeSimilarPdpProfile(apnVec); EXPECT_EQ(apnVec.size(), 1); + PdpProfile pdpProfile3 = pdpProfile; + pdpProfile3.apnTypes = "default"; + apnVec.push_back(pdpProfile3); + apnManager->TryMergeSimilarPdpProfile(apnVec); + EXPECT_EQ(apnVec.size(), 1); } /** -- Gitee From 98280bfb329770759252a537acd728864819b3dd Mon Sep 17 00:00:00 2001 From: fanqibing Date: Mon, 14 Apr 2025 22:02:42 +0800 Subject: [PATCH 040/145] =?UTF-8?q?=E8=A7=A3=E5=86=B3telephony=E6=AD=BB?= =?UTF-8?q?=E9=94=81=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: fanqibing --- .../state_machine/incall_data_state_machine.h | 1 + services/src/cellular_data_handler.cpp | 6 +++++- .../state_machine/incall_data_state_machine.cpp | 15 +++++++++++++++ 3 files changed, 21 insertions(+), 1 deletion(-) diff --git a/services/include/state_machine/incall_data_state_machine.h b/services/include/state_machine/incall_data_state_machine.h index 4ac9de8b..23f634c5 100644 --- a/services/include/state_machine/incall_data_state_machine.h +++ b/services/include/state_machine/incall_data_state_machine.h @@ -43,6 +43,7 @@ public: void UpdateCallState(int32_t state); void Init(int32_t callState); bool IsSecondaryActiveState() const; + void DeInit(); protected: sptr idleState_; diff --git a/services/src/cellular_data_handler.cpp b/services/src/cellular_data_handler.cpp index 4df737fe..cba8fa29 100644 --- a/services/src/cellular_data_handler.cpp +++ b/services/src/cellular_data_handler.cpp @@ -1373,7 +1373,7 @@ void CellularDataHandler::IncallDataComplete(const InnerEvent::Pointer &event) { TELEPHONY_LOGI("Slot%{public}d: MSG_INCALL_DATA_COMPLETE", slotId_); if (incallDataStateMachine_ != nullptr) { - incallDataStateMachine_ = nullptr; + incallDataStateMachine_->DeInit(); } } @@ -1407,6 +1407,10 @@ void CellularDataHandler::HandleImsCallChanged(int32_t state) if (state == TelCallStatus::CALL_STATUS_DIALING || state == TelCallStatus::CALL_STATUS_INCOMING) { if (incallDataStateMachine_ == nullptr) { incallDataStateMachine_ = CreateIncallDataStateMachine(state); + } else { + if (incallDataStateMachine_->GetCurrentState() == nullptr) { + incallDataStateMachine_->Init(state); + } } } if (incallDataStateMachine_ == nullptr) { diff --git a/services/src/state_machine/incall_data_state_machine.cpp b/services/src/state_machine/incall_data_state_machine.cpp index 5e27fd72..a623094f 100644 --- a/services/src/state_machine/incall_data_state_machine.cpp +++ b/services/src/state_machine/incall_data_state_machine.cpp @@ -172,6 +172,21 @@ bool IncallDataStateMachine::IsSecondaryActiveState() const return currentState_ == activatingSecondaryState_ || currentState_ == activatedSecondaryState_; } +void IncallDataStateMachine::DeInit() +{ + idleState_ = nullptr; + secondaryActiveState_ = nullptr; + activatingSecondaryState_ = nullptr; + activatedSecondaryState_ = nullptr; + deactivatingSecondaryState_ = nullptr; + currentState_ = nullptr; + cellularDataHandler_.reset(); + apnManager_ = nullptr; + + slotId_ = INVALID_SLOT_ID; + callState_ = static_cast(TelCallStatus::CALL_STATUS_IDLE); +} + void IdleState::StateBegin() { TELEPHONY_LOGI("Enter Idle State"); -- Gitee From 487c5e880790b4032bd3f7fb1e3ff25fe1c25728 Mon Sep 17 00:00:00 2001 From: lizefan Date: Tue, 15 Apr 2025 09:33:41 +0800 Subject: [PATCH 041/145] idl for cellulardata Signed-off-by: lizefan --- BUILD.gn | 10 +- frameworks/native/BUILD.gn | 54 +- frameworks/native/ICellularDataManager.idl | 59 + .../native/apn_activate_report_info.cpp | 66 + frameworks/native/apn_attribute.cpp | 173 +++ frameworks/native/cellular_data_client.cpp | 68 +- .../native/cellular_data_service_proxy.cpp | 1075 ----------------- .../native/cellular_data_service_proxy.h | 207 ---- ...back.cpp => data_sim_account_callback.cpp} | 2 +- .../innerkits/apn_activate_report_info.h | 51 + interfaces/innerkits/apn_attribute.h | 48 + interfaces/innerkits/cellular_data_client.h | 5 +- ...all_back.h => data_sim_account_callback.h} | 0 .../innerkits/i_cellular_data_manager.h | 191 --- services/include/cellular_data_service.h | 26 +- services/include/cellular_data_service_stub.h | 172 --- services/src/cellular_data_dump_helper.cpp | 4 +- services/src/cellular_data_service.cpp | 80 +- services/src/cellular_data_service_stub.cpp | 679 ----------- services/src/data_connection_monitor.cpp | 4 +- .../src/utils/network_search_callback.cpp | 3 +- test/BUILD.gn | 3 + test/cellular_data_service_test.cpp | 17 +- test/cellular_data_test.cpp | 2 +- .../getcellulardatastate_fuzzer/BUILD.gn | 1 + .../getcellulardatastate_fuzzer.cpp | 80 +- test/unit_test/cellular_data_code_test.cpp | 10 +- test/zero_branch_test.cpp | 172 ++- 28 files changed, 768 insertions(+), 2494 deletions(-) create mode 100644 frameworks/native/ICellularDataManager.idl create mode 100644 frameworks/native/apn_activate_report_info.cpp create mode 100644 frameworks/native/apn_attribute.cpp delete mode 100644 frameworks/native/cellular_data_service_proxy.cpp delete mode 100644 frameworks/native/cellular_data_service_proxy.h rename frameworks/native/{data_sim_account_call_back.cpp => data_sim_account_callback.cpp} (95%) create mode 100644 interfaces/innerkits/apn_activate_report_info.h create mode 100644 interfaces/innerkits/apn_attribute.h rename interfaces/innerkits/{data_sim_account_call_back.h => data_sim_account_callback.h} (100%) delete mode 100644 interfaces/innerkits/i_cellular_data_manager.h delete mode 100644 services/include/cellular_data_service_stub.h delete mode 100644 services/src/cellular_data_service_stub.cpp diff --git a/BUILD.gn b/BUILD.gn index 67d967d9..c5831b29 100644 --- a/BUILD.gn +++ b/BUILD.gn @@ -27,6 +27,8 @@ ohos_shared_library("tel_cellular_data") { sources = [ "$DATA_SERVICE_EXT_WRAPPER_ROOT/src/data_service_ext_wrapper.cpp", "$TELEPHONY_EXT_WRAPPER_ROOT/src/telephony_ext_wrapper.cpp", + "frameworks/native/apn_activate_report_info.cpp", + "frameworks/native/apn_attribute.cpp", "services/src/apn_manager/apn_holder.cpp", "services/src/apn_manager/apn_item.cpp", "services/src/apn_manager/apn_manager.cpp", @@ -39,7 +41,6 @@ ohos_shared_library("tel_cellular_data") { "services/src/cellular_data_rdb_observer.cpp", "services/src/cellular_data_roaming_observer.cpp", "services/src/cellular_data_service.cpp", - "services/src/cellular_data_service_stub.cpp", "services/src/cellular_data_setting_observer.cpp", "services/src/data_connection_manager.cpp", "services/src/data_connection_monitor.cpp", @@ -75,6 +76,8 @@ ohos_shared_library("tel_cellular_data") { "interfaces/innerkits", ] + deps = [ "frameworks/native:cellulardata_interface_stub" ] + external_deps = [ "ability_base:want", "ability_base:zuri", @@ -144,6 +147,8 @@ ohos_static_library("tel_cellular_data_static") { sources = [ "$DATA_SERVICE_EXT_WRAPPER_ROOT/src/data_service_ext_wrapper.cpp", "$TELEPHONY_EXT_WRAPPER_ROOT/src/telephony_ext_wrapper.cpp", + "frameworks/native/apn_activate_report_info.cpp", + "frameworks/native/apn_attribute.cpp", "services/src/apn_manager/apn_holder.cpp", "services/src/apn_manager/apn_item.cpp", "services/src/apn_manager/apn_manager.cpp", @@ -156,7 +161,6 @@ ohos_static_library("tel_cellular_data_static") { "services/src/cellular_data_rdb_observer.cpp", "services/src/cellular_data_roaming_observer.cpp", "services/src/cellular_data_service.cpp", - "services/src/cellular_data_service_stub.cpp", "services/src/cellular_data_setting_observer.cpp", "services/src/data_connection_manager.cpp", "services/src/data_connection_monitor.cpp", @@ -192,6 +196,8 @@ ohos_static_library("tel_cellular_data_static") { "interfaces/innerkits", ] + deps = [ "frameworks/native:cellulardata_interface_stub" ] + external_deps = [ "ability_base:want", "ability_base:zuri", diff --git a/frameworks/native/BUILD.gn b/frameworks/native/BUILD.gn index 93b81ef6..7e7b493b 100644 --- a/frameworks/native/BUILD.gn +++ b/frameworks/native/BUILD.gn @@ -10,6 +10,7 @@ # 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("//build/config/components/idl_tool/idl.gni") import("//build/ohos.gni") SUBSYSTEM_DIR = "../.." @@ -17,6 +18,7 @@ TELEPHONY_DATA_DIR = "../../../telephony_data" config("cellular_data_util_config") { # header file path include_dirs = [ + "${target_gen_dir}", "$SUBSYSTEM_DIR/interfaces/innerkits", "$SUBSYSTEM_DIR/services/include/apn_manager", "$SUBSYSTEM_DIR/services/include/common", @@ -38,6 +40,48 @@ config("cellular_data_util_config") { } } +config("cellulardata_interface_config") { + include_dirs = [ + "${target_gen_dir}", + "${target_gen_dir}/callback", + "${target_gen_dir}/type", + "$SUBSYSTEM_DIR/interfaces/innerkits", + "$SUBSYSTEM_DIR/services/include", + "$SUBSYSTEM_DIR/services/include/apn_manager", + "$SUBSYSTEM_DIR/services/include/common", + "$SUBSYSTEM_DIR/services/include/state_machine", + "$SUBSYSTEM_DIR/services/include/utils", + ] +} + +idl_gen_interface("cellulardata_interface") { + sources = [ "ICellularDataManager.idl" ] + log_domainid = "0xD001F03" + log_tag = "CellularDataApi" +} + +ohos_source_set("cellulardata_interface_stub") { + sanitize = { + cfi = true + cfi_cross_dso = true + debug = false + } + public_configs = [ ":cellulardata_interface_config" ] + output_values = get_target_outputs(":cellulardata_interface") + sources = [] + sources += filter_include(output_values, [ "*_stub.cpp" ]) + deps = [ ":cellulardata_interface" ] + external_deps = [ + "core_service:libtel_common", + "core_service:tel_core_service_api", + "hilog:libhilog", + "samgr:samgr_proxy", + "telephony_data:tel_telephony_data", + ] + part_name = "cellular_data" + subsystem_name = "telephony" +} + ohos_shared_library("tel_cellular_data_api") { sanitize = { cfi = true @@ -46,16 +90,20 @@ ohos_shared_library("tel_cellular_data_api") { } branch_protector_ret = "pac_ret" sources = [ + "$SUBSYSTEM_DIR/frameworks/native/apn_activate_report_info.cpp", + "$SUBSYSTEM_DIR/frameworks/native/apn_attribute.cpp", "$SUBSYSTEM_DIR/frameworks/native/cellular_data_client.cpp", - "$SUBSYSTEM_DIR/frameworks/native/cellular_data_service_proxy.cpp", - "$SUBSYSTEM_DIR/frameworks/native/data_sim_account_call_back.cpp", + "$SUBSYSTEM_DIR/frameworks/native/data_sim_account_callback.cpp", "$SUBSYSTEM_DIR/frameworks/native/sim_account_callback_stub.cpp", ] - + output_values = get_target_outputs(":cellulardata_interface") + sources += filter_include(output_values, [ "*_proxy.cpp" ]) version_script = "$SUBSYSTEM_DIR/interfaces/innerkits/libtel_cellular_data_api.versionscript" public_configs = [ ":cellular_data_util_config" ] + deps = [ ":cellulardata_interface" ] + external_deps = [ "c_utils:utils", "core_service:libtel_common", diff --git a/frameworks/native/ICellularDataManager.idl b/frameworks/native/ICellularDataManager.idl new file mode 100644 index 00000000..579f08e1 --- /dev/null +++ b/frameworks/native/ICellularDataManager.idl @@ -0,0 +1,59 @@ +/* + * Copyright (c) 2024 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. + */ + +sequenceable ApnAttribute..OHOS.Telephony.ApnAttribute; +sequenceable ApnActivateReportInfo..OHOS.Telephony.ApnActivateReportInfoIpc; +interface OHOS.Telephony.SimAccountCallback; +interface OHOS.Telephony.ICellularDataManager { + void IsCellularDataEnabled([out] boolean dataEnabled); + void EnableCellularData([in] boolean enable); + void EnableIntelligenceSwitch([in] boolean enable); + void GetCellularDataState([out] int state); + void IsCellularDataRoamingEnabled([in] int slotId, [inout] boolean dataRoamingEnabled); + void EnableCellularDataRoaming([in] int slotId, [in] boolean enable); + void HandleApnChanged([in] int slotId); + void GetDefaultCellularDataSlotId([out] int slotId); + void GetDefaultCellularDataSimId([out] int simId); + void SetDefaultCellularDataSlotId([in] int slotId); + void GetCellularDataFlowType([out] int type); + void HasInternetCapability([in] int slotId, [in] int cid, [out] int capability); + void ClearCellularDataConnections([in] int slotId); + void ClearAllConnections([in] int slotId, [in] int reason); + void RegisterSimAccountCallback([in] SimAccountCallback callbackparam); + void UnregisterSimAccountCallback([in] SimAccountCallback callbackparam); + void GetDataConnApnAttr([in] int slotId, [out] ApnAttribute apnAttr); + void GetDataConnIpType([in] int slotId, [out] String ipType); + void GetApnState([in] int slotId, [in] String apnType, [out] int state); + void GetDataRecoveryState([out] int state); + void IsNeedDoRecovery([in] int slotId, [in] boolean needDoRecovery); + void InitCellularDataController([in] int slotId); + void EstablishAllApnsIfConnectable([in] int slotId); + void ReleaseCellularDataConnection([in] int slotId); + void GetCellularDataSupplierId([in] int slotId, [in] unsigned long capability, [out] unsigned int supplierId); + void CorrectNetSupplierNoAvailable([in] int slotId); + void GetSupplierRegisterState([in] unsigned int supplierId, [out] int regState); + void GetIfSupportDunApn([out] boolean isSupportDun); + void GetDefaultActReportInfo([in] int slotId, [out] ApnActivateReportInfoIpc info); + void GetInternalActReportInfo([in] int slotId, [out] ApnActivateReportInfoIpc info); + void GetIntelligenceSwitchState([out] boolean switchState); + void QueryApnIds(ApnInfo apnInfo, [out] List apnIdList); + void SetPreferApn(int apnId); + void QueryAllApnInfo([out] List apnInfoList); + void SendUrspDecodeResult(int slotId, List buffer); + void SendUePolicySectionIdentifier(int slotId, List buffer); + void SendImsRsdList(int slotId, List buffer); + void GetNetworkSliceAllowedNssai(int slotId, List buffer); + void GetNetworkSliceEhplmn(int slotId); +}; diff --git a/frameworks/native/apn_activate_report_info.cpp b/frameworks/native/apn_activate_report_info.cpp new file mode 100644 index 00000000..b3dc76b0 --- /dev/null +++ b/frameworks/native/apn_activate_report_info.cpp @@ -0,0 +1,66 @@ +/* + * Copyright (C) 2025 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 "apn_item.h" +#include "apn_activate_report_info.h" + +namespace OHOS { +namespace Telephony { +bool ApnActivateReportInfoIpc::Marshalling(Parcel &parcel) const +{ + if (!parcel.WriteUint32(actTimes)) { + return false; + } + if (!parcel.WriteUint32(averDuration)) { + return false; + } + if (!parcel.WriteUint32(topReason)) { + return false; + } + if (!parcel.WriteUint32(actSuccTimes)) { + return false; + } + return true; +} + +ApnActivateReportInfoIpc* ApnActivateReportInfoIpc::Unmarshalling(Parcel &parcel) +{ + ApnActivateReportInfoIpc* info = new (std::nothrow) ApnActivateReportInfoIpc(); + if (info == nullptr) { + return nullptr; + } + if (!parcel.ReadUint32(info->actTimes)) { + return nullptr; + } + if (!parcel.ReadUint32(info->averDuration)) { + return nullptr; + } + if (!parcel.ReadUint32(info->topReason)) { + return nullptr; + } + if (!parcel.ReadUint32(info->actSuccTimes)) { + return nullptr; + } + return info; +} + +void ApnActivateReportInfoIpc::transferToReportInfo(ApnActivateReportInfoIpc infoIpc, ApnActivateReportInfo &info) +{ + info.actTimes = infoIpc.actTimes; + info.averDuration = infoIpc.averDuration; + info.topReason = infoIpc.topReason; + info.actSuccTimes = infoIpc.actSuccTimes; +} +} +} \ No newline at end of file diff --git a/frameworks/native/apn_attribute.cpp b/frameworks/native/apn_attribute.cpp new file mode 100644 index 00000000..3e47af88 --- /dev/null +++ b/frameworks/native/apn_attribute.cpp @@ -0,0 +1,173 @@ +/* + * Copyright (c) 2025 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 "apn_item.h" +#include "apn_attribute.h" +#include "parcel.h" + +namespace OHOS { +namespace Telephony { + +bool ApnAttribute::Marshalling(Parcel &parcel) const +{ + if (!parcel.WriteString(types_)) { + return false; + } + if (!parcel.WriteString(numeric_)) { + return false; + } + if (!parcel.WriteInt32(profileId_)) { + return false; + } + if (!parcel.WriteString(protocol_)) { + return false; + } + if (!parcel.WriteString(roamingProtocol_)) { + return false; + } + if (!parcel.WriteInt32(authType_)) { + return false; + } + if (!parcel.WriteString(apn_)) { + return false; + } + if (!parcel.WriteString(apnName_)) { + return false; + } + if (!parcel.WriteString(user_)) { + return false; + } + if (!parcel.WriteString(password_)) { + return false; + } + if (!parcel.WriteBool(isRoamingApn_)) { + return false; + } + if (!parcel.WriteString(homeUrl_)) { + return false; + } + if (!parcel.WriteString(proxyIpAddress_)) { + return false; + } + if (!parcel.WriteString(mmsIpAddress_)) { + return false; + } + if (!parcel.WriteBool(isEdited_)) { + return false; + } + return true; +} + +static bool UnmarshallingExt(Parcel &parcel, ApnAttribute* attribute) +{ + if (!parcel.ReadString(attribute->apnName_)) { + return false; + } + if (!parcel.ReadString(attribute->user_)) { + return false; + } + if (!parcel.ReadString(attribute->password_)) { + return false; + } + if (!parcel.ReadBool(attribute->isRoamingApn_)) { + return false; + } + if (!parcel.ReadString(attribute->homeUrl_)) { + return false; + } + if (!parcel.ReadString(attribute->proxyIpAddress_)) { + return false; + } + if (!parcel.ReadString(attribute->mmsIpAddress_)) { + return false; + } + if (!parcel.ReadBool(attribute->isEdited_)) { + return false; + } + return true; +} + +ApnAttribute* ApnAttribute::Unmarshalling(Parcel &parcel) +{ + ApnAttribute* attribute = new (std::nothrow) ApnAttribute(); + if (attribute == nullptr) { + return nullptr; + } + if (!parcel.ReadString(attribute->types_)) { + return nullptr; + } + if (!parcel.ReadString(attribute->numeric_)) { + return nullptr; + } + if (!parcel.ReadInt32(attribute->profileId_)) { + return nullptr; + } + if (!parcel.ReadString(attribute->protocol_)) { + return nullptr; + } + if (!parcel.ReadString(attribute->roamingProtocol_)) { + return nullptr; + } + if (!parcel.ReadInt32(attribute->authType_)) { + return nullptr; + } + if (!parcel.ReadString(attribute->apn_)) { + return nullptr; + } + if (!UnmarshallingExt(parcel, attribute)) { + return nullptr; + } + return attribute; +} + +void ApnAttribute::TransferApnAttributeBeforeIpc(ApnItem::Attribute &apnAttr, ApnAttribute &apnAfterTrans) +{ + apnAfterTrans.types_ = apnAttr.types_; + apnAfterTrans.numeric_ = apnAttr.numeric_; + apnAfterTrans.profileId_ = apnAttr.profileId_; + apnAfterTrans.protocol_ = apnAttr.protocol_; + apnAfterTrans.roamingProtocol_ = apnAttr.roamingProtocol_; + apnAfterTrans.authType_ = apnAttr.authType_; + apnAfterTrans.apn_ = apnAttr.apn_; + apnAfterTrans.apnName_ = apnAttr.apnName_; + apnAfterTrans.user_ = apnAttr.user_; + apnAfterTrans.password_ = apnAttr.password_; + apnAfterTrans.isRoamingApn_ = apnAttr.isRoamingApn_; + apnAfterTrans.homeUrl_ = apnAttr.homeUrl_; + apnAfterTrans.proxyIpAddress_ = apnAttr.proxyIpAddress_; + apnAfterTrans.mmsIpAddress_ = apnAttr.mmsIpAddress_; + apnAfterTrans.isEdited_ = apnAttr.isEdited_; +} + +void ApnAttribute::TransferApnAttributeAfterIpc(ApnItem::Attribute &apnAttr, ApnAttribute &apnAfterTrans) +{ + apnAfterTrans.types_.copy(apnAttr.types_, apnAfterTrans.types_.size(), 0); + apnAfterTrans.numeric_.copy(apnAttr.numeric_, apnAfterTrans.numeric_.size(), 0); + apnAttr.profileId_ = apnAfterTrans.profileId_; + apnAfterTrans.protocol_.copy(apnAttr.protocol_, apnAfterTrans.protocol_.size(), 0); + apnAfterTrans.roamingProtocol_.copy(apnAttr.roamingProtocol_, apnAfterTrans.roamingProtocol_.size(), 0); + apnAttr.authType_ = apnAfterTrans.authType_; + apnAfterTrans.apn_.copy(apnAttr.apn_, apnAfterTrans.apn_.size(), 0); + apnAfterTrans.apnName_.copy(apnAttr.apnName_, apnAfterTrans.apnName_.size(), 0); + apnAfterTrans.user_.copy(apnAttr.user_, apnAfterTrans.user_.size(), 0); + apnAfterTrans.password_.copy(apnAttr.password_, apnAfterTrans.password_.size(), 0); + apnAttr.isRoamingApn_ = apnAfterTrans.isRoamingApn_; + apnAfterTrans.homeUrl_.copy(apnAttr.homeUrl_, apnAfterTrans.homeUrl_.size(), 0); + apnAfterTrans.proxyIpAddress_.copy(apnAttr.proxyIpAddress_, apnAfterTrans.proxyIpAddress_.size(), 0); + apnAfterTrans.mmsIpAddress_.copy(apnAttr.mmsIpAddress_, apnAfterTrans.mmsIpAddress_.size(), 0); + apnAttr.isEdited_ = apnAfterTrans.isEdited_; +} +} +} \ No newline at end of file diff --git a/frameworks/native/cellular_data_client.cpp b/frameworks/native/cellular_data_client.cpp index d5b61571..57b3d180 100644 --- a/frameworks/native/cellular_data_client.cpp +++ b/frameworks/native/cellular_data_client.cpp @@ -16,8 +16,10 @@ #include "cellular_data_client.h" #include "__mutex_base" +#include "apn_activate_report_info.h" +#include "cellular_data_manager_proxy.h" #include "cellular_data_types.h" -#include "i_cellular_data_manager.h" +#include "icellular_data_manager.h" #include "if_system_ability_manager.h" #include "iremote_broker.h" #include "iremote_object.h" @@ -149,7 +151,13 @@ int32_t CellularDataClient::GetDefaultCellularDataSlotId() TELEPHONY_LOGE("proxy is null"); return TELEPHONY_ERR_IPC_CONNECT_STUB_FAIL; } - defaultCellularDataSlotId_ = proxy->GetDefaultCellularDataSlotId(); + int32_t slotId; + int32_t ret = proxy->GetDefaultCellularDataSlotId(slotId); + if (ret != TELEPHONY_ERR_SUCCESS) { + TELEPHONY_LOGE("GetDefaultCellularDataSlotId IPC error, %{public}d", ret); + return ret; + } + defaultCellularDataSlotId_ = slotId; return defaultCellularDataSlotId_; } @@ -201,7 +209,7 @@ int32_t CellularDataClient::UpdateDefaultCellularDataSlotId() TELEPHONY_LOGE("proxy is null"); return TELEPHONY_ERR_IPC_CONNECT_STUB_FAIL; } - defaultCellularDataSlotId_ = proxy->GetDefaultCellularDataSlotId(); + proxy->GetDefaultCellularDataSlotId(defaultCellularDataSlotId_); proxy->GetDefaultCellularDataSimId(defaultCellularDataSimId_); return defaultCellularDataSlotId_; } @@ -243,7 +251,12 @@ int32_t CellularDataClient::GetCellularDataState() TELEPHONY_LOGE("proxy is null"); return TELEPHONY_ERR_IPC_CONNECT_STUB_FAIL; } - return proxy->GetCellularDataState(); + int32_t state; + int32_t ret = proxy->GetCellularDataState(state); + if (ret != TELEPHONY_ERR_SUCCESS) { + return ret; + } + return state; } int32_t CellularDataClient::GetApnState(int32_t slotId, const std::string &apnType) @@ -253,7 +266,12 @@ int32_t CellularDataClient::GetApnState(int32_t slotId, const std::string &apnTy TELEPHONY_LOGE("proxy is null"); return TELEPHONY_ERR_IPC_CONNECT_STUB_FAIL; } - return proxy->GetApnState(slotId, apnType); + int32_t state; + int32_t ret = proxy->GetApnState(slotId, apnType, state); + if (ret != TELEPHONY_ERR_SUCCESS) { + return ret; + } + return state; } int32_t CellularDataClient::GetDataRecoveryState() @@ -263,7 +281,12 @@ int32_t CellularDataClient::GetDataRecoveryState() TELEPHONY_LOGE("proxy is null"); return TELEPHONY_ERR_IPC_CONNECT_STUB_FAIL; } - return proxy->GetDataRecoveryState(); + int32_t state; + int32_t ret = proxy->GetDataRecoveryState(state); + if (ret != TELEPHONY_ERR_SUCCESS) { + return ret; + } + return state; } int32_t CellularDataClient::IsCellularDataRoamingEnabled(int32_t slotId, bool &dataRoamingEnabled) @@ -293,7 +316,12 @@ int32_t CellularDataClient::GetCellularDataFlowType() TELEPHONY_LOGE("proxy is null"); return TELEPHONY_ERR_IPC_CONNECT_STUB_FAIL; } - return proxy->GetCellularDataFlowType(); + int32_t type; + int32_t ret = proxy->GetCellularDataFlowType(type); + if (ret != TELEPHONY_ERR_SUCCESS) { + return ret; + } + return type; } int32_t CellularDataClient::HasInternetCapability(int32_t slotId, int32_t cid) @@ -303,7 +331,12 @@ int32_t CellularDataClient::HasInternetCapability(int32_t slotId, int32_t cid) TELEPHONY_LOGE("proxy is null"); return TELEPHONY_ERR_IPC_CONNECT_STUB_FAIL; } - return proxy->HasInternetCapability(slotId, cid); + int32_t capability; + int32_t ret = proxy->HasInternetCapability(slotId, cid, capability); + if (ret != TELEPHONY_ERR_SUCCESS) { + return ret; + } + return capability; } int32_t CellularDataClient::ClearCellularDataConnections(int32_t slotId) @@ -323,7 +356,11 @@ int32_t CellularDataClient::GetDataConnApnAttr(int32_t slotId, ApnItem::Attribut TELEPHONY_LOGE("proxy is null"); return TELEPHONY_ERR_IPC_CONNECT_STUB_FAIL; } - return proxy->GetDataConnApnAttr(slotId, apnAttr); + ApnAttribute apnAfterTrans; + ApnAttribute::TransferApnAttributeBeforeIpc(apnAttr, apnAfterTrans); + int32_t ret = proxy->GetDataConnApnAttr(slotId, apnAfterTrans); + ApnAttribute::TransferApnAttributeAfterIpc(apnAttr, apnAfterTrans); + return ret; } int32_t CellularDataClient::GetDataConnIpType(int32_t slotId, std::string &ipType) @@ -343,7 +380,8 @@ int32_t CellularDataClient::ClearAllConnections(int32_t slotId, DisConnectionRea TELEPHONY_LOGE("proxy is null"); return TELEPHONY_ERR_IPC_CONNECT_STUB_FAIL; } - return proxy->ClearAllConnections(slotId, reason); + int32_t reasonIpc = static_cast (reason); + return proxy->ClearAllConnections(slotId, reasonIpc); } int32_t CellularDataClient::HandleApnChanged(int32_t slotId) @@ -468,7 +506,10 @@ int32_t CellularDataClient::GetDefaultActReportInfo(int32_t slotId, ApnActivateR TELEPHONY_LOGE("proxy is null"); return TELEPHONY_ERR_IPC_CONNECT_STUB_FAIL; } - return proxy->GetDefaultActReportInfo(slotId, info); + ApnActivateReportInfoIpc infoIpc = info; + int32_t ret = proxy->GetDefaultActReportInfo(slotId, infoIpc); + ApnActivateReportInfoIpc::transferToReportInfo(infoIpc, info); + return ret; } int32_t CellularDataClient::GetInternalActReportInfo(int32_t slotId, ApnActivateReportInfo &info) @@ -478,7 +519,10 @@ int32_t CellularDataClient::GetInternalActReportInfo(int32_t slotId, ApnActivate TELEPHONY_LOGE("proxy is null"); return TELEPHONY_ERR_IPC_CONNECT_STUB_FAIL; } - return proxy->GetInternalActReportInfo(slotId, info); + ApnActivateReportInfoIpc infoIpc = info; + int32_t ret = proxy->GetInternalActReportInfo(slotId, infoIpc); + ApnActivateReportInfoIpc::transferToReportInfo(infoIpc, info); + return ret; } int32_t CellularDataClient::QueryApnIds(ApnInfo apnInfo, std::vector &apnIdList) diff --git a/frameworks/native/cellular_data_service_proxy.cpp b/frameworks/native/cellular_data_service_proxy.cpp deleted file mode 100644 index d216b96b..00000000 --- a/frameworks/native/cellular_data_service_proxy.cpp +++ /dev/null @@ -1,1075 +0,0 @@ -/* - * Copyright (C) 2021-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 "cellular_data_service_proxy.h" - -#include "iremote_object.h" -#include "message_option.h" -#include "message_parcel.h" -#include "telephony_errors.h" -#include "telephony_log_wrapper.h" -#include "securec.h" -#include "string_ex.h" - -namespace OHOS { -namespace Telephony { -constexpr int32_t BUFFER_MAX = 65538; -int32_t CellularDataServiceProxy::IsCellularDataEnabled(bool &dataEnabled) -{ - MessageParcel data; - MessageParcel reply; - MessageOption option; - data.WriteInterfaceToken(CellularDataServiceProxy::GetDescriptor()); - if (Remote() == nullptr) { - TELEPHONY_LOGE("remote is null"); - return TELEPHONY_ERR_IPC_CONNECT_STUB_FAIL; - } - int32_t error = Remote()->SendRequest((uint32_t)CellularDataInterfaceCode::IS_CELLULAR_DATA_ENABLED, data, - reply, option); - if (error != TELEPHONY_SUCCESS) { - TELEPHONY_LOGE("call failed! errCode:%{public}d", error); - return TELEPHONY_ERR_IPC_CONNECT_STUB_FAIL; - } - int32_t result = reply.ReadInt32(); - if (result == TELEPHONY_SUCCESS) { - dataEnabled = reply.ReadBool(); - } - - return result; -} - -int32_t CellularDataServiceProxy::EnableCellularData(bool enable) -{ - MessageParcel data; - MessageParcel reply; - MessageOption option; - data.WriteInterfaceToken(CellularDataServiceProxy::GetDescriptor()); - data.WriteBool(enable); - if (Remote() == nullptr) { - TELEPHONY_LOGE("remote is null"); - return TELEPHONY_ERR_IPC_CONNECT_STUB_FAIL; - } - int32_t error = Remote()->SendRequest((uint32_t)CellularDataInterfaceCode::ENABLE_CELLULAR_DATA, data, - reply, option); - if (error != TELEPHONY_SUCCESS) { - TELEPHONY_LOGE("call failed! errCode:%{public}d", error); - return TELEPHONY_ERR_IPC_CONNECT_STUB_FAIL; - } - int32_t result = reply.ReadInt32(); - return result; -} - -int32_t CellularDataServiceProxy::GetIntelligenceSwitchState(bool &state) -{ - MessageParcel data; - MessageParcel reply; - MessageOption option; - data.WriteInterfaceToken(CellularDataServiceProxy::GetDescriptor()); - if (Remote() == nullptr) { - TELEPHONY_LOGE("remote is null"); - return TELEPHONY_ERR_IPC_CONNECT_STUB_FAIL; - } - int32_t error = Remote()->SendRequest((uint32_t)CellularDataInterfaceCode::GET_INTELLIGENCE_SWITCH_STATE, data, - reply, option); - if (error != TELEPHONY_SUCCESS) { - TELEPHONY_LOGE("call failed! errCode:%{public}d", error); - return TELEPHONY_ERR_IPC_CONNECT_STUB_FAIL; - } - int32_t result = reply.ReadInt32(); - state = reply.ReadBool(); - return result; -} - -int32_t CellularDataServiceProxy::EnableIntelligenceSwitch(bool enable) -{ - MessageParcel data; - MessageParcel reply; - MessageOption option; - data.WriteInterfaceToken(CellularDataServiceProxy::GetDescriptor()); - data.WriteBool(enable); - if (Remote() == nullptr) { - TELEPHONY_LOGE("remote is null"); - return TELEPHONY_ERR_IPC_CONNECT_STUB_FAIL; - } - int32_t error = Remote()->SendRequest((uint32_t)CellularDataInterfaceCode::ENABLE_INTELLIGENCE_SWITCH, data, - reply, option); - if (error != TELEPHONY_SUCCESS) { - TELEPHONY_LOGE("call failed! errCode:%{public}d", error); - return TELEPHONY_ERR_IPC_CONNECT_STUB_FAIL; - } - int32_t result = reply.ReadInt32(); - return result; -} - -int32_t CellularDataServiceProxy::GetCellularDataState() -{ - MessageParcel data; - MessageParcel reply; - MessageOption option; - data.WriteInterfaceToken(CellularDataServiceProxy::GetDescriptor()); - if (Remote() == nullptr) { - TELEPHONY_LOGE("remote is null"); - return TELEPHONY_ERR_IPC_CONNECT_STUB_FAIL; - } - int32_t error = Remote()->SendRequest((uint32_t)CellularDataInterfaceCode::GET_CELLULAR_DATA_STATE, data, - reply, option); - if (error != TELEPHONY_SUCCESS) { - TELEPHONY_LOGE("call failed! errCode:%{public}d", error); - return TELEPHONY_ERR_IPC_CONNECT_STUB_FAIL; - } - int32_t result = reply.ReadInt32(); - return result; -} - -int32_t CellularDataServiceProxy::GetApnState(int32_t slotId, const std::string &apnType) -{ - MessageParcel data; - MessageParcel reply; - MessageOption option; - data.WriteInterfaceToken(CellularDataServiceProxy::GetDescriptor()); - data.WriteInt32(slotId); - data.WriteString(apnType); - if (Remote() == nullptr) { - TELEPHONY_LOGE("remote is null"); - return TELEPHONY_ERR_IPC_CONNECT_STUB_FAIL; - } - int32_t error = Remote()->SendRequest((uint32_t)CellularDataInterfaceCode::GET_CELLULAR_DATA_APN_STATE, data, - reply, option); - if (error != TELEPHONY_SUCCESS) { - TELEPHONY_LOGE("function GetCellularDataState call failed! errCode:%{public}d", error); - return TELEPHONY_ERR_IPC_CONNECT_STUB_FAIL; - } - int32_t result = reply.ReadInt32(); - return result; -} - -int32_t CellularDataServiceProxy::GetDataRecoveryState() -{ - MessageParcel data; - MessageParcel reply; - MessageOption option; - data.WriteInterfaceToken(CellularDataServiceProxy::GetDescriptor()); - if (Remote() == nullptr) { - TELEPHONY_LOGE("remote is null"); - return TELEPHONY_ERR_IPC_CONNECT_STUB_FAIL; - } - int32_t error = Remote()->SendRequest((uint32_t)CellularDataInterfaceCode::GET_RECOVERY_STATE, data, - reply, option); - if (error != TELEPHONY_SUCCESS) { - TELEPHONY_LOGE("function GetDefaultCellularDataSlotId call failed! errCode:%{public}d", error); - return TELEPHONY_ERR_IPC_CONNECT_STUB_FAIL; - } - int32_t result = reply.ReadInt32(); - return result; -} - -int32_t CellularDataServiceProxy::IsCellularDataRoamingEnabled(int32_t slotId, bool &dataRoamingEnabled) -{ - MessageParcel data; - MessageParcel reply; - MessageOption option; - data.WriteInterfaceToken(CellularDataServiceProxy::GetDescriptor()); - data.WriteInt32(slotId); - if (Remote() == nullptr) { - TELEPHONY_LOGE("remote is null"); - return TELEPHONY_ERR_IPC_CONNECT_STUB_FAIL; - } - int32_t error = Remote()->SendRequest((uint32_t)CellularDataInterfaceCode::IS_DATA_ROAMING_ENABLED, data, - reply, option); - if (error != TELEPHONY_SUCCESS) { - TELEPHONY_LOGE("call failed! errCode:%{public}d", error); - return TELEPHONY_ERR_IPC_CONNECT_STUB_FAIL; - } - int32_t result = reply.ReadInt32(); - if (result == TELEPHONY_SUCCESS) { - dataRoamingEnabled = reply.ReadBool(); - } - - return result; -} - -int32_t CellularDataServiceProxy::EnableCellularDataRoaming(int32_t slotId, bool enable) -{ - MessageParcel data; - MessageParcel reply; - MessageOption option; - data.WriteInterfaceToken(CellularDataServiceProxy::GetDescriptor()); - data.WriteInt32(slotId); - data.WriteBool(enable); - if (Remote() == nullptr) { - TELEPHONY_LOGE("remote is null"); - return TELEPHONY_ERR_IPC_CONNECT_STUB_FAIL; - } - int32_t error = Remote()->SendRequest((uint32_t)CellularDataInterfaceCode::ENABLE_DATA_ROAMING, data, - reply, option); - if (error != TELEPHONY_SUCCESS) { - TELEPHONY_LOGE("call failed! errCode:%{public}d", error); - return TELEPHONY_ERR_IPC_CONNECT_STUB_FAIL; - } - int32_t result = reply.ReadInt32(); - return result; -} - -int32_t CellularDataServiceProxy::HandleApnChanged(int32_t slotId) -{ - MessageParcel data; - MessageParcel reply; - MessageOption option; - data.WriteInterfaceToken(CellularDataServiceProxy::GetDescriptor()); - data.WriteInt32(slotId); - if (Remote() == nullptr) { - TELEPHONY_LOGE("remote is null"); - return TELEPHONY_ERR_IPC_CONNECT_STUB_FAIL; - } - int32_t error = Remote()->SendRequest((uint32_t)CellularDataInterfaceCode::APN_DATA_CHANGED, data, reply, option); - if (error != TELEPHONY_SUCCESS) { - TELEPHONY_LOGE("call failed! errCode:%{public}d", error); - return TELEPHONY_ERR_IPC_CONNECT_STUB_FAIL; - } - int32_t result = reply.ReadInt32(); - return result; -} - -int32_t CellularDataServiceProxy::GetDefaultCellularDataSlotId() -{ - MessageParcel data; - MessageParcel reply; - MessageOption option; - data.WriteInterfaceToken(CellularDataServiceProxy::GetDescriptor()); - if (Remote() == nullptr) { - TELEPHONY_LOGE("remote is null"); - return TELEPHONY_ERR_IPC_CONNECT_STUB_FAIL; - } - int32_t error = Remote()->SendRequest((uint32_t)CellularDataInterfaceCode::GET_DEFAULT_SLOT_ID, data, - reply, option); - if (error != TELEPHONY_SUCCESS) { - TELEPHONY_LOGE("call failed! errCode:%{public}d", error); - return TELEPHONY_ERR_IPC_CONNECT_STUB_FAIL; - } - int32_t result = reply.ReadInt32(); - return result; -} - -int32_t CellularDataServiceProxy::GetDefaultCellularDataSimId(int32_t &simId) -{ - MessageParcel data; - data.WriteInterfaceToken(CellularDataServiceProxy::GetDescriptor()); - if (Remote() == nullptr) { - TELEPHONY_LOGE("failed: remote is null"); - return TELEPHONY_ERR_IPC_CONNECT_STUB_FAIL; - } - MessageParcel reply; - MessageOption option; - int32_t error = Remote()->SendRequest((uint32_t)CellularDataInterfaceCode::GET_DEFAULT_SIM_ID, data, reply, option); - if (error != TELEPHONY_SUCCESS) { - TELEPHONY_LOGE("SendRequest failed! errCode:%{public}d", error); - return TELEPHONY_ERR_IPC_CONNECT_STUB_FAIL; - } - int32_t result = reply.ReadInt32(); - TELEPHONY_LOGD("end: result=%{public}d", result); - if (result == TELEPHONY_ERR_SUCCESS) { - simId = reply.ReadInt32(); - } - return result; -} - -int32_t CellularDataServiceProxy::SetDefaultCellularDataSlotId(int32_t slotId) -{ - MessageParcel data; - MessageParcel reply; - MessageOption option; - data.WriteInterfaceToken(CellularDataServiceProxy::GetDescriptor()); - data.WriteInt32(slotId); - if (Remote() == nullptr) { - TELEPHONY_LOGE("remote is null"); - return TELEPHONY_ERR_IPC_CONNECT_STUB_FAIL; - } - int32_t error = Remote()->SendRequest((uint32_t)CellularDataInterfaceCode::SET_DEFAULT_SLOT_ID, data, - reply, option); - if (error != TELEPHONY_SUCCESS) { - TELEPHONY_LOGE("call failed! errCode:%{public}d", error); - return TELEPHONY_ERR_IPC_CONNECT_STUB_FAIL; - } - int32_t result = reply.ReadInt32(); - return result; -} - -int32_t CellularDataServiceProxy::GetCellularDataFlowType() -{ - MessageParcel data; - MessageParcel reply; - MessageOption option; - data.WriteInterfaceToken(CellularDataServiceProxy::GetDescriptor()); - if (Remote() == nullptr) { - TELEPHONY_LOGE("remote is null"); - return TELEPHONY_ERR_IPC_CONNECT_STUB_FAIL; - } - int32_t error = Remote()->SendRequest((uint32_t)CellularDataInterfaceCode::GET_FLOW_TYPE_ID, data, reply, option); - if (error != TELEPHONY_SUCCESS) { - TELEPHONY_LOGE("call failed! errCode:%{public}d", error); - return TELEPHONY_ERR_IPC_CONNECT_STUB_FAIL; - } - int32_t result = reply.ReadInt32(); - return result; -} - -int32_t CellularDataServiceProxy::HasInternetCapability(int32_t slotId, int32_t cid) -{ - MessageParcel data; - MessageParcel reply; - MessageOption option; - data.WriteInterfaceToken(CellularDataServiceProxy::GetDescriptor()); - data.WriteInt32(slotId); - data.WriteInt32(cid); - if (Remote() == nullptr) { - TELEPHONY_LOGE("remote is null"); - return TELEPHONY_ERR_IPC_CONNECT_STUB_FAIL; - } - int32_t error = Remote()->SendRequest((uint32_t)CellularDataInterfaceCode::HAS_CAPABILITY, data, reply, option); - if (error != TELEPHONY_SUCCESS) { - TELEPHONY_LOGE("Strategy switch fail! errCode:%{public}d", error); - return TELEPHONY_ERR_IPC_CONNECT_STUB_FAIL; - } - int32_t result = reply.ReadInt32(); - return result; -} - -int32_t CellularDataServiceProxy::ClearCellularDataConnections(int32_t slotId) -{ - MessageParcel data; - MessageParcel reply; - MessageOption option; - data.WriteInterfaceToken(CellularDataServiceProxy::GetDescriptor()); - data.WriteInt32(slotId); - if (Remote() == nullptr) { - TELEPHONY_LOGE("remote is null"); - return TELEPHONY_ERR_IPC_CONNECT_STUB_FAIL; - } - int32_t error = Remote()->SendRequest((uint32_t)CellularDataInterfaceCode::CLEAR_ALL_CONNECTIONS, data, - reply, option); - if (error != TELEPHONY_SUCCESS) { - TELEPHONY_LOGE("Strategy switch fail! errCode:%{public}d", error); - return TELEPHONY_ERR_IPC_CONNECT_STUB_FAIL; - } - int32_t result = reply.ReadInt32(); - return result; -} - -int32_t CellularDataServiceProxy::ClearAllConnections(int32_t slotId, DisConnectionReason reason) -{ - MessageParcel data; - MessageParcel reply; - MessageOption option; - data.WriteInterfaceToken(CellularDataServiceProxy::GetDescriptor()); - data.WriteInt32(slotId); - data.WriteInt32(static_cast(reason)); - if (Remote() == nullptr) { - TELEPHONY_LOGE("remote is null"); - return TELEPHONY_ERR_IPC_CONNECT_STUB_FAIL; - } - int32_t error = Remote()->SendRequest((uint32_t)CellularDataInterfaceCode::CLEAR_ALL_CONNECTIONS_USE_REASON, data, - reply, option); - if (error != TELEPHONY_SUCCESS) { - TELEPHONY_LOGE("Strategy switch fail! errCode:%{public}d", error); - return TELEPHONY_ERR_IPC_CONNECT_STUB_FAIL; - } - int32_t result = reply.ReadInt32(); - return result; -} - -int32_t CellularDataServiceProxy::RegisterSimAccountCallback(const sptr &callback) -{ - if (callback == nullptr) { - TELEPHONY_LOGE("callback is nullptr!"); - return TELEPHONY_ERR_ARGUMENT_NULL; - } - MessageParcel data; - MessageParcel reply; - MessageOption option; - if (!data.WriteInterfaceToken(CellularDataServiceProxy::GetDescriptor())) { - TELEPHONY_LOGE("write interface token failed!"); - return TELEPHONY_ERR_WRITE_DESCRIPTOR_TOKEN_FAIL; - } - if (!data.WriteRemoteObject(callback->AsObject())) { - TELEPHONY_LOGE("write remote object failed!"); - return TELEPHONY_ERR_WRITE_DATA_FAIL; - } - sptr remote = Remote(); - if (remote == nullptr) { - TELEPHONY_LOGE("remote is nullptr!"); - return TELEPHONY_ERR_IPC_CONNECT_STUB_FAIL; - } - int32_t error = remote->SendRequest(static_cast(CellularDataInterfaceCode::REG_SIM_ACCOUNT_CALLBACK), - data, reply, option); - if (error != TELEPHONY_SUCCESS) { - TELEPHONY_LOGD("error! errCode:%{public}d", error); - return error; - } - return reply.ReadInt32(); -} - -int32_t CellularDataServiceProxy::UnregisterSimAccountCallback(const sptr &callback) -{ - MessageParcel data; - MessageParcel reply; - MessageOption option; - if (!data.WriteInterfaceToken(CellularDataServiceProxy::GetDescriptor())) { - TELEPHONY_LOGE("write interface token failed!"); - return TELEPHONY_ERR_WRITE_DESCRIPTOR_TOKEN_FAIL; - } - if (!data.WriteRemoteObject(callback->AsObject())) { - TELEPHONY_LOGE("write remote object failed!"); - return TELEPHONY_ERR_WRITE_DATA_FAIL; - } - sptr remote = Remote(); - if (remote == nullptr) { - TELEPHONY_LOGE("remote is nullptr!"); - return TELEPHONY_ERR_IPC_CONNECT_STUB_FAIL; - } - int32_t error = remote->SendRequest(static_cast(CellularDataInterfaceCode::UN_REG_SIM_ACCOUNT_CALLBACK), - data, reply, option); - if (error != TELEPHONY_SUCCESS) { - TELEPHONY_LOGE("error! errCode:%{public}d", error); - return error; - } - return reply.ReadInt32(); -} - -int32_t CellularDataServiceProxy::GetDataConnApnAttr(int32_t slotId, ApnItem::Attribute &apnAttr) -{ - MessageParcel dataParcel; - MessageParcel replyParcel; - MessageOption option; - if (!dataParcel.WriteInterfaceToken(CellularDataServiceProxy::GetDescriptor())) { - TELEPHONY_LOGE("write interface token failed!"); - return TELEPHONY_ERR_WRITE_DESCRIPTOR_TOKEN_FAIL; - } - if (!dataParcel.WriteInt32(slotId)) { - TELEPHONY_LOGE("write userId failed!"); - return TELEPHONY_ERR_WRITE_DATA_FAIL; - } - sptr remote = Remote(); - if (remote == nullptr) { - TELEPHONY_LOGE("remote is nullptr!"); - return TELEPHONY_ERR_IPC_CONNECT_STUB_FAIL; - } - int32_t error = remote->SendRequest((uint32_t)CellularDataInterfaceCode::GET_DATA_CONN_APN_ATTR, - dataParcel, replyParcel, option); - if (error != TELEPHONY_SUCCESS) { - TELEPHONY_LOGE("Strategy switch fail! errCode:%{public}d", error); - return TELEPHONY_ERR_IPC_CONNECT_STUB_FAIL; - } - int32_t result = replyParcel.ReadInt32(); - if (result == TELEPHONY_ERR_SUCCESS) { - auto apnAttrPtr = replyParcel.ReadRawData(sizeof(ApnItem::Attribute)); - if (apnAttrPtr == nullptr) { - return TELEPHONY_ERR_READ_DATA_FAIL; - } - if (memcpy_s(&apnAttr, sizeof(ApnItem::Attribute), apnAttrPtr, sizeof(ApnItem::Attribute)) != EOK) { - return TELEPHONY_ERR_MEMCPY_FAIL; - } - } else { - TELEPHONY_LOGE("end failed: result=%{public}d", result); - } - - return TELEPHONY_ERR_SUCCESS; -} - -int32_t CellularDataServiceProxy::GetDataConnIpType(int32_t slotId, std::string &ipType) -{ - MessageParcel dataParcel; - MessageParcel replyParcel; - MessageOption option; - if (!dataParcel.WriteInterfaceToken(CellularDataServiceProxy::GetDescriptor())) { - TELEPHONY_LOGE("write interface token failed!"); - return TELEPHONY_ERR_WRITE_DESCRIPTOR_TOKEN_FAIL; - } - if (!dataParcel.WriteInt32(slotId)) { - TELEPHONY_LOGE("write userId failed!"); - return TELEPHONY_ERR_WRITE_DATA_FAIL; - } - sptr remote = Remote(); - if (remote == nullptr) { - TELEPHONY_LOGE("remote is nullptr!"); - return TELEPHONY_ERR_IPC_CONNECT_STUB_FAIL; - } - int32_t error = remote->SendRequest((uint32_t)CellularDataInterfaceCode::GET_DATA_CONN_IP_TYPE, dataParcel, - replyParcel, option); - if (error != TELEPHONY_SUCCESS) { - TELEPHONY_LOGE("Strategy switch fail! errCode:%{public}d", error); - return TELEPHONY_ERR_IPC_CONNECT_STUB_FAIL; - } - int32_t result = replyParcel.ReadInt32(); - TELEPHONY_LOGI("end: result=%{public}d", result); - if (result == TELEPHONY_ERR_SUCCESS) { - ipType = replyParcel.ReadString(); - } - - return TELEPHONY_ERR_SUCCESS; -} - -int32_t CellularDataServiceProxy::IsNeedDoRecovery(int32_t slotId, bool needDoRecovery) -{ - MessageParcel dataParcel; - MessageParcel replyParcel; - MessageOption option; - if (!dataParcel.WriteInterfaceToken(CellularDataServiceProxy::GetDescriptor())) { - TELEPHONY_LOGE("write interface token failed!"); - return TELEPHONY_ERR_WRITE_DESCRIPTOR_TOKEN_FAIL; - } - dataParcel.WriteInt32(slotId); - dataParcel.WriteBool(needDoRecovery); - sptr remote = Remote(); - if (remote == nullptr) { - TELEPHONY_LOGE("remote is nullptr!"); - return TELEPHONY_ERR_IPC_CONNECT_STUB_FAIL; - } - int32_t error = remote->SendRequest((uint32_t)CellularDataInterfaceCode::IS_NEED_DO_RECOVERY, dataParcel, - replyParcel, option); - if (error != TELEPHONY_SUCCESS) { - TELEPHONY_LOGE("function IsNeedDoRecovery call failed! errCode:%{public}d", error); - return TELEPHONY_ERR_IPC_CONNECT_STUB_FAIL; - } - int32_t result = replyParcel.ReadInt32(); - return result; -} - -int32_t CellularDataServiceProxy::InitCellularDataController(int32_t slotId) -{ - MessageParcel dataParcel; - MessageParcel replyParcel; - MessageOption option; - if (!dataParcel.WriteInterfaceToken(CellularDataServiceProxy::GetDescriptor())) { - TELEPHONY_LOGE("write interface token failed!"); - return TELEPHONY_ERR_WRITE_DESCRIPTOR_TOKEN_FAIL; - } - dataParcel.WriteInt32(slotId); - sptr remote = Remote(); - if (remote == nullptr) { - TELEPHONY_LOGE("remote is nullptr!"); - return TELEPHONY_ERR_IPC_CONNECT_STUB_FAIL; - } - int32_t error = remote->SendRequest((uint32_t)CellularDataInterfaceCode::INIT_CELLULAR_DATA_CONTROLLER, dataParcel, - replyParcel, option); - if (error != TELEPHONY_SUCCESS) { - TELEPHONY_LOGE("function InitCellularDataController call failed! errCode:%{public}d", error); - return TELEPHONY_ERR_IPC_CONNECT_STUB_FAIL; - } - int32_t result = replyParcel.ReadInt32(); - return result; -} - -int32_t CellularDataServiceProxy::EstablishAllApnsIfConnectable(int32_t slotId) -{ - MessageParcel data; - MessageParcel reply; - MessageOption option; - data.WriteInterfaceToken(CellularDataServiceProxy::GetDescriptor()); - data.WriteInt32(slotId); - if (Remote() == nullptr) { - TELEPHONY_LOGE("remote is null"); - return TELEPHONY_ERR_IPC_CONNECT_STUB_FAIL; - } - - int32_t error = Remote()->SendRequest((uint32_t)CellularDataInterfaceCode::ESTABLISH_ALL_APNS_IF_CONNECTABLE, - data, reply, option); - if (error != TELEPHONY_SUCCESS) { - TELEPHONY_LOGE("EstablishAllApnsIfConnectable fail! errCode: %{public}d", error); - return TELEPHONY_ERR_IPC_CONNECT_STUB_FAIL; - } - int32_t result = reply.ReadInt32(); - return result; -} - -int32_t CellularDataServiceProxy::ReleaseCellularDataConnection(int32_t slotId) -{ - MessageParcel dataParcel; - MessageParcel replyParcel; - MessageOption option; - if (!dataParcel.WriteInterfaceToken(CellularDataServiceProxy::GetDescriptor())) { - TELEPHONY_LOGE("write interface token failed!"); - return TELEPHONY_ERR_WRITE_DESCRIPTOR_TOKEN_FAIL; - } - if (!dataParcel.WriteInt32(slotId)) { - TELEPHONY_LOGE("write slotId failed"); - return TELEPHONY_ERR_WRITE_DATA_FAIL; - } - sptr remote = Remote(); - if (remote == nullptr) { - TELEPHONY_LOGE("remote is nullptr!"); - return TELEPHONY_ERR_IPC_CONNECT_STUB_FAIL; - } - int32_t error = remote->SendRequest((uint32_t)CellularDataInterfaceCode::RELEASE_CELLULAR_DATA_CONNECTION, - dataParcel, replyParcel, option); - if (error != TELEPHONY_SUCCESS) { - TELEPHONY_LOGE("function ReleaseCellularDataConnection call failed! errCode:%{public}d", error); - return TELEPHONY_ERR_IPC_CONNECT_STUB_FAIL; - } - int32_t result; - if (!replyParcel.ReadInt32(result)) { - TELEPHONY_LOGE("read reply result failed"); - } - return result; -} - -int32_t CellularDataServiceProxy::GetCellularDataSupplierId(int32_t slotId, uint64_t capability, uint32_t &supplierId) -{ - MessageParcel dataParcel; - MessageParcel replyParcel; - MessageOption option; - if (!dataParcel.WriteInterfaceToken(CellularDataServiceProxy::GetDescriptor())) { - TELEPHONY_LOGE("write interface token failed!"); - return TELEPHONY_ERR_WRITE_DESCRIPTOR_TOKEN_FAIL; - } - dataParcel.WriteInt32(slotId); - dataParcel.WriteUint64(capability); - sptr remote = Remote(); - if (remote == nullptr) { - TELEPHONY_LOGE("remote is nullptr!"); - return TELEPHONY_ERR_IPC_CONNECT_STUB_FAIL; - } - int32_t error = remote->SendRequest((uint32_t)CellularDataInterfaceCode::GET_CELLULAR_DATA_SUPPLIERID, - dataParcel, replyParcel, option); - if (error != TELEPHONY_SUCCESS) { - TELEPHONY_LOGE("function GetCellularDataSupplierId call failed! errCode:%{public}d", error); - return TELEPHONY_ERR_IPC_CONNECT_STUB_FAIL; - } - int32_t result = replyParcel.ReadInt32(); - TELEPHONY_LOGD("end: result=%{public}d", result); - if (result == TELEPHONY_ERR_SUCCESS) { - supplierId = replyParcel.ReadUint32(); - } - return result; -} - -int32_t CellularDataServiceProxy::CorrectNetSupplierNoAvailable(int32_t slotId) -{ - MessageParcel dataParcel; - MessageParcel replyParcel; - MessageOption option; - if (!dataParcel.WriteInterfaceToken(CellularDataServiceProxy::GetDescriptor())) { - TELEPHONY_LOGE("write interface token failed!"); - return TELEPHONY_ERR_WRITE_DESCRIPTOR_TOKEN_FAIL; - } - dataParcel.WriteInt32(slotId); - sptr remote = Remote(); - if (remote == nullptr) { - TELEPHONY_LOGE("remote is nullptr!"); - return TELEPHONY_ERR_IPC_CONNECT_STUB_FAIL; - } - int32_t error = remote->SendRequest((uint32_t)CellularDataInterfaceCode::CORRECT_NET_SUPPLIER_NO_AVAILABLE, - dataParcel, replyParcel, option); - if (error != TELEPHONY_SUCCESS) { - TELEPHONY_LOGE("function CorrectNetSupplierNoAvailable call failed! errCode:%{public}d", error); - return TELEPHONY_ERR_IPC_CONNECT_STUB_FAIL; - } - int32_t result = replyParcel.ReadInt32(); - return result; -} - -int32_t CellularDataServiceProxy::GetSupplierRegisterState(uint32_t supplierId, int32_t ®State) -{ - MessageParcel dataParcel; - MessageParcel replyParcel; - MessageOption option; - if (!dataParcel.WriteInterfaceToken(CellularDataServiceProxy::GetDescriptor())) { - TELEPHONY_LOGE("write interface token failed!"); - return TELEPHONY_ERR_WRITE_DESCRIPTOR_TOKEN_FAIL; - } - dataParcel.WriteUint32(supplierId); - sptr remote = Remote(); - if (remote == nullptr) { - TELEPHONY_LOGE("remote is nullptr!"); - return TELEPHONY_ERR_IPC_CONNECT_STUB_FAIL; - } - int32_t error = remote->SendRequest((uint32_t)CellularDataInterfaceCode::GET_SUPPLIER_REGISTER_STATE, - dataParcel, replyParcel, option); - if (error != TELEPHONY_SUCCESS) { - TELEPHONY_LOGE("function GetSupplierRegisterState call failed! errCode:%{public}d", error); - return TELEPHONY_ERR_IPC_CONNECT_STUB_FAIL; - } - int32_t result = replyParcel.ReadInt32(); - TELEPHONY_LOGD("end: result=%{public}d", result); - if (result == TELEPHONY_ERR_SUCCESS) { - regState = replyParcel.ReadInt32(); - } - return result; -} - -int32_t CellularDataServiceProxy::GetIfSupportDunApn(bool &isSupportDun) -{ - MessageParcel data; - MessageParcel reply; - MessageOption option; - if (!data.WriteInterfaceToken(CellularDataServiceProxy::GetDescriptor())) { - TELEPHONY_LOGE("write interface token failed!"); - return TELEPHONY_ERR_WRITE_DESCRIPTOR_TOKEN_FAIL; - } - sptr remote = Remote(); - if (remote == nullptr) { - TELEPHONY_LOGE("remote is nullptr!"); - return TELEPHONY_ERR_IPC_CONNECT_STUB_FAIL; - } - int32_t error = remote->SendRequest((uint32_t)CellularDataInterfaceCode::GET_IF_SUPPORT_DUN_APN, data, - reply, option); - if (error != TELEPHONY_SUCCESS) { - TELEPHONY_LOGE("call failed! errCode:%{public}d", error); - return TELEPHONY_ERR_IPC_CONNECT_STUB_FAIL; - } - int32_t result = reply.ReadInt32(); - if (result == TELEPHONY_ERR_SUCCESS) { - isSupportDun = reply.ReadBool(); - } - return result; -} - -int32_t CellularDataServiceProxy::GetDefaultActReportInfo(int32_t slotId, ApnActivateReportInfo &info) -{ - MessageParcel dataParcel; - MessageParcel replyParcel; - MessageOption option; - if (!dataParcel.WriteInterfaceToken(CellularDataServiceProxy::GetDescriptor())) { - TELEPHONY_LOGE("write interface token failed!"); - return TELEPHONY_ERR_WRITE_DESCRIPTOR_TOKEN_FAIL; - } - dataParcel.WriteInt32(slotId); - sptr remote = Remote(); - if (remote == nullptr) { - TELEPHONY_LOGE("remote is nullptr!"); - return TELEPHONY_ERR_IPC_CONNECT_STUB_FAIL; - } - int32_t error = remote->SendRequest((uint32_t)CellularDataInterfaceCode::GET_DEFAULT_ACT_REPORT_INFO, - dataParcel, replyParcel, option); - if (error != TELEPHONY_SUCCESS) { - TELEPHONY_LOGE("function GetDefaultActReportInfo call failed! errCode:%{public}d", error); - return TELEPHONY_ERR_IPC_CONNECT_STUB_FAIL; - } - int32_t result = replyParcel.ReadInt32(); - TELEPHONY_LOGD("end: result=%{public}d", result); - if (result == TELEPHONY_ERR_SUCCESS) { - info.actTimes = replyParcel.ReadUint32(); - info.averDuration = replyParcel.ReadUint32(); - info.topReason = replyParcel.ReadUint32(); - info.actSuccTimes = replyParcel.ReadUint32(); - } - return result; -} - -int32_t CellularDataServiceProxy::GetInternalActReportInfo(int32_t slotId, ApnActivateReportInfo &info) -{ - MessageParcel dataParcel; - MessageParcel replyParcel; - MessageOption option; - if (!dataParcel.WriteInterfaceToken(CellularDataServiceProxy::GetDescriptor())) { - TELEPHONY_LOGE("write interface token failed!"); - return TELEPHONY_ERR_WRITE_DESCRIPTOR_TOKEN_FAIL; - } - dataParcel.WriteInt32(slotId); - sptr remote = Remote(); - if (remote == nullptr) { - TELEPHONY_LOGE("remote is nullptr!"); - return TELEPHONY_ERR_IPC_CONNECT_STUB_FAIL; - } - int32_t error = remote->SendRequest((uint32_t)CellularDataInterfaceCode::GET_INTERNAL_ACT_REPORT_INFO, - dataParcel, replyParcel, option); - if (error != TELEPHONY_SUCCESS) { - TELEPHONY_LOGE("function GetInternalActReportInfo call failed! errCode:%{public}d", error); - return TELEPHONY_ERR_IPC_CONNECT_STUB_FAIL; - } - int32_t result = replyParcel.ReadInt32(); - TELEPHONY_LOGD("end: result=%{public}d", result); - if (result == TELEPHONY_ERR_SUCCESS) { - info.actTimes = replyParcel.ReadUint32(); - info.averDuration = replyParcel.ReadUint32(); - info.topReason = replyParcel.ReadUint32(); - info.actSuccTimes = replyParcel.ReadUint32(); - } - return result; -} - -int32_t CellularDataServiceProxy::QueryApnIds(ApnInfo apnInfo, std::vector &apnIdList) -{ - MessageParcel dataParcel; - MessageParcel replyParcel; - MessageOption option; - if (!dataParcel.WriteInterfaceToken(CellularDataServiceProxy::GetDescriptor())) { - TELEPHONY_LOGE("write interface token failed!"); - return TELEPHONY_ERR_WRITE_DESCRIPTOR_TOKEN_FAIL; - } - dataParcel.WriteString16(apnInfo.apnName); - dataParcel.WriteString16(apnInfo.apn); - dataParcel.WriteString16(apnInfo.mcc); - dataParcel.WriteString16(apnInfo.mnc); - dataParcel.WriteString16(apnInfo.user); - dataParcel.WriteString16(apnInfo.type); - dataParcel.WriteString16(apnInfo.proxy); - dataParcel.WriteString16(apnInfo.mmsproxy); - TELEPHONY_LOGI("QueryApnIds type: %{public}s", Str16ToStr8(apnInfo.type).c_str()); - sptr remote = Remote(); - if (remote == nullptr) { - TELEPHONY_LOGE("remote is nullptr!"); - return TELEPHONY_ERR_IPC_CONNECT_STUB_FAIL; - } - int32_t error = remote->SendRequest((uint32_t)CellularDataInterfaceCode::QUERY_APN_INFO, - dataParcel, replyParcel, option); - if (error != TELEPHONY_SUCCESS) { - TELEPHONY_LOGE("function QueryApnIds call failed! errCode:%{public}d", error); - return TELEPHONY_ERR_IPC_CONNECT_STUB_FAIL; - } - int32_t result = replyParcel.ReadInt32(); - TELEPHONY_LOGI("QueryApnIds end: result=%{public}d", result); - if (result == TELEPHONY_ERR_SUCCESS) { - int32_t size = replyParcel.ReadInt32(); - if (size > MAX_REPLY_COUNT) { - TELEPHONY_LOGE("QueryApnIds size error = %{public}d", size); - return result; - } - TELEPHONY_LOGI("QueryApnIds size = %{public}d", size); - apnIdList.clear(); - for (int i = 0; i < size; i++) { - int apnId = replyParcel.ReadInt32(); - TELEPHONY_LOGI("QueryApnIds success apnId = %{public}d", apnId); - apnIdList.emplace_back(apnId); - } - } - return result; -} - -int32_t CellularDataServiceProxy::SetPreferApn(int32_t apnId) -{ - MessageParcel dataParcel; - MessageParcel replyParcel; - MessageOption option; - if (!dataParcel.WriteInterfaceToken(CellularDataServiceProxy::GetDescriptor())) { - TELEPHONY_LOGE("write interface token failed!"); - return TELEPHONY_ERR_WRITE_DESCRIPTOR_TOKEN_FAIL; - } - dataParcel.WriteInt32(apnId); - sptr remote = Remote(); - if (remote == nullptr) { - TELEPHONY_LOGE("remote is nullptr!"); - return TELEPHONY_ERR_IPC_CONNECT_STUB_FAIL; - } - int32_t error = remote->SendRequest((uint32_t)CellularDataInterfaceCode::SET_PREFER_APN, - dataParcel, replyParcel, option); - if (error != TELEPHONY_SUCCESS) { - TELEPHONY_LOGE("function SetPreferApn call failed! errCode:%{public}d", error); - return TELEPHONY_ERR_IPC_CONNECT_STUB_FAIL; - } - return replyParcel.ReadInt32(); -} - -int32_t CellularDataServiceProxy::QueryAllApnInfo(std::vector &apnInfoList) -{ - MessageParcel dataParcel; - MessageParcel replyParcel; - MessageOption option; - if (!dataParcel.WriteInterfaceToken(CellularDataServiceProxy::GetDescriptor())) { - TELEPHONY_LOGE("write interface token failed!"); - return TELEPHONY_ERR_WRITE_DESCRIPTOR_TOKEN_FAIL; - } - sptr remote = Remote(); - if (remote == nullptr) { - TELEPHONY_LOGE("remote is nullptr!"); - return TELEPHONY_ERR_IPC_CONNECT_STUB_FAIL; - } - int32_t error = remote->SendRequest((uint32_t)CellularDataInterfaceCode::QUERY_ALL_APN_INFO, - dataParcel, replyParcel, option); - if (error != TELEPHONY_SUCCESS) { - TELEPHONY_LOGE("function QueryAllApnInfo call failed! errCode:%{public}d", error); - return TELEPHONY_ERR_IPC_CONNECT_STUB_FAIL; - } - int32_t result = replyParcel.ReadInt32(); - TELEPHONY_LOGI("QueryAllApnInfo end: result=%{public}d", result); - if (result == TELEPHONY_ERR_SUCCESS) { - int32_t size = replyParcel.ReadInt32(); - if (size > MAX_REPLY_COUNT) { - TELEPHONY_LOGE("QueryAllApnInfo size error = %{public}d", size); - return result; - } - TELEPHONY_LOGI("QueryAllApnInfo size = %{public}d", size); - apnInfoList.clear(); - for (int i = 0; i < size; i++) { - ApnInfo apnInfo; - apnInfo.ReadFromParcel(replyParcel); - apnInfoList.emplace_back(apnInfo); - } - } - return result; -} - -int32_t CellularDataServiceProxy::SendUrspDecodeResult(int32_t slotId, std::vector buffer) -{ - MessageParcel data; - MessageParcel reply; - MessageOption option; - if (!data.WriteInterfaceToken(CellularDataServiceProxy::GetDescriptor())) { - TELEPHONY_LOGE("write interface token failed!"); - return TELEPHONY_ERR_WRITE_DESCRIPTOR_TOKEN_FAIL; - } - data.WriteInt32(slotId); - int32_t bufferlen = (int32_t)buffer.size(); - if (bufferlen <= 0 || bufferlen > BUFFER_MAX) { - TELEPHONY_LOGE("buffer length is invalid: %{public}d", bufferlen); - return TELEPHONY_ERR_ARGUMENT_INVALID; - } - data.WriteInt32(bufferlen); - for (int i = 0; i < bufferlen; ++i) { - data.WriteInt32(buffer[i]); - } - if (Remote() == nullptr) { - TELEPHONY_LOGE("remote is null"); - return TELEPHONY_ERR_IPC_CONNECT_STUB_FAIL; - } - - int32_t error = Remote()->SendRequest((uint32_t)CellularDataInterfaceCode::SEND_MANAGE_UEPOLICY_DECODE_RESULT, - data, reply, option); - if (error != TELEPHONY_SUCCESS) { - TELEPHONY_LOGE("SendUrspDecodeResult fail! errCode: %{public}d", error); - return TELEPHONY_ERR_IPC_CONNECT_STUB_FAIL; - } - int32_t result = reply.ReadInt32(); - return result; -} - -int32_t CellularDataServiceProxy::SendUePolicySectionIdentifier(int32_t slotId, std::vector buffer) -{ - MessageParcel data; - MessageParcel reply; - MessageOption option; - if (!data.WriteInterfaceToken(CellularDataServiceProxy::GetDescriptor())) { - TELEPHONY_LOGE("write interface token failed!"); - return TELEPHONY_ERR_WRITE_DESCRIPTOR_TOKEN_FAIL; - } - data.WriteInt32(slotId); - int32_t bufferlen = (int32_t)buffer.size(); - if (bufferlen <= 0 || bufferlen > BUFFER_MAX) { - TELEPHONY_LOGE("buffer length is invalid: %{public}d", bufferlen); - return TELEPHONY_ERR_ARGUMENT_INVALID; - } - data.WriteInt32(bufferlen); - for (int i = 0; i < bufferlen; ++i) { - data.WriteInt32(buffer[i]); - } - if (Remote() == nullptr) { - TELEPHONY_LOGE("remote is null"); - return TELEPHONY_ERR_IPC_CONNECT_STUB_FAIL; - } - - int32_t error = Remote()->SendRequest((uint32_t)CellularDataInterfaceCode::SEND_UE_STATE_INDICATION, - data, reply, option); - if (error != TELEPHONY_SUCCESS) { - TELEPHONY_LOGE("SendUePolicySectionIdentifier fail! errCode: %{public}d", error); - return TELEPHONY_ERR_IPC_CONNECT_STUB_FAIL; - } - int32_t result = reply.ReadInt32(); - return result; -} - -int32_t CellularDataServiceProxy::SendImsRsdList(int32_t slotId, std::vector buffer) -{ - MessageParcel data; - MessageParcel reply; - MessageOption option; - if (!data.WriteInterfaceToken(CellularDataServiceProxy::GetDescriptor())) { - TELEPHONY_LOGE("write interface token failed!"); - return TELEPHONY_ERR_WRITE_DESCRIPTOR_TOKEN_FAIL; - } - data.WriteInt32(slotId); - int32_t bufferlen = (int32_t)buffer.size(); - if (bufferlen <= 0 || bufferlen > BUFFER_MAX) { - TELEPHONY_LOGE("buffer length is invalid: %{public}d", bufferlen); - return TELEPHONY_ERR_ARGUMENT_INVALID; - } - data.WriteInt32(bufferlen); - for (int i = 0; i < bufferlen; ++i) { - data.WriteInt32(buffer[i]); - } - if (Remote() == nullptr) { - TELEPHONY_LOGE("remote is null"); - return TELEPHONY_ERR_IPC_CONNECT_STUB_FAIL; - } - - int32_t error = Remote()->SendRequest((uint32_t)CellularDataInterfaceCode::SEND_IMS_RSDLIST, - data, reply, option); - if (error != TELEPHONY_SUCCESS) { - TELEPHONY_LOGE("SendImsRsdList fail! errCode: %{public}d", error); - return TELEPHONY_ERR_IPC_CONNECT_STUB_FAIL; - } - int32_t result = reply.ReadInt32(); - return result; -} - -int32_t CellularDataServiceProxy::GetNetworkSliceAllowedNssai(int32_t slotId, std::vector buffer) -{ - MessageParcel data; - MessageParcel reply; - MessageOption option; - if (!data.WriteInterfaceToken(CellularDataServiceProxy::GetDescriptor())) { - TELEPHONY_LOGE("write interface token failed!"); - return TELEPHONY_ERR_WRITE_DESCRIPTOR_TOKEN_FAIL; - } - data.WriteInt32(slotId); - int32_t bufferlen = (int32_t)buffer.size(); - if (bufferlen <= 0 || bufferlen > BUFFER_MAX) { - TELEPHONY_LOGE("buffer length is invalid: %{public}d", bufferlen); - return TELEPHONY_ERR_ARGUMENT_INVALID; - } - data.WriteInt32(bufferlen); - for (int i = 0; i < bufferlen; ++i) { - data.WriteInt32(buffer[i]); - } - if (Remote() == nullptr) { - TELEPHONY_LOGE("remote is null"); - return TELEPHONY_ERR_IPC_CONNECT_STUB_FAIL; - } - - int32_t error = Remote()->SendRequest((uint32_t)CellularDataInterfaceCode::SYNC_ALLOWED_NSSAI_WITH_MODEM, - data, reply, option); - if (error != TELEPHONY_SUCCESS) { - TELEPHONY_LOGE("GetNetworkSliceAllowedNssai fail! errCode: %{public}d", error); - return TELEPHONY_ERR_IPC_CONNECT_STUB_FAIL; - } - int32_t result = reply.ReadInt32(); - return result; -} - -int32_t CellularDataServiceProxy::GetNetworkSliceEhplmn(int32_t slotId) -{ - MessageParcel data; - MessageParcel reply; - MessageOption option; - if (!data.WriteInterfaceToken(CellularDataServiceProxy::GetDescriptor())) { - TELEPHONY_LOGE("write interface token failed!"); - return TELEPHONY_ERR_WRITE_DESCRIPTOR_TOKEN_FAIL; - } - data.WriteInt32(slotId); - if (Remote() == nullptr) { - TELEPHONY_LOGE("remote is null"); - return TELEPHONY_ERR_IPC_CONNECT_STUB_FAIL; - } - - int32_t error = Remote()->SendRequest((uint32_t)CellularDataInterfaceCode::SYNC_EHPLMN_WITH_MODEM, - data, reply, option); - if (error != TELEPHONY_SUCCESS) { - TELEPHONY_LOGE("GetNetworkSliceEhplmn fail! errCode: %{public}d", error); - return TELEPHONY_ERR_IPC_CONNECT_STUB_FAIL; - } - int32_t result = reply.ReadInt32(); - return result; -} - -} // namespace Telephony -} // namespace OHOS diff --git a/frameworks/native/cellular_data_service_proxy.h b/frameworks/native/cellular_data_service_proxy.h deleted file mode 100644 index 72b7e375..00000000 --- a/frameworks/native/cellular_data_service_proxy.h +++ /dev/null @@ -1,207 +0,0 @@ -/* - * Copyright (C) 2021-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 CELLULAR_DATA_SERVICE_PROXY_H -#define CELLULAR_DATA_SERVICE_PROXY_H - -#include - -#include "cellular_data_ipc_interface_code.h" -#include "functional" -#include "i_cellular_data_manager.h" -#include "iremote_broker.h" -#include "iremote_proxy.h" -#include "refbase.h" -#include "cellular_data_constant.h" - -namespace OHOS { -class IRemoteObject; -namespace Telephony { -class CellularDataServiceProxy : public IRemoteProxy { -public: - explicit CellularDataServiceProxy(const sptr &impl) : IRemoteProxy(impl) - {} - ~CellularDataServiceProxy() = default; - - /** - * Whether the cellular data user switch is enabled - * - * @return return errorCode of is cellulardata enabled - */ - virtual int32_t IsCellularDataEnabled(bool &dataEnabled); - - /** - * Whether to enable intelligence switch - * - * @param enable allow or not - * @return return 84082688 invalid parameter, 1 data enable success, 0 enable fail - */ - int32_t EnableIntelligenceSwitch(bool enable); - - /** - * Whether to enable cellular data user switch - * - * @param enable allow or not - * @return return 84082688 invalid parameter, 1 data enable success, 0 enable fail - */ - int32_t EnableCellularData(bool enable); - - /** - * Cellular data connection status - * - * @return 84082688 Indicates that a cellular data link is unknown - * 11 Indicates that a cellular data link is disconnected - * 12 Indicates that a cellular data link is being connected - * 13 Indicates that a cellular data link is connected - * 14 Indicates that a cellular data link is suspended - */ - int32_t GetCellularDataState(); - - /** - * Get the apn status based on slotId and apnType - * - * @param slotId card slot identification - * @param apnType apn type, eg."default" - * @return apnstate - */ - int32_t GetApnState(int32_t slotId, const std::string &apnType); - - int32_t GetDataRecoveryState(); - - /** - * Whether roaming is allowed - * - * @param slotId card slot identification - * @return return 84082688 invalid parameter, 0 roaming is not allowed, 1 roaming is allowed - */ - int32_t IsCellularDataRoamingEnabled(int32_t slotId, bool &dataRoamingEnabled); - - /** - * Whether roaming switches are allowed - * - * @param slotId card slot identification - * @param enable Whether roaming switches are allowed - * @return Returns 0 on failure, 1 on failure. 84082688 invalid parameter - */ - int32_t EnableCellularDataRoaming(int32_t slotId, bool enable); - - /** - * Processing of APN content changes - * - * @param slotId card slot identification - * @return the number of apns created else 84082688 invalid parameter - */ - int32_t HandleApnChanged(int32_t slotId); - - /** - * Get the slotId that uses the data traffic by default - * - * @return default settings data card, -1 error code - */ - int32_t GetDefaultCellularDataSlotId(); - - /** - * Get the sim id that uses the data traffic by default - * - * @param simId Returns default settings data sim id - * @return Returns 0 on success, others on failure. - */ - int32_t GetDefaultCellularDataSimId(int32_t &simId); - - /** - * set the slotId that uses the data traffic by default - * - * @param slotId card slot identification - * @return 1 set success, 0 set fail, 84082688 invalid parameter - */ - int32_t SetDefaultCellularDataSlotId(int32_t slotId); - - /** - * get data packet type - * - * @return 0 Indicates that there is no uplink or down link data, - * 1 Indicates that there is only down link data, - * 2 Indicates that there is only uplink data, - * 3 Indicates that there is uplink and down link data - * 4 Indicates that there is no uplink or down link data, - * and the bottom-layer link is in the dormant state - * 84082688 Indicates invalid parameter - */ - int32_t GetCellularDataFlowType(); - - /** - * Get the State Of Intelligence Switch - * - * @param switchState Returns switch state - * @return Returns 0 on success, others on failure. - */ - int32_t GetIntelligenceSwitchState(bool &switchState); - - int32_t HasInternetCapability(int32_t slotId, int32_t cid); - - int32_t ClearCellularDataConnections(int32_t slotId); - - int32_t ClearAllConnections(int32_t slotId, DisConnectionReason reason); - - int32_t RegisterSimAccountCallback(const sptr &callback); - - int32_t UnregisterSimAccountCallback(const sptr &callback); - - int32_t GetDataConnApnAttr(int32_t slotId, ApnItem::Attribute &apnAttr); - - int32_t GetDataConnIpType(int32_t slotId, std::string &ipType); - - int32_t IsNeedDoRecovery(int32_t slotId, bool needDoRecovery); - - int32_t InitCellularDataController(int32_t slotId); - - int32_t EstablishAllApnsIfConnectable(int32_t slotId); - - int32_t ReleaseCellularDataConnection(int32_t slotId); - - int32_t GetCellularDataSupplierId(int32_t slotId, uint64_t capability, uint32_t &supplierId); - - int32_t CorrectNetSupplierNoAvailable(int32_t slotId); - - int32_t GetSupplierRegisterState(uint32_t supplierId, int32_t ®State); - - int32_t SendUrspDecodeResult(int32_t slotId, std::vector buffer); - - int32_t SendUePolicySectionIdentifier(int32_t slotId, std::vector buffer); - - int32_t SendImsRsdList(int32_t slotId, std::vector buffer); - - int32_t GetNetworkSliceAllowedNssai(int32_t slotId, std::vector buffer); - - int32_t GetNetworkSliceEhplmn(int32_t slotId); - - int32_t GetIfSupportDunApn(bool &isSupportDun); - - int32_t GetDefaultActReportInfo(int32_t slotId, ApnActivateReportInfo &info); - - int32_t GetInternalActReportInfo(int32_t slotId, ApnActivateReportInfo &info); - - int32_t QueryApnIds(ApnInfo apnInfo, std::vector &apnIdList); - - int32_t SetPreferApn(int32_t apnId); - - int32_t QueryAllApnInfo(std::vector &apnInfoList); - -private: - static inline BrokerDelegator delegator_; -}; -} // namespace Telephony -} // namespace OHOS -#endif // CELLULAR_DATA_SERVICE_PROXY_H diff --git a/frameworks/native/data_sim_account_call_back.cpp b/frameworks/native/data_sim_account_callback.cpp similarity index 95% rename from frameworks/native/data_sim_account_call_back.cpp rename to frameworks/native/data_sim_account_callback.cpp index 6591994a..c0723eea 100644 --- a/frameworks/native/data_sim_account_call_back.cpp +++ b/frameworks/native/data_sim_account_callback.cpp @@ -13,7 +13,7 @@ * limitations under the License. */ -#include "data_sim_account_call_back.h" +#include "data_sim_account_callback.h" #include "cellular_data_client.h" #include "telephony_log_wrapper.h" diff --git a/interfaces/innerkits/apn_activate_report_info.h b/interfaces/innerkits/apn_activate_report_info.h new file mode 100644 index 00000000..16375b1c --- /dev/null +++ b/interfaces/innerkits/apn_activate_report_info.h @@ -0,0 +1,51 @@ +/* + * Copyright (C) 2025 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 APN_ACTIVATE_REPORT_INFO_H +#define APN_ACTIVATE_REPORT_INFO_H + +#include "parcel.h" +#include "apn_item.h" +namespace OHOS { +namespace Telephony { +struct ApnActivateReportInfoIpc : public Parcelable { + uint32_t actTimes; + uint32_t averDuration; + uint32_t topReason; + uint32_t actSuccTimes; + + ApnActivateReportInfoIpc() + { + actTimes = 0; + averDuration = 0; + topReason = 0; + actSuccTimes = 0; + } + + ApnActivateReportInfoIpc(const ApnActivateReportInfo& obj) + { + actTimes = obj.actTimes; + averDuration = obj.averDuration; + topReason = obj.topReason; + actSuccTimes = obj.actSuccTimes; + } + + static void transferToReportInfo(ApnActivateReportInfoIpc infoIpc, ApnActivateReportInfo &info); + + bool Marshalling(Parcel &parcel) const override; + static ApnActivateReportInfoIpc* Unmarshalling(Parcel &parcel); +}; +} +} +#endif //APN_ACTIVATE_REPORT_INFO_H \ No newline at end of file diff --git a/interfaces/innerkits/apn_attribute.h b/interfaces/innerkits/apn_attribute.h new file mode 100644 index 00000000..d92e8353 --- /dev/null +++ b/interfaces/innerkits/apn_attribute.h @@ -0,0 +1,48 @@ +/* + * Copyright (C) 2025 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 APN_ATTRIBUTE_H +#define APN_ATTRIBUTE_H + +#include "apn_item.h" +#include "parcel.h" +namespace OHOS { +namespace Telephony { +constexpr static int ALL_APN_ITEM_CHAR_LENGTH = 256; +struct ApnAttribute final : public Parcelable { + std::string types_; + std::string numeric_; + int32_t profileId_ = 0; + std::string protocol_; + std::string roamingProtocol_; + int32_t authType_ = 0; + std::string apn_; + std::string apnName_; + std::string user_; + std::string password_; + bool isRoamingApn_ = false; + std::string homeUrl_; + std::string proxyIpAddress_; + std::string mmsIpAddress_; + bool isEdited_ = false; + + bool Marshalling(Parcel &parcel) const override; + static ApnAttribute* Unmarshalling(Parcel &parcel); + + static void TransferApnAttributeBeforeIpc(ApnItem::Attribute &apnAttr, ApnAttribute &apnAfterTrans); + static void TransferApnAttributeAfterIpc(ApnItem::Attribute &apnAttr, ApnAttribute &apnAfterTrans); +}; +} +} +#endif //APN_ATTRIBUTE_H \ No newline at end of file diff --git a/interfaces/innerkits/cellular_data_client.h b/interfaces/innerkits/cellular_data_client.h index bf199cde..ee44f1de 100644 --- a/interfaces/innerkits/cellular_data_client.h +++ b/interfaces/innerkits/cellular_data_client.h @@ -20,11 +20,12 @@ #include #include -#include "data_sim_account_call_back.h" -#include "i_cellular_data_manager.h" +#include "data_sim_account_callback.h" +#include "icellular_data_manager.h" #include "sim_account_callback.h" #include "apn_item.h" #include "cellular_data_constant.h" +#include "apn_attribute.h" namespace OHOS { namespace Telephony { diff --git a/interfaces/innerkits/data_sim_account_call_back.h b/interfaces/innerkits/data_sim_account_callback.h similarity index 100% rename from interfaces/innerkits/data_sim_account_call_back.h rename to interfaces/innerkits/data_sim_account_callback.h diff --git a/interfaces/innerkits/i_cellular_data_manager.h b/interfaces/innerkits/i_cellular_data_manager.h deleted file mode 100644 index de5ec728..00000000 --- a/interfaces/innerkits/i_cellular_data_manager.h +++ /dev/null @@ -1,191 +0,0 @@ -/* - * Copyright (C) 2021-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 I_CELLULAR_DATA_MANAGER_H -#define I_CELLULAR_DATA_MANAGER_H - -#include "iremote_broker.h" -#include "sim_account_callback.h" -#include "apn_item.h" -#include "cellular_data_constant.h" - -namespace OHOS { -namespace Telephony { -class ICellularDataManager : public IRemoteBroker { -public: - /** - * Whether the cellular data user switch is enabled - * - * @return return errorCode of is cellulardata enabled - */ - virtual int32_t IsCellularDataEnabled(bool &dataEnabled) = 0; - - /** - * Whether to enable cellular data user switch - * - * @param enable allow or not - * @return return 84082688 invalid parameter, 1 data enable success, 0 enable fail - */ - virtual int32_t EnableCellularData(bool enable) = 0; - - /** - * Whether to enable intelligence switch - * - * @param enable allow or not - * @return return 84082688 invalid parameter, 1 data enable success, 0 enable fail - */ - virtual int32_t EnableIntelligenceSwitch(bool enable) = 0; - - /** - * Cellular data connection status - * - * @return 84082688 Indicates that a cellular data link is unknown - * 11 Indicates that a cellular data link is disconnected - * 12 Indicates that a cellular data link is being connected - * 13 Indicates that a cellular data link is connected - * 14 Indicates that a cellular data link is suspended - */ - virtual int32_t GetCellularDataState() = 0; - - /** - * Whether roaming is allowed - * - * @param slotId card slot identification - * @param dataRoamingEnabled result of data is enabled - * @return return errorCode of is cellulardata enabled - */ - virtual int32_t IsCellularDataRoamingEnabled(int32_t slotId, bool &dataRoamingEnabled) = 0; - - /** - * Whether roaming switches are allowed - * - * @param slotId card slot identification - * @param enable Whether roaming switches are allowed - * @return Returns 0 on failure, 1 on failure. 84082688 invalid parameter - */ - virtual int32_t EnableCellularDataRoaming(int32_t slotId, bool enable) = 0; - - /** - * Processing of APN content changes - * - * @param slotId card slot identification - * @param apns changed apns - * @return the number of apns created else 84082688 invalid parameter - */ - virtual int32_t HandleApnChanged(int32_t slotId) = 0; - - /** - * Get the slotId that uses the data traffic by default - * - * @return default settings data card, -1 error code - */ - virtual int32_t GetDefaultCellularDataSlotId() = 0; - - /** - * Get the simId that uses the data traffic by default - * - * @param simId Returns default settings data sim id - * @return Returns 0 on success, others on failure. - */ - virtual int32_t GetDefaultCellularDataSimId(int32_t &simId) = 0; - - /** - * set the slotId that uses the data traffic by default - * - * @return 1 set success, 0 set fail, 84082688 invalid parameter - */ - virtual int32_t SetDefaultCellularDataSlotId(int32_t slotId) = 0; - - /** - * get data packet type - * - * @return 0 Indicates that there is no uplink or down link data, - * 1 Indicates that there is only down link data, - * 2 Indicates that there is only uplink data, - * 3 Indicates that there is uplink and down link data - * 4 Indicates that there is no uplink or down link data, - * and the bottom-layer link is in the dormant state - * 84082688 Indicates invalid parameter - */ - virtual int32_t GetCellularDataFlowType() = 0; - - /** - * get intelligence switch state - * - * @param state the state of intelligence switch - * @return return 84082688 invalid parameter, 1 data enable success, 0 enable fail - */ - virtual int32_t GetIntelligenceSwitchState(bool &state) = 0; - - virtual int32_t HasInternetCapability(int32_t slotId, int32_t cid) = 0; - - virtual int32_t ClearCellularDataConnections(int32_t slotId) = 0; - - virtual int32_t ClearAllConnections(int32_t slotId, DisConnectionReason reason) = 0; - - virtual int32_t RegisterSimAccountCallback(const sptr &callback) = 0; - - virtual int32_t UnregisterSimAccountCallback(const sptr &callback) = 0; - - virtual int32_t GetDataConnApnAttr(int32_t slotId, ApnItem::Attribute &apnAttr) = 0; - - virtual int32_t GetDataConnIpType(int32_t slotId, std::string &ipType) = 0; - - virtual int32_t GetApnState(int32_t slotId, const std::string &apnType) = 0; - - virtual int32_t GetDataRecoveryState() = 0; - - virtual int32_t IsNeedDoRecovery(int32_t slotId, bool needDoRecovery) = 0; - - virtual int32_t InitCellularDataController(int32_t slotId) = 0; - - virtual int32_t EstablishAllApnsIfConnectable(int32_t slotId) = 0; - - virtual int32_t ReleaseCellularDataConnection(int32_t slotId) = 0; - - virtual int32_t GetCellularDataSupplierId(int32_t slotId, uint64_t capability, uint32_t &supplierId) = 0; - - virtual int32_t CorrectNetSupplierNoAvailable(int32_t slotId) = 0; - - virtual int32_t GetSupplierRegisterState(uint32_t supplierId, int32_t ®State) = 0; - - virtual int32_t GetIfSupportDunApn(bool &isSupportDun) = 0; - - virtual int32_t GetDefaultActReportInfo(int32_t slotId, ApnActivateReportInfo &info) = 0; - - virtual int32_t GetInternalActReportInfo(int32_t slotId, ApnActivateReportInfo &info) = 0; - - virtual int32_t QueryApnIds(ApnInfo apnInfo, std::vector &apnIdList) = 0; - - virtual int32_t SetPreferApn(int32_t apnId) = 0; - - virtual int32_t QueryAllApnInfo(std::vector &apnInfoList) = 0; - - virtual int32_t SendUrspDecodeResult(int32_t slotId, std::vector buffer) = 0; - - virtual int32_t SendUePolicySectionIdentifier(int32_t slotId, std::vector buffer) = 0; - - virtual int32_t SendImsRsdList(int32_t slotId, std::vector buffer) = 0; - - virtual int32_t GetNetworkSliceAllowedNssai(int32_t slotId, std::vector buffer) = 0; - - virtual int32_t GetNetworkSliceEhplmn(int32_t slotId) = 0; - -public: - DECLARE_INTERFACE_DESCRIPTOR(u"ohos.telephony.ICellularDataManager"); -}; -} // namespace Telephony -} // namespace OHOS -#endif // I_CELLULAR_DATA_MANAGER_H diff --git a/services/include/cellular_data_service.h b/services/include/cellular_data_service.h index 0c44c861..be119ebd 100644 --- a/services/include/cellular_data_service.h +++ b/services/include/cellular_data_service.h @@ -21,10 +21,12 @@ #include "singleton.h" #include "system_ability.h" -#include "cellular_data_service_stub.h" +#include "cellular_data_manager_stub.h" #include "cellular_data_constant.h" #include "cellular_data_controller.h" #include "traffic_management.h" +#include "apn_activate_report_info.h" +#include "apn_attribute.h" #include "apn_item.h" namespace OHOS { @@ -34,7 +36,7 @@ enum class ServiceRunningState { STATE_RUNNING, }; -class CellularDataService : public SystemAbility, public CellularDataServiceStub { +class CellularDataService : public SystemAbility, public CellularDataManagerStub { DECLARE_DELAYED_REF_SINGLETON(CellularDataService) DECLARE_SYSTEM_ABILITY(CellularDataService) @@ -55,18 +57,18 @@ public: std::string GetFlowDataInfoDump(); int32_t IsCellularDataEnabled(bool &dataEnabled) override; int32_t EnableCellularData(bool enable) override; - int32_t GetCellularDataState() override; + int32_t GetCellularDataState(int32_t &state) override; int32_t IsCellularDataRoamingEnabled(const int32_t slotId, bool &dataRoamingEnabled) override; int32_t EnableCellularDataRoaming(const int32_t slotId, bool enable) override; int32_t HandleApnChanged(const int32_t slotId) override; - int32_t GetDefaultCellularDataSlotId() override; + int32_t GetDefaultCellularDataSlotId(int32_t &slotId) override; int32_t GetDefaultCellularDataSimId(int32_t &simId) override; int32_t SetDefaultCellularDataSlotId(const int32_t slotId) override; - int32_t GetCellularDataFlowType() override; + int32_t GetCellularDataFlowType(int32_t &type) override; void DispatchEvent(int32_t slotId, const AppExecFwk::InnerEvent::Pointer &event); - int32_t HasInternetCapability(const int32_t slotId, const int32_t cid) override; + int32_t HasInternetCapability(const int32_t slotId, const int32_t cid, int32_t &capability) override; int32_t ClearCellularDataConnections(const int32_t slotId) override; - int32_t ClearAllConnections(const int32_t slotId, DisConnectionReason reason) override; + int32_t ClearAllConnections(const int32_t slotId, const int32_t reason) override; int32_t ChangeConnectionForDsds(const int32_t slotId, bool enable); int32_t StrategySwitch(int32_t slotId, bool enable); int32_t RequestNet(const NetRequest &request); @@ -75,11 +77,11 @@ public: int32_t RemoveUid(const NetRequest &request); int32_t GetServiceRunningState(); int64_t GetSpendTime(); - int32_t GetApnState(int32_t slotId, const std::string &apnType) override; - int32_t GetDataRecoveryState() override; + int32_t GetApnState(int32_t slotId, const std::string &apnType, int &state) override; + int32_t GetDataRecoveryState(int32_t &state) override; int32_t RegisterSimAccountCallback(const sptr &callback) override; int32_t UnregisterSimAccountCallback(const sptr &callback) override; - int32_t GetDataConnApnAttr(int32_t slotId, ApnItem::Attribute &apnAttr) override; + int32_t GetDataConnApnAttr(int32_t slotId, ApnAttribute &apnAttr) override; int32_t GetDataConnIpType(int32_t slotId, std::string &ipType) override; int32_t IsNeedDoRecovery(int32_t slotId, bool needDoRecovery) override; int32_t EnableIntelligenceSwitch(bool enable) override; @@ -91,8 +93,8 @@ public: int32_t CorrectNetSupplierNoAvailable(int32_t slotId) override; int32_t GetSupplierRegisterState(uint32_t supplierId, int32_t ®State) override; int32_t GetIfSupportDunApn(bool &isSupportDun) override; - int32_t GetDefaultActReportInfo(int32_t slotId, ApnActivateReportInfo &info) override; - int32_t GetInternalActReportInfo(int32_t slotId, ApnActivateReportInfo &info) override; + int32_t GetDefaultActReportInfo(int32_t slotId, ApnActivateReportInfoIpc &info) override; + int32_t GetInternalActReportInfo(int32_t slotId, ApnActivateReportInfoIpc &info) override; int32_t QueryApnIds(ApnInfo apnInfo, std::vector &apnIdList) override; int32_t SetPreferApn(int32_t apnId) override; int32_t QueryAllApnInfo(std::vector &apnInfoList) override; diff --git a/services/include/cellular_data_service_stub.h b/services/include/cellular_data_service_stub.h deleted file mode 100644 index 44b456a1..00000000 --- a/services/include/cellular_data_service_stub.h +++ /dev/null @@ -1,172 +0,0 @@ -/* - * Copyright (C) 2021-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 CELLULAR_DATA_SERVICE_STUB_H -#define CELLULAR_DATA_SERVICE_STUB_H - -#include - -#include "iremote_object.h" -#include "iremote_stub.h" - -#include "cellular_data_ipc_interface_code.h" -#include "i_cellular_data_manager.h" - -namespace OHOS { -namespace Telephony { -class CellularDataServiceStub : public IRemoteStub { -public: - CellularDataServiceStub(); - ~CellularDataServiceStub(); - int32_t OnRemoteRequest( - uint32_t code, MessageParcel &data, MessageParcel &reply, MessageOption &option) override; - int32_t OnRegisterSimAccountCallback(MessageParcel &data, MessageParcel &reply); - int32_t OnUnregisterSimAccountCallback(MessageParcel &data, MessageParcel &reply); - -private: - int32_t OnIsCellularDataEnabled(MessageParcel &data, MessageParcel &reply); - int32_t OnEnableCellularData(MessageParcel &data, MessageParcel &reply); - int32_t OnGetCellularDataState(MessageParcel &data, MessageParcel &reply); - int32_t OnIsCellularDataRoamingEnabled(MessageParcel &data, MessageParcel &reply); - int32_t OnEnableCellularDataRoaming(MessageParcel &data, MessageParcel &reply); - int32_t OnHandleApnChanged(MessageParcel &data, MessageParcel &reply); - int32_t OnGetDefaultCellularDataSlotId(MessageParcel &data, MessageParcel &reply); - int32_t OnGetDefaultCellularDataSimId(MessageParcel &data, MessageParcel &reply); - int32_t OnSetDefaultCellularDataSlotId(MessageParcel &data, MessageParcel &reply); - int32_t OnGetCellularDataFlowType(MessageParcel &data, MessageParcel &reply); - int32_t OnHasInternetCapability(MessageParcel &data, MessageParcel &reply); - int32_t OnClearCellularDataConnections(MessageParcel &data, MessageParcel &reply); - int32_t OnGetDataConnApnAttr(MessageParcel &data, MessageParcel &reply); - int32_t OnGetDataConnIpType(MessageParcel &data, MessageParcel &reply); - int32_t OnClearAllConnections(MessageParcel &data, MessageParcel &reply); - int32_t OnGetApnState(MessageParcel &data, MessageParcel &reply); - int32_t OnGetRecoveryState(MessageParcel &data, MessageParcel &reply); - int32_t OnIsNeedDoRecovery(MessageParcel &data, MessageParcel &reply); - int32_t OnEnableIntelligenceSwitch(MessageParcel &data, MessageParcel &reply); - int32_t OnInitCellularDataController(MessageParcel &data, MessageParcel &reply); - int32_t OnGetIntelligenceSwitchState(MessageParcel &data, MessageParcel &reply); - int32_t OnEstablishAllApnsIfConnectable(MessageParcel &data, MessageParcel &reply); - int32_t OnReleaseCellularDataConnection(MessageParcel &data, MessageParcel &reply); - int32_t OnGetCellularDataSupplierId(MessageParcel &data, MessageParcel &reply); - int32_t OnCorrectNetSupplierNoAvailable(MessageParcel &data, MessageParcel &reply); - int32_t OnGetSupplierRegisterState(MessageParcel &data, MessageParcel &reply); - int32_t SetTimer(uint32_t code); - void CancelTimer(int32_t id); - int32_t OnIsSupportDunApn(MessageParcel &data, MessageParcel &reply); - int32_t OnGetDefaultActReportInfo(MessageParcel &data, MessageParcel &reply); - int32_t OnGetInternalActReportInfo(MessageParcel &data, MessageParcel &reply); - int32_t OnQueryApnInfo(MessageParcel &data, MessageParcel &reply); - int32_t OnSetPreferApn(MessageParcel &data, MessageParcel &reply); - int32_t OnQueryAllApnInfo(MessageParcel &data, MessageParcel &reply); - int32_t OnSendUrspDecodeResult(MessageParcel &data, MessageParcel &reply); - int32_t OnSendUePolicySectionIdentifier(MessageParcel &data, MessageParcel &reply); - int32_t OnSendImsRsdList(MessageParcel &data, MessageParcel &reply); - int32_t OnGetNetworkSliceAllowedNssai(MessageParcel &data, MessageParcel &reply); - int32_t OnGetNetworkSliceEhplmn(MessageParcel &data, MessageParcel &reply); - -private: - using Fun = std::function; - std::map eventIdFunMap_ { - { (uint32_t)CellularDataInterfaceCode::IS_CELLULAR_DATA_ENABLED, - [this](MessageParcel &data, MessageParcel &reply) { return OnIsCellularDataEnabled(data, reply); } }, - { (uint32_t)CellularDataInterfaceCode::ENABLE_CELLULAR_DATA, - [this](MessageParcel &data, MessageParcel &reply) { return OnEnableCellularData(data, reply); } }, - { (uint32_t)CellularDataInterfaceCode::GET_CELLULAR_DATA_STATE, - [this](MessageParcel &data, MessageParcel &reply) { return OnGetCellularDataState(data, reply); } }, - { (uint32_t)CellularDataInterfaceCode::IS_DATA_ROAMING_ENABLED, - [this](MessageParcel &data, MessageParcel &reply) { return OnIsCellularDataRoamingEnabled(data, reply); } }, - { (uint32_t)CellularDataInterfaceCode::ENABLE_DATA_ROAMING, - [this](MessageParcel &data, MessageParcel &reply) { return OnEnableCellularDataRoaming(data, reply); } }, - { (uint32_t)CellularDataInterfaceCode::APN_DATA_CHANGED, - [this](MessageParcel &data, MessageParcel &reply) { return OnHandleApnChanged(data, reply); } }, - { (uint32_t)CellularDataInterfaceCode::GET_DEFAULT_SLOT_ID, - [this](MessageParcel &data, MessageParcel &reply) { return OnGetDefaultCellularDataSlotId(data, reply); } }, - { (uint32_t)CellularDataInterfaceCode::GET_DEFAULT_SIM_ID, - [this](MessageParcel &data, MessageParcel &reply) { return OnGetDefaultCellularDataSimId(data, reply); } }, - { (uint32_t)CellularDataInterfaceCode::SET_DEFAULT_SLOT_ID, - [this](MessageParcel &data, MessageParcel &reply) { return OnSetDefaultCellularDataSlotId(data, reply); } }, - { (uint32_t)CellularDataInterfaceCode::GET_FLOW_TYPE_ID, - [this](MessageParcel &data, MessageParcel &reply) { return OnGetCellularDataFlowType(data, reply); } }, - { (uint32_t)CellularDataInterfaceCode::HAS_CAPABILITY, - [this](MessageParcel &data, MessageParcel &reply) { return OnHasInternetCapability(data, reply); } }, - { (uint32_t)CellularDataInterfaceCode::CLEAR_ALL_CONNECTIONS, - [this](MessageParcel &data, MessageParcel &reply) { return OnClearCellularDataConnections(data, reply); } }, - { (uint32_t)CellularDataInterfaceCode::CLEAR_ALL_CONNECTIONS_USE_REASON, - [this](MessageParcel &data, MessageParcel &reply) { return OnClearAllConnections(data, reply); } }, - { (uint32_t)CellularDataInterfaceCode::REG_SIM_ACCOUNT_CALLBACK, - [this](MessageParcel &data, MessageParcel &reply) { return OnRegisterSimAccountCallback(data, reply); } }, - { (uint32_t)CellularDataInterfaceCode::UN_REG_SIM_ACCOUNT_CALLBACK, - [this](MessageParcel &data, MessageParcel &reply) { return OnUnregisterSimAccountCallback(data, reply); } }, - { (uint32_t)CellularDataInterfaceCode::GET_DATA_CONN_APN_ATTR, - [this](MessageParcel &data, MessageParcel &reply) { return OnGetDataConnApnAttr(data, reply); } }, - { (uint32_t)CellularDataInterfaceCode::GET_DATA_CONN_IP_TYPE, - [this](MessageParcel &data, MessageParcel &reply) { return OnGetDataConnIpType(data, reply); } }, - { (uint32_t)CellularDataInterfaceCode::GET_CELLULAR_DATA_APN_STATE, - [this](MessageParcel &data, MessageParcel &reply) { return OnGetApnState(data, reply); } }, - { (uint32_t)CellularDataInterfaceCode::GET_RECOVERY_STATE, - [this](MessageParcel &data, MessageParcel &reply) { return OnGetRecoveryState(data, reply); } }, - { (uint32_t)CellularDataInterfaceCode::IS_NEED_DO_RECOVERY, - [this](MessageParcel &data, MessageParcel &reply) { return OnIsNeedDoRecovery(data, reply); } }, - { (uint32_t)CellularDataInterfaceCode::ENABLE_INTELLIGENCE_SWITCH, - [this](MessageParcel &data, MessageParcel &reply) { return OnEnableIntelligenceSwitch(data, reply); } }, - { (uint32_t)CellularDataInterfaceCode::INIT_CELLULAR_DATA_CONTROLLER, - [this](MessageParcel &data, MessageParcel &reply) { return OnInitCellularDataController(data, reply); } }, - { (uint32_t)CellularDataInterfaceCode::GET_INTELLIGENCE_SWITCH_STATE, - [this](MessageParcel &data, MessageParcel &reply) { return OnGetIntelligenceSwitchState(data, reply); } }, - { (uint32_t)CellularDataInterfaceCode::ESTABLISH_ALL_APNS_IF_CONNECTABLE, - [this](MessageParcel &data, MessageParcel &reply) { - return OnEstablishAllApnsIfConnectable(data, reply); } }, - { (uint32_t)CellularDataInterfaceCode::RELEASE_CELLULAR_DATA_CONNECTION, - [this](MessageParcel &data, MessageParcel &reply) { return OnReleaseCellularDataConnection(data, reply); }}, - { (uint32_t)CellularDataInterfaceCode::GET_CELLULAR_DATA_SUPPLIERID, - [this](MessageParcel &data, MessageParcel &reply) { return OnGetCellularDataSupplierId(data, reply); } }, - { (uint32_t)CellularDataInterfaceCode::CORRECT_NET_SUPPLIER_NO_AVAILABLE, - [this](MessageParcel &data, MessageParcel &reply) { - return OnCorrectNetSupplierNoAvailable(data, reply); } }, - { (uint32_t)CellularDataInterfaceCode::GET_SUPPLIER_REGISTER_STATE, - [this](MessageParcel &data, MessageParcel &reply) { return OnGetSupplierRegisterState(data, reply); } }, - { (uint32_t)CellularDataInterfaceCode::GET_IF_SUPPORT_DUN_APN, - [this](MessageParcel &data, MessageParcel &reply) { return OnIsSupportDunApn(data, reply); } }, - { (uint32_t)CellularDataInterfaceCode::GET_DEFAULT_ACT_REPORT_INFO, - [this](MessageParcel &data, MessageParcel &reply) { return OnGetDefaultActReportInfo(data, reply); } }, - { (uint32_t)CellularDataInterfaceCode::GET_INTERNAL_ACT_REPORT_INFO, - [this](MessageParcel &data, MessageParcel &reply) { return OnGetInternalActReportInfo(data, reply); } }, - { (uint32_t)CellularDataInterfaceCode::QUERY_APN_INFO, - [this](MessageParcel &data, MessageParcel &reply) { return OnQueryApnInfo(data, reply); } }, - { (uint32_t)CellularDataInterfaceCode::SET_PREFER_APN, - [this](MessageParcel &data, MessageParcel &reply) { return OnSetPreferApn(data, reply); } }, - { (uint32_t)CellularDataInterfaceCode::QUERY_ALL_APN_INFO, - [this](MessageParcel &data, MessageParcel &reply) { return OnQueryAllApnInfo(data, reply); } }, - { (uint32_t)CellularDataInterfaceCode::SEND_MANAGE_UEPOLICY_DECODE_RESULT, - [this](MessageParcel &data, MessageParcel &reply) { return OnSendUrspDecodeResult(data, reply); } }, - { (uint32_t)CellularDataInterfaceCode::SEND_UE_STATE_INDICATION, - [this](MessageParcel &data, MessageParcel &reply) { return OnSendUePolicySectionIdentifier(data, reply); }}, - { (uint32_t)CellularDataInterfaceCode::SEND_IMS_RSDLIST, - [this](MessageParcel &data, MessageParcel &reply) { return OnSendImsRsdList(data, reply); } }, - { (uint32_t)CellularDataInterfaceCode::SYNC_ALLOWED_NSSAI_WITH_MODEM, - [this](MessageParcel &data, MessageParcel &reply) { return OnGetNetworkSliceAllowedNssai(data, reply); } }, - { (uint32_t)CellularDataInterfaceCode::SYNC_EHPLMN_WITH_MODEM, - [this](MessageParcel &data, MessageParcel &reply) { return OnGetNetworkSliceEhplmn(data, reply); } } - }; - std::map collieCodeStringMap_ = { - { uint32_t(CellularDataInterfaceCode::GET_CELLULAR_DATA_STATE), "GET_CELLULAR_DATA_STATE" }, - { uint32_t(CellularDataInterfaceCode::IS_CELLULAR_DATA_ENABLED), "IS_CELLULAR_DATA_ENABLED" }, - { uint32_t(CellularDataInterfaceCode::ENABLE_CELLULAR_DATA), "ENABLE_CELLULAR_DATA" }, - { uint32_t(CellularDataInterfaceCode::GET_DEFAULT_SLOT_ID), "GET_DEFAULT_SLOT_ID" }, - }; -}; -} // namespace Telephony -} // namespace OHOS -#endif // CELLULAR_DATA_SERVICE_STUB_H diff --git a/services/src/cellular_data_dump_helper.cpp b/services/src/cellular_data_dump_helper.cpp index 61210cc9..d8b9d39e 100644 --- a/services/src/cellular_data_dump_helper.cpp +++ b/services/src/cellular_data_dump_helper.cpp @@ -108,7 +108,9 @@ void CellularDataDumpHelper::ShowCellularDataInfo(std::string &result) const result.append(GetBoolValue(dataEnabled)); result.append("\n"); result.append("CellularDataState : "); - result.append(GetCellularDataConnectionState(dataService.GetCellularDataState())); + int32_t cellularDataState; + dataService.GetCellularDataState(cellularDataState); + result.append(GetCellularDataConnectionState(cellularDataState)); result.append("\n"); } } // namespace Telephony diff --git a/services/src/cellular_data_service.cpp b/services/src/cellular_data_service.cpp index c9bafdd7..bf3a6d86 100644 --- a/services/src/cellular_data_service.cpp +++ b/services/src/cellular_data_service.cpp @@ -106,7 +106,8 @@ int32_t CellularDataService::GetIntelligenceSwitchState(bool &switchState) return TELEPHONY_ERR_ILLEGAL_USE_OF_SYSTEM_API; } if (!TelephonyPermission::CheckPermission(Permission::GET_TELEPHONY_STATE)) { - int32_t slotId = CellularDataService::GetDefaultCellularDataSlotId(); + int32_t slotId; + CellularDataService::GetDefaultCellularDataSlotId(slotId); CellularDataHiSysEvent::WriteDataActivateFaultEvent( slotId, switchState, CellularDataErrorCode::DATA_ERROR_PERMISSION_ERROR, Permission::SET_TELEPHONY_STATE); return TELEPHONY_ERR_PERMISSION_ERR; @@ -168,7 +169,8 @@ int32_t CellularDataService::EnableCellularData(bool enable) return TELEPHONY_ERR_ILLEGAL_USE_OF_SYSTEM_API; } if (!TelephonyPermission::CheckPermission(Permission::SET_TELEPHONY_STATE)) { - int32_t slotId = CellularDataService::GetDefaultCellularDataSlotId(); + int32_t slotId; + CellularDataService::GetDefaultCellularDataSlotId(slotId); CellularDataHiSysEvent::WriteDataActivateFaultEvent( slotId, enable, CellularDataErrorCode::DATA_ERROR_PERMISSION_ERROR, Permission::SET_TELEPHONY_STATE); return TELEPHONY_ERR_PERMISSION_ERR; @@ -188,7 +190,8 @@ int32_t CellularDataService::EnableIntelligenceSwitch(bool enable) return TELEPHONY_ERR_ILLEGAL_USE_OF_SYSTEM_API; } if (!TelephonyPermission::CheckPermission(Permission::SET_TELEPHONY_STATE)) { - int32_t slotId = CellularDataService::GetDefaultCellularDataSlotId(); + int32_t slotId; + CellularDataService::GetDefaultCellularDataSlotId(slotId); CellularDataHiSysEvent::WriteDataActivateFaultEvent( slotId, enable, CellularDataErrorCode::DATA_ERROR_PERMISSION_ERROR, Permission::SET_TELEPHONY_STATE); return TELEPHONY_ERR_PERMISSION_ERR; @@ -201,9 +204,10 @@ int32_t CellularDataService::EnableIntelligenceSwitch(bool enable) return cellularDataController->SetIntelligenceSwitchEnable(enable); } -int32_t CellularDataService::GetCellularDataState() +int32_t CellularDataService::GetCellularDataState(int32_t &state) { - int32_t slotId = CellularDataService::GetDefaultCellularDataSlotId(); + int32_t slotId; + CellularDataService::GetDefaultCellularDataSlotId(slotId); #ifdef OHOS_BUILD_ENABLE_TELEPHONY_EXT if (TELEPHONY_EXT_WRAPPER.isVSimEnabled_ && TELEPHONY_EXT_WRAPPER.isVSimEnabled_()) { TELEPHONY_LOGI("VSimEnabled slotId: %{public}d => %{public}d", slotId, CELLULAR_DATA_VSIM_SLOT_ID); @@ -221,23 +225,23 @@ int32_t CellularDataService::GetCellularDataState() if (reason == DisConnectionReason::REASON_GSM_AND_CALLING_ONLY && cellularDataController->IsRestrictedMode()) { dataState = static_cast(DataConnectionStatus::DATA_STATE_SUSPENDED); } - return dataState; + state = dataState; + return TELEPHONY_ERR_SUCCESS; } -int32_t CellularDataService::GetApnState(int32_t slotId, const std::string &apnType) +int32_t CellularDataService::GetApnState(int32_t slotId, const std::string &apnType, int &state) { std::shared_ptr cellularDataController = GetCellularDataController(slotId); if (cellularDataController == nullptr) { TELEPHONY_LOGE("cellularDataControllers is null, slotId=%{public}d", slotId); return CELLULAR_DATA_INVALID_PARAM; } - int32_t apnState = static_cast(cellularDataController->GetCellularDataState(apnType)); - return apnState; + state = static_cast(cellularDataController->GetCellularDataState(apnType)); + return TELEPHONY_ERR_SUCCESS; } -int32_t CellularDataService::GetDataRecoveryState() +int32_t CellularDataService::GetDataRecoveryState(int32_t &state) { - int32_t state = 0; std::lock_guard guard(mapLock_); for (const auto &controller : cellularDataControllers_) { auto cellularDataController = controller.second; @@ -247,7 +251,7 @@ int32_t CellularDataService::GetDataRecoveryState() int32_t curState = cellularDataController->GetDataRecoveryState(); state = (curState > state) ? curState : state; } - return state; + return TELEPHONY_ERR_SUCCESS; } int32_t CellularDataService::IsCellularDataRoamingEnabled(const int32_t slotId, bool &dataRoamingEnabled) @@ -483,9 +487,10 @@ int32_t CellularDataService::HandleApnChanged(const int32_t slotId) : static_cast(DataRespondCode::SET_FAILED); } -int32_t CellularDataService::GetDefaultCellularDataSlotId() +int32_t CellularDataService::GetDefaultCellularDataSlotId(int32_t &slotId) { - return CoreManagerInner::GetInstance().GetDefaultCellularDataSlotId(); + slotId = CoreManagerInner::GetInstance().GetDefaultCellularDataSlotId(); + return TELEPHONY_ERR_SUCCESS; } int32_t CellularDataService::GetDefaultCellularDataSimId(int32_t &simId) @@ -512,7 +517,8 @@ int32_t CellularDataService::SetDefaultCellularDataSlotId(const int32_t slotId) TELEPHONY_LOGE("sim is not active!"); return TELEPHONY_ERR_SLOTID_INVALID; } - int32_t formerSlotId = GetDefaultCellularDataSlotId(); + int32_t formerSlotId; + GetDefaultCellularDataSlotId(formerSlotId); if (formerSlotId < 0) { TELEPHONY_LOGI("No old card slot id."); } @@ -524,9 +530,10 @@ int32_t CellularDataService::SetDefaultCellularDataSlotId(const int32_t slotId) return TELEPHONY_ERR_SUCCESS; } -int32_t CellularDataService::GetCellularDataFlowType() +int32_t CellularDataService::GetCellularDataFlowType(int32_t &type) { - int32_t slotId = CellularDataService::GetDefaultCellularDataSlotId(); + int32_t slotId; + CellularDataService::GetDefaultCellularDataSlotId(slotId); std::shared_ptr cellularDataController = GetCellularDataController(slotId); if (cellularDataController == nullptr) { TELEPHONY_LOGE("cellularDataControllers is null, slotId=%{public}d", slotId); @@ -559,14 +566,17 @@ std::string CellularDataService::GetEndTime() std::string CellularDataService::GetCellularDataSlotIdDump() { std::ostringstream oss; - oss << "slotId:" << GetDefaultCellularDataSlotId(); + int32_t slotId; + GetDefaultCellularDataSlotId(slotId); + oss << "slotId:" << slotId; return oss.str(); } std::string CellularDataService::GetStateMachineCurrentStatusDump() { std::ostringstream oss; - int32_t slotId = GetDefaultCellularDataSlotId(); + int32_t slotId; + GetDefaultCellularDataSlotId(slotId); std::shared_ptr cellularDataController = GetCellularDataController(slotId); if (cellularDataController == nullptr) { oss << "default slotId: " << slotId; @@ -582,7 +592,8 @@ std::string CellularDataService::GetStateMachineCurrentStatusDump() std::string CellularDataService::GetFlowDataInfoDump() { std::ostringstream oss; - int32_t slotId = GetDefaultCellularDataSlotId(); + int32_t slotId; + GetDefaultCellularDataSlotId(slotId); std::shared_ptr cellularDataController = GetCellularDataController(slotId); if (cellularDataController == nullptr) { oss << "default slotId: " << slotId; @@ -607,7 +618,7 @@ int32_t CellularDataService::StrategySwitch(int32_t slotId, bool enable) return result; } -int32_t CellularDataService::HasInternetCapability(const int32_t slotId, const int32_t cid) +int32_t CellularDataService::HasInternetCapability(const int32_t slotId, const int32_t cid, int32_t &capability) { std::shared_ptr cellularDataController = GetCellularDataController(slotId); if (cellularDataController == nullptr) { @@ -615,8 +626,9 @@ int32_t CellularDataService::HasInternetCapability(const int32_t slotId, const i return CELLULAR_DATA_INVALID_PARAM; } bool result = cellularDataController->HasInternetCapability(cid); - return result ? static_cast(RequestNetCode::REQUEST_SUCCESS) - : static_cast(RequestNetCode::REQUEST_FAILED); + capability = result ? static_cast(RequestNetCode::REQUEST_SUCCESS) + : static_cast(RequestNetCode::REQUEST_FAILED); + return TELEPHONY_ERR_SUCCESS; } int32_t CellularDataService::ClearCellularDataConnections(const int32_t slotId) @@ -625,10 +637,10 @@ int32_t CellularDataService::ClearCellularDataConnections(const int32_t slotId) TELEPHONY_LOGE("Permission denied!"); return TELEPHONY_ERR_PERMISSION_ERR; } - return ClearAllConnections(slotId, DisConnectionReason::REASON_CLEAR_CONNECTION); + return ClearAllConnections(slotId, (int32_t) DisConnectionReason::REASON_CLEAR_CONNECTION); } -int32_t CellularDataService::ClearAllConnections(const int32_t slotId, DisConnectionReason reason) +int32_t CellularDataService::ClearAllConnections(const int32_t slotId, const int32_t reason) { if (!TelephonyPermission::CheckPermission(Permission::SET_TELEPHONY_STATE)) { TELEPHONY_LOGE("Permission denied!"); @@ -639,7 +651,7 @@ int32_t CellularDataService::ClearAllConnections(const int32_t slotId, DisConnec TELEPHONY_LOGE("cellularDataControllers is null, slotId=%{public}d", slotId); return CELLULAR_DATA_INVALID_PARAM; } - bool result = cellularDataController->ClearAllConnections(reason); + bool result = cellularDataController->ClearAllConnections((DisConnectionReason) reason); return result ? static_cast(RequestNetCode::REQUEST_SUCCESS) : static_cast(RequestNetCode::REQUEST_FAILED); } @@ -676,7 +688,7 @@ int32_t CellularDataService::UnregisterSimAccountCallback(const sptrGetDataConnApnAttr(apnAttr); + ApnItem::Attribute apn; + cellularDataController->GetDataConnApnAttr(apn); + ApnAttribute::TransferApnAttributeBeforeIpc(apn, apnAttr); return TELEPHONY_ERR_SUCCESS; } @@ -836,7 +850,8 @@ int32_t CellularDataService::GetIfSupportDunApn(bool &isSupportDun) TELEPHONY_LOGE("Permission denied!"); return TELEPHONY_ERR_PERMISSION_ERR; } - int32_t slotId = CellularDataService::GetDefaultCellularDataSlotId(); + int32_t slotId; + CellularDataService::GetDefaultCellularDataSlotId(slotId); auto cellularDataController = GetCellularDataController(slotId); if (cellularDataController == nullptr) { TELEPHONY_LOGE("cellularDataControllers is null, slotId=%{public}d", slotId); @@ -846,8 +861,9 @@ int32_t CellularDataService::GetIfSupportDunApn(bool &isSupportDun) return TELEPHONY_ERR_SUCCESS; } -int32_t CellularDataService::GetDefaultActReportInfo(int32_t slotId, ApnActivateReportInfo &info) +int32_t CellularDataService::GetDefaultActReportInfo(int32_t slotId, ApnActivateReportInfoIpc &infoIpc) { + ApnActivateReportInfo info; if (!TelephonyPermission::CheckPermission(Permission::GET_TELEPHONY_STATE)) { TELEPHONY_LOGE("Permission denied!"); return TELEPHONY_ERR_PERMISSION_ERR; @@ -858,11 +874,13 @@ int32_t CellularDataService::GetDefaultActReportInfo(int32_t slotId, ApnActivate return CELLULAR_DATA_INVALID_PARAM; } bool result = cellularDataController->GetDefaultActReportInfo(info); + infoIpc = info; return result ? TELEPHONY_ERR_SUCCESS : TELEPHONY_ERR_FAIL; } -int32_t CellularDataService::GetInternalActReportInfo(int32_t slotId, ApnActivateReportInfo &info) +int32_t CellularDataService::GetInternalActReportInfo(int32_t slotId, ApnActivateReportInfoIpc &infoIpc) { + ApnActivateReportInfo info; if (!TelephonyPermission::CheckPermission(Permission::GET_TELEPHONY_STATE)) { TELEPHONY_LOGE("Permission denied!"); return TELEPHONY_ERR_PERMISSION_ERR; diff --git a/services/src/cellular_data_service_stub.cpp b/services/src/cellular_data_service_stub.cpp deleted file mode 100644 index 5bddccf7..00000000 --- a/services/src/cellular_data_service_stub.cpp +++ /dev/null @@ -1,679 +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. - */ - -#include "cellular_data_service_stub.h" - -#include - -#include "cellular_data_controller.h" -#include "cellular_data_service.h" -#include "ipc_skeleton.h" -#include "sim_account_callback_proxy.h" -#include "telephony_errors.h" -#include "telephony_log_wrapper.h" - -#ifdef HICOLLIE_ENABLE -#include "xcollie/xcollie.h" -#include "xcollie/xcollie_define.h" -#define XCOLLIE_TIMEOUT_SECONDS 30 -#endif - -namespace OHOS { -namespace Telephony { -constexpr int32_t BUFFER_MAX = 65538; -CellularDataServiceStub::CellularDataServiceStub() = default; - -CellularDataServiceStub::~CellularDataServiceStub() = default; - -int32_t CellularDataServiceStub::OnRemoteRequest( - uint32_t code, MessageParcel &data, MessageParcel &reply, MessageOption &option) -{ - std::u16string myDescriptor = CellularDataServiceStub::GetDescriptor(); - std::u16string remoteDescriptor = data.ReadInterfaceToken(); - // NetManager has no transport description - if (myDescriptor != remoteDescriptor) { - TELEPHONY_LOGE("descriptor check fail!"); - return TELEPHONY_ERR_DESCRIPTOR_MISMATCH; - } - std::map::iterator it = eventIdFunMap_.find(code); - if (it != eventIdFunMap_.end()) { - if (it->second != nullptr) { - int32_t idTimer = SetTimer(code); - int32_t result = it->second(data, reply); - CancelTimer(idTimer); - return result; - } - } else { - TELEPHONY_LOGE("event code is not exist"); - } - return IPCObjectStub::OnRemoteRequest(code, data, reply, option); -} - -int32_t CellularDataServiceStub::SetTimer(uint32_t code) -{ -#ifdef HICOLLIE_ENABLE - int32_t idTimer = HiviewDFX::INVALID_ID; - std::map::iterator itCollieId = collieCodeStringMap_.find(code); - if (itCollieId != collieCodeStringMap_.end()) { - std::string collieStr = itCollieId->second; - std::string collieName = "CellularDataServiceStub: " + collieStr; - unsigned int flag = HiviewDFX::XCOLLIE_FLAG_NOOP; - auto TimerCallback = [collieStr](void *) { - TELEPHONY_LOGE("OnRemoteRequest timeout func: %{public}s", collieStr.c_str()); - }; - idTimer = HiviewDFX::XCollie::GetInstance().SetTimer( - collieName, XCOLLIE_TIMEOUT_SECONDS, TimerCallback, nullptr, flag); - TELEPHONY_LOGD("SetTimer id: %{public}d, name: %{public}s.", idTimer, collieStr.c_str()); - } - return idTimer; -#else - TELEPHONY_LOGD("No HICOLLIE_ENABLE"); - return -1; -#endif -} - -void CellularDataServiceStub::CancelTimer(int32_t id) -{ -#ifdef HICOLLIE_ENABLE - if (id == HiviewDFX::INVALID_ID) { - return; - } - TELEPHONY_LOGD("CancelTimer id: %{public}d.", id); - HiviewDFX::XCollie::GetInstance().CancelTimer(id); -#else - return; -#endif -} - -int32_t CellularDataServiceStub::OnIsCellularDataEnabled(MessageParcel &data, MessageParcel &reply) -{ - bool dataEnabled = false; - int32_t result = IsCellularDataEnabled(dataEnabled); - if (!reply.WriteInt32(result)) { - TELEPHONY_LOGE("write int32 reply failed."); - return TELEPHONY_ERR_WRITE_REPLY_FAIL; - } - if (result != TELEPHONY_ERR_SUCCESS) { - return result; - } - if (!reply.WriteBool(dataEnabled)) { - TELEPHONY_LOGE("write bool reply failed."); - return TELEPHONY_ERR_WRITE_REPLY_FAIL; - } - return TELEPHONY_SUCCESS; -} - -int32_t CellularDataServiceStub::OnEnableCellularData(MessageParcel &data, MessageParcel &reply) -{ - bool enable = data.ReadBool(); - int32_t result = EnableCellularData(enable); - if (!reply.WriteInt32(result)) { - TELEPHONY_LOGE("fail to write parcel"); - return TELEPHONY_ERR_WRITE_REPLY_FAIL; - } - return result; -} - -int32_t CellularDataServiceStub::OnEnableIntelligenceSwitch(MessageParcel &data, MessageParcel &reply) -{ - bool enable = data.ReadBool(); - int32_t result = EnableIntelligenceSwitch(enable); - if (!reply.WriteInt32(result)) { - TELEPHONY_LOGE("fail to write parcel"); - return TELEPHONY_ERR_WRITE_REPLY_FAIL; - } - return result; -} - -int32_t CellularDataServiceStub::OnGetCellularDataState(MessageParcel &data, MessageParcel &reply) -{ - int32_t result = GetCellularDataState(); - if (!reply.WriteInt32(result)) { - TELEPHONY_LOGE("fail to write parcel"); - return TELEPHONY_ERR_WRITE_REPLY_FAIL; - } - return result; -} - -int32_t CellularDataServiceStub::OnIsCellularDataRoamingEnabled(MessageParcel &data, MessageParcel &reply) -{ - int32_t slotId = data.ReadInt32(); - bool dataRoamingEnabled = false; - int32_t result = IsCellularDataRoamingEnabled(slotId, dataRoamingEnabled); - if (!reply.WriteInt32(result)) { - TELEPHONY_LOGE("write int32 reply failed."); - return TELEPHONY_ERR_WRITE_REPLY_FAIL; - } - if (result != TELEPHONY_ERR_SUCCESS) { - return result; - } - if (!reply.WriteBool(dataRoamingEnabled)) { - TELEPHONY_LOGE("write bool reply failed."); - return TELEPHONY_ERR_WRITE_REPLY_FAIL; - } - - return TELEPHONY_SUCCESS; -} - -int32_t CellularDataServiceStub::OnEnableCellularDataRoaming(MessageParcel &data, MessageParcel &reply) -{ - int32_t slotId = data.ReadInt32(); - bool enable = data.ReadBool(); - int32_t result = EnableCellularDataRoaming(slotId, enable); - if (!reply.WriteInt32(result)) { - TELEPHONY_LOGE("fail to write parcel"); - return TELEPHONY_ERR_WRITE_REPLY_FAIL; - } - return result; -} - -int32_t CellularDataServiceStub::OnGetIntelligenceSwitchState(MessageParcel &data, MessageParcel &reply) -{ - bool switchState = false; - int32_t result = GetIntelligenceSwitchState(switchState); - if (!reply.WriteInt32(result)) { - TELEPHONY_LOGE("write int32 reply failed."); - return TELEPHONY_ERR_WRITE_REPLY_FAIL; - } - if (result != TELEPHONY_ERR_SUCCESS) { - return result; - } - if (!reply.WriteBool(switchState)) { - TELEPHONY_LOGE("write bool reply failed."); - return TELEPHONY_ERR_WRITE_REPLY_FAIL; - } - return TELEPHONY_SUCCESS; -} - -int32_t CellularDataServiceStub::OnHandleApnChanged(MessageParcel &data, MessageParcel &reply) -{ - int32_t slotId = data.ReadInt32(); - int32_t result = HandleApnChanged(slotId); - if (!reply.WriteInt32(result)) { - TELEPHONY_LOGE("fail to write parcel"); - return TELEPHONY_ERR_WRITE_REPLY_FAIL; - } - return result; -} - -int32_t CellularDataServiceStub::OnGetDefaultCellularDataSlotId(MessageParcel &data, MessageParcel &reply) -{ - int32_t result = GetDefaultCellularDataSlotId(); - if (!reply.WriteInt32(result)) { - TELEPHONY_LOGE("fail to write parcel"); - return TELEPHONY_ERR_WRITE_REPLY_FAIL; - } - return result; -} - -int32_t CellularDataServiceStub::OnGetDefaultCellularDataSimId(MessageParcel &data, MessageParcel &reply) -{ - int32_t simId = 0; - int32_t result = GetDefaultCellularDataSimId(simId); - if (!reply.WriteInt32(result)) { - TELEPHONY_LOGE("write int32 reply failed."); - return TELEPHONY_ERR_WRITE_REPLY_FAIL; - } - if (result != TELEPHONY_ERR_SUCCESS) { - return result; - } - if (!reply.WriteInt32(simId)) { - TELEPHONY_LOGE("write int32 reply failed."); - return TELEPHONY_ERR_WRITE_REPLY_FAIL; - } - return TELEPHONY_SUCCESS; -} - -int32_t CellularDataServiceStub::OnSetDefaultCellularDataSlotId(MessageParcel &data, MessageParcel &reply) -{ - int32_t slotId = data.ReadInt32(); - int32_t result = SetDefaultCellularDataSlotId(slotId); - if (!reply.WriteInt32(result)) { - TELEPHONY_LOGE("fail to write parcel"); - return TELEPHONY_ERR_WRITE_REPLY_FAIL; - } - return result; -} - -int32_t CellularDataServiceStub::OnGetCellularDataFlowType(MessageParcel &data, MessageParcel &reply) -{ - int32_t result = GetCellularDataFlowType(); - if (!reply.WriteInt32(result)) { - TELEPHONY_LOGE("fail to write parcel"); - return TELEPHONY_ERR_WRITE_REPLY_FAIL; - } - return result; -} - -int32_t CellularDataServiceStub::OnHasInternetCapability(MessageParcel &data, MessageParcel &reply) -{ - int32_t slotId = data.ReadInt32(); - int32_t cid = data.ReadInt32(); - int32_t result = HasInternetCapability(slotId, cid); - if (!reply.WriteInt32(result)) { - TELEPHONY_LOGE("fail to write parcel"); - return TELEPHONY_ERR_WRITE_REPLY_FAIL; - } - return result; -} - -int32_t CellularDataServiceStub::OnClearCellularDataConnections(MessageParcel &data, MessageParcel &reply) -{ - int32_t slotId = data.ReadInt32(); - int32_t result = ClearCellularDataConnections(slotId); - if (!reply.WriteInt32(result)) { - TELEPHONY_LOGE("fail to write parcel"); - return TELEPHONY_ERR_WRITE_REPLY_FAIL; - } - return result; -} - -int32_t CellularDataServiceStub::OnClearAllConnections(MessageParcel &data, MessageParcel &reply) -{ - int32_t slotId = data.ReadInt32(); - DisConnectionReason reason = static_cast(data.ReadInt32()); - int32_t result = ClearAllConnections(slotId, reason); - if (!reply.WriteInt32(result)) { - TELEPHONY_LOGE("fail to write parcel"); - return TELEPHONY_ERR_WRITE_REPLY_FAIL; - } - return result; -} - -int32_t CellularDataServiceStub::OnRegisterSimAccountCallback(MessageParcel &data, MessageParcel &reply) -{ - sptr callback = iface_cast(data.ReadRemoteObject()); - int32_t result; - if (callback == nullptr) { - TELEPHONY_LOGE("callback is nullptr!"); - result = TELEPHONY_ERR_ARGUMENT_NULL; - } else { - result = RegisterSimAccountCallback(callback); - } - reply.WriteInt32(result); - return result; -} - -int32_t CellularDataServiceStub::OnUnregisterSimAccountCallback(MessageParcel &data, MessageParcel &reply) -{ - sptr callback = iface_cast(data.ReadRemoteObject()); - int32_t result; - if (callback == nullptr) { - TELEPHONY_LOGE("callback is nullptr!"); - result = TELEPHONY_ERR_ARGUMENT_NULL; - } else { - result = UnregisterSimAccountCallback(callback); - } - reply.WriteInt32(result); - return result; -} - -int32_t CellularDataServiceStub::OnGetDataConnApnAttr(MessageParcel &data, MessageParcel &reply) -{ - int32_t slotId = data.ReadInt32(); - ApnItem::Attribute apnAttr; - int32_t result = GetDataConnApnAttr(slotId, apnAttr); - if (!reply.WriteInt32(result)) { - TELEPHONY_LOGE("write int32 reply failed."); - return TELEPHONY_ERR_WRITE_REPLY_FAIL; - } - if (!reply.WriteRawData(&apnAttr, sizeof(ApnItem::Attribute))) { - TELEPHONY_LOGE("write apnAttr reply failed."); - return TELEPHONY_ERR_WRITE_REPLY_FAIL; - } - return TELEPHONY_SUCCESS; -} - -int32_t CellularDataServiceStub::OnGetDataConnIpType(MessageParcel &data, MessageParcel &reply) -{ - int32_t slotId = data.ReadInt32(); - std::string ipType; - int32_t result = GetDataConnIpType(slotId, ipType); - if (!reply.WriteInt32(result)) { - TELEPHONY_LOGE("write int32 reply failed."); - return TELEPHONY_ERR_WRITE_REPLY_FAIL; - } - if (!reply.WriteString(ipType)) { - TELEPHONY_LOGE("write int32 reply failed."); - return TELEPHONY_ERR_WRITE_REPLY_FAIL; - } - return TELEPHONY_SUCCESS; -} - -int32_t CellularDataServiceStub::OnGetApnState(MessageParcel &data, MessageParcel &reply) -{ - int32_t slotId = data.ReadInt32(); - std::string apnType = data.ReadString(); - int32_t result = GetApnState(slotId, apnType); - if (!reply.WriteInt32(result)) { - TELEPHONY_LOGE("fail to write parcel"); - return TELEPHONY_ERR_WRITE_REPLY_FAIL; - } - return result; -} - -int32_t CellularDataServiceStub::OnGetRecoveryState(MessageParcel &data, MessageParcel &reply) -{ - int32_t result = GetDataRecoveryState(); - if (!reply.WriteInt32(result)) { - TELEPHONY_LOGE("fail to write parcel"); - return TELEPHONY_ERR_WRITE_REPLY_FAIL; - } - return result; -} - -int32_t CellularDataServiceStub::OnIsNeedDoRecovery(MessageParcel &data, MessageParcel &reply) -{ - int32_t slotId = data.ReadInt32(); - int32_t needDoRecovery = data.ReadBool(); - int32_t result = IsNeedDoRecovery(slotId, needDoRecovery); - if (!reply.WriteInt32(result)) { - TELEPHONY_LOGE("write int32 reply failed."); - return TELEPHONY_ERR_WRITE_REPLY_FAIL; - } - return result; -} - -int32_t CellularDataServiceStub::OnInitCellularDataController(MessageParcel &data, MessageParcel &reply) -{ - int32_t slotId = data.ReadInt32(); - int32_t result = InitCellularDataController(slotId); - if (!reply.WriteInt32(result)) { - TELEPHONY_LOGE("write int32 reply failed."); - return TELEPHONY_ERR_WRITE_REPLY_FAIL; - } - return result; -} - -int32_t CellularDataServiceStub::OnEstablishAllApnsIfConnectable(MessageParcel &data, MessageParcel &reply) -{ - int32_t slotId = data.ReadInt32(); - int32_t result = EstablishAllApnsIfConnectable(slotId); - if (!reply.WriteInt32(result)) { - TELEPHONY_LOGE("fail to write parcel"); - return TELEPHONY_ERR_WRITE_REPLY_FAIL; - } - return result; -} - -int32_t CellularDataServiceStub::OnReleaseCellularDataConnection(MessageParcel &data, MessageParcel &reply) -{ - int32_t slotId; - if (!data.ReadInt32(slotId)) { - TELEPHONY_LOGE("write int32 slotId failed."); - return TELEPHONY_ERR_READ_DATA_FAIL; - } - int32_t result = ReleaseCellularDataConnection(slotId); - if (!reply.WriteInt32(result)) { - TELEPHONY_LOGE("write int32 reply failed."); - return TELEPHONY_ERR_WRITE_REPLY_FAIL; - } - return result; -} - -int32_t CellularDataServiceStub::OnGetCellularDataSupplierId(MessageParcel &data, MessageParcel &reply) -{ - int32_t slotId = data.ReadInt32(); - uint64_t capability = data.ReadUint64(); - uint32_t supplierId = 0; - int32_t result = GetCellularDataSupplierId(slotId, capability, supplierId); - if (!reply.WriteInt32(result)) { - TELEPHONY_LOGE("write int32 reply failed."); - return TELEPHONY_ERR_WRITE_REPLY_FAIL; - } - if (!reply.WriteUint32(supplierId)) { - TELEPHONY_LOGE("write uint32 reply failed."); - return TELEPHONY_ERR_WRITE_REPLY_FAIL; - } - return result; -} - -int32_t CellularDataServiceStub::OnCorrectNetSupplierNoAvailable(MessageParcel &data, MessageParcel &reply) -{ - int32_t slotId = data.ReadInt32(); - int32_t result = CorrectNetSupplierNoAvailable(slotId); - if (!reply.WriteInt32(result)) { - TELEPHONY_LOGE("write int32 reply failed."); - return TELEPHONY_ERR_WRITE_REPLY_FAIL; - } - return result; -} - -int32_t CellularDataServiceStub::OnGetSupplierRegisterState(MessageParcel &data, MessageParcel &reply) -{ - uint32_t supplierId = data.ReadUint32(); - int32_t regState = -1; - int32_t result = GetSupplierRegisterState(supplierId, regState); - if (!reply.WriteInt32(result)) { - TELEPHONY_LOGE("write int32 reply failed."); - return TELEPHONY_ERR_WRITE_REPLY_FAIL; - } - if (!reply.WriteInt32(regState)) { - TELEPHONY_LOGE("write int32 reply failed."); - return TELEPHONY_ERR_WRITE_REPLY_FAIL; - } - return result; -} - -int32_t CellularDataServiceStub::OnIsSupportDunApn(MessageParcel &data, MessageParcel &reply) -{ - bool isSupportDun = false; - int32_t result = GetIfSupportDunApn(isSupportDun); - if (!reply.WriteInt32(result)) { - TELEPHONY_LOGE("fail to write parcel"); - return TELEPHONY_ERR_WRITE_REPLY_FAIL; - } - if (!reply.WriteBool(isSupportDun)) { - TELEPHONY_LOGE("fail to write parcel"); - return TELEPHONY_ERR_WRITE_REPLY_FAIL; - } - return result; -} - -int32_t CellularDataServiceStub::OnGetDefaultActReportInfo(MessageParcel &data, MessageParcel &reply) -{ - int32_t slotId = data.ReadInt32(); - ApnActivateReportInfo info; - int32_t result = GetDefaultActReportInfo(slotId, info); - if (!reply.WriteInt32(result)) { - TELEPHONY_LOGE("OnGetDefaultActReportInfo write int32 reply failed."); - return TELEPHONY_ERR_WRITE_REPLY_FAIL; - } - reply.WriteInt32(info.actTimes); - reply.WriteInt32(info.averDuration); - reply.WriteInt32(info.topReason); - reply.WriteInt32(info.actSuccTimes); - return result; -} - -int32_t CellularDataServiceStub::OnGetInternalActReportInfo(MessageParcel &data, MessageParcel &reply) -{ - int32_t slotId = data.ReadInt32(); - ApnActivateReportInfo info; - int32_t result = GetInternalActReportInfo(slotId, info); - if (!reply.WriteInt32(result)) { - TELEPHONY_LOGE("OnGetInternalActReportInfo write int32 reply failed."); - return TELEPHONY_ERR_WRITE_REPLY_FAIL; - } - reply.WriteInt32(info.actTimes); - reply.WriteInt32(info.averDuration); - reply.WriteInt32(info.topReason); - reply.WriteInt32(info.actSuccTimes); - return result; -} - -int32_t CellularDataServiceStub::OnQueryApnInfo(MessageParcel &data, MessageParcel &reply) -{ - ApnInfo info; - info.apnName = data.ReadString16(); - info.apn = data.ReadString16(); - info.mcc = data.ReadString16(); - info.mnc = data.ReadString16(); - info.user = data.ReadString16(); - info.type = data.ReadString16(); - info.proxy = data.ReadString16(); - info.mmsproxy = data.ReadString16(); - std::vector apnIdList; - int32_t result = QueryApnIds(info, apnIdList); - int32_t size = static_cast(apnIdList.size()); - bool ret = reply.WriteInt32(result); - ret = (ret && reply.WriteInt32(size)); - if (!ret) { - TELEPHONY_LOGE("OnQueryApnInfo write reply failed."); - return TELEPHONY_ERR_WRITE_REPLY_FAIL; - } - std::vector::iterator it = apnIdList.begin(); - while (it != apnIdList.end()) { - TELEPHONY_LOGI("OnQueryApnInfo slotIndex = %{public}d", (*it)); - if (!reply.WriteInt32(*it)) { - TELEPHONY_LOGE("OnQueryApnInfo IccAccountInfo reply Marshalling is false"); - return TELEPHONY_ERR_WRITE_REPLY_FAIL; - } - ++it; - } - return 0; -} - -int32_t CellularDataServiceStub::OnSetPreferApn(MessageParcel &data, MessageParcel &reply) -{ - int32_t apnId = data.ReadInt32(); - int32_t result = SetPreferApn(apnId); - if (!reply.WriteInt32(result)) { - TELEPHONY_LOGE("fail to write parcel"); - return TELEPHONY_ERR_WRITE_REPLY_FAIL; - } - return result; -} - -int32_t CellularDataServiceStub::OnQueryAllApnInfo(MessageParcel &data, MessageParcel &reply) -{ - std::vector allApnInfoList; - int32_t result = QueryAllApnInfo(allApnInfoList); - int32_t size = static_cast(allApnInfoList.size()); - bool ret = reply.WriteInt32(result); - ret = (ret && reply.WriteInt32(size)); - if (!ret) { - TELEPHONY_LOGE("OnQueryAllApnInfo write reply failed."); - return TELEPHONY_ERR_WRITE_REPLY_FAIL; - } - std::vector::iterator it = allApnInfoList.begin(); - while (it != allApnInfoList.end()) { - TELEPHONY_LOGI("OnQueryAllApnInfo apn = %{public}s", Str16ToStr8((*it).apn).c_str()); - if (!(*it).Marshalling(reply)) { - TELEPHONY_LOGE("OnQueryAllApnInfo ApnInfo reply Marshalling is false"); - return TELEPHONY_ERR_WRITE_REPLY_FAIL; - } - ++it; - } - return 0; -} - -int32_t CellularDataServiceStub::OnSendUrspDecodeResult(MessageParcel &data, MessageParcel &reply) -{ - int32_t slotId = data.ReadInt32(); - int32_t buffer_len = data.ReadInt32(); - if (buffer_len <= 0 || buffer_len > BUFFER_MAX) { - TELEPHONY_LOGE("buffer length is invalid: %{public}d", buffer_len); - return TELEPHONY_ERR_ARGUMENT_INVALID; - } - std::vector buffer; - for (int i = 0; i < buffer_len; ++i) { - buffer.push_back(data.ReadUint8()); - } - int32_t result = SendUrspDecodeResult(slotId, buffer); - if (result != TELEPHONY_ERR_SUCCESS) { - return result; - } - return TELEPHONY_SUCCESS; -} - -int32_t CellularDataServiceStub::OnSendUePolicySectionIdentifier(MessageParcel &data, MessageParcel &reply) -{ - int32_t slotId = data.ReadInt32(); - int32_t buffer_len = data.ReadInt32(); - if (buffer_len <= 0 || buffer_len > BUFFER_MAX) { - TELEPHONY_LOGE("buffer length is invalid: %{public}d", buffer_len); - return TELEPHONY_ERR_ARGUMENT_INVALID; - } - std::vector buffer; - for (int i = 0; i < buffer_len; ++i) { - buffer.push_back(data.ReadUint8()); - } - int32_t result = SendUePolicySectionIdentifier(slotId, buffer); - if (result != TELEPHONY_ERR_SUCCESS) { - return result; - } - return TELEPHONY_SUCCESS; -} - -int32_t CellularDataServiceStub::OnSendImsRsdList(MessageParcel &data, MessageParcel &reply) -{ - int32_t slotId = data.ReadInt32(); - int32_t buffer_len = data.ReadInt32(); - if (buffer_len <= 0 || buffer_len > BUFFER_MAX) { - TELEPHONY_LOGE("buffer length is invalid: %{public}d", buffer_len); - return TELEPHONY_ERR_ARGUMENT_INVALID; - } - std::vector buffer; - for (int i = 0; i < buffer_len; ++i) { - uint8_t temp; - if (!data.ReadUint8(temp)) { - TELEPHONY_LOGE("write Uint8 buffer failed."); - return TELEPHONY_ERR_READ_DATA_FAIL; - } - buffer.push_back(data.ReadUint8()); - } - int32_t result = SendImsRsdList(slotId, buffer); - if (result != TELEPHONY_ERR_SUCCESS) { - return result; - } - return TELEPHONY_SUCCESS; -} - -int32_t CellularDataServiceStub::OnGetNetworkSliceAllowedNssai(MessageParcel &data, MessageParcel &reply) -{ - int32_t slotId = data.ReadInt32(); - int32_t buffer_len = data.ReadInt32(); - if (buffer_len <= 0 || buffer_len > BUFFER_MAX) { - TELEPHONY_LOGE("buffer length is invalid: %{public}d", buffer_len); - return TELEPHONY_ERR_ARGUMENT_INVALID; - } - std::vector buffer; - for (int i = 0; i < buffer_len; ++i) { - uint8_t temp; - if (!data.ReadUint8(temp)) { - TELEPHONY_LOGE("write Uint8 buffer failed."); - return TELEPHONY_ERR_READ_DATA_FAIL; - } - buffer.push_back(data.ReadUint8()); - } - int32_t result = GetNetworkSliceAllowedNssai(slotId, buffer); - if (result != TELEPHONY_ERR_SUCCESS) { - return result; - } - return TELEPHONY_SUCCESS; -} - -int32_t CellularDataServiceStub::OnGetNetworkSliceEhplmn(MessageParcel &data, MessageParcel &reply) -{ - int32_t slotId = data.ReadInt32(); - int32_t result = GetNetworkSliceEhplmn(slotId); - if (result != TELEPHONY_ERR_SUCCESS) { - return result; - } - return TELEPHONY_SUCCESS; -} -} // namespace Telephony -} // namespace OHOS \ No newline at end of file diff --git a/services/src/data_connection_monitor.cpp b/services/src/data_connection_monitor.cpp index 7bfd5649..1a3cdbb1 100644 --- a/services/src/data_connection_monitor.cpp +++ b/services/src/data_connection_monitor.cpp @@ -154,7 +154,7 @@ void DataConnectionMonitor::HandleRecovery() TELEPHONY_LOGI("Slot%{public}d: Handle Recovery: cleanup connections", slotId_); dataRecoveryState_ = RecoveryState::STATE_REREGISTER_NETWORK; int32_t ret = DelayedRefSingleton::GetInstance().ClearAllConnections( - slotId_, DisConnectionReason::REASON_RETRY_CONNECTION); + slotId_, (int32_t) DisConnectionReason::REASON_RETRY_CONNECTION); if (ret != static_cast(RequestNetCode::REQUEST_SUCCESS)) { TELEPHONY_LOGE("Slot%{public}d: Handle Recovery: cleanup connections failed", slotId_); } @@ -170,7 +170,7 @@ void DataConnectionMonitor::HandleRecovery() TELEPHONY_LOGI("Slot%{public}d: Handle Recovery: radio restart", slotId_); dataRecoveryState_ = RecoveryState::STATE_REQUEST_CONTEXT_LIST; int32_t ret = DelayedRefSingleton::GetInstance().ClearAllConnections( - slotId_, DisConnectionReason::REASON_RETRY_CONNECTION); + slotId_, (int32_t)DisConnectionReason::REASON_RETRY_CONNECTION); if (ret != static_cast(RequestNetCode::REQUEST_SUCCESS)) { TELEPHONY_LOGE("Slot%{public}d: Handle Recovery: radio restart cleanup connections failed", slotId_); } diff --git a/services/src/utils/network_search_callback.cpp b/services/src/utils/network_search_callback.cpp index ef09e25c..6ecd7311 100644 --- a/services/src/utils/network_search_callback.cpp +++ b/services/src/utils/network_search_callback.cpp @@ -22,7 +22,8 @@ namespace OHOS { namespace Telephony { bool NetworkSearchCallback::HasInternetCapability(int32_t slotId, int32_t cId) { - int32_t result = DelayedRefSingleton::GetInstance().HasInternetCapability(slotId, cId); + int32_t result; + DelayedRefSingleton::GetInstance().HasInternetCapability(slotId, cId, result); if (result == static_cast(RequestNetCode::REQUEST_SUCCESS)) { return true; } diff --git a/test/BUILD.gn b/test/BUILD.gn index 3fdb01a0..42fc5749 100644 --- a/test/BUILD.gn +++ b/test/BUILD.gn @@ -39,6 +39,7 @@ ohos_unittest("tel_cellular_data_test") { deps = [ "$SOURCE_DIR:tel_cellular_data_static", + "$SOURCE_DIR/frameworks/native:cellulardata_interface_stub", "$SOURCE_DIR/frameworks/native:tel_cellular_data_api", ] @@ -103,6 +104,7 @@ ohos_unittest("tel_cellular_state_machine_test") { deps = [ "$SOURCE_DIR:tel_cellular_data_static", + "$SOURCE_DIR/frameworks/native:cellulardata_interface_stub", "$SOURCE_DIR/frameworks/native:tel_cellular_data_api", "//third_party/googletest:gmock_main", ] @@ -167,6 +169,7 @@ ohos_unittest("tel_cellular_state_branch_test") { deps = [ "$SOURCE_DIR:tel_cellular_data_static", + "$SOURCE_DIR/frameworks/native:cellulardata_interface_stub", "$SOURCE_DIR/frameworks/native:tel_cellular_data_api", ] diff --git a/test/cellular_data_service_test.cpp b/test/cellular_data_service_test.cpp index c0dfd68d..6c6191cb 100644 --- a/test/cellular_data_service_test.cpp +++ b/test/cellular_data_service_test.cpp @@ -22,6 +22,7 @@ #include "gtest/gtest.h" #include "tel_ril_network_parcel.h" #include "traffic_management.h" +#include "apn_attribute.h" namespace OHOS { namespace Telephony { @@ -60,14 +61,14 @@ HWTEST_F(CellularDataServiceTest, CellularDataService_001, TestSize.Level1) service->isInitSuccess_ = true; bool dataEnabled = false; bool dataRoamingEnabled = false; + int32_t state; ASSERT_NE(TELEPHONY_ERR_SUCCESS, service->IsCellularDataEnabled(dataEnabled)); ASSERT_NE(TELEPHONY_ERR_SUCCESS, service->EnableCellularData(false)); ASSERT_NE(TELEPHONY_ERR_SUCCESS, service->EnableCellularData(true)); ASSERT_NE(TELEPHONY_ERR_SUCCESS, service->EnableIntelligenceSwitch(false)); ASSERT_NE(TELEPHONY_ERR_SUCCESS, service->EnableIntelligenceSwitch(true)); - ASSERT_NE(TELEPHONY_ERR_SUCCESS, service->GetCellularDataState()); - ASSERT_EQ(static_cast(DisConnectionReason::REASON_CHANGE_CONNECTION), - service->GetApnState(DEFAULT_SIM_SLOT_ID, std::string())); + ASSERT_NE(TELEPHONY_ERR_SUCCESS, service->GetCellularDataState(state)); + ASSERT_EQ(TELEPHONY_ERR_SUCCESS, service->GetApnState(DEFAULT_SIM_SLOT_ID, std::string(), state)); ASSERT_NE(TELEPHONY_ERR_SUCCESS, service->IsCellularDataRoamingEnabled(DEFAULT_SIM_SLOT_ID, dataRoamingEnabled)); ASSERT_NE(TELEPHONY_ERR_SUCCESS, service->EnableCellularDataRoaming(DEFAULT_SIM_SLOT_ID, true)); NetRequest request; @@ -87,16 +88,18 @@ HWTEST_F(CellularDataServiceTest, CellularDataService_001, TestSize.Level1) */ HWTEST_F(CellularDataServiceTest, CellularDataService_002, TestSize.Level1) { - ASSERT_NE(TELEPHONY_ERR_SUCCESS, service->GetCellularDataFlowType()); + int32_t type; + ASSERT_NE(TELEPHONY_ERR_SUCCESS, service->GetCellularDataFlowType(type)); ASSERT_EQ("default slotId: -1", service->GetStateMachineCurrentStatusDump()); service->GetFlowDataInfoDump(); ASSERT_NE(TELEPHONY_ERR_SUCCESS, service->StrategySwitch(DEFAULT_SIM_SLOT_ID, false)); - ASSERT_EQ(TELEPHONY_ERR_SUCCESS, service->HasInternetCapability(DEFAULT_SIM_SLOT_ID, 0)); - DisConnectionReason reason = DisConnectionReason::REASON_NORMAL; + int32_t capability; + ASSERT_EQ(TELEPHONY_ERR_SUCCESS, service->HasInternetCapability(DEFAULT_SIM_SLOT_ID, 0, capability)); + int32_t reason = static_cast(DisConnectionReason::REASON_NORMAL); ASSERT_NE(TELEPHONY_ERR_SUCCESS, service->ClearAllConnections(DEFAULT_SIM_SLOT_ID, reason)); ASSERT_EQ(TELEPHONY_ERR_SUCCESS, service->ChangeConnectionForDsds(DEFAULT_SIM_SLOT_ID, false)); ASSERT_EQ(TELEPHONY_ERR_SUCCESS, service->ChangeConnectionForDsds(DEFAULT_SIM_SLOT_ID, true)); - ApnItem::Attribute apnAttr; + ApnAttribute apnAttr; ASSERT_NE(TELEPHONY_ERR_SUCCESS, service->GetDataConnApnAttr(DEFAULT_SIM_SLOT_ID, apnAttr)); std::string ipType; ASSERT_EQ(TELEPHONY_ERR_SUCCESS, service->GetDataConnIpType(DEFAULT_SIM_SLOT_ID, ipType)); diff --git a/test/cellular_data_test.cpp b/test/cellular_data_test.cpp index b017735b..62278106 100644 --- a/test/cellular_data_test.cpp +++ b/test/cellular_data_test.cpp @@ -32,7 +32,7 @@ #include "gtest/gtest_pred_impl.h" #include "gtest/hwext/gtest-tag.h" #include "hap_token_info.h" -#include "i_cellular_data_manager.h" +#include "icellular_data_manager.h" #include "iosfwd" #include "iostream" #include "net_conn_callback_stub.h" diff --git a/test/fuzztest/getcellulardatastate_fuzzer/BUILD.gn b/test/fuzztest/getcellulardatastate_fuzzer/BUILD.gn index 6da942c1..ceb34fbd 100644 --- a/test/fuzztest/getcellulardatastate_fuzzer/BUILD.gn +++ b/test/fuzztest/getcellulardatastate_fuzzer/BUILD.gn @@ -33,6 +33,7 @@ ohos_fuzztest("GetCellularDataStateFuzzTest") { deps = [ "$SOURCE_DIR:tel_cellular_data", + "$SOURCE_DIR/frameworks/native:cellulardata_interface_stub", "$SOURCE_DIR/frameworks/native:tel_cellular_data_api", ] diff --git a/test/fuzztest/getcellulardatastate_fuzzer/getcellulardatastate_fuzzer.cpp b/test/fuzztest/getcellulardatastate_fuzzer/getcellulardatastate_fuzzer.cpp index 5dfd3274..c77c32e0 100644 --- a/test/fuzztest/getcellulardatastate_fuzzer/getcellulardatastate_fuzzer.cpp +++ b/test/fuzztest/getcellulardatastate_fuzzer/getcellulardatastate_fuzzer.cpp @@ -21,9 +21,10 @@ #include "adddatatoken_fuzzer.h" #include "cellular_data_ipc_interface_code.h" #include "cellular_data_service.h" -#include "cellular_data_service_stub.h" +#include "cellular_data_manager_stub.h" #include "system_ability_definition.h" #include +#include "icellular_data_manager.h" using namespace OHOS::Telephony; namespace OHOS { @@ -42,26 +43,6 @@ bool IsServiceInited() return g_isInited; } -void OnRemoteRequest(const uint8_t *data, size_t size) -{ - if (!IsServiceInited()) { - return; - } - - MessageParcel dataMessageParcel; - if (!dataMessageParcel.WriteInterfaceToken(CellularDataServiceStub::GetDescriptor())) { - return; - } - dataMessageParcel.WriteBuffer(data, size); - dataMessageParcel.RewindRead(0); - FuzzedDataProvider fdp(data, size); - uint32_t code = fdp.ConsumeIntegralInRange(0, - static_cast(CellularDataInterfaceCode::GET_SUPPLIER_REGISTER_STATE) + 1); - MessageParcel reply; - MessageOption option; - DelayedSingleton::GetInstance()->OnRemoteRequest(code, dataMessageParcel, reply, option); -} - void EnableCellularData(const uint8_t *data, size_t size) { if (!IsServiceInited()) { @@ -71,8 +52,10 @@ void EnableCellularData(const uint8_t *data, size_t size) MessageParcel dataMessageParcel; dataMessageParcel.WriteBuffer(data, size); dataMessageParcel.RewindRead(0); + uint32_t code = static_cast(ICellularDataManagerIpcCode::COMMAND_ENABLE_CELLULAR_DATA); MessageParcel reply; - DelayedSingleton::GetInstance()->OnEnableCellularData(dataMessageParcel, reply); + MessageOption option(MessageOption::TF_SYNC); + DelayedSingleton::GetInstance()->OnRemoteRequest(code, dataMessageParcel, reply, option); } void GetCellularDataState(const uint8_t *data, size_t size) @@ -84,8 +67,10 @@ void GetCellularDataState(const uint8_t *data, size_t size) MessageParcel dataMessageParcel; dataMessageParcel.WriteBuffer(data, size); dataMessageParcel.RewindRead(0); + uint32_t code = static_cast(ICellularDataManagerIpcCode::COMMAND_GET_CELLULAR_DATA_STATE); MessageParcel reply; - DelayedSingleton::GetInstance()->OnGetCellularDataState(dataMessageParcel, reply); + MessageOption option(MessageOption::TF_SYNC); + DelayedSingleton::GetInstance()->OnRemoteRequest(code, dataMessageParcel, reply, option); } void IsCellularDataEnabled(const uint8_t *data, size_t size) @@ -97,8 +82,10 @@ void IsCellularDataEnabled(const uint8_t *data, size_t size) MessageParcel dataMessageParcel; dataMessageParcel.WriteBuffer(data, size); dataMessageParcel.RewindRead(0); + uint32_t code = static_cast(ICellularDataManagerIpcCode::COMMAND_IS_CELLULAR_DATA_ENABLED); MessageParcel reply; - DelayedSingleton::GetInstance()->OnIsCellularDataEnabled(dataMessageParcel, reply); + MessageOption option(MessageOption::TF_SYNC); + DelayedSingleton::GetInstance()->OnRemoteRequest(code, dataMessageParcel, reply, option); } void IsCellularDataRoamingEnabled(const uint8_t *data, size_t size) @@ -112,8 +99,10 @@ void IsCellularDataRoamingEnabled(const uint8_t *data, size_t size) dataMessageParcel.WriteInt32(slotId); dataMessageParcel.WriteBuffer(data, size); dataMessageParcel.RewindRead(0); + uint32_t code = static_cast(ICellularDataManagerIpcCode::COMMAND_IS_CELLULAR_DATA_ROAMING_ENABLED); MessageParcel reply; - DelayedSingleton::GetInstance()->OnIsCellularDataRoamingEnabled(dataMessageParcel, reply); + MessageOption option(MessageOption::TF_SYNC); + DelayedSingleton::GetInstance()->OnRemoteRequest(code, dataMessageParcel, reply, option); } void GetDefaultCellularDataSlotId(const uint8_t *data, size_t size) @@ -125,8 +114,10 @@ void GetDefaultCellularDataSlotId(const uint8_t *data, size_t size) MessageParcel dataMessageParcel; dataMessageParcel.WriteBuffer(data, size); dataMessageParcel.RewindRead(0); + uint32_t code = static_cast(ICellularDataManagerIpcCode::COMMAND_IS_CELLULAR_DATA_ROAMING_ENABLED); MessageParcel reply; - DelayedSingleton::GetInstance()->OnGetDefaultCellularDataSlotId(dataMessageParcel, reply); + MessageOption option(MessageOption::TF_SYNC); + DelayedSingleton::GetInstance()->OnRemoteRequest(code, dataMessageParcel, reply, option); } void EnableCellularDataRoaming(const uint8_t *data, size_t size) @@ -141,8 +132,10 @@ void EnableCellularDataRoaming(const uint8_t *data, size_t size) dataMessageParcel.WriteInt32(slotId); dataMessageParcel.WriteBuffer(data, size); dataMessageParcel.RewindRead(0); + uint32_t code = static_cast(ICellularDataManagerIpcCode::COMMAND_ENABLE_CELLULAR_DATA_ROAMING); MessageParcel reply; - DelayedSingleton::GetInstance()->OnEnableCellularDataRoaming(dataMessageParcel, reply); + MessageOption option(MessageOption::TF_SYNC); + DelayedSingleton::GetInstance()->OnRemoteRequest(code, dataMessageParcel, reply, option); } void SetDefaultCellularDataSlotId(const uint8_t *data, size_t size) @@ -157,8 +150,10 @@ void SetDefaultCellularDataSlotId(const uint8_t *data, size_t size) dataMessageParcel.WriteInt32(slotId); dataMessageParcel.WriteBuffer(data, size); dataMessageParcel.RewindRead(0); + uint32_t code = static_cast(ICellularDataManagerIpcCode::COMMAND_SET_DEFAULT_CELLULAR_DATA_SLOT_ID); MessageParcel reply; - DelayedSingleton::GetInstance()->OnSetDefaultCellularDataSlotId(dataMessageParcel, reply); + MessageOption option(MessageOption::TF_SYNC); + DelayedSingleton::GetInstance()->OnRemoteRequest(code, dataMessageParcel, reply, option); } void HasInternetCapability(const uint8_t *data, size_t size) @@ -173,8 +168,10 @@ void HasInternetCapability(const uint8_t *data, size_t size) dataMessageParcel.WriteInt32(slotId); dataMessageParcel.WriteBuffer(data, size); dataMessageParcel.RewindRead(0); + uint32_t code = static_cast(ICellularDataManagerIpcCode::COMMAND_HAS_INTERNET_CAPABILITY); MessageParcel reply; - DelayedSingleton::GetInstance()->OnHasInternetCapability(dataMessageParcel, reply); + MessageOption option(MessageOption::TF_SYNC); + DelayedSingleton::GetInstance()->OnRemoteRequest(code, dataMessageParcel, reply, option); } void ClearCellularDataConnections(const uint8_t *data, size_t size) @@ -189,8 +186,10 @@ void ClearCellularDataConnections(const uint8_t *data, size_t size) dataMessageParcel.WriteInt32(slotId); dataMessageParcel.WriteBuffer(data, size); dataMessageParcel.RewindRead(0); + uint32_t code = static_cast(ICellularDataManagerIpcCode::COMMAND_CLEAR_CELLULAR_DATA_CONNECTIONS); MessageParcel reply; - DelayedSingleton::GetInstance()->OnClearCellularDataConnections(dataMessageParcel, reply); + MessageOption option(MessageOption::TF_SYNC); + DelayedSingleton::GetInstance()->OnRemoteRequest(code, dataMessageParcel, reply, option); } void GetCellularDataFlowType(const uint8_t *data, size_t size) @@ -202,8 +201,10 @@ void GetCellularDataFlowType(const uint8_t *data, size_t size) MessageParcel dataMessageParcel; dataMessageParcel.WriteBuffer(data, size); dataMessageParcel.RewindRead(0); + uint32_t code = static_cast(ICellularDataManagerIpcCode::COMMAND_GET_CELLULAR_DATA_FLOW_TYPE); MessageParcel reply; - DelayedSingleton::GetInstance()->OnGetCellularDataFlowType(dataMessageParcel, reply); + MessageOption option(MessageOption::TF_SYNC); + DelayedSingleton::GetInstance()->OnRemoteRequest(code, dataMessageParcel, reply, option); } void RegisterSimAccountCallback(const uint8_t *data, size_t size) @@ -214,8 +215,10 @@ void RegisterSimAccountCallback(const uint8_t *data, size_t size) MessageParcel dataMessageParcel; dataMessageParcel.WriteBuffer(data, size); dataMessageParcel.RewindRead(0); + uint32_t code = static_cast(ICellularDataManagerIpcCode::COMMAND_REGISTER_SIM_ACCOUNT_CALLBACK); MessageParcel reply; - DelayedSingleton::GetInstance()->OnRegisterSimAccountCallback(dataMessageParcel, reply); + MessageOption option(MessageOption::TF_SYNC); + DelayedSingleton::GetInstance()->OnRemoteRequest(code, dataMessageParcel, reply, option); } void UnregisterSimAccountCallback(const uint8_t *data, size_t size) @@ -226,8 +229,10 @@ void UnregisterSimAccountCallback(const uint8_t *data, size_t size) MessageParcel dataMessageParcel; dataMessageParcel.WriteBuffer(data, size); dataMessageParcel.RewindRead(0); + uint32_t code = static_cast(ICellularDataManagerIpcCode::COMMAND_UNREGISTER_SIM_ACCOUNT_CALLBACK); MessageParcel reply; - DelayedSingleton::GetInstance()->OnUnregisterSimAccountCallback(dataMessageParcel, reply); + MessageOption option(MessageOption::TF_SYNC); + DelayedSingleton::GetInstance()->OnRemoteRequest(code, dataMessageParcel, reply, option); } void GetDefaultActReportInfo(const uint8_t *data, size_t size) @@ -238,8 +243,10 @@ void GetDefaultActReportInfo(const uint8_t *data, size_t size) MessageParcel dataMessageParcel; dataMessageParcel.WriteBuffer(data, size); dataMessageParcel.RewindRead(0); + uint32_t code = static_cast(ICellularDataManagerIpcCode::COMMAND_GET_DEFAULT_ACT_REPORT_INFO); MessageParcel reply; - DelayedSingleton::GetInstance()->OnGetDefaultActReportInfo(dataMessageParcel, reply); + MessageOption option(MessageOption::TF_SYNC); + DelayedSingleton::GetInstance()->OnRemoteRequest(code, dataMessageParcel, reply, option); } void GetInternalActReportInfo(const uint8_t *data, size_t size) @@ -250,8 +257,10 @@ void GetInternalActReportInfo(const uint8_t *data, size_t size) MessageParcel dataMessageParcel; dataMessageParcel.WriteBuffer(data, size); dataMessageParcel.RewindRead(0); + uint32_t code = static_cast(ICellularDataManagerIpcCode::COMMAND_GET_INTERNAL_ACT_REPORT_INFO); MessageParcel reply; - DelayedSingleton::GetInstance()->OnGetInternalActReportInfo(dataMessageParcel, reply); + MessageOption option(MessageOption::TF_SYNC); + DelayedSingleton::GetInstance()->OnRemoteRequest(code, dataMessageParcel, reply, option); } void DoSomethingInterestingWithMyAPI(const uint8_t *data, size_t size) @@ -260,7 +269,6 @@ void DoSomethingInterestingWithMyAPI(const uint8_t *data, size_t size) return; } - OnRemoteRequest(data, size); EnableCellularData(data, size); GetCellularDataState(data, size); IsCellularDataEnabled(data, size); diff --git a/test/unit_test/cellular_data_code_test.cpp b/test/unit_test/cellular_data_code_test.cpp index d54576ea..5ebdfccd 100644 --- a/test/unit_test/cellular_data_code_test.cpp +++ b/test/unit_test/cellular_data_code_test.cpp @@ -288,9 +288,10 @@ public: static void GetDefaultSlotId() { sptr proxy = CellularDataClient::GetInstance().GetProxy(); + int32_t slotId; if (proxy != nullptr) { - int32_t result = proxy->GetDefaultCellularDataSlotId(); - std::cout << "get default slot id is := " << result << std::endl; + int32_t result = proxy->GetDefaultCellularDataSlotId(slotId); + std::cout << "get default slot id is := " << slotId << std::endl; } else { std::cout << "get default slot id fail" << std::endl; } @@ -313,10 +314,11 @@ public: static void GetDataFlowType() { + int32_t type; sptr proxy = CellularDataClient::GetInstance().GetProxy(); if (proxy != nullptr) { - int32_t result = proxy->GetCellularDataFlowType(); - std::cout << "get CellDataFlowType is := " << result << std::endl; + int32_t result = proxy->GetCellularDataFlowType(type); + std::cout << "get CellDataFlowType is := " << type << std::endl; } else { std::cout << "get CellDataFlowType is fail" << std::endl; } diff --git a/test/zero_branch_test.cpp b/test/zero_branch_test.cpp index 57cc6fbb..68c55e9b 100644 --- a/test/zero_branch_test.cpp +++ b/test/zero_branch_test.cpp @@ -29,7 +29,7 @@ #include "cellular_data_rdb_observer.h" #include "cellular_data_roaming_observer.h" #include "cellular_data_service.h" -#include "cellular_data_service_stub.h" +#include "cellular_data_manager_stub.h" #include "cellular_data_setting_observer.h" #include "cellular_data_settings_rdb_helper.h" #include "cellular_data_state_machine.h" @@ -54,6 +54,8 @@ #include "telephony_hisysevent.h" #include "telephony_log_wrapper.h" #include "uri.h" +#include "apn_attribute.h" +#include "icellular_data_manager.h" namespace OHOS { namespace Telephony { @@ -669,25 +671,29 @@ HWTEST_F(BranchTest, Telephony_CellularDataService_001, Function | MediumTest | service.InitModule(); bool dataEnabled = false; bool dataRoamingEnabled = false; + int32_t cellularDataState; + int32_t slotId; + int32_t capability; + int32_t type; ASSERT_NE(TELEPHONY_ERR_SUCCESS, service.IsCellularDataEnabled(dataEnabled)); ASSERT_NE(TELEPHONY_ERR_SUCCESS, service.EnableCellularData(false)); ASSERT_NE(TELEPHONY_ERR_SUCCESS, service.EnableCellularData(true)); - ASSERT_NE(TELEPHONY_ERR_SUCCESS, service.GetCellularDataState()); + ASSERT_NE(TELEPHONY_ERR_SUCCESS, service.GetCellularDataState(cellularDataState)); ASSERT_NE(TELEPHONY_ERR_SUCCESS, service.IsCellularDataRoamingEnabled(INVALID_SLOTID, dataRoamingEnabled)); ASSERT_NE(TELEPHONY_ERR_SUCCESS, service.EnableCellularDataRoaming(INVALID_SLOTID, false)); ASSERT_NE(TELEPHONY_ERR_SUCCESS, service.IsCellularDataRoamingEnabled(DEFAULT_SIM_SLOT_ID, dataRoamingEnabled)); ASSERT_NE(TELEPHONY_ERR_SUCCESS, service.EnableCellularDataRoaming(DEFAULT_SIM_SLOT_ID, true)); ASSERT_NE(TELEPHONY_ERR_SUCCESS, service.HandleApnChanged(INVALID_SLOTID)); ASSERT_NE(TELEPHONY_ERR_SUCCESS, service.HandleApnChanged(DEFAULT_SIM_SLOT_ID)); - ASSERT_NE(TELEPHONY_ERR_SUCCESS, service.GetDefaultCellularDataSlotId()); + ASSERT_NE(TELEPHONY_ERR_SUCCESS, service.GetDefaultCellularDataSlotId(slotId)); ASSERT_NE(TELEPHONY_ERR_SUCCESS, service.SetDefaultCellularDataSlotId(INVALID_SLOTID)); ASSERT_NE(TELEPHONY_ERR_SUCCESS, service.SetDefaultCellularDataSlotId(DEFAULT_SIM_SLOT_ID)); - ASSERT_NE(TELEPHONY_ERR_SUCCESS, service.GetCellularDataFlowType()); - ASSERT_NE(TELEPHONY_ERR_SUCCESS, service.HasInternetCapability(INVALID_SLOTID, 0)); - ASSERT_NE(TELEPHONY_ERR_SUCCESS, service.HasInternetCapability(DEFAULT_SIM_SLOT_ID, 0)); + ASSERT_NE(TELEPHONY_ERR_SUCCESS, service.GetCellularDataFlowType(type)); + ASSERT_NE(TELEPHONY_ERR_SUCCESS, service.HasInternetCapability(INVALID_SLOTID, 0, capability)); + ASSERT_NE(TELEPHONY_ERR_SUCCESS, service.HasInternetCapability(DEFAULT_SIM_SLOT_ID, 0, capability)); ASSERT_NE(TELEPHONY_ERR_SUCCESS, service.ClearCellularDataConnections(INVALID_SLOTID)); ASSERT_NE(TELEPHONY_ERR_SUCCESS, service.ClearCellularDataConnections(DEFAULT_SIM_SLOT_ID)); - DisConnectionReason reason = DisConnectionReason::REASON_NORMAL; + int32_t reason = static_cast(DisConnectionReason::REASON_NORMAL); ASSERT_NE(TELEPHONY_ERR_SUCCESS, service.ClearAllConnections(INVALID_SLOTID, reason)); ASSERT_NE(TELEPHONY_ERR_SUCCESS, service.ClearAllConnections(DEFAULT_SIM_SLOT_ID, reason)); ASSERT_NE(TELEPHONY_ERR_SUCCESS, service.ChangeConnectionForDsds(INVALID_SLOTID, false)); @@ -720,28 +726,33 @@ HWTEST_F(BranchTest, Telephony_CellularDataService_002, Function | MediumTest | service.InitModule(); bool dataEnabled = false; bool dataRoamingEnabled = false; + int32_t cellularDataState; + int32_t state; + int32_t slotId; + int32_t capability; + int32_t type; ASSERT_NE(TELEPHONY_ERR_SUCCESS, service.IsCellularDataEnabled(dataEnabled)); ASSERT_NE(TELEPHONY_ERR_SUCCESS, service.EnableIntelligenceSwitch(false)); ASSERT_NE(TELEPHONY_ERR_SUCCESS, service.EnableIntelligenceSwitch(true)); ASSERT_NE(TELEPHONY_ERR_SUCCESS, service.EnableCellularData(false)); - ASSERT_NE(TELEPHONY_ERR_SUCCESS, service.GetCellularDataState()); + ASSERT_NE(TELEPHONY_ERR_SUCCESS, service.GetCellularDataState(cellularDataState)); ASSERT_NE(TELEPHONY_ERR_SUCCESS, service.IsCellularDataRoamingEnabled(INVALID_SLOTID, dataRoamingEnabled)); ASSERT_NE(TELEPHONY_ERR_SUCCESS, service.EnableCellularDataRoaming(INVALID_SLOTID, false)); ASSERT_NE(TELEPHONY_ERR_SUCCESS, service.HandleApnChanged(INVALID_SLOTID)); - ASSERT_NE(TELEPHONY_ERR_SUCCESS, service.GetDefaultCellularDataSlotId()); + ASSERT_NE(TELEPHONY_ERR_SUCCESS, service.GetDefaultCellularDataSlotId(slotId)); ASSERT_NE(TELEPHONY_ERR_SUCCESS, service.SetDefaultCellularDataSlotId(INVALID_SLOTID)); - ASSERT_NE(TELEPHONY_ERR_SUCCESS, service.GetCellularDataFlowType()); - ASSERT_NE(TELEPHONY_ERR_SUCCESS, service.HasInternetCapability(INVALID_SLOTID, 0)); + ASSERT_NE(TELEPHONY_ERR_SUCCESS, service.GetCellularDataFlowType(type)); + ASSERT_NE(TELEPHONY_ERR_SUCCESS, service.HasInternetCapability(INVALID_SLOTID, 0, capability)); ASSERT_NE(TELEPHONY_ERR_SUCCESS, service.ClearCellularDataConnections(INVALID_SLOTID)); - DisConnectionReason reason = DisConnectionReason::REASON_NORMAL; + int32_t reason = static_cast(DisConnectionReason::REASON_NORMAL); ASSERT_NE(TELEPHONY_ERR_SUCCESS, service.ClearAllConnections(INVALID_SLOTID, reason)); ASSERT_NE(TELEPHONY_ERR_SUCCESS, service.ChangeConnectionForDsds(INVALID_SLOTID, false)); ASSERT_NE(TELEPHONY_ERR_SUCCESS, service.StrategySwitch(INVALID_SLOTID, false)); ASSERT_FALSE(service.GetCellularDataController(INVALID_SLOTID) != nullptr); ASSERT_FALSE(service.GetCellularDataController(INVALID_SLOTID_TWO) != nullptr); - ASSERT_EQ(CELLULAR_DATA_INVALID_PARAM, service.GetApnState(DEFAULT_SIM_SLOT_ID, std::string())); - ASSERT_EQ(CELLULAR_DATA_INVALID_PARAM, service.GetApnState(INVALID_SLOTID, std::string())); - ASSERT_EQ(service.GetDataRecoveryState(), 0); + ASSERT_EQ(CELLULAR_DATA_INVALID_PARAM, service.GetApnState(DEFAULT_SIM_SLOT_ID, std::string(), state)); + ASSERT_EQ(CELLULAR_DATA_INVALID_PARAM, service.GetApnState(INVALID_SLOTID, std::string(), state)); + ASSERT_EQ(service.GetDataRecoveryState(state), 0); ASSERT_NE(TELEPHONY_ERR_SUCCESS, service.InitCellularDataController(2)); ASSERT_NE(TELEPHONY_ERR_SUCCESS, service.InitCellularDataController(INVALID_SLOTID)); service.GetFlowDataInfoDump(); @@ -765,27 +776,31 @@ HWTEST_F(BranchTest, Telephony_CellularDataService_003, Function | MediumTest | service.cellularDataControllers_.clear(); bool dataEnabled = false; bool dataRoamingEnabled = false; + int32_t cellularDataState; + int32_t slotId; + int32_t capability; + int32_t type; ASSERT_NE(TELEPHONY_ERR_SUCCESS, service.IsCellularDataEnabled(dataEnabled)); ASSERT_NE(TELEPHONY_ERR_SUCCESS, service.EnableCellularData(false)); ASSERT_NE(TELEPHONY_ERR_SUCCESS, service.EnableCellularData(true)); ASSERT_NE(TELEPHONY_ERR_SUCCESS, service.EnableCellularDataRoaming(INVALID_SLOTID, false)); ASSERT_NE(TELEPHONY_ERR_SUCCESS, service.IsCellularDataRoamingEnabled(DEFAULT_SIM_SLOT_ID, dataRoamingEnabled)); ASSERT_NE(TELEPHONY_ERR_SUCCESS, service.EnableCellularDataRoaming(DEFAULT_SIM_SLOT_ID, true)); - ASSERT_NE(TELEPHONY_ERR_SUCCESS, service.GetCellularDataState()); + ASSERT_NE(TELEPHONY_ERR_SUCCESS, service.GetCellularDataState(cellularDataState)); ASSERT_NE(TELEPHONY_ERR_SUCCESS, service.IsCellularDataRoamingEnabled(INVALID_SLOTID, dataRoamingEnabled)); ASSERT_NE(TELEPHONY_ERR_SUCCESS, service.HandleApnChanged(INVALID_SLOTID)); ASSERT_NE(TELEPHONY_ERR_SUCCESS, service.HandleApnChanged(DEFAULT_SIM_SLOT_ID)); ASSERT_NE(TELEPHONY_ERR_SUCCESS, service.SetDefaultCellularDataSlotId(INVALID_SLOTID)); ASSERT_NE(TELEPHONY_ERR_SUCCESS, service.SetDefaultCellularDataSlotId(DEFAULT_SIM_SLOT_ID)); - ASSERT_NE(TELEPHONY_ERR_SUCCESS, service.GetCellularDataFlowType()); - ASSERT_NE(TELEPHONY_ERR_SUCCESS, service.HasInternetCapability(INVALID_SLOTID, 0)); - ASSERT_NE(TELEPHONY_ERR_SUCCESS, service.HasInternetCapability(DEFAULT_SIM_SLOT_ID, 0)); - ASSERT_NE(TELEPHONY_ERR_SUCCESS, service.GetDefaultCellularDataSlotId()); + ASSERT_NE(TELEPHONY_ERR_SUCCESS, service.GetCellularDataFlowType(type)); + ASSERT_NE(TELEPHONY_ERR_SUCCESS, service.HasInternetCapability(INVALID_SLOTID, 0, capability)); + ASSERT_NE(TELEPHONY_ERR_SUCCESS, service.HasInternetCapability(DEFAULT_SIM_SLOT_ID, 0, capability)); + ASSERT_NE(TELEPHONY_ERR_SUCCESS, service.GetDefaultCellularDataSlotId(slotId)); ASSERT_NE(TELEPHONY_ERR_SUCCESS, service.StrategySwitch(INVALID_SLOTID, false)); ASSERT_NE(TELEPHONY_ERR_SUCCESS, service.StrategySwitch(DEFAULT_SIM_SLOT_ID, false)); ASSERT_NE(TELEPHONY_ERR_SUCCESS, service.ClearCellularDataConnections(INVALID_SLOTID)); ASSERT_NE(TELEPHONY_ERR_SUCCESS, service.ClearCellularDataConnections(DEFAULT_SIM_SLOT_ID)); - DisConnectionReason reason = DisConnectionReason::REASON_NORMAL; + int32_t reason = static_cast(DisConnectionReason::REASON_NORMAL); ASSERT_NE(TELEPHONY_ERR_SUCCESS, service.ClearAllConnections(INVALID_SLOTID, reason)); ASSERT_NE(TELEPHONY_ERR_SUCCESS, service.ClearAllConnections(DEFAULT_SIM_SLOT_ID, reason)); ASSERT_NE(TELEPHONY_ERR_SUCCESS, service.ChangeConnectionForDsds(INVALID_SLOTID, false)); @@ -811,6 +826,7 @@ HWTEST_F(BranchTest, Telephony_CellularDataService_004, Function | MediumTest | DataAccessToken token; CellularDataService service; std::vector strV; + int32_t state; ASSERT_EQ(TELEPHONY_ERR_FAIL, service.Dump(INVALID_FD, strV)); service.state_ = ServiceRunningState::STATE_RUNNING; service.OnStart(); @@ -818,12 +834,12 @@ HWTEST_F(BranchTest, Telephony_CellularDataService_004, Function | MediumTest | service.GetFlowDataInfoDump(); ASSERT_NE(TELEPHONY_ERR_SUCCESS, service.EnableIntelligenceSwitch(false)); ASSERT_NE(TELEPHONY_ERR_SUCCESS, service.EnableIntelligenceSwitch(true)); - ASSERT_EQ(CELLULAR_DATA_INVALID_PARAM, service.GetApnState(DEFAULT_SIM_SLOT_ID, std::string())); - ASSERT_EQ(CELLULAR_DATA_INVALID_PARAM, service.GetApnState(INVALID_SLOTID, std::string())); - ASSERT_EQ(service.GetDataRecoveryState(), 0); + ASSERT_EQ(CELLULAR_DATA_INVALID_PARAM, service.GetApnState(DEFAULT_SIM_SLOT_ID, std::string(), state)); + ASSERT_EQ(CELLULAR_DATA_INVALID_PARAM, service.GetApnState(INVALID_SLOTID, std::string(), state)); + ASSERT_EQ(service.GetDataRecoveryState(state), 0); ASSERT_EQ(TELEPHONY_ERR_SUCCESS, service.InitCellularDataController(2)); ASSERT_NE(TELEPHONY_ERR_SUCCESS, service.InitCellularDataController(INVALID_SLOTID)); - ApnItem::Attribute apnAttr; + ApnAttribute apnAttr; ASSERT_NE(TELEPHONY_ERR_SUCCESS, service.GetDataConnApnAttr(INVALID_SLOTID, apnAttr)); ASSERT_NE(TELEPHONY_ERR_SUCCESS, service.GetDataConnApnAttr(DEFAULT_SIM_SLOT_ID, apnAttr)); std::string ipType; @@ -843,6 +859,7 @@ HWTEST_F(BranchTest, Telephony_CellularDataService_005, Function | MediumTest | DataAccessToken token; CellularDataService service; std::vector strV; + int32_t state; ASSERT_EQ(TELEPHONY_ERR_FAIL, service.Dump(INVALID_FD, strV)); service.state_ = ServiceRunningState::STATE_RUNNING; service.OnStart(); @@ -850,13 +867,13 @@ HWTEST_F(BranchTest, Telephony_CellularDataService_005, Function | MediumTest | service.cellularDataControllers_.clear(); ASSERT_NE(TELEPHONY_ERR_SUCCESS, service.EnableIntelligenceSwitch(false)); ASSERT_NE(TELEPHONY_ERR_SUCCESS, service.EnableIntelligenceSwitch(true)); - ASSERT_EQ(CELLULAR_DATA_INVALID_PARAM, service.GetApnState(DEFAULT_SIM_SLOT_ID, std::string())); - ASSERT_EQ(CELLULAR_DATA_INVALID_PARAM, service.GetApnState(INVALID_SLOTID, std::string())); - ASSERT_EQ(service.GetDataRecoveryState(), 0); + ASSERT_EQ(CELLULAR_DATA_INVALID_PARAM, service.GetApnState(DEFAULT_SIM_SLOT_ID, std::string(), state)); + ASSERT_EQ(CELLULAR_DATA_INVALID_PARAM, service.GetApnState(INVALID_SLOTID, std::string(), state)); + ASSERT_EQ(service.GetDataRecoveryState(state), 0); ASSERT_EQ(TELEPHONY_ERR_SUCCESS, service.InitCellularDataController(2)); ASSERT_NE(TELEPHONY_ERR_SUCCESS, service.InitCellularDataController(INVALID_SLOTID)); service.GetFlowDataInfoDump(); - ApnItem::Attribute apnAttr; + ApnAttribute apnAttr; ASSERT_NE(TELEPHONY_ERR_SUCCESS, service.GetDataConnApnAttr(INVALID_SLOTID, apnAttr)); ASSERT_NE(TELEPHONY_ERR_SUCCESS, service.GetDataConnApnAttr(DEFAULT_SIM_SLOT_ID, apnAttr)); std::string ipType; @@ -1817,36 +1834,81 @@ HWTEST_F(BranchTest, CellularDataUtils_Test_01, Function | MediumTest | Level3) dataConnectionMonitor->GetDataFlowType(); dataConnectionMonitor->IsNeedDoRecovery(true); dataConnectionMonitor->IsNeedDoRecovery(false); +} + +/** + * @tc.number CellularDataUtils_Test_02 + * @tc.name test error branch + * @tc.desc Function test + */ +HWTEST_F(BranchTest, CellularDataUtils_Test_02, Function | MediumTest | Level3) +{ + auto cellularDataService = DelayedSingleton::GetInstance(); + MessageParcel data; + MessageParcel reply; + MessageOption option(MessageOption::TF_SYNC); + EXPECT_GE(cellularDataService->OnRemoteRequest(static_cast( + ICellularDataManagerIpcCode::COMMAND_IS_CELLULAR_DATA_ENABLED), data, reply, option), 0); + EXPECT_GE(cellularDataService->OnRemoteRequest(static_cast( + ICellularDataManagerIpcCode::COMMAND_ENABLE_CELLULAR_DATA), data, reply, option), 0); + EXPECT_GE(cellularDataService->OnRemoteRequest(static_cast( + ICellularDataManagerIpcCode::COMMAND_ENABLE_INTELLIGENCE_SWITCH), data, reply, option), 0); + EXPECT_GE(cellularDataService->OnRemoteRequest(static_cast( + ICellularDataManagerIpcCode::COMMAND_GET_CELLULAR_DATA_STATE), data, reply, option), 0); + EXPECT_GE(cellularDataService->OnRemoteRequest(static_cast( + ICellularDataManagerIpcCode::COMMAND_IS_CELLULAR_DATA_ROAMING_ENABLED), data, reply, option), 0); + EXPECT_GE(cellularDataService->OnRemoteRequest(static_cast( + ICellularDataManagerIpcCode::COMMAND_ENABLE_CELLULAR_DATA_ROAMING), data, reply, option), 0); + EXPECT_GE(cellularDataService->OnRemoteRequest(static_cast( + ICellularDataManagerIpcCode::COMMAND_HANDLE_APN_CHANGED), data, reply, option), 0); + EXPECT_GE(cellularDataService->OnRemoteRequest(static_cast( + ICellularDataManagerIpcCode::COMMAND_GET_DEFAULT_CELLULAR_DATA_SLOT_ID), data, reply, option), 0); + EXPECT_GE(cellularDataService->OnRemoteRequest(static_cast( + ICellularDataManagerIpcCode::COMMAND_GET_DEFAULT_CELLULAR_DATA_SIM_ID), data, reply, option), 0); + EXPECT_GE(cellularDataService->OnRemoteRequest(static_cast( + ICellularDataManagerIpcCode::COMMAND_SET_DEFAULT_CELLULAR_DATA_SLOT_ID), data, reply, option), 0); +} + +/** + * @tc.number CellularDataUtils_Test_03 + * @tc.name test error branch + * @tc.desc Function test + */ +HWTEST_F(BranchTest, CellularDataUtils_Test_03, Function | MediumTest | Level3) +{ auto cellularDataService = DelayedSingleton::GetInstance(); MessageParcel data; MessageParcel reply; - EXPECT_GE(cellularDataService->OnIsCellularDataEnabled(data, reply), 0); - EXPECT_GE(cellularDataService->OnEnableCellularData(data, reply), 0); - EXPECT_GE(cellularDataService->OnGetCellularDataState(data, reply), 0); - EXPECT_GE(cellularDataService->OnIsCellularDataRoamingEnabled(data, reply), 0); - EXPECT_GE(cellularDataService->OnEnableCellularDataRoaming(data, reply), 0); - EXPECT_GE(cellularDataService->OnHandleApnChanged(data, reply), 0); - cellularDataService->OnGetDefaultCellularDataSlotId(data, reply); - EXPECT_GE(cellularDataService->OnGetDefaultCellularDataSimId(data, reply), 0); - EXPECT_GE(cellularDataService->OnSetDefaultCellularDataSlotId(data, reply), 0); - EXPECT_GE(cellularDataService->OnGetCellularDataFlowType(data, reply), 0); - EXPECT_GE(cellularDataService->OnHasInternetCapability(data, reply), 0); - EXPECT_GE(cellularDataService->OnClearCellularDataConnections(data, reply), 0); - EXPECT_GE(cellularDataService->OnRegisterSimAccountCallback(data, reply), 0); - EXPECT_GE(cellularDataService->OnUnregisterSimAccountCallback(data, reply), 0); - EXPECT_GE(cellularDataService->OnEnableIntelligenceSwitch(data, reply), 0); - EXPECT_GE(cellularDataService->OnGetDataConnApnAttr(data, reply), 0); - EXPECT_GE(cellularDataService->OnGetDataConnIpType(data, reply), 0); - EXPECT_GE(cellularDataService->OnGetApnState(data, reply), 0); - EXPECT_GE(cellularDataService->OnGetRecoveryState(data, reply), 0); - EXPECT_GE(cellularDataService->OnIsNeedDoRecovery(data, reply), 0); - EXPECT_GE(cellularDataService->OnIsNeedDoRecovery(data, reply), 0); - EXPECT_GE(cellularDataService->OnClearAllConnections(data, reply), 0); - EXPECT_GE(cellularDataService->OnGetCellularDataSupplierId(data, reply), 0); - EXPECT_GE(cellularDataService->OnCorrectNetSupplierNoAvailable(data, reply), 0); - EXPECT_GE(cellularDataService->OnGetSupplierRegisterState(data, reply), 0); + MessageOption option(MessageOption::TF_SYNC); + EXPECT_GE(cellularDataService->OnRemoteRequest(static_cast( + ICellularDataManagerIpcCode::COMMAND_GET_CELLULAR_DATA_FLOW_TYPE), data, reply, option), 0); + EXPECT_GE(cellularDataService->OnRemoteRequest(static_cast( + ICellularDataManagerIpcCode::COMMAND_HAS_INTERNET_CAPABILITY), data, reply, option), 0); + EXPECT_GE(cellularDataService->OnRemoteRequest(static_cast( + ICellularDataManagerIpcCode::COMMAND_CLEAR_CELLULAR_DATA_CONNECTIONS), data, reply, option), 0); + EXPECT_GE(cellularDataService->OnRemoteRequest(static_cast( + ICellularDataManagerIpcCode::COMMAND_CLEAR_ALL_CONNECTIONS), data, reply, option), 0); + EXPECT_GE(cellularDataService->OnRemoteRequest(static_cast( + ICellularDataManagerIpcCode::COMMAND_GET_DATA_CONN_APN_ATTR), data, reply, option), 0); + EXPECT_GE(cellularDataService->OnRemoteRequest(static_cast( + ICellularDataManagerIpcCode::COMMAND_GET_DATA_CONN_IP_TYPE), data, reply, option), 0); + EXPECT_GE(cellularDataService->OnRemoteRequest(static_cast( + ICellularDataManagerIpcCode::COMMAND_GET_APN_STATE), data, reply, option), 0); + EXPECT_GE(cellularDataService->OnRemoteRequest(static_cast( + ICellularDataManagerIpcCode::COMMAND_GET_DATA_RECOVERY_STATE), data, reply, option), 0); + EXPECT_GE(cellularDataService->OnRemoteRequest(static_cast( + ICellularDataManagerIpcCode::COMMAND_IS_NEED_DO_RECOVERY), data, reply, option), 0); + EXPECT_GE(cellularDataService->OnRemoteRequest(static_cast( + ICellularDataManagerIpcCode::COMMAND_INIT_CELLULAR_DATA_CONTROLLER), data, reply, option), 0); + EXPECT_GE(cellularDataService->OnRemoteRequest(static_cast( + ICellularDataManagerIpcCode::COMMAND_ESTABLISH_ALL_APNS_IF_CONNECTABLE), data, reply, option), 0); + EXPECT_GE(cellularDataService->OnRemoteRequest(static_cast( + ICellularDataManagerIpcCode::COMMAND_RELEASE_CELLULAR_DATA_CONNECTION), data, reply, option), 0); + EXPECT_GE(cellularDataService->OnRemoteRequest(static_cast( + ICellularDataManagerIpcCode::COMMAND_GET_CELLULAR_DATA_SUPPLIER_ID), data, reply, option), 0); + EXPECT_GE(cellularDataService->OnRemoteRequest(static_cast( + ICellularDataManagerIpcCode::COMMAND_CORRECT_NET_SUPPLIER_NO_AVAILABLE), data, reply, option), 0); } - /** * @tc.number CellularDataSettingsRdbHelper_Test_01 * @tc.name test error branch -- Gitee From 36cf0f712101640f842f258d28c6084db42cab9c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E6=B3=BD=E5=87=A1?= Date: Tue, 15 Apr 2025 03:02:29 +0000 Subject: [PATCH 042/145] update frameworks/native/ICellularDataManager.idl. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 李泽凡 --- frameworks/native/ICellularDataManager.idl | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/frameworks/native/ICellularDataManager.idl b/frameworks/native/ICellularDataManager.idl index 579f08e1..f18e869b 100644 --- a/frameworks/native/ICellularDataManager.idl +++ b/frameworks/native/ICellularDataManager.idl @@ -15,6 +15,7 @@ sequenceable ApnAttribute..OHOS.Telephony.ApnAttribute; sequenceable ApnActivateReportInfo..OHOS.Telephony.ApnActivateReportInfoIpc; +sequenceable CellularDataTypes..OHOS.Telephony.ApnInfo; interface OHOS.Telephony.SimAccountCallback; interface OHOS.Telephony.ICellularDataManager { void IsCellularDataEnabled([out] boolean dataEnabled); @@ -48,12 +49,12 @@ interface OHOS.Telephony.ICellularDataManager { void GetDefaultActReportInfo([in] int slotId, [out] ApnActivateReportInfoIpc info); void GetInternalActReportInfo([in] int slotId, [out] ApnActivateReportInfoIpc info); void GetIntelligenceSwitchState([out] boolean switchState); - void QueryApnIds(ApnInfo apnInfo, [out] List apnIdList); - void SetPreferApn(int apnId); + void QueryApnIds([in] ApnInfo apnInfo, [out] List apnIdList); + void SetPreferApn([in] int apnId); void QueryAllApnInfo([out] List apnInfoList); - void SendUrspDecodeResult(int slotId, List buffer); - void SendUePolicySectionIdentifier(int slotId, List buffer); - void SendImsRsdList(int slotId, List buffer); - void GetNetworkSliceAllowedNssai(int slotId, List buffer); - void GetNetworkSliceEhplmn(int slotId); + void SendUrspDecodeResult([in] int slotId, [in] List buffer); + void SendUePolicySectionIdentifier([in] int slotId, [in] List buffer); + void SendImsRsdList([in] int slotId, [in] List buffer); + void GetNetworkSliceAllowedNssai([in] int slotId, [in] List buffer); + void GetNetworkSliceEhplmn([in] int slotId); }; -- Gitee From 13892244eba8b6a4812e089f019b4538d2f8aff2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E6=B3=BD=E5=87=A1?= Date: Tue, 15 Apr 2025 03:32:30 +0000 Subject: [PATCH 043/145] update interfaces/innerkits/cellular_data_types.h. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 李泽凡 --- interfaces/innerkits/cellular_data_types.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/interfaces/innerkits/cellular_data_types.h b/interfaces/innerkits/cellular_data_types.h index d499225a..81d6828a 100644 --- a/interfaces/innerkits/cellular_data_types.h +++ b/interfaces/innerkits/cellular_data_types.h @@ -127,9 +127,9 @@ struct ApnInfo : public Parcelable { return true; }; - std::shared_ptr UnMarshalling(Parcel &parcel) + ApnInfo* Unmarshalling(Parcel &parcel) { - std::shared_ptr param = std::make_shared(); + ApnInfo* param = new ApnInfo(); if (param == nullptr || !param->ReadFromParcel(parcel)) { param = nullptr; } -- Gitee From 7b01f81ee50b58c4410e326ab77ab0b495d2cfef Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E6=B3=BD=E5=87=A1?= Date: Tue, 15 Apr 2025 03:39:19 +0000 Subject: [PATCH 044/145] update services/src/cellular_data_service.cpp. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 李泽凡 --- services/src/cellular_data_service.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/services/src/cellular_data_service.cpp b/services/src/cellular_data_service.cpp index bf3a6d86..387c3cbb 100644 --- a/services/src/cellular_data_service.cpp +++ b/services/src/cellular_data_service.cpp @@ -941,25 +941,25 @@ int32_t CellularDataService::QueryAllApnInfo(std::vector &allApnInfoLis return 0; } -int32_t CellularDataService::SendUrspDecodeResult(int32_t slotId, std::vector buffer) +int32_t CellularDataService::SendUrspDecodeResult(int32_t slotId, const std::vector& buffer) { int32_t eventid = static_cast(CellularDataEventCode::MSG_SEND_UEPOLICY_COMMAND_REJECT); return CoreManagerInner::GetInstance().SendUrspDecodeResult(slotId, buffer, eventid); } -int32_t CellularDataService::SendUePolicySectionIdentifier(int32_t slotId, std::vector buffer) +int32_t CellularDataService::SendUePolicySectionIdentifier(int32_t slotId, const std::vector& buffer) { int32_t eventid = static_cast(CellularDataEventCode::MSG_SEND_UE_STATE_INDICATION); return CoreManagerInner::GetInstance().SendUePolicySectionIdentifier(slotId, buffer, eventid); } -int32_t CellularDataService::SendImsRsdList(int32_t slotId, std::vector buffer) +int32_t CellularDataService::SendImsRsdList(int32_t slotId, const std::vector& buffer) { int32_t eventid = static_cast(CellularDataEventCode::MSG_SEND_IMS_RSDLIST); return CoreManagerInner::GetInstance().SendImsRsdList(slotId, buffer, eventid); } -int32_t CellularDataService::GetNetworkSliceAllowedNssai(int32_t slotId, std::vector buffer) +int32_t CellularDataService::GetNetworkSliceAllowedNssai(int32_t slotId, const std::vector& buffer) { int32_t eventid = static_cast(CellularDataEventCode::MSG_SYNC_ALLOWED_NSSAI_WITH_MODEM); return CoreManagerInner::GetInstance().GetNetworkSliceAllowedNssai(slotId, buffer, eventid); -- Gitee From 774cf6b0f917c5a462545134b1cd7c783e908310 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E6=B3=BD=E5=87=A1?= Date: Tue, 15 Apr 2025 03:42:14 +0000 Subject: [PATCH 045/145] update services/include/cellular_data_service.h. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 李泽凡 --- services/include/cellular_data_service.h | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/services/include/cellular_data_service.h b/services/include/cellular_data_service.h index be119ebd..0fdc29f3 100644 --- a/services/include/cellular_data_service.h +++ b/services/include/cellular_data_service.h @@ -98,10 +98,10 @@ public: int32_t QueryApnIds(ApnInfo apnInfo, std::vector &apnIdList) override; int32_t SetPreferApn(int32_t apnId) override; int32_t QueryAllApnInfo(std::vector &apnInfoList) override; - int32_t SendUrspDecodeResult(int32_t slotId, std::vector buffer) override; - int32_t SendUePolicySectionIdentifier(int32_t slotId, std::vector buffer) override; - int32_t SendImsRsdList(int32_t slotId, std::vector buffer) override; - int32_t GetNetworkSliceAllowedNssai(int32_t slotId, std::vector buffer) override; + int32_t SendUrspDecodeResult(int32_t slotId, const std::vector& buffer) override; + int32_t SendUePolicySectionIdentifier(int32_t slotId, const std::vector& buffer) override; + int32_t SendImsRsdList(int32_t slotId, const std::vector& buffer) override; + int32_t GetNetworkSliceAllowedNssai(int32_t slotId, const std::vector& buffer) override; int32_t GetNetworkSliceEhplmn(int32_t slotId) override; private: -- Gitee From c995dbce0735b08a5cfabf00752e2272eaee4230 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E6=B3=BD=E5=87=A1?= Date: Tue, 15 Apr 2025 06:36:07 +0000 Subject: [PATCH 046/145] update interfaces/innerkits/cellular_data_types.h. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 李泽凡 --- interfaces/innerkits/cellular_data_types.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/interfaces/innerkits/cellular_data_types.h b/interfaces/innerkits/cellular_data_types.h index 81d6828a..5597fbbf 100644 --- a/interfaces/innerkits/cellular_data_types.h +++ b/interfaces/innerkits/cellular_data_types.h @@ -127,7 +127,7 @@ struct ApnInfo : public Parcelable { return true; }; - ApnInfo* Unmarshalling(Parcel &parcel) + static ApnInfo* Unmarshalling(Parcel &parcel) { ApnInfo* param = new ApnInfo(); if (param == nullptr || !param->ReadFromParcel(parcel)) { -- Gitee From 14f9508125f3b27157359717dcd0115f82dd8229 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E6=B3=BD=E5=87=A1?= Date: Tue, 15 Apr 2025 07:00:15 +0000 Subject: [PATCH 047/145] update services/include/cellular_data_service.h. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 李泽凡 --- services/include/cellular_data_service.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/services/include/cellular_data_service.h b/services/include/cellular_data_service.h index 0fdc29f3..8ab58df6 100644 --- a/services/include/cellular_data_service.h +++ b/services/include/cellular_data_service.h @@ -95,7 +95,7 @@ public: int32_t GetIfSupportDunApn(bool &isSupportDun) override; int32_t GetDefaultActReportInfo(int32_t slotId, ApnActivateReportInfoIpc &info) override; int32_t GetInternalActReportInfo(int32_t slotId, ApnActivateReportInfoIpc &info) override; - int32_t QueryApnIds(ApnInfo apnInfo, std::vector &apnIdList) override; + int32_t QueryApnIds(const ApnInfo& apnInfo, std::vector &apnIdList) override; int32_t SetPreferApn(int32_t apnId) override; int32_t QueryAllApnInfo(std::vector &apnInfoList) override; int32_t SendUrspDecodeResult(int32_t slotId, const std::vector& buffer) override; -- Gitee From 4d8b22a3d3240d86682510c0a19d4eb24821fc42 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E6=B3=BD=E5=87=A1?= Date: Tue, 15 Apr 2025 07:00:58 +0000 Subject: [PATCH 048/145] update services/src/cellular_data_service.cpp. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 李泽凡 --- services/src/cellular_data_service.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/services/src/cellular_data_service.cpp b/services/src/cellular_data_service.cpp index 387c3cbb..3509e768 100644 --- a/services/src/cellular_data_service.cpp +++ b/services/src/cellular_data_service.cpp @@ -894,7 +894,7 @@ int32_t CellularDataService::GetInternalActReportInfo(int32_t slotId, ApnActivat return result ? TELEPHONY_ERR_SUCCESS : TELEPHONY_ERR_FAIL; } -int32_t CellularDataService::QueryApnIds(ApnInfo apnInfo, std::vector &apnIdList) +int32_t CellularDataService::QueryApnIds(const ApnInfo& apnInfo, std::vector &apnIdList) { if (!TelephonyPermission::CheckPermission(Permission::MANAGE_APN_SETTING)) { TELEPHONY_LOGE("Permission denied!"); -- Gitee From d7fd38848b20913a9c4e33bdbe810e8a8d15f128 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E6=B3=BD=E5=87=A1?= Date: Tue, 15 Apr 2025 07:50:33 +0000 Subject: [PATCH 049/145] update frameworks/native/ICellularDataManager.idl. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 李泽凡 --- frameworks/native/ICellularDataManager.idl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/frameworks/native/ICellularDataManager.idl b/frameworks/native/ICellularDataManager.idl index f18e869b..80ce10a4 100644 --- a/frameworks/native/ICellularDataManager.idl +++ b/frameworks/native/ICellularDataManager.idl @@ -1,5 +1,5 @@ /* - * Copyright (c) 2024 Huawei Device Co., Ltd. + * Copyright (c) 2025 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 -- Gitee From 81f4756963a9166c481ace385e14ff5ebea0f061 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=BC=A0=E6=96=87=E6=9D=B0?= Date: Tue, 15 Apr 2025 10:10:14 +0000 Subject: [PATCH 050/145] preferences preferences MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 张文杰 --- test/BUILD.gn | 1 + 1 file changed, 1 insertion(+) diff --git a/test/BUILD.gn b/test/BUILD.gn index 42fc5749..2e737b04 100644 --- a/test/BUILD.gn +++ b/test/BUILD.gn @@ -66,6 +66,7 @@ ohos_unittest("tel_cellular_data_test") { "netmanager_base:net_conn_manager_if", "netmanager_base:net_policy_manager_if", "netmanager_base:net_stats_manager_if", + "preferences:native_preferences", "relational_store:native_dataability", "relational_store:native_rdb", "safwk:system_ability_fwk", -- Gitee From 84f8306fadf58f215e3789167f8d66aceb5edf24 Mon Sep 17 00:00:00 2001 From: benlau Date: Tue, 15 Apr 2025 22:04:57 +0800 Subject: [PATCH 051/145] =?UTF-8?q?=E5=90=8C=E5=90=8DAPN=20bug=20fix?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: benlau --- services/src/apn_manager/apn_item.cpp | 11 ++-- services/src/apn_manager/apn_manager.cpp | 5 ++ services/src/cellular_data_handler.cpp | 1 + services/src/state_machine/active.cpp | 8 +++ .../src/utils/cellular_data_rdb_helper.cpp | 13 +++-- test/apn_manager_test.cpp | 58 ++++++++++++++----- 6 files changed, 70 insertions(+), 26 deletions(-) diff --git a/services/src/apn_manager/apn_item.cpp b/services/src/apn_manager/apn_item.cpp index 0e8d62ca..144594ab 100644 --- a/services/src/apn_manager/apn_item.cpp +++ b/services/src/apn_manager/apn_item.cpp @@ -159,16 +159,13 @@ sptr ApnItem::BuildOtherApnAttributes(sptr &apnItem, const Pdp bool ApnItem::IsSimilarPdpProfile(const PdpProfile &newPdpProfile, const PdpProfile &oldPdpProfile) { return (newPdpProfile.apn == oldPdpProfile.apn) && - (newPdpProfile.authUser == oldPdpProfile.authUser) && (newPdpProfile.authPwd == oldPdpProfile.authPwd) && - (newPdpProfile.proxyIpAddress == oldPdpProfile.proxyIpAddress) && - (newPdpProfile.mmsIpAddress == oldPdpProfile.mmsIpAddress) && + IsSimilarProperty(newPdpProfile.proxyIpAddress, oldPdpProfile.proxyIpAddress) && IsSimilarProtocol(newPdpProfile.pdpProtocol, oldPdpProfile.pdpProtocol) && IsSimilarProtocol(newPdpProfile.roamPdpProtocol, oldPdpProfile.roamPdpProtocol) && + (newPdpProfile.mvnoType == oldPdpProfile.mvnoType) && + (newPdpProfile.mvnoMatchData == oldPdpProfile.mvnoMatchData) && IsSimilarProperty(newPdpProfile.homeUrl, oldPdpProfile.homeUrl) && - IsSimilarProperty(newPdpProfile.mmsIpAddress, oldPdpProfile.mmsIpAddress) && - (newPdpProfile.authType == oldPdpProfile.authType || - newPdpProfile.authType == static_cast(ApnAuthType::NONE) || - oldPdpProfile.authType == static_cast(ApnAuthType::NONE)); + IsSimilarProperty(newPdpProfile.mmsIpAddress, oldPdpProfile.mmsIpAddress); } bool ApnItem::IsSimilarProtocol(const std::string &newProtocol, const std::string &oldProtocol) diff --git a/services/src/apn_manager/apn_manager.cpp b/services/src/apn_manager/apn_manager.cpp index 563db38b..93f6bf7a 100644 --- a/services/src/apn_manager/apn_manager.cpp +++ b/services/src/apn_manager/apn_manager.cpp @@ -700,6 +700,9 @@ void ApnManager::MergePdpProfile(PdpProfile &newProfile, PdpProfile &oldProfile) { if (oldProfile.apnTypes.find(DATA_CONTEXT_ROLE_DEFAULT) != std::string::npos) { newProfile.authType = oldProfile.authType; + newProfile.authUser = oldProfile.authUser; + newProfile.authPwd = oldProfile.authPwd; + newProfile.server = oldProfile.server; } newProfile.apnTypes = newProfile.apnTypes + ',' + oldProfile.apnTypes; newProfile.pdpProtocol = (newProfile.pdpProtocol == PROTOCOL_IPV4V6) ? @@ -708,6 +711,8 @@ void ApnManager::MergePdpProfile(PdpProfile &newProfile, PdpProfile &oldProfile) newProfile.roamPdpProtocol : oldProfile.roamPdpProtocol; newProfile.homeUrl = newProfile.homeUrl.empty() ? oldProfile.homeUrl : newProfile.homeUrl; newProfile.mmsIpAddress = newProfile.mmsIpAddress.empty() ? oldProfile.mmsIpAddress : newProfile.mmsIpAddress; + newProfile.proxyIpAddress = newProfile.proxyIpAddress.empty() ? + oldProfile.proxyIpAddress : newProfile.proxyIpAddress; if (preferId_ == oldProfile.profileId) { TELEPHONY_LOGI("preferId change from %{public}d to %{public}d", oldProfile.profileId, newProfile.profileId); preferId_ = newProfile.profileId; diff --git a/services/src/cellular_data_handler.cpp b/services/src/cellular_data_handler.cpp index cba8fa29..7fc61b4b 100644 --- a/services/src/cellular_data_handler.cpp +++ b/services/src/cellular_data_handler.cpp @@ -812,6 +812,7 @@ bool CellularDataHandler::HandleCompatibleDataConnection( TELEPHONY_LOGI("Enter HandleCompatibleDataConnection"); int32_t oldApnId = ApnManager::FindApnIdByCapability(stateMachine->GetCapability()); int32_t newApnId = ApnManager::FindApnIdByCapability(apnHolder->GetCapability()); + apnHolder->ReleaseAllCellularData(); if (stateMachine->IsActiveState()) { TELEPHONY_LOGI("set reuse apnId[%{public}d] for apnId[%{public}d]", newApnId, oldApnId); stateMachine->SetReuseApnCap(apnHolder->GetCapability()); diff --git a/services/src/state_machine/active.cpp b/services/src/state_machine/active.cpp index a1929fec..d73323fc 100644 --- a/services/src/state_machine/active.cpp +++ b/services/src/state_machine/active.cpp @@ -118,6 +118,10 @@ bool Active::ProcessDisconnectAllDone(const AppExecFwk::InnerEvent::Pointer &eve TELEPHONY_LOGE("object is null"); return false; } + if (stateMachine->GetReuseApnCap() != NetManagerStandard::NetCap::NET_CAPABILITY_END) { + stateMachine->SetIfReuseSupplierId(false); + stateMachine->SetReuseApnCap(NetManagerStandard::NetCap::NET_CAPABILITY_END); + } DisConnectionReason reason = object->GetReason(); Inactive *inActive = static_cast(stateMachine->inActiveState_.GetRefPtr()); if (inActive == nullptr) { @@ -147,6 +151,10 @@ bool Active::ProcessLostConnection(const AppExecFwk::InnerEvent::Pointer &event) TELEPHONY_LOGE("stateMachine is null"); return false; } + if (stateMachine->GetReuseApnCap() != NetManagerStandard::NetCap::NET_CAPABILITY_END) { + stateMachine->SetIfReuseSupplierId(false); + stateMachine->SetReuseApnCap(NetManagerStandard::NetCap::NET_CAPABILITY_END); + } CellularDataHiSysEvent::WriteDataDeactiveBehaviorEvent(stateMachine->GetSlotId(), DataDisconnectCause::LOST_CONNECTION, ApnManager::FindApnNameByApnId(stateMachine->apnId_)); Inactive *inActive = static_cast(stateMachine->inActiveState_.GetRefPtr()); diff --git a/services/src/utils/cellular_data_rdb_helper.cpp b/services/src/utils/cellular_data_rdb_helper.cpp index 3bafeb46..d2958e1d 100644 --- a/services/src/utils/cellular_data_rdb_helper.cpp +++ b/services/src/utils/cellular_data_rdb_helper.cpp @@ -233,13 +233,10 @@ void CellularDataRdbHelper::MakePdpProfile( result->GetString(index, apnBean.apn); result->GetColumnIndex(PdpProfileData::AUTH_USER, index); result->GetString(index, apnBean.authUser); - int32_t authType; result->GetColumnIndex(PdpProfileData::AUTH_TYPE, index); - result->GetInt(index, authType); - if (authType == -1) { + result->GetInt(index, apnBean.authType); + if (apnBean.authType == -1) { apnBean.authType = (apnBean.authUser.empty()) ? SETUP_DATA_AUTH_NONE : SETUP_DATA_AUTH_PAP_CHAP; - } else { - apnBean.authType = authType; } result->GetColumnIndex(PdpProfileData::AUTH_PWD, index); result->GetString(index, apnBean.authPwd); @@ -263,6 +260,12 @@ void CellularDataRdbHelper::MakePdpProfile( if (apnBean.roamPdpProtocol.empty()) { apnBean.roamPdpProtocol = "IP"; } + result->GetColumnIndex(PdpProfileData::HOME_URL, index); + result->GetString(index, apnBean.homeUrl); + result->GetColumnIndex(PdpProfileData::MMS_IP_ADDRESS, index); + result->GetString(index, apnBean.mmsIpAddress); + result->GetColumnIndex(PdpProfileData::SERVER, index); + result->GetString(index, apnBean.server); } bool CellularDataRdbHelper::IsMvnoDataMatched(const std::string &mvnoDataFromSim, const PdpProfile &apnBean) diff --git a/test/apn_manager_test.cpp b/test/apn_manager_test.cpp index dacbcbb9..e125797f 100644 --- a/test/apn_manager_test.cpp +++ b/test/apn_manager_test.cpp @@ -1305,24 +1305,54 @@ HWTEST_F(ApnManagerTest, ApnItem_IsSimilarPdpProfile_001, TestSize.Level0) EXPECT_FALSE(ApnItem::IsSimilarPdpProfile(p1, p2)); p1.apn = ""; p2.apn = ""; - p1.authType = 1; - p2.authType = 2; + p1.proxyIpAddress = "1"; + p2.proxyIpAddress = ""; + EXPECT_TRUE(ApnItem::IsSimilarPdpProfile(p1, p2)); + p1.proxyIpAddress = ""; + p2.proxyIpAddress = "1"; + EXPECT_TRUE(ApnItem::IsSimilarPdpProfile(p1, p2)); + p1.proxyIpAddress = "1"; + p2.proxyIpAddress = "2"; EXPECT_FALSE(ApnItem::IsSimilarPdpProfile(p1, p2)); - p1.authType = 0; - p2.authType = 1; + p1.proxyIpAddress = ""; + p2.proxyIpAddress = ""; + p1.mvnoType = "1"; + p2.mvnoType = ""; + EXPECT_FALSE(ApnItem::IsSimilarPdpProfile(p1, p2)); +} + +/** + * @tc.name : ApnItem_IsSimilarPdpProfile_002 + * @tc.number: ApnItemTest_007 + */ +HWTEST_F(ApnManagerTest, ApnItem_IsSimilarPdpProfile_002, TestSize.Level0) +{ + PdpProfile p1; + PdpProfile p2; + p1.mvnoMatchData = "1"; + p2.mvnoMatchData = ""; + EXPECT_FALSE(ApnItem::IsSimilarPdpProfile(p1, p2)); + p1.mvnoMatchData = ""; + p2.mvnoMatchData = ""; + p1.homeUrl = "1"; + p2.homeUrl = ""; EXPECT_TRUE(ApnItem::IsSimilarPdpProfile(p1, p2)); - p1.authType = 1; - p2.authType = 0; + p1.homeUrl = ""; + p2.homeUrl = "1"; EXPECT_TRUE(ApnItem::IsSimilarPdpProfile(p1, p2)); - p1.authType = 1; - p2.authType = 1; - p1.authUser = "1"; - p2.authUser = "2"; + p1.homeUrl = "1"; + p2.homeUrl = "2"; EXPECT_FALSE(ApnItem::IsSimilarPdpProfile(p1, p2)); - p1.authUser = "1"; - p2.authUser = "1"; - p1.authPwd = "1"; - p2.authPwd = "2"; + p1.homeUrl = ""; + p2.homeUrl = ""; + p1.mmsIpAddress = "1"; + p2.mmsIpAddress = ""; + EXPECT_TRUE(ApnItem::IsSimilarPdpProfile(p1, p2)); + p1.mmsIpAddress = ""; + p2.mmsIpAddress = "1"; + EXPECT_TRUE(ApnItem::IsSimilarPdpProfile(p1, p2)); + p1.mmsIpAddress = "1"; + p2.mmsIpAddress = "2"; EXPECT_FALSE(ApnItem::IsSimilarPdpProfile(p1, p2)); } -- Gitee From 8fa7a483e5cbc2de56e5dcf37ab6f7d4a2cf674c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=BC=A0=E6=96=87=E6=9D=B0?= Date: Wed, 16 Apr 2025 10:01:56 +0000 Subject: [PATCH 052/145] update test/BUILD.gn. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 张文杰 --- test/BUILD.gn | 1 + 1 file changed, 1 insertion(+) diff --git a/test/BUILD.gn b/test/BUILD.gn index 2e737b04..cc70f790 100644 --- a/test/BUILD.gn +++ b/test/BUILD.gn @@ -328,6 +328,7 @@ ohos_unittest("tel_cellular_data_traffic_test") { "netmanager_base:net_conn_manager_if", "netmanager_base:net_policy_manager_if", "netmanager_base:net_stats_manager_if", + "preferences:native_preferences", "relational_store:native_dataability", "relational_store:native_rdb", "safwk:system_ability_fwk", -- Gitee From 6aa6fa39049190cd932e8f9e79c4cf42d6dd8ac9 Mon Sep 17 00:00:00 2001 From: cavalier Date: Wed, 16 Apr 2025 18:44:02 +0800 Subject: [PATCH 053/145] fix activate pdp failed Signed-off-by: cavalier --- services/src/cellular_data_handler.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/services/src/cellular_data_handler.cpp b/services/src/cellular_data_handler.cpp index 7fc61b4b..640f3119 100644 --- a/services/src/cellular_data_handler.cpp +++ b/services/src/cellular_data_handler.cpp @@ -947,6 +947,8 @@ void CellularDataHandler::UpdateApnInfo(const int32_t profileId) int32_t profileIdValue = 0; if (!GetCurrentDataShareApnInfo(dataShareHelper, simId, profileIdValue)) { TELEPHONY_LOGE("GetCurrentDataShareApnInfo fail."); + dataShareHelper->Release(); + return; } if (profileIdValue != profileId) { DataShare::DataSharePredicates predicates; -- Gitee From 7759d098db4f456af0f28a12e94094ec88a5f13d Mon Sep 17 00:00:00 2001 From: HuuuuDaxia <2443930064@qq.com> Date: Thu, 17 Apr 2025 17:41:15 +0800 Subject: [PATCH 054/145] deactivate cellular Signed-off-by: HuuuuDaxia <2443930064@qq.com> --- services/include/apn_manager/apn_holder.h | 1 + services/include/cellular_data_handler.h | 3 ++ services/src/apn_manager/apn_holder.cpp | 8 ++- services/src/cellular_data_handler.cpp | 30 ++++++++--- .../include/telephony_ext_wrapper.h | 5 ++ .../src/telephony_ext_wrapper.cpp | 12 +++++ test/cellular_data_handler_test.cpp | 52 +++++++++++++++++++ 7 files changed, 104 insertions(+), 7 deletions(-) diff --git a/services/include/apn_manager/apn_holder.h b/services/include/apn_manager/apn_holder.h index 68ea52e7..d729545d 100644 --- a/services/include/apn_manager/apn_holder.h +++ b/services/include/apn_manager/apn_holder.h @@ -68,6 +68,7 @@ public: void RemoveUid(uint32_t uid); HasSystemUse GetUidStatus() const; void SetApnBadState(bool isBad); + bool IsReqUidsEmpty(); private: ApnHolder(ApnHolder &apnHolder) = default; diff --git a/services/include/cellular_data_handler.h b/services/include/cellular_data_handler.h index ed1e9a80..af812932 100644 --- a/services/include/cellular_data_handler.h +++ b/services/include/cellular_data_handler.h @@ -84,6 +84,9 @@ public: void ReleaseCellularDataConnection(); bool UpdateNetworkInfo(); bool IsSupportDunApn(); + void ConnectIfNeed( + const AppExecFwk::InnerEvent::Pointer &event, sptr apnHolder, const NetRequest &request); + ApnActivateReportInfo GetDefaultActReportInfo(); ApnActivateReportInfo GetInternalActReportInfo(); diff --git a/services/src/apn_manager/apn_holder.cpp b/services/src/apn_manager/apn_holder.cpp index 0264cb73..18554028 100644 --- a/services/src/apn_manager/apn_holder.cpp +++ b/services/src/apn_manager/apn_holder.cpp @@ -70,11 +70,16 @@ sptr ApnHolder::GetCurrentApn() const { return apnItem_; } - +bool ApnHolder::IsReqUidsEmpty() +{ + std::shared_lock lock(reqUidsMutex_); + return reqUids_.empty(); +} void ApnHolder::AddUid(uint32_t uid) { std::unique_lock lock(reqUidsMutex_); if (reqUids_.find(uid) != reqUids_.end()) { + TELEPHONY_LOGI("apnholder add uid %{public}u", uid); return; } reqUids_.insert(uid); @@ -86,6 +91,7 @@ void ApnHolder::RemoveUid(uint32_t uid) auto it = reqUids_.find(uid); if (it != reqUids_.end()) { reqUids_.erase(it); + TELEPHONY_LOGI("apnholder erase uid %{public}u", uid); return; } } diff --git a/services/src/cellular_data_handler.cpp b/services/src/cellular_data_handler.cpp index 640f3119..9e5085cb 100644 --- a/services/src/cellular_data_handler.cpp +++ b/services/src/cellular_data_handler.cpp @@ -1182,7 +1182,21 @@ void CellularDataHandler::SendEstablishDataConnectionEvent(int32_t id) TELEPHONY_LOGE("Slot%{public}d: send data connection event failed", slotId_); } } - +void CellularDataHandler::ConnectIfNeed( + const InnerEvent::Pointer &event, sptr apnHolder, const NetRequest &request) +{ + if (event == nullptr || apnHolder == nullptr) { + return; + } + if (event->GetParam() == TYPE_REQUEST_NET) { + TELEPHONY_LOGI("try to activate Cellular"); + apnHolder->RequestCellularData(request); + int32_t id = ApnManager::FindApnIdByCapability(request.capability); + SendEstablishDataConnectionEvent(id); + return; + } + return; +} void CellularDataHandler::MsgRequestNetwork(const InnerEvent::Pointer &event) { if (apnManager_ == nullptr || event == nullptr) { @@ -1202,8 +1216,13 @@ void CellularDataHandler::MsgRequestNetwork(const InnerEvent::Pointer &event) TELEPHONY_LOGE("Slot%{public}d: apnHolder is null.", slotId_); return; } - + WriteEventCellularRequest(request, event->GetParam()); #ifdef OHOS_BUILD_ENABLE_TELEPHONY_EXT + if (TELEPHONY_EXT_WRAPPER.judgeOtherRequestHolding_ && + TELEPHONY_EXT_WRAPPER.judgeOtherRequestHolding_(request, apnHolder->GetUidStatus())) { + ConnectIfNeed(event, apnHolder, request); + return; + } if (IsSimRequestNetOnVSimEnabled(event->GetParam(), apnHolder->IsMmsType())) { return; } @@ -1216,15 +1235,14 @@ void CellularDataHandler::MsgRequestNetwork(const InnerEvent::Pointer &event) TELEPHONY_EXT_WRAPPER.isAllCellularDataAllowed_(request, apnHolder->GetUidStatus()); } #endif - WriteEventCellularRequest(request, event->GetParam()); if (isAllCellularDataAllowed) { TELEPHONY_LOGD("allow cellular data"); if (event->GetParam() == TYPE_REQUEST_NET) { apnHolder->RequestCellularData(request); } else { - if (!apnHolder->ReleaseCellularData(request)) { - return; - } + if (apnHolder->IsReqUidsEmpty()) { + apnHolder->ReleaseAllCellularData(); + } } } else { if (event->GetParam() == TYPE_REQUEST_NET) { diff --git a/services/telephony_ext_wrapper/include/telephony_ext_wrapper.h b/services/telephony_ext_wrapper/include/telephony_ext_wrapper.h index 7b972a5d..a59cb3e4 100644 --- a/services/telephony_ext_wrapper/include/telephony_ext_wrapper.h +++ b/services/telephony_ext_wrapper/include/telephony_ext_wrapper.h @@ -51,6 +51,8 @@ public: typedef void (*RESTART_RADIO_IF_RQUIRED)(int32_t, int32_t); typedef bool (*GET_USER_DATA_ROAMING_EXPEND)(int32_t, bool); typedef void (*SEND_APN_NEED_RETRY_INFO)(int32_t); + typedef bool (*JUDGE_OTHER_REQUEST_HOLDING)(const NetRequest &, const HasSystemUse hasSystemUse); + DATA_EDN_SELF_CURE dataEndSelfCure_ = nullptr; IS_APN_ALLOWED_ACTIVE isApnAllowedActive_ = nullptr; GET_VSIM_SLOT_ID getVSimSlotId_ = nullptr; @@ -66,6 +68,8 @@ public: HANDLE_DEND_FAILCAUSE handleDendFailcause_ = nullptr; CONVERT_PDP_ERROR convertPdpError_ = nullptr; RESTART_RADIO_IF_RQUIRED restartRadioIfRequired_ = nullptr; + JUDGE_OTHER_REQUEST_HOLDING judgeOtherRequestHolding_ = nullptr; + private: void* telephonyExtWrapperHandle_ = nullptr; void* telephonyVSimWrapperHandle_ = nullptr; @@ -81,6 +85,7 @@ private: void InitConvertPdpError(); void InitRestartRadioIfRequired(); void InitSendApnNeedRetryInfo(); + void InitJudgeOtherRequestHolding(); }; #define TELEPHONY_EXT_WRAPPER ::OHOS::DelayedRefSingleton::GetInstance() diff --git a/services/telephony_ext_wrapper/src/telephony_ext_wrapper.cpp b/services/telephony_ext_wrapper/src/telephony_ext_wrapper.cpp index fdee092c..d88fae80 100644 --- a/services/telephony_ext_wrapper/src/telephony_ext_wrapper.cpp +++ b/services/telephony_ext_wrapper/src/telephony_ext_wrapper.cpp @@ -62,6 +62,18 @@ void TelephonyExtWrapper::InitTelephonyExtWrapperForCellularData() InitConvertPdpError(); InitRestartRadioIfRequired(); InitSendApnNeedRetryInfo(); + InitJudgeOtherRequestHolding(); +} + +void TelephonyExtWrapper::InitJudgeOtherRequestHolding() +{ + judgeOtherRequestHolding_ = + (JUDGE_OTHER_REQUEST_HOLDING)dlsym(telephonyExtWrapperHandle_, "JudgeOtherRequestHolding"); + if (judgeOtherRequestHolding_ == nullptr) { + TELEPHONY_LOGE("telephony ext wrapper symbol JudgeOtherRequestHolding failed, error: %{public}s", dlerror()); + return; + } + TELEPHONY_LOGD("telephony ext wrapper init JudgeOtherRequestHolding success"); } void TelephonyExtWrapper::InitDataEndSelfCure() diff --git a/test/cellular_data_handler_test.cpp b/test/cellular_data_handler_test.cpp index f1dac62b..dbe4cdfe 100644 --- a/test/cellular_data_handler_test.cpp +++ b/test/cellular_data_handler_test.cpp @@ -1014,5 +1014,57 @@ HWTEST_F(CellularDataHandlerTest, Telephony_CellularDataHandler_002, Function | controller.cellularDataHandler_ = nullptr; EXPECT_FALSE(controller.RemoveUid(request)); } + +/** + * @tc.number Telephony_MsgRequest + * @tc.name test error branch + * @tc.desc Function test + */ +HWTEST_F(CellularDataHandlerTest, Telephony_MsgRequest, Function | MediumTest | Level1) +{ + EventFwk::MatchingSkills matchingSkills; + matchingSkills.AddEvent(EventFwk::CommonEventSupport::COMMON_EVENT_CALL_STATE_CHANGED); + EventFwk::CommonEventSubscribeInfo subscriberInfo(matchingSkills); + auto cellularDataHandler = std::make_shared(subscriberInfo, 0); + cellularDataHandler->Init(); + NetRequest request1; + request1.capability = NetManagerStandard::NET_CAPABILITY_INTERNET; + request1.registerType = REGISTER; + + EXPECT_TRUE(cellularDataHandler->RequestNet(request1)); + NetRequest request2; + request2.capability = NetManagerStandard::NET_CAPABILITY_INTERNET; + request2.registerType = REQUEST; + EXPECT_TRUE(cellularDataHandler->RequestNet(request2)); + auto apnHolder = + cellularDataHandler->apnManager_->FindApnHolderById(ApnManager::FindApnIdByCapability(request1.capability)); + + sleep(2); +} +/** + * @tc.number Telephony_ConnectIfNeed + * @tc.name test error branch + * @tc.desc Function test + */ +HWTEST_F(CellularDataHandlerTest, Telephony_ConnectIfNeed, Function | MediumTest | Level1) +{ + EventFwk::MatchingSkills matchingSkills; + matchingSkills.AddEvent(EventFwk::CommonEventSupport::COMMON_EVENT_CALL_STATE_CHANGED); + EventFwk::CommonEventSubscribeInfo subscriberInfo(matchingSkills); + auto cellularDataHandler = std::make_shared(subscriberInfo, 0); + cellularDataHandler->Init(); + + NetRequest request1; + request1.capability = NetManagerStandard::NET_CAPABILITY_INTERNET; + request1.registerType = REQUEST; + EXPECT_TRUE(cellularDataHandler->RequestNet(request1)); + auto event1 = AppExecFwk::InnerEvent::Get(CellularDataEventCode::MSG_REQUEST_NETWORK, TYPE_REQUEST_NET); + auto apnHolder = + cellularDataHandler->apnManager_->FindApnHolderById(ApnManager::FindApnIdByCapability(request1.capability)); + cellularDataHandler->ConnectIfNeed(event1, apnHolder, request1); + auto event2 = AppExecFwk::InnerEvent::Get(CellularDataEventCode::MSG_REQUEST_NETWORK, TYPE_RELEASE_NET); + cellularDataHandler->ConnectIfNeed(event2, apnHolder, request1); + cellularDataHandler->ConnectIfNeed(event2, nullptr, request1); +} } // namespace Telephony } // namespace OHOS \ No newline at end of file -- Gitee From 825238ca62d7ec339bcb6d18fb2e35ff6c4be038 Mon Sep 17 00:00:00 2001 From: HuuuuDaxia <2443930064@qq.com> Date: Thu, 17 Apr 2025 11:13:31 +0000 Subject: [PATCH 055/145] add Signed-off-by: HuuuuDaxia <2443930064@qq.com> --- services/src/cellular_data_handler.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/services/src/cellular_data_handler.cpp b/services/src/cellular_data_handler.cpp index 9e5085cb..9d10407e 100644 --- a/services/src/cellular_data_handler.cpp +++ b/services/src/cellular_data_handler.cpp @@ -1242,7 +1242,7 @@ void CellularDataHandler::MsgRequestNetwork(const InnerEvent::Pointer &event) } else { if (apnHolder->IsReqUidsEmpty()) { apnHolder->ReleaseAllCellularData(); - } + } } } else { if (event->GetParam() == TYPE_REQUEST_NET) { -- Gitee From 9be09e431aa5fded0be74a5db1660871cd28250e Mon Sep 17 00:00:00 2001 From: HuuuuDaxia <2443930064@qq.com> Date: Thu, 17 Apr 2025 11:31:19 +0000 Subject: [PATCH 056/145] add Signed-off-by: HuuuuDaxia <2443930064@qq.com> --- test/cellular_data_handler_test.cpp | 3 --- 1 file changed, 3 deletions(-) diff --git a/test/cellular_data_handler_test.cpp b/test/cellular_data_handler_test.cpp index dbe4cdfe..5495a600 100644 --- a/test/cellular_data_handler_test.cpp +++ b/test/cellular_data_handler_test.cpp @@ -1036,9 +1036,6 @@ HWTEST_F(CellularDataHandlerTest, Telephony_MsgRequest, Function | MediumTest | request2.capability = NetManagerStandard::NET_CAPABILITY_INTERNET; request2.registerType = REQUEST; EXPECT_TRUE(cellularDataHandler->RequestNet(request2)); - auto apnHolder = - cellularDataHandler->apnManager_->FindApnHolderById(ApnManager::FindApnIdByCapability(request1.capability)); - sleep(2); } /** -- Gitee From 6f2baf3cd6bcd6d08aa3dddadf6e69cad28454be Mon Sep 17 00:00:00 2001 From: HuuuuDaxia <2443930064@qq.com> Date: Fri, 18 Apr 2025 03:12:39 +0000 Subject: [PATCH 057/145] add Signed-off-by: HuuuuDaxia <2443930064@qq.com> --- services/src/apn_manager/apn_holder.cpp | 2 ++ services/src/cellular_data_handler.cpp | 4 ++-- test/cellular_data_handler_test.cpp | 1 + 3 files changed, 5 insertions(+), 2 deletions(-) diff --git a/services/src/apn_manager/apn_holder.cpp b/services/src/apn_manager/apn_holder.cpp index 18554028..af50a9cb 100644 --- a/services/src/apn_manager/apn_holder.cpp +++ b/services/src/apn_manager/apn_holder.cpp @@ -70,11 +70,13 @@ sptr ApnHolder::GetCurrentApn() const { return apnItem_; } + bool ApnHolder::IsReqUidsEmpty() { std::shared_lock lock(reqUidsMutex_); return reqUids_.empty(); } + void ApnHolder::AddUid(uint32_t uid) { std::unique_lock lock(reqUidsMutex_); diff --git a/services/src/cellular_data_handler.cpp b/services/src/cellular_data_handler.cpp index 9d10407e..8fdf29e3 100644 --- a/services/src/cellular_data_handler.cpp +++ b/services/src/cellular_data_handler.cpp @@ -1182,6 +1182,7 @@ void CellularDataHandler::SendEstablishDataConnectionEvent(int32_t id) TELEPHONY_LOGE("Slot%{public}d: send data connection event failed", slotId_); } } + void CellularDataHandler::ConnectIfNeed( const InnerEvent::Pointer &event, sptr apnHolder, const NetRequest &request) { @@ -1193,10 +1194,9 @@ void CellularDataHandler::ConnectIfNeed( apnHolder->RequestCellularData(request); int32_t id = ApnManager::FindApnIdByCapability(request.capability); SendEstablishDataConnectionEvent(id); - return; } - return; } + void CellularDataHandler::MsgRequestNetwork(const InnerEvent::Pointer &event) { if (apnManager_ == nullptr || event == nullptr) { diff --git a/test/cellular_data_handler_test.cpp b/test/cellular_data_handler_test.cpp index 5495a600..5ee3e8c0 100644 --- a/test/cellular_data_handler_test.cpp +++ b/test/cellular_data_handler_test.cpp @@ -1038,6 +1038,7 @@ HWTEST_F(CellularDataHandlerTest, Telephony_MsgRequest, Function | MediumTest | EXPECT_TRUE(cellularDataHandler->RequestNet(request2)); sleep(2); } + /** * @tc.number Telephony_ConnectIfNeed * @tc.name test error branch -- Gitee From 4c992a9d435c43fab8e6b5c0b0bda4c648581cff Mon Sep 17 00:00:00 2001 From: xhttt123 <2317512661@qq.com> Date: Fri, 18 Apr 2025 09:10:02 +0000 Subject: [PATCH 058/145] update test/mock/mock_core_service.h. Signed-off-by: xhttt123 <2317512661@qq.com> --- test/mock/mock_core_service.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/mock/mock_core_service.h b/test/mock/mock_core_service.h index 9cd7528f..ffb3c9b7 100644 --- a/test/mock/mock_core_service.h +++ b/test/mock/mock_core_service.h @@ -41,7 +41,7 @@ public: MOCK_METHOD( int32_t, SetRadioState, (int32_t slotId, bool isOn, const sptr &callback), (override)); MOCK_METHOD(int32_t, GetRadioState, (int32_t slotId, const sptr &callback), (override)); - MOCK_METHOD(int32_t, GetImei, (int32_t slotId, std::u16string &imei), (override)); + MOCK_METHOD(int32_t, GetImei, (int32_t slotId, const sptr &callback), (override)); MOCK_METHOD(int32_t, GetImeiSv, (int32_t slotId, std::u16string &imeiSv), (override)); MOCK_METHOD(int32_t, GetMeid, (int32_t slotId, std::u16string &meid), (override)); MOCK_METHOD(int32_t, GetUniqueDeviceId, (int32_t slotId, std::u16string &deviceId), (override)); -- Gitee From 60f2b8a22e51b31704bdc55c8da270b359989da7 Mon Sep 17 00:00:00 2001 From: xhttt123 <2317512661@qq.com> Date: Fri, 18 Apr 2025 09:16:46 +0000 Subject: [PATCH 059/145] update test/mock/mock_network_search.h. Signed-off-by: xhttt123 <2317512661@qq.com> --- test/mock/mock_network_search.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/mock/mock_network_search.h b/test/mock/mock_network_search.h index ae9c4e76..2ae5939e 100644 --- a/test/mock/mock_network_search.h +++ b/test/mock/mock_network_search.h @@ -58,7 +58,7 @@ public: MOCK_METHOD1(GetPsRegState, int32_t(int32_t slotId)); MOCK_METHOD1(GetCsRegState, int32_t(int32_t slotId)); MOCK_METHOD1(GetPsRoamingState, int32_t(int32_t slotId)); - MOCK_METHOD2(GetImei, int32_t(int32_t slotId, std::u16string &imei)); + MOCK_METHOD2(GetImei, int32_t(int32_t slotId, const sptr &callback)); MOCK_METHOD2(GetImeiSv, int32_t(int32_t slotId, std::u16string &imeiSv)); MOCK_METHOD3(GetImsRegStatus, int32_t(int32_t slotId, ImsServiceType imsSrvType, ImsRegInfo &info)); MOCK_METHOD2(GetCellInfoList, int32_t(int32_t slotId, std::vector> &cellInfo)); -- Gitee From 618bc3ebb4b08193a38ff02203da73566e0880fa Mon Sep 17 00:00:00 2001 From: xhttt123 <2317512661@qq.com> Date: Fri, 18 Apr 2025 09:34:31 +0000 Subject: [PATCH 060/145] update test/mock/mock_network_search.h. Signed-off-by: xhttt123 <2317512661@qq.com> --- test/mock/mock_network_search.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/mock/mock_network_search.h b/test/mock/mock_network_search.h index 2ae5939e..ae9c4e76 100644 --- a/test/mock/mock_network_search.h +++ b/test/mock/mock_network_search.h @@ -58,7 +58,7 @@ public: MOCK_METHOD1(GetPsRegState, int32_t(int32_t slotId)); MOCK_METHOD1(GetCsRegState, int32_t(int32_t slotId)); MOCK_METHOD1(GetPsRoamingState, int32_t(int32_t slotId)); - MOCK_METHOD2(GetImei, int32_t(int32_t slotId, const sptr &callback)); + MOCK_METHOD2(GetImei, int32_t(int32_t slotId, std::u16string &imei)); MOCK_METHOD2(GetImeiSv, int32_t(int32_t slotId, std::u16string &imeiSv)); MOCK_METHOD3(GetImsRegStatus, int32_t(int32_t slotId, ImsServiceType imsSrvType, ImsRegInfo &info)); MOCK_METHOD2(GetCellInfoList, int32_t(int32_t slotId, std::vector> &cellInfo)); -- Gitee From 19d8683544c3cace06096a495178497f33c405be Mon Sep 17 00:00:00 2001 From: wwz99 Date: Mon, 21 Apr 2025 08:49:41 +0000 Subject: [PATCH 061/145] update services/include/cellular_data_handler.h. Signed-off-by: wwz99 --- services/include/cellular_data_handler.h | 1 + 1 file changed, 1 insertion(+) diff --git a/services/include/cellular_data_handler.h b/services/include/cellular_data_handler.h index af812932..5dc7ac27 100644 --- a/services/include/cellular_data_handler.h +++ b/services/include/cellular_data_handler.h @@ -162,6 +162,7 @@ private: void HandleEstablishAllApnsIfConnectable(const AppExecFwk::InnerEvent::Pointer &event); #ifdef OHOS_BUILD_ENABLE_TELEPHONY_EXT bool IsSimRequestNetOnVSimEnabled(int32_t reqType, bool isMmsType) const; + bool NotifyReqCellularData(bool isCellularDataRequested); #endif void SetNetRequest(NetRequest &request, const std::unique_ptr &netRequest); void SendEstablishDataConnectionEvent(int32_t id); -- Gitee From 16ef2b97ebdbc1828637743f9bbba8e7af909740 Mon Sep 17 00:00:00 2001 From: wwz99 Date: Mon, 21 Apr 2025 09:04:37 +0000 Subject: [PATCH 062/145] update services/src/cellular_data_handler.cpp. Signed-off-by: wwz99 --- services/src/cellular_data_handler.cpp | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/services/src/cellular_data_handler.cpp b/services/src/cellular_data_handler.cpp index 8fdf29e3..bf081a47 100644 --- a/services/src/cellular_data_handler.cpp +++ b/services/src/cellular_data_handler.cpp @@ -1025,6 +1025,8 @@ void CellularDataHandler::DisconnectDataComplete(const InnerEvent::Pointer &even UpdatePhysicalConnectionState(connectionManager_->isNoActiveConnection()); if (apnHolder->IsDataCallEnabled()) { RetryOrClearConnection(apnHolder, reason, netInfo); + } else { + NotifyReqCellularData(false); } if (!apnManager_->HasAnyConnectedState()) { connectionManager_->StopStallDetectionTimer(); @@ -1053,6 +1055,7 @@ void CellularDataHandler::RetryOrClearConnection(const sptr &apnHolde if (reason == DisConnectionReason::REASON_CLEAR_CONNECTION) { TELEPHONY_LOGI("clear connection"); ClearConnection(apnHolder, reason); + NotifyReqCellularData(false); } else if (reason == DisConnectionReason::REASON_PERMANENT_REJECT) { TELEPHONY_LOGI("permannent reject, mark bad and clear connection"); apnHolder->SetApnBadState(true); @@ -1164,6 +1167,16 @@ bool CellularDataHandler::IsSimRequestNetOnVSimEnabled(int32_t reqType, bool isM } return false; } + +bool CellularDataHandler::NotifyReqCellularData(bool isCellularDataRequested) +{ + if (TELEPHONY_EXT_WRAPPER.dynamicLoadNotifyReqCellularDataStatus_) { + TELEPHONY_EXT_WRAPPER.dynamicLoadNotifyReqCellularDataStatus_(isCellularDataRequested); + TELEPHONY_LOGE("NotifyReqCellularData isCellularDataRequested %{public}d", isCellularDataRequested); + return true; + } + return false; +} #endif void CellularDataHandler::SetNetRequest(NetRequest &request, const std::unique_ptr &netRequest) @@ -1239,10 +1252,14 @@ void CellularDataHandler::MsgRequestNetwork(const InnerEvent::Pointer &event) TELEPHONY_LOGD("allow cellular data"); if (event->GetParam() == TYPE_REQUEST_NET) { apnHolder->RequestCellularData(request); +#ifdef OHOS_BUILD_ENABLE_TELEPHONY_EXT + NotifyReqCellularData(true); +#endif } else { if (apnHolder->IsReqUidsEmpty()) { apnHolder->ReleaseAllCellularData(); } + NotifyReqCellularData(false); } } else { if (event->GetParam() == TYPE_REQUEST_NET) { @@ -2571,6 +2588,9 @@ void CellularDataHandler::ReleaseCellularDataConnection() return; } ClearConnection(apnHolder, DisConnectionReason::REASON_CLEAR_CONNECTION); +#ifdef OHOS_BUILD_ENABLE_TELEPHONY_EXT + NotifyReqCellularData(false); +#endif } bool CellularDataHandler::UpdateNetworkInfo() -- Gitee From 0a813a4fc09214a014551dc660b72e29542616aa Mon Sep 17 00:00:00 2001 From: wwz99 Date: Mon, 21 Apr 2025 09:05:55 +0000 Subject: [PATCH 063/145] update services/telephony_ext_wrapper/include/telephony_ext_wrapper.h. Signed-off-by: wwz99 --- services/telephony_ext_wrapper/include/telephony_ext_wrapper.h | 1 + 1 file changed, 1 insertion(+) diff --git a/services/telephony_ext_wrapper/include/telephony_ext_wrapper.h b/services/telephony_ext_wrapper/include/telephony_ext_wrapper.h index a59cb3e4..86629459 100644 --- a/services/telephony_ext_wrapper/include/telephony_ext_wrapper.h +++ b/services/telephony_ext_wrapper/include/telephony_ext_wrapper.h @@ -73,6 +73,7 @@ public: private: void* telephonyExtWrapperHandle_ = nullptr; void* telephonyVSimWrapperHandle_ = nullptr; + void* telephonyDynamicLoadWrapperHandle_ = nullptr; void InitTelephonyExtWrapperForCellularData(); void InitDataEndSelfCure(); -- Gitee From 74763f75610f1513bc1da7a3ca0f9ab06a082137 Mon Sep 17 00:00:00 2001 From: wwz99 Date: Mon, 21 Apr 2025 09:12:54 +0000 Subject: [PATCH 064/145] update services/telephony_ext_wrapper/src/telephony_ext_wrapper.cpp. Signed-off-by: wwz99 --- .../src/telephony_ext_wrapper.cpp | 28 +++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/services/telephony_ext_wrapper/src/telephony_ext_wrapper.cpp b/services/telephony_ext_wrapper/src/telephony_ext_wrapper.cpp index d88fae80..3ea9186b 100644 --- a/services/telephony_ext_wrapper/src/telephony_ext_wrapper.cpp +++ b/services/telephony_ext_wrapper/src/telephony_ext_wrapper.cpp @@ -22,6 +22,7 @@ namespace Telephony { namespace { const std::string TELEPHONY_EXT_WRAPPER_PATH = "libtelephony_ext_service.z.so"; const std::string TELEPHONY_VSIM_WRAPPER_PATH = "libtel_vsim_symbol.z.so"; +const std::string TELEPHONY_DYNAMIC_LOAD_WRAPPER_PATH = "libtel_dynamic_load_service.z.so"; } // namespace TelephonyExtWrapper::TelephonyExtWrapper() {} @@ -36,10 +37,15 @@ TelephonyExtWrapper::~TelephonyExtWrapper() dlclose(telephonyVSimWrapperHandle_); telephonyVSimWrapperHandle_ = nullptr; } + if (telephonyDynamicLoadWrapperHandle_ != nullptr) { + dlclose(telephonyDynamicLoadWrapperHandle_); + telephonyDynamicLoadWrapperHandle_ = nullptr; + } } void TelephonyExtWrapper::InitTelephonyExtWrapper() { + InitTelephonyExtWrapperForDynamicLoad(); TELEPHONY_LOGD("TelephonyExtWrapper::InitTelephonyExtWrapper() start"); InitTelephonyExtWrapperForCellularData(); InitTelephonyExtWrapperForVSim(); @@ -190,5 +196,27 @@ void TelephonyExtWrapper::InitSendApnNeedRetryInfo() TELEPHONY_LOGD("telephony ext wrapper init SendApnNeedRetryInfo success"); } +void TelephonyExtWrapper::InitTelephonyExtWrapperForDynamicLoad() +{ + TELEPHONY_LOGI("[DynamicLoad]telephony ext wrapper dynamic load init begin"); + telephonyDynamicLoadWrapperHandle_ = dlopen(TELEPHONY_DYNAMIC_LOAD_WRAPPER_PATH.c_str(), RTLD_NOW); + if (telephonyDynamicLoadWrapperHandle_ == nullptr) { + TELEPHONY_LOGE("[DynamicLoad] libtel_dynamic_load_service.z.so was not loaded, error: %{public}s", dlerror()); + return; + } + dynamicLoadInit_ = (DynamicLoadInit)dlsym(telephonyDynamicLoadWrapperHandle_, "InitDynamicLoadHandle"); + if (dynamicLoadInit_ == nullptr) { + TELEPHONY_LOGE("[DynamicLoad] telephony ext wrapper symbol failed, error: %{public}s", dlerror()); + return; + } + dynamicLoadNotifyReqCellularDataStatus_ = + (NotifyReqCellularData)dlsym(telephonyDynamicLoadWrapperHandle_, "InformReqCellularDataStatus"); + if (dynamicLoadNotifyReqCellularDataStatus_ == nullptr) { + TELEPHONY_LOGE("[DynamicLoad] telephony ext wrapper dynamicLoadNotifyReqCellularDataStatus_ symbol failed,\ + error: %{public}s", dlerror()); + return; + } + TELEPHONY_LOGI("[DynamicLoad]telephony ext wrapper dynamic load init success"); +} } // namespace Telephony } // namespace OHOS \ No newline at end of file -- Gitee From 1f5b3824358744b72a86ea7c4d69400cd0601553 Mon Sep 17 00:00:00 2001 From: wwz99 Date: Mon, 21 Apr 2025 09:29:38 +0000 Subject: [PATCH 065/145] update test/cellular_data_handler_branch_test.cpp. Signed-off-by: wwz99 --- test/cellular_data_handler_branch_test.cpp | 24 ++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/test/cellular_data_handler_branch_test.cpp b/test/cellular_data_handler_branch_test.cpp index f6d1e99f..4b55faac 100644 --- a/test/cellular_data_handler_branch_test.cpp +++ b/test/cellular_data_handler_branch_test.cpp @@ -216,6 +216,30 @@ HWTEST_F(CellularDataHandlerBranchTest, DisconnectDataComplete_001, Function | M ASSERT_EQ(event->GetSharedObject(), nullptr); } +HWTEST_F(CellularDataHandlerBranchTest, DisconnectDataComplete_002, Function | MediumTest | Level3) +{ + EventFwk::MatchingSkills matchingSkills; + matchingSkills.AddEvent(EventFwk::CommonEventSupport::COMMON_EVENT_CALL_STATE_CHANGED); + EventFwk::CommonEventSubscribeInfo subscriberInfo(matchingSkills); + auto cellularDataHandler = std::make_shared(subscriberInfo, 2); + cellularDataHandler->Init(); + + std::shared_ptr resultInfo = std::make_shared(); + resultInfo->flag = 2; + auto event = AppExecFwk::InnerEvent::Get(0, resultInfo); + sptr apnHolder = cellularDataHandler->apnManager_->FindApnHolderById(2); + sptr connectionManager = std::make_unique(0).release(); + if (connectionManager == nullptr) { + return; + } + connectionManager->Init(); + std::shared_ptr cellularDataStateMachine = + std::make_shared(connectionManager, cellularDataHandler); + apnHolder->SetCellularDataStateMachine(cellularDataStateMachine); + cellularDataHandler->DisconnectDataComplete(event); + ASSERT_EQ(event->GetSharedObject(), resultInfo); +} + HWTEST_F(CellularDataHandlerBranchTest, UpdatePhysicalConnectionState_001, Function | MediumTest | Level3) { EventFwk::MatchingSkills matchingSkills; -- Gitee From 895556c7dafa12aa63d7da7a8219936e45ac2eb7 Mon Sep 17 00:00:00 2001 From: wwz99 Date: Mon, 21 Apr 2025 11:28:55 +0000 Subject: [PATCH 066/145] update services/telephony_ext_wrapper/include/telephony_ext_wrapper.h. Signed-off-by: wwz99 --- .../telephony_ext_wrapper/include/telephony_ext_wrapper.h | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/services/telephony_ext_wrapper/include/telephony_ext_wrapper.h b/services/telephony_ext_wrapper/include/telephony_ext_wrapper.h index 86629459..3582c2b7 100644 --- a/services/telephony_ext_wrapper/include/telephony_ext_wrapper.h +++ b/services/telephony_ext_wrapper/include/telephony_ext_wrapper.h @@ -52,6 +52,8 @@ public: typedef bool (*GET_USER_DATA_ROAMING_EXPEND)(int32_t, bool); typedef void (*SEND_APN_NEED_RETRY_INFO)(int32_t); typedef bool (*JUDGE_OTHER_REQUEST_HOLDING)(const NetRequest &, const HasSystemUse hasSystemUse); + typedef void (*DynamicLoadInit)(void); + typedef void (*NotifyReqCellularData)(bool isReqCellularData); DATA_EDN_SELF_CURE dataEndSelfCure_ = nullptr; IS_APN_ALLOWED_ACTIVE isApnAllowedActive_ = nullptr; @@ -69,6 +71,8 @@ public: CONVERT_PDP_ERROR convertPdpError_ = nullptr; RESTART_RADIO_IF_RQUIRED restartRadioIfRequired_ = nullptr; JUDGE_OTHER_REQUEST_HOLDING judgeOtherRequestHolding_ = nullptr; + DynamicLoadInit dynamicLoadInit_ = nullptr; + NotifyReqCellularData dynamicLoadNotifyReqCellularDataStatus_ = nullptr; private: void* telephonyExtWrapperHandle_ = nullptr; @@ -87,6 +91,7 @@ private: void InitRestartRadioIfRequired(); void InitSendApnNeedRetryInfo(); void InitJudgeOtherRequestHolding(); + void InitTelephonyExtWrapperForDynamicLoad(); }; #define TELEPHONY_EXT_WRAPPER ::OHOS::DelayedRefSingleton::GetInstance() -- Gitee From 6465c8b9ef883a30921fdaf07ad11feea817bd10 Mon Sep 17 00:00:00 2001 From: wwz99 Date: Mon, 21 Apr 2025 11:31:03 +0000 Subject: [PATCH 067/145] update services/telephony_ext_wrapper/src/telephony_ext_wrapper.cpp. Signed-off-by: wwz99 --- services/telephony_ext_wrapper/src/telephony_ext_wrapper.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/services/telephony_ext_wrapper/src/telephony_ext_wrapper.cpp b/services/telephony_ext_wrapper/src/telephony_ext_wrapper.cpp index 3ea9186b..fa4de0f2 100644 --- a/services/telephony_ext_wrapper/src/telephony_ext_wrapper.cpp +++ b/services/telephony_ext_wrapper/src/telephony_ext_wrapper.cpp @@ -209,7 +209,7 @@ void TelephonyExtWrapper::InitTelephonyExtWrapperForDynamicLoad() TELEPHONY_LOGE("[DynamicLoad] telephony ext wrapper symbol failed, error: %{public}s", dlerror()); return; } - dynamicLoadNotifyReqCellularDataStatus_ = + dynamicLoadNotifyReqCellularDataStatus_ = (NotifyReqCellularData)dlsym(telephonyDynamicLoadWrapperHandle_, "InformReqCellularDataStatus"); if (dynamicLoadNotifyReqCellularDataStatus_ == nullptr) { TELEPHONY_LOGE("[DynamicLoad] telephony ext wrapper dynamicLoadNotifyReqCellularDataStatus_ symbol failed,\ -- Gitee From bb514b1101ae1de44d11a3e3266728204f1bac93 Mon Sep 17 00:00:00 2001 From: wwz99 Date: Mon, 21 Apr 2025 11:46:00 +0000 Subject: [PATCH 068/145] update services/src/cellular_data_handler.cpp. Signed-off-by: wwz99 --- services/src/cellular_data_handler.cpp | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/services/src/cellular_data_handler.cpp b/services/src/cellular_data_handler.cpp index bf081a47..ab96e719 100644 --- a/services/src/cellular_data_handler.cpp +++ b/services/src/cellular_data_handler.cpp @@ -1028,6 +1028,12 @@ void CellularDataHandler::DisconnectDataComplete(const InnerEvent::Pointer &even } else { NotifyReqCellularData(false); } + DisconnectDataCompletely(apnHolder, reason) + +} + +static void DisconnectDataCompletely(std::shared_ptr apnHolder, DisConnectionReason reason) +{ if (!apnManager_->HasAnyConnectedState()) { connectionManager_->StopStallDetectionTimer(); connectionManager_->EndNetStatistics(); -- Gitee From 693067707baa7b8e89499116eab96e0122a776ca Mon Sep 17 00:00:00 2001 From: wwz99 Date: Mon, 21 Apr 2025 12:16:45 +0000 Subject: [PATCH 069/145] update services/src/cellular_data_handler.cpp. Signed-off-by: wwz99 --- services/src/cellular_data_handler.cpp | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/services/src/cellular_data_handler.cpp b/services/src/cellular_data_handler.cpp index ab96e719..d355989d 100644 --- a/services/src/cellular_data_handler.cpp +++ b/services/src/cellular_data_handler.cpp @@ -1029,10 +1029,9 @@ void CellularDataHandler::DisconnectDataComplete(const InnerEvent::Pointer &even NotifyReqCellularData(false); } DisconnectDataCompletely(apnHolder, reason) - } -static void DisconnectDataCompletely(std::shared_ptr apnHolder, DisConnectionReason reason) +void DisconnectDataCompletely(std::shared_ptr apnHolder, DisConnectionReason reason) { if (!apnManager_->HasAnyConnectedState()) { connectionManager_->StopStallDetectionTimer(); -- Gitee From 314ae4a107517e54da3bd54a786e954365da5746 Mon Sep 17 00:00:00 2001 From: wwz99 Date: Mon, 21 Apr 2025 12:18:20 +0000 Subject: [PATCH 070/145] update services/include/cellular_data_handler.h. Signed-off-by: wwz99 --- services/include/cellular_data_handler.h | 1 + 1 file changed, 1 insertion(+) diff --git a/services/include/cellular_data_handler.h b/services/include/cellular_data_handler.h index 5dc7ac27..27490880 100644 --- a/services/include/cellular_data_handler.h +++ b/services/include/cellular_data_handler.h @@ -106,6 +106,7 @@ private: void PsRadioEmergencyStateClose(const AppExecFwk::InnerEvent::Pointer &event); void EstablishDataConnectionComplete(const AppExecFwk::InnerEvent::Pointer &event); void DisconnectDataComplete(const AppExecFwk::InnerEvent::Pointer &event); + void DisconnectDataCompletely(); void MsgEstablishDataConnection(const AppExecFwk::InnerEvent::Pointer &event); void MsgRequestNetwork(const AppExecFwk::InnerEvent::Pointer &event); void HandleSettingSwitchChanged(const AppExecFwk::InnerEvent::Pointer &event); -- Gitee From 21c4a34daa1504f17fcbcb4444fd1ecd6a61346b Mon Sep 17 00:00:00 2001 From: wwz99 Date: Mon, 21 Apr 2025 12:32:34 +0000 Subject: [PATCH 071/145] update services/src/cellular_data_handler.cpp. Signed-off-by: wwz99 --- services/src/cellular_data_handler.cpp | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/services/src/cellular_data_handler.cpp b/services/src/cellular_data_handler.cpp index d355989d..7cd8ff82 100644 --- a/services/src/cellular_data_handler.cpp +++ b/services/src/cellular_data_handler.cpp @@ -1026,7 +1026,9 @@ void CellularDataHandler::DisconnectDataComplete(const InnerEvent::Pointer &even if (apnHolder->IsDataCallEnabled()) { RetryOrClearConnection(apnHolder, reason, netInfo); } else { +#ifdef OHOS_BUILD_ENABLE_TELEPHONY_EXT NotifyReqCellularData(false); +#endif } DisconnectDataCompletely(apnHolder, reason) } @@ -1060,7 +1062,9 @@ void CellularDataHandler::RetryOrClearConnection(const sptr &apnHolde if (reason == DisConnectionReason::REASON_CLEAR_CONNECTION) { TELEPHONY_LOGI("clear connection"); ClearConnection(apnHolder, reason); +#ifdef OHOS_BUILD_ENABLE_TELEPHONY_EXT NotifyReqCellularData(false); +#endif } else if (reason == DisConnectionReason::REASON_PERMANENT_REJECT) { TELEPHONY_LOGI("permannent reject, mark bad and clear connection"); apnHolder->SetApnBadState(true); @@ -1264,7 +1268,9 @@ void CellularDataHandler::MsgRequestNetwork(const InnerEvent::Pointer &event) if (apnHolder->IsReqUidsEmpty()) { apnHolder->ReleaseAllCellularData(); } +#ifdef OHOS_BUILD_ENABLE_TELEPHONY_EXT NotifyReqCellularData(false); +#endif } } else { if (event->GetParam() == TYPE_REQUEST_NET) { -- Gitee From 0eafc101aff6d2c9c88916edab76e698e56c25cc Mon Sep 17 00:00:00 2001 From: wwz99 Date: Mon, 21 Apr 2025 12:49:38 +0000 Subject: [PATCH 072/145] update services/src/cellular_data_handler.cpp. Signed-off-by: wwz99 --- services/src/cellular_data_handler.cpp | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/services/src/cellular_data_handler.cpp b/services/src/cellular_data_handler.cpp index 7cd8ff82..ae50bcde 100644 --- a/services/src/cellular_data_handler.cpp +++ b/services/src/cellular_data_handler.cpp @@ -1030,11 +1030,6 @@ void CellularDataHandler::DisconnectDataComplete(const InnerEvent::Pointer &even NotifyReqCellularData(false); #endif } - DisconnectDataCompletely(apnHolder, reason) -} - -void DisconnectDataCompletely(std::shared_ptr apnHolder, DisConnectionReason reason) -{ if (!apnManager_->HasAnyConnectedState()) { connectionManager_->StopStallDetectionTimer(); connectionManager_->EndNetStatistics(); @@ -1043,6 +1038,11 @@ void DisconnectDataCompletely(std::shared_ptr apnHolder, DisConnectio incallDataStateMachine_->SendEvent(incallEvent); } } + DisconnectDataCompletely(apnHolder, reason); +} + +void DisconnectDataCompletely(std::shared_ptr apnHolder, DisConnectionReason reason) +{ if (reason == DisConnectionReason::REASON_CHANGE_CONNECTION) { HandleSortConnection(); } -- Gitee From fec85ed6187051256ac8a1f5a4abbf723b68f387 Mon Sep 17 00:00:00 2001 From: wwz99 Date: Mon, 21 Apr 2025 12:51:30 +0000 Subject: [PATCH 073/145] update services/include/cellular_data_handler.h. Signed-off-by: wwz99 --- services/include/cellular_data_handler.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/services/include/cellular_data_handler.h b/services/include/cellular_data_handler.h index 27490880..b1686ac6 100644 --- a/services/include/cellular_data_handler.h +++ b/services/include/cellular_data_handler.h @@ -106,7 +106,7 @@ private: void PsRadioEmergencyStateClose(const AppExecFwk::InnerEvent::Pointer &event); void EstablishDataConnectionComplete(const AppExecFwk::InnerEvent::Pointer &event); void DisconnectDataComplete(const AppExecFwk::InnerEvent::Pointer &event); - void DisconnectDataCompletely(); + void DisconnectDataCompletely(sptr &apnHolder, DisConnectionReason reason) void MsgEstablishDataConnection(const AppExecFwk::InnerEvent::Pointer &event); void MsgRequestNetwork(const AppExecFwk::InnerEvent::Pointer &event); void HandleSettingSwitchChanged(const AppExecFwk::InnerEvent::Pointer &event); -- Gitee From ca73d99c1432ee2d81bc3dbc4f63f7a35290eb88 Mon Sep 17 00:00:00 2001 From: wwz99 Date: Mon, 21 Apr 2025 12:54:07 +0000 Subject: [PATCH 074/145] update services/src/cellular_data_handler.cpp. Signed-off-by: wwz99 --- services/src/cellular_data_handler.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/services/src/cellular_data_handler.cpp b/services/src/cellular_data_handler.cpp index ae50bcde..0abe5b6c 100644 --- a/services/src/cellular_data_handler.cpp +++ b/services/src/cellular_data_handler.cpp @@ -1041,7 +1041,7 @@ void CellularDataHandler::DisconnectDataComplete(const InnerEvent::Pointer &even DisconnectDataCompletely(apnHolder, reason); } -void DisconnectDataCompletely(std::shared_ptr apnHolder, DisConnectionReason reason) +void DisconnectDataCompletely(const sptr &apnHolder, DisConnectionReason reason) { if (reason == DisConnectionReason::REASON_CHANGE_CONNECTION) { HandleSortConnection(); -- Gitee From 668142bafe6145641e7443264e62c15a83bf04f1 Mon Sep 17 00:00:00 2001 From: wwz99 Date: Mon, 21 Apr 2025 12:56:38 +0000 Subject: [PATCH 075/145] update services/src/cellular_data_handler.cpp. Signed-off-by: wwz99 --- services/src/cellular_data_handler.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/services/src/cellular_data_handler.cpp b/services/src/cellular_data_handler.cpp index 0abe5b6c..5f77d2ad 100644 --- a/services/src/cellular_data_handler.cpp +++ b/services/src/cellular_data_handler.cpp @@ -1041,7 +1041,7 @@ void CellularDataHandler::DisconnectDataComplete(const InnerEvent::Pointer &even DisconnectDataCompletely(apnHolder, reason); } -void DisconnectDataCompletely(const sptr &apnHolder, DisConnectionReason reason) +void DisconnectDataCompletely(sptr &apnHolder, DisConnectionReason reason) { if (reason == DisConnectionReason::REASON_CHANGE_CONNECTION) { HandleSortConnection(); -- Gitee From b0a3bf4b9e83ed5a47d3a9bf7891ca8d5fd56aea Mon Sep 17 00:00:00 2001 From: wwz99 Date: Tue, 22 Apr 2025 01:18:51 +0000 Subject: [PATCH 076/145] update services/include/cellular_data_handler.h. Signed-off-by: wwz99 --- services/include/cellular_data_handler.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/services/include/cellular_data_handler.h b/services/include/cellular_data_handler.h index b1686ac6..4a913e01 100644 --- a/services/include/cellular_data_handler.h +++ b/services/include/cellular_data_handler.h @@ -106,7 +106,7 @@ private: void PsRadioEmergencyStateClose(const AppExecFwk::InnerEvent::Pointer &event); void EstablishDataConnectionComplete(const AppExecFwk::InnerEvent::Pointer &event); void DisconnectDataComplete(const AppExecFwk::InnerEvent::Pointer &event); - void DisconnectDataCompletely(sptr &apnHolder, DisConnectionReason reason) + void DisconnectDataCompletely(sptr &apnHolder, DisConnectionReason reason); void MsgEstablishDataConnection(const AppExecFwk::InnerEvent::Pointer &event); void MsgRequestNetwork(const AppExecFwk::InnerEvent::Pointer &event); void HandleSettingSwitchChanged(const AppExecFwk::InnerEvent::Pointer &event); -- Gitee From aacd72f00dafd9e93f167a061ec770ae1b618197 Mon Sep 17 00:00:00 2001 From: wwz99 Date: Tue, 22 Apr 2025 03:15:15 +0000 Subject: [PATCH 077/145] update services/src/cellular_data_handler.cpp. Signed-off-by: wwz99 --- services/src/cellular_data_handler.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/services/src/cellular_data_handler.cpp b/services/src/cellular_data_handler.cpp index 5f77d2ad..9319d904 100644 --- a/services/src/cellular_data_handler.cpp +++ b/services/src/cellular_data_handler.cpp @@ -1041,7 +1041,7 @@ void CellularDataHandler::DisconnectDataComplete(const InnerEvent::Pointer &even DisconnectDataCompletely(apnHolder, reason); } -void DisconnectDataCompletely(sptr &apnHolder, DisConnectionReason reason) +void CellularDataHandler::DisconnectDataCompletely(sptr &apnHolder, DisConnectionReason reason) { if (reason == DisConnectionReason::REASON_CHANGE_CONNECTION) { HandleSortConnection(); -- Gitee From b46137b0d20a8521d3aa4e24ac45e86e5aaa7c05 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E6=B3=BD=E5=87=A1?= Date: Tue, 22 Apr 2025 03:37:45 +0000 Subject: [PATCH 078/145] add InterfaceToken for fuzzer add InterfaceToken for fuzzer MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 李泽凡 --- .../getcellulardatastate_fuzzer.cpp | 42 +++++++++++++++++++ 1 file changed, 42 insertions(+) diff --git a/test/fuzztest/getcellulardatastate_fuzzer/getcellulardatastate_fuzzer.cpp b/test/fuzztest/getcellulardatastate_fuzzer/getcellulardatastate_fuzzer.cpp index c77c32e0..60a20445 100644 --- a/test/fuzztest/getcellulardatastate_fuzzer/getcellulardatastate_fuzzer.cpp +++ b/test/fuzztest/getcellulardatastate_fuzzer/getcellulardatastate_fuzzer.cpp @@ -50,6 +50,9 @@ void EnableCellularData(const uint8_t *data, size_t size) } MessageParcel dataMessageParcel; + if (!dataMessageParcel.WriteInterfaceToken(CellularDataServiceStub::GetDescriptor())) { + return; + } dataMessageParcel.WriteBuffer(data, size); dataMessageParcel.RewindRead(0); uint32_t code = static_cast(ICellularDataManagerIpcCode::COMMAND_ENABLE_CELLULAR_DATA); @@ -65,6 +68,9 @@ void GetCellularDataState(const uint8_t *data, size_t size) } MessageParcel dataMessageParcel; + if (!dataMessageParcel.WriteInterfaceToken(CellularDataServiceStub::GetDescriptor())) { + return; + } dataMessageParcel.WriteBuffer(data, size); dataMessageParcel.RewindRead(0); uint32_t code = static_cast(ICellularDataManagerIpcCode::COMMAND_GET_CELLULAR_DATA_STATE); @@ -80,6 +86,9 @@ void IsCellularDataEnabled(const uint8_t *data, size_t size) } MessageParcel dataMessageParcel; + if (!dataMessageParcel.WriteInterfaceToken(CellularDataServiceStub::GetDescriptor())) { + return; + } dataMessageParcel.WriteBuffer(data, size); dataMessageParcel.RewindRead(0); uint32_t code = static_cast(ICellularDataManagerIpcCode::COMMAND_IS_CELLULAR_DATA_ENABLED); @@ -96,6 +105,9 @@ void IsCellularDataRoamingEnabled(const uint8_t *data, size_t size) FuzzedDataProvider fdp(data, size); int32_t slotId = fdp.ConsumeIntegralInRange(0, SLOT_NUM_MAX); MessageParcel dataMessageParcel; + if (!dataMessageParcel.WriteInterfaceToken(CellularDataServiceStub::GetDescriptor())) { + return; + } dataMessageParcel.WriteInt32(slotId); dataMessageParcel.WriteBuffer(data, size); dataMessageParcel.RewindRead(0); @@ -112,6 +124,9 @@ void GetDefaultCellularDataSlotId(const uint8_t *data, size_t size) } MessageParcel dataMessageParcel; + if (!dataMessageParcel.WriteInterfaceToken(CellularDataServiceStub::GetDescriptor())) { + return; + } dataMessageParcel.WriteBuffer(data, size); dataMessageParcel.RewindRead(0); uint32_t code = static_cast(ICellularDataManagerIpcCode::COMMAND_IS_CELLULAR_DATA_ROAMING_ENABLED); @@ -129,6 +144,9 @@ void EnableCellularDataRoaming(const uint8_t *data, size_t size) FuzzedDataProvider fdp(data, size); int32_t slotId = fdp.ConsumeIntegralInRange(0, SLOT_NUM_MAX); MessageParcel dataMessageParcel; + if (!dataMessageParcel.WriteInterfaceToken(CellularDataServiceStub::GetDescriptor())) { + return; + } dataMessageParcel.WriteInt32(slotId); dataMessageParcel.WriteBuffer(data, size); dataMessageParcel.RewindRead(0); @@ -147,6 +165,9 @@ void SetDefaultCellularDataSlotId(const uint8_t *data, size_t size) FuzzedDataProvider fdp(data, size); int32_t slotId = fdp.ConsumeIntegralInRange(0, SLOT_NUM_MAX); MessageParcel dataMessageParcel; + if (!dataMessageParcel.WriteInterfaceToken(CellularDataServiceStub::GetDescriptor())) { + return; + } dataMessageParcel.WriteInt32(slotId); dataMessageParcel.WriteBuffer(data, size); dataMessageParcel.RewindRead(0); @@ -165,6 +186,9 @@ void HasInternetCapability(const uint8_t *data, size_t size) FuzzedDataProvider fdp(data, size); int32_t slotId = fdp.ConsumeIntegralInRange(0, SLOT_NUM_MAX); MessageParcel dataMessageParcel; + if (!dataMessageParcel.WriteInterfaceToken(CellularDataServiceStub::GetDescriptor())) { + return; + } dataMessageParcel.WriteInt32(slotId); dataMessageParcel.WriteBuffer(data, size); dataMessageParcel.RewindRead(0); @@ -183,6 +207,9 @@ void ClearCellularDataConnections(const uint8_t *data, size_t size) FuzzedDataProvider fdp(data, size); int32_t slotId = fdp.ConsumeIntegralInRange(0, SLOT_NUM_MAX); MessageParcel dataMessageParcel; + if (!dataMessageParcel.WriteInterfaceToken(CellularDataServiceStub::GetDescriptor())) { + return; + } dataMessageParcel.WriteInt32(slotId); dataMessageParcel.WriteBuffer(data, size); dataMessageParcel.RewindRead(0); @@ -199,6 +226,9 @@ void GetCellularDataFlowType(const uint8_t *data, size_t size) } MessageParcel dataMessageParcel; + if (!dataMessageParcel.WriteInterfaceToken(CellularDataServiceStub::GetDescriptor())) { + return; + } dataMessageParcel.WriteBuffer(data, size); dataMessageParcel.RewindRead(0); uint32_t code = static_cast(ICellularDataManagerIpcCode::COMMAND_GET_CELLULAR_DATA_FLOW_TYPE); @@ -213,6 +243,9 @@ void RegisterSimAccountCallback(const uint8_t *data, size_t size) return; } MessageParcel dataMessageParcel; + if (!dataMessageParcel.WriteInterfaceToken(CellularDataServiceStub::GetDescriptor())) { + return; + } dataMessageParcel.WriteBuffer(data, size); dataMessageParcel.RewindRead(0); uint32_t code = static_cast(ICellularDataManagerIpcCode::COMMAND_REGISTER_SIM_ACCOUNT_CALLBACK); @@ -227,6 +260,9 @@ void UnregisterSimAccountCallback(const uint8_t *data, size_t size) return; } MessageParcel dataMessageParcel; + if (!dataMessageParcel.WriteInterfaceToken(CellularDataServiceStub::GetDescriptor())) { + return; + } dataMessageParcel.WriteBuffer(data, size); dataMessageParcel.RewindRead(0); uint32_t code = static_cast(ICellularDataManagerIpcCode::COMMAND_UNREGISTER_SIM_ACCOUNT_CALLBACK); @@ -241,6 +277,9 @@ void GetDefaultActReportInfo(const uint8_t *data, size_t size) return; } MessageParcel dataMessageParcel; + if (!dataMessageParcel.WriteInterfaceToken(CellularDataServiceStub::GetDescriptor())) { + return; + } dataMessageParcel.WriteBuffer(data, size); dataMessageParcel.RewindRead(0); uint32_t code = static_cast(ICellularDataManagerIpcCode::COMMAND_GET_DEFAULT_ACT_REPORT_INFO); @@ -255,6 +294,9 @@ void GetInternalActReportInfo(const uint8_t *data, size_t size) return; } MessageParcel dataMessageParcel; + if (!dataMessageParcel.WriteInterfaceToken(CellularDataServiceStub::GetDescriptor())) { + return; + } dataMessageParcel.WriteBuffer(data, size); dataMessageParcel.RewindRead(0); uint32_t code = static_cast(ICellularDataManagerIpcCode::COMMAND_GET_INTERNAL_ACT_REPORT_INFO); -- Gitee From 830f171133ada8849941f73358178d96f3ed4b40 Mon Sep 17 00:00:00 2001 From: wwz99 Date: Tue, 22 Apr 2025 03:45:59 +0000 Subject: [PATCH 079/145] update test/cellular_data_handler_branch_test.cpp. Signed-off-by: wwz99 --- test/cellular_data_handler_branch_test.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/cellular_data_handler_branch_test.cpp b/test/cellular_data_handler_branch_test.cpp index 4b55faac..63c4ce77 100644 --- a/test/cellular_data_handler_branch_test.cpp +++ b/test/cellular_data_handler_branch_test.cpp @@ -221,7 +221,7 @@ HWTEST_F(CellularDataHandlerBranchTest, DisconnectDataComplete_002, Function | M EventFwk::MatchingSkills matchingSkills; matchingSkills.AddEvent(EventFwk::CommonEventSupport::COMMON_EVENT_CALL_STATE_CHANGED); EventFwk::CommonEventSubscribeInfo subscriberInfo(matchingSkills); - auto cellularDataHandler = std::make_shared(subscriberInfo, 2); + auto cellularDataHandler = std::make_shared(subscriberInfo, 2); cellularDataHandler->Init(); std::shared_ptr resultInfo = std::make_shared(); -- Gitee From 252612d7fa794ddda7ee5d3f5e0501af3bfb663e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E6=B3=BD=E5=87=A1?= Date: Tue, 22 Apr 2025 06:48:22 +0000 Subject: [PATCH 080/145] update test/fuzztest/getcellulardatastate_fuzzer/getcellulardatastate_fuzzer.cpp. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 李泽凡 --- .../getcellulardatastate_fuzzer.cpp | 34 +++++++++++-------- 1 file changed, 19 insertions(+), 15 deletions(-) diff --git a/test/fuzztest/getcellulardatastate_fuzzer/getcellulardatastate_fuzzer.cpp b/test/fuzztest/getcellulardatastate_fuzzer/getcellulardatastate_fuzzer.cpp index 60a20445..4bee6c88 100644 --- a/test/fuzztest/getcellulardatastate_fuzzer/getcellulardatastate_fuzzer.cpp +++ b/test/fuzztest/getcellulardatastate_fuzzer/getcellulardatastate_fuzzer.cpp @@ -30,7 +30,11 @@ using namespace OHOS::Telephony; namespace OHOS { static bool g_isInited = false; constexpr int32_t SLOT_NUM_MAX = 3; - +static constexpr const char16_t *descriptor = u"OHOS.Telephony.ICellularDataManager"; +static inline const std::u16string GetDescriptor() +{ + return descriptor; +} bool IsServiceInited() { if (!g_isInited) { @@ -50,7 +54,7 @@ void EnableCellularData(const uint8_t *data, size_t size) } MessageParcel dataMessageParcel; - if (!dataMessageParcel.WriteInterfaceToken(CellularDataServiceStub::GetDescriptor())) { + if (!dataMessageParcel.WriteInterfaceToken(GetDescriptor())) { return; } dataMessageParcel.WriteBuffer(data, size); @@ -68,7 +72,7 @@ void GetCellularDataState(const uint8_t *data, size_t size) } MessageParcel dataMessageParcel; - if (!dataMessageParcel.WriteInterfaceToken(CellularDataServiceStub::GetDescriptor())) { + if (!dataMessageParcel.WriteInterfaceToken(GetDescriptor())) { return; } dataMessageParcel.WriteBuffer(data, size); @@ -86,7 +90,7 @@ void IsCellularDataEnabled(const uint8_t *data, size_t size) } MessageParcel dataMessageParcel; - if (!dataMessageParcel.WriteInterfaceToken(CellularDataServiceStub::GetDescriptor())) { + if (!dataMessageParcel.WriteInterfaceToken(GetDescriptor())) { return; } dataMessageParcel.WriteBuffer(data, size); @@ -105,7 +109,7 @@ void IsCellularDataRoamingEnabled(const uint8_t *data, size_t size) FuzzedDataProvider fdp(data, size); int32_t slotId = fdp.ConsumeIntegralInRange(0, SLOT_NUM_MAX); MessageParcel dataMessageParcel; - if (!dataMessageParcel.WriteInterfaceToken(CellularDataServiceStub::GetDescriptor())) { + if (!dataMessageParcel.WriteInterfaceToken(GetDescriptor())) { return; } dataMessageParcel.WriteInt32(slotId); @@ -124,7 +128,7 @@ void GetDefaultCellularDataSlotId(const uint8_t *data, size_t size) } MessageParcel dataMessageParcel; - if (!dataMessageParcel.WriteInterfaceToken(CellularDataServiceStub::GetDescriptor())) { + if (!dataMessageParcel.WriteInterfaceToken(GetDescriptor())) { return; } dataMessageParcel.WriteBuffer(data, size); @@ -144,7 +148,7 @@ void EnableCellularDataRoaming(const uint8_t *data, size_t size) FuzzedDataProvider fdp(data, size); int32_t slotId = fdp.ConsumeIntegralInRange(0, SLOT_NUM_MAX); MessageParcel dataMessageParcel; - if (!dataMessageParcel.WriteInterfaceToken(CellularDataServiceStub::GetDescriptor())) { + if (!dataMessageParcel.WriteInterfaceToken(GetDescriptor())) { return; } dataMessageParcel.WriteInt32(slotId); @@ -165,7 +169,7 @@ void SetDefaultCellularDataSlotId(const uint8_t *data, size_t size) FuzzedDataProvider fdp(data, size); int32_t slotId = fdp.ConsumeIntegralInRange(0, SLOT_NUM_MAX); MessageParcel dataMessageParcel; - if (!dataMessageParcel.WriteInterfaceToken(CellularDataServiceStub::GetDescriptor())) { + if (!dataMessageParcel.WriteInterfaceToken(GetDescriptor())) { return; } dataMessageParcel.WriteInt32(slotId); @@ -186,7 +190,7 @@ void HasInternetCapability(const uint8_t *data, size_t size) FuzzedDataProvider fdp(data, size); int32_t slotId = fdp.ConsumeIntegralInRange(0, SLOT_NUM_MAX); MessageParcel dataMessageParcel; - if (!dataMessageParcel.WriteInterfaceToken(CellularDataServiceStub::GetDescriptor())) { + if (!dataMessageParcel.WriteInterfaceToken(GetDescriptor())) { return; } dataMessageParcel.WriteInt32(slotId); @@ -207,7 +211,7 @@ void ClearCellularDataConnections(const uint8_t *data, size_t size) FuzzedDataProvider fdp(data, size); int32_t slotId = fdp.ConsumeIntegralInRange(0, SLOT_NUM_MAX); MessageParcel dataMessageParcel; - if (!dataMessageParcel.WriteInterfaceToken(CellularDataServiceStub::GetDescriptor())) { + if (!dataMessageParcel.WriteInterfaceToken(GetDescriptor())) { return; } dataMessageParcel.WriteInt32(slotId); @@ -226,7 +230,7 @@ void GetCellularDataFlowType(const uint8_t *data, size_t size) } MessageParcel dataMessageParcel; - if (!dataMessageParcel.WriteInterfaceToken(CellularDataServiceStub::GetDescriptor())) { + if (!dataMessageParcel.WriteInterfaceToken(GetDescriptor())) { return; } dataMessageParcel.WriteBuffer(data, size); @@ -243,7 +247,7 @@ void RegisterSimAccountCallback(const uint8_t *data, size_t size) return; } MessageParcel dataMessageParcel; - if (!dataMessageParcel.WriteInterfaceToken(CellularDataServiceStub::GetDescriptor())) { + if (!dataMessageParcel.WriteInterfaceToken(GetDescriptor())) { return; } dataMessageParcel.WriteBuffer(data, size); @@ -260,7 +264,7 @@ void UnregisterSimAccountCallback(const uint8_t *data, size_t size) return; } MessageParcel dataMessageParcel; - if (!dataMessageParcel.WriteInterfaceToken(CellularDataServiceStub::GetDescriptor())) { + if (!dataMessageParcel.WriteInterfaceToken(GetDescriptor())) { return; } dataMessageParcel.WriteBuffer(data, size); @@ -277,7 +281,7 @@ void GetDefaultActReportInfo(const uint8_t *data, size_t size) return; } MessageParcel dataMessageParcel; - if (!dataMessageParcel.WriteInterfaceToken(CellularDataServiceStub::GetDescriptor())) { + if (!dataMessageParcel.WriteInterfaceToken(GetDescriptor())) { return; } dataMessageParcel.WriteBuffer(data, size); @@ -294,7 +298,7 @@ void GetInternalActReportInfo(const uint8_t *data, size_t size) return; } MessageParcel dataMessageParcel; - if (!dataMessageParcel.WriteInterfaceToken(CellularDataServiceStub::GetDescriptor())) { + if (!dataMessageParcel.WriteInterfaceToken(GetDescriptor())) { return; } dataMessageParcel.WriteBuffer(data, size); -- Gitee From 462a9f8fb0e5fa477304afb8c51f1bbf36362b11 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E6=B3=BD=E5=87=A1?= Date: Tue, 22 Apr 2025 07:30:36 +0000 Subject: [PATCH 081/145] update test/fuzztest/getcellulardatastate_fuzzer/getcellulardatastate_fuzzer.cpp. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 李泽凡 --- .../getcellulardatastate_fuzzer.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/test/fuzztest/getcellulardatastate_fuzzer/getcellulardatastate_fuzzer.cpp b/test/fuzztest/getcellulardatastate_fuzzer/getcellulardatastate_fuzzer.cpp index 4bee6c88..22b45425 100644 --- a/test/fuzztest/getcellulardatastate_fuzzer/getcellulardatastate_fuzzer.cpp +++ b/test/fuzztest/getcellulardatastate_fuzzer/getcellulardatastate_fuzzer.cpp @@ -30,10 +30,10 @@ using namespace OHOS::Telephony; namespace OHOS { static bool g_isInited = false; constexpr int32_t SLOT_NUM_MAX = 3; -static constexpr const char16_t *descriptor = u"OHOS.Telephony.ICellularDataManager"; +static constexpr const char16_t *DESCRIPTOR = u"OHOS.Telephony.ICellularDataManager"; static inline const std::u16string GetDescriptor() { - return descriptor; + return DESCRIPTOR; } bool IsServiceInited() { -- Gitee From 101120891d9de2c01614cce35983925ceae42981 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=BC=A0=E6=96=87=E6=9D=B0?= Date: Tue, 22 Apr 2025 11:23:15 +0000 Subject: [PATCH 082/145] tel_cellular_data_client_test add native_preferences MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 张文杰 --- test/BUILD.gn | 1 + 1 file changed, 1 insertion(+) diff --git a/test/BUILD.gn b/test/BUILD.gn index cc70f790..cc619a64 100644 --- a/test/BUILD.gn +++ b/test/BUILD.gn @@ -261,6 +261,7 @@ ohos_unittest("tel_cellular_data_client_test") { "netmanager_base:net_policy_manager_if", "netmanager_base:net_stats_manager_if", "relational_store:native_dataability", + "preferences:native_preferences", "relational_store:native_rdb", "safwk:system_ability_fwk", "samgr:samgr_proxy", -- Gitee From 33b3c18e807bf66db135ede19451bc5f2b0e9a50 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=BC=A0=E6=96=87=E6=9D=B0?= Date: Tue, 22 Apr 2025 11:24:00 +0000 Subject: [PATCH 083/145] update test/fuzztest/getcellulardatastate_fuzzer/BUILD.gn. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 张文杰 --- test/fuzztest/getcellulardatastate_fuzzer/BUILD.gn | 1 + 1 file changed, 1 insertion(+) diff --git a/test/fuzztest/getcellulardatastate_fuzzer/BUILD.gn b/test/fuzztest/getcellulardatastate_fuzzer/BUILD.gn index ceb34fbd..b9d96e99 100644 --- a/test/fuzztest/getcellulardatastate_fuzzer/BUILD.gn +++ b/test/fuzztest/getcellulardatastate_fuzzer/BUILD.gn @@ -57,6 +57,7 @@ ohos_fuzztest("GetCellularDataStateFuzzTest") { "netmanager_base:net_conn_manager_if", "netmanager_base:net_policy_manager_if", "netmanager_base:net_stats_manager_if", + "preferences:native_preferences", "relational_store:native_rdb", "telephony_data:tel_telephony_data", ] -- Gitee From f43dd3b757058edcb7f098c167025150b42cc377 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=BC=A0=E6=96=87=E6=9D=B0?= Date: Tue, 22 Apr 2025 11:24:32 +0000 Subject: [PATCH 084/145] update test/fuzztest/updatecellulardata_fuzzer/BUILD.gn. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 张文杰 --- test/fuzztest/updatecellulardata_fuzzer/BUILD.gn | 1 + 1 file changed, 1 insertion(+) diff --git a/test/fuzztest/updatecellulardata_fuzzer/BUILD.gn b/test/fuzztest/updatecellulardata_fuzzer/BUILD.gn index 98404ea8..0d1208dc 100644 --- a/test/fuzztest/updatecellulardata_fuzzer/BUILD.gn +++ b/test/fuzztest/updatecellulardata_fuzzer/BUILD.gn @@ -60,6 +60,7 @@ ohos_fuzztest("UpdateCellularDataFuzzTest") { "netmanager_base:net_conn_manager_if", "netmanager_base:net_policy_manager_if", "netmanager_base:net_stats_manager_if", + "preferences:native_preferences", "relational_store:native_dataability", "relational_store:native_rdb", "safwk:system_ability_fwk", -- Gitee From 2b5ed6b6a5d41ea89af76ed574e6f67ae157b1c7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=BC=A0=E6=96=87=E6=9D=B0?= Date: Tue, 22 Apr 2025 11:26:20 +0000 Subject: [PATCH 085/145] update test/BUILD.gn. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 张文杰 --- test/BUILD.gn | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/BUILD.gn b/test/BUILD.gn index cc619a64..cd3911f4 100644 --- a/test/BUILD.gn +++ b/test/BUILD.gn @@ -260,8 +260,8 @@ ohos_unittest("tel_cellular_data_client_test") { "netmanager_base:net_conn_manager_if", "netmanager_base:net_policy_manager_if", "netmanager_base:net_stats_manager_if", - "relational_store:native_dataability", "preferences:native_preferences", + "relational_store:native_dataability", "relational_store:native_rdb", "safwk:system_ability_fwk", "samgr:samgr_proxy", -- Gitee From a97692b115ce17b030f09fb093bd569f0b8720e4 Mon Sep 17 00:00:00 2001 From: xhttt123 <2317512661@qq.com> Date: Tue, 22 Apr 2025 13:46:16 +0000 Subject: [PATCH 086/145] update test/mock/mock_core_service.h. Signed-off-by: xhttt123 <2317512661@qq.com> --- test/mock/mock_core_service.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/test/mock/mock_core_service.h b/test/mock/mock_core_service.h index 9cd7528f..43e27492 100644 --- a/test/mock/mock_core_service.h +++ b/test/mock/mock_core_service.h @@ -42,7 +42,7 @@ public: int32_t, SetRadioState, (int32_t slotId, bool isOn, const sptr &callback), (override)); MOCK_METHOD(int32_t, GetRadioState, (int32_t slotId, const sptr &callback), (override)); MOCK_METHOD(int32_t, GetImei, (int32_t slotId, std::u16string &imei), (override)); - MOCK_METHOD(int32_t, GetImeiSv, (int32_t slotId, std::u16string &imeiSv), (override)); + MOCK_METHOD(int32_t, GetImeiSv, (int32_t slotId, const sptr &callback), (override)); MOCK_METHOD(int32_t, GetMeid, (int32_t slotId, std::u16string &meid), (override)); MOCK_METHOD(int32_t, GetUniqueDeviceId, (int32_t slotId, std::u16string &deviceId), (override)); MOCK_METHOD(bool, IsNrSupported, (int32_t slotId), (override)); @@ -102,9 +102,9 @@ public: MOCK_METHOD(int32_t, SetPrimarySlotId, (int32_t slotId), (override)); MOCK_METHOD(int32_t, GetPrimarySlotId, (int32_t & slotId), (override)); MOCK_METHOD(int32_t, SetShowNumber, (int32_t slotId, const std::u16string &number), (override)); - MOCK_METHOD(int32_t, GetShowNumber, (int32_t slotId, std::u16string &showNumber), (override)); + MOCK_METHOD(int32_t, GetShowNumber, (int32_t slotId, const sptr &callback), (override)); MOCK_METHOD(int32_t, SetShowName, (int32_t slotId, const std::u16string &name), (override)); - MOCK_METHOD(int32_t, GetShowName, (int32_t slotId, std::u16string &showName), (override)); + MOCK_METHOD(int32_t, GetShowName, (int32_t slotId, const sptr &callback), (override)); MOCK_METHOD(int32_t, GetActiveSimAccountInfoList, (std::vector & iccAccountInfoList), (override)); MOCK_METHOD(int32_t, GetOperatorConfigs, (int32_t slotId, OperatorConfig &poc), (override)); MOCK_METHOD(int32_t, RefreshSimState, (int32_t slotId), (override)); -- Gitee From b01372071de8444fec3606bc437ca52d3aaef7cc Mon Sep 17 00:00:00 2001 From: xhttt123 <2317512661@qq.com> Date: Tue, 22 Apr 2025 23:33:50 +0000 Subject: [PATCH 087/145] update test/mock/mock_core_service.h. Signed-off-by: xhttt123 <2317512661@qq.com> --- test/mock/mock_core_service.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/test/mock/mock_core_service.h b/test/mock/mock_core_service.h index 43e27492..2aff93be 100644 --- a/test/mock/mock_core_service.h +++ b/test/mock/mock_core_service.h @@ -41,8 +41,8 @@ public: MOCK_METHOD( int32_t, SetRadioState, (int32_t slotId, bool isOn, const sptr &callback), (override)); MOCK_METHOD(int32_t, GetRadioState, (int32_t slotId, const sptr &callback), (override)); - MOCK_METHOD(int32_t, GetImei, (int32_t slotId, std::u16string &imei), (override)); - MOCK_METHOD(int32_t, GetImeiSv, (int32_t slotId, const sptr &callback), (override)); + MOCK_METHOD(int32_t, GetImei, (int32_t slotId, const sptr &callback), (override)); + MOCK_METHOD(int32_t, GetImeiSv, (int32_t slotId, const sptr &callback), (override)); MOCK_METHOD(int32_t, GetMeid, (int32_t slotId, std::u16string &meid), (override)); MOCK_METHOD(int32_t, GetUniqueDeviceId, (int32_t slotId, std::u16string &deviceId), (override)); MOCK_METHOD(bool, IsNrSupported, (int32_t slotId), (override)); -- Gitee From df1b78f5e711970c5fb8884bc972fb909c9ed190 Mon Sep 17 00:00:00 2001 From: shenyujuan Date: Wed, 23 Apr 2025 03:28:42 +0000 Subject: [PATCH 088/145] update test/mock/mock_net_conn_service.h. Signed-off-by: shenyujuan --- test/mock/mock_net_conn_service.h | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/test/mock/mock_net_conn_service.h b/test/mock/mock_net_conn_service.h index 3db4a4e0..b8fdf91e 100644 --- a/test/mock/mock_net_conn_service.h +++ b/test/mock/mock_net_conn_service.h @@ -97,8 +97,8 @@ public: MOCK_METHOD(int32_t, RegisterPreAirplaneCallback, (const sptr callback)); MOCK_METHOD(int32_t, UnregisterPreAirplaneCallback, (const sptr callback)); MOCK_METHOD( - int32_t, DecreaseSupplierScore, (NetBearType bearerType, const std::string &ident, uint32_t &supplierId)); - MOCK_METHOD(int32_t, IncreaseSupplierScore, (uint32_t supplierId)); + int32_t, GetDefaultSupplierId, (NetBearType bearerType, const std::string &ident, uint32_t &supplierId)); + MOCK_METHOD(int32_t, UpdateSupplierScore, (uint32_t supplierId, uint32_t detectionStatus)); MOCK_METHOD(int32_t, EnableVnicNetwork, (const sptr &netLinkInfo, const std::set &uids)); MOCK_METHOD(int32_t, DisableVnicNetwork, ()); MOCK_METHOD(int32_t, EnableDistributedClientNet, (const std::string &virnicAddr, const std::string &iif)); @@ -114,8 +114,6 @@ public: MOCK_METHOD(int32_t, GetPacUrl, (std::string &pacUrl)); MOCK_METHOD(int32_t, SetAppIsFrozened, (uint32_t uid, bool isFrozened)); MOCK_METHOD(int32_t, EnableAppFrozenedCallbackLimitation, (bool flag)); - MOCK_METHOD(int32_t, UpdateSupplierScore, - (NetBearType bearerType, const std::string &ident, uint32_t detectionStatus, uint32_t &supplierId)); }; } // namespace NetManagerStandard -- Gitee From f863c20ad841c5b3de7772dd277a425a9754b77c Mon Sep 17 00:00:00 2001 From: wwz99 Date: Wed, 23 Apr 2025 07:02:47 +0000 Subject: [PATCH 089/145] update services/include/cellular_data_handler.h. Signed-off-by: wwz99 --- services/include/cellular_data_handler.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/services/include/cellular_data_handler.h b/services/include/cellular_data_handler.h index 4a913e01..6ada15bd 100644 --- a/services/include/cellular_data_handler.h +++ b/services/include/cellular_data_handler.h @@ -106,7 +106,7 @@ private: void PsRadioEmergencyStateClose(const AppExecFwk::InnerEvent::Pointer &event); void EstablishDataConnectionComplete(const AppExecFwk::InnerEvent::Pointer &event); void DisconnectDataComplete(const AppExecFwk::InnerEvent::Pointer &event); - void DisconnectDataCompletely(sptr &apnHolder, DisConnectionReason reason); + void HandleDisconnectDataCompleteForMmsType(sptr &apnHolder); void MsgEstablishDataConnection(const AppExecFwk::InnerEvent::Pointer &event); void MsgRequestNetwork(const AppExecFwk::InnerEvent::Pointer &event); void HandleSettingSwitchChanged(const AppExecFwk::InnerEvent::Pointer &event); -- Gitee From 0c657912466079f4ce6aec58f173f03ef3dc3ba9 Mon Sep 17 00:00:00 2001 From: wwz99 Date: Wed, 23 Apr 2025 07:07:45 +0000 Subject: [PATCH 090/145] update services/src/cellular_data_handler.cpp. Signed-off-by: wwz99 --- services/src/cellular_data_handler.cpp | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/services/src/cellular_data_handler.cpp b/services/src/cellular_data_handler.cpp index 9319d904..cac1412a 100644 --- a/services/src/cellular_data_handler.cpp +++ b/services/src/cellular_data_handler.cpp @@ -1038,14 +1038,14 @@ void CellularDataHandler::DisconnectDataComplete(const InnerEvent::Pointer &even incallDataStateMachine_->SendEvent(incallEvent); } } - DisconnectDataCompletely(apnHolder, reason); -} - -void CellularDataHandler::DisconnectDataCompletely(sptr &apnHolder, DisConnectionReason reason) -{ if (reason == DisConnectionReason::REASON_CHANGE_CONNECTION) { HandleSortConnection(); } + HandleDisconnectDataCompleteForMmsType(apnHolder); +} + +void CellularDataHandler::HandleDisconnectDataCompleteForMmsType(sptr &apnHolder) +{ if (apnHolder->IsMmsType()) { SetDataPermittedForMms(false); RemoveEvent(CellularDataEventCode::MSG_RESUME_DATA_PERMITTED_TIMEOUT); -- Gitee From fb68e779d0777d3b3e528efa4c45f0c9552daf58 Mon Sep 17 00:00:00 2001 From: wwz99 Date: Wed, 23 Apr 2025 07:10:00 +0000 Subject: [PATCH 091/145] update test/BUILD.gn. Signed-off-by: wwz99 --- test/BUILD.gn | 1 + 1 file changed, 1 insertion(+) diff --git a/test/BUILD.gn b/test/BUILD.gn index cc70f790..8caae8f4 100644 --- a/test/BUILD.gn +++ b/test/BUILD.gn @@ -41,6 +41,7 @@ ohos_unittest("tel_cellular_data_test") { "$SOURCE_DIR:tel_cellular_data_static", "$SOURCE_DIR/frameworks/native:cellulardata_interface_stub", "$SOURCE_DIR/frameworks/native:tel_cellular_data_api", + "//third_party/googletest:gmock_main", ] external_deps = [ -- Gitee From f1815f4b3a0d71881dd3bed9d3491867dc9c573e Mon Sep 17 00:00:00 2001 From: wwz99 Date: Wed, 23 Apr 2025 08:34:14 +0000 Subject: [PATCH 092/145] update test/cellular_data_test.cpp. Signed-off-by: wwz99 --- test/cellular_data_test.cpp | 110 ++++++++++++++++++++++++++++++++++++ 1 file changed, 110 insertions(+) diff --git a/test/cellular_data_test.cpp b/test/cellular_data_test.cpp index 62278106..67f9dfea 100644 --- a/test/cellular_data_test.cpp +++ b/test/cellular_data_test.cpp @@ -18,6 +18,8 @@ #define private public #include +#include +#include #include "cellular_data_client.h" #include "cellular_data_controller.h" @@ -55,8 +57,10 @@ namespace OHOS { namespace Telephony { +using namespace testing; using namespace testing::ext; using namespace OHOS::NetManagerStandard; +using ::testing::NiceMock; static const int32_t SLEEP_TIME = 1; static const int32_t SIM_SLOT_ID_1 = DEFAULT_SIM_SLOT_ID + 1; @@ -117,6 +121,34 @@ public: bool isCallback_ = false; }; +class MockDlsym { +public: + MOCK_METHOD(void *, dlopen, (const char *fileName, int flag)); + MOCK_METHOD(void *, dlsym, (void *handle, const char *symbol)); +}; + +NiceMock *mockDlsym; + +extern "c" { +// mock dlopen +void *dlopen(const char *fileName, int flag) +{ + if (mockDlsym == nullptr) { + mockDlsym = new NiceMock(); + } + return mockDlsym->dlopen(fileName, flag); +} + +// mock dlsym +void *dlsym(void *handle, const char *symbol) +{ + if (mockDlsym == nullptr) { + mockDlsym = new NiceMock(); + } + return mockDlsym->dlsym(handle, symbol); +} +} + class CellularDataTest : public testing::Test { public: static void SetUpTestCase(); @@ -1074,6 +1106,84 @@ HWTEST_F(CellularDataTest, Telephony_Cellulardata_InitTelephonyExtService_0100, } } + +/** + * @tc.number Telephony_Cellulardata_InitTelephonyExtService_0101 + * @tc.name Init Telephony Ext Service. + * @tc.desc Function test + */ +HWTEST_F(CellularDataTest, Telephony_Cellulardata_InitTelephonyExtService_0101, Function | MediumTest | Level1) +{ + mockDlsym = new NiceMock(); + EXPECT_CALL(*mockDlsym, dlopen(_, _)) + .WillRepeatedly(Return(nullptr)); + TELEPHONY_EXT_WRAPPER.InitTelephonyExtWrapperForDynamicLoad(); + EXPECT_EQ(TELEPHONY_EXT_WRAPPER.telephonyDynamicLoadWrapperHandle_, nullptr); + delete mockDlsym; + mockDlsym = nullptr; +} + +/** + * @tc.number Telephony_Cellulardata_InitTelephonyExtService_0102 + * @tc.name Init Telephony Ext Service. + * @tc.desc Function test + */ +HWTEST_F(CellularDataTest, Telephony_Cellulardata_InitTelephonyExtService_0102, Function | MediumTest | Level1) +{ + mockDlsym = new NiceMock(); + EXPECT_CALL(*mockDlsym, dlsym(_, _)) + .WillRepeatedly(Return(nullptr)); + TELEPHONY_EXT_WRAPPER.InitTelephonyExtWrapperForDynamicLoad(); + EXPECT_EQ(TELEPHONY_EXT_WRAPPER.telephonyDynamicLoadWrapperHandle_ != nullptr, true); + EXPECT_EQ(TELEPHONY_EXT_WRAPPER.dynamicLoadInit_, nullptr); + delete mockDlsym; + mockDlsym = nullptr; +} + +/** + * @tc.number Telephony_Cellulardata_InitTelephonyExtService_0103 + * @tc.name Init Telephony Ext Service. + * @tc.desc Function test + */ +HWTEST_F(CellularDataTest, Telephony_Cellulardata_InitTelephonyExtService_0103, Function | MediumTest | Level1) +{ + mockDlsym = new NiceMock(); + EXPECT_CALL(*mockDlsym, dlsym(_, _)) + .WillOnce(Return(reinterpret_cast(0x1234))) + .WillOnce(Return(nullptr)); + auto controller = std::make_shared(DEFAULT_SIM_SLOT_ID); + controller->Init(); + ASSERT_TRUE(controller->cellularDataHandler_ != nullptr); + TELEPHONY_EXT_WRAPPER.InitTelephonyExtWrapperForDynamicLoad(); + EXPECT_EQ(TELEPHONY_EXT_WRAPPER.telephonyDynamicLoadWrapperHandle_ != nullptr, true); + EXPECT_EQ(TELEPHONY_EXT_WRAPPER.dynamicLoadInit_ != nullptr, true); +#ifdef OHOS_BUILD_ENABLE_TELEPHONY_EXT + controller->cellularDataHandler_->NotifyReqCellularData(false); +#endif + EXPECT_EQ(TELEPHONY_EXT_WRAPPER.dynamicLoadNotifyReqCellularDataStatus_, nullptr); + delete mockDlsym; + mockDlsym = nullptr; +} + +/** + * @tc.number Telephony_Cellulardata_InitTelephonyExtService_0104 + * @tc.name Init Telephony Ext Service. + * @tc.desc Function test + */ +HWTEST_F(CellularDataTest, Telephony_Cellulardata_InitTelephonyExtService_0104, Function | MediumTest | Level1) +{ + auto controller = std::make_shared(DEFAULT_SIM_SLOT_ID); + controller->Init(); + ASSERT_TRUE(controller->cellularDataHandler_ != nullptr); + TELEPHONY_EXT_WRAPPER.InitTelephonyExtWrapperForDynamicLoad(); + EXPECT_EQ(TELEPHONY_EXT_WRAPPER.telephonyDynamicLoadWrapperHandle_ != nullptr, true); + EXPECT_EQ(TELEPHONY_EXT_WRAPPER.dynamicLoadInit_ != nullptr, true); +#ifdef OHOS_BUILD_ENABLE_TELEPHONY_EXT + controller->cellularDataHandler_->NotifyReqCellularData(true); +#endif + EXPECT_EQ(TELEPHONY_EXT_WRAPPER.dynamicLoadNotifyReqCellularDataStatus_ != nullptr, true); +} + /** * @tc.number GetDataConnApnAttr_Test_01 * @tc.name Test the GetDataConnApnAttr function -- Gitee From fe48a655f6f4c4494d45fd77324ba7eb3f13d9d8 Mon Sep 17 00:00:00 2001 From: wwz99 Date: Wed, 23 Apr 2025 08:36:09 +0000 Subject: [PATCH 093/145] update test/cellular_data_test.cpp. Signed-off-by: wwz99 --- test/cellular_data_test.cpp | 1 - 1 file changed, 1 deletion(-) diff --git a/test/cellular_data_test.cpp b/test/cellular_data_test.cpp index 67f9dfea..9c92abec 100644 --- a/test/cellular_data_test.cpp +++ b/test/cellular_data_test.cpp @@ -1106,7 +1106,6 @@ HWTEST_F(CellularDataTest, Telephony_Cellulardata_InitTelephonyExtService_0100, } } - /** * @tc.number Telephony_Cellulardata_InitTelephonyExtService_0101 * @tc.name Init Telephony Ext Service. -- Gitee From b9ac24c43cd6c6b282a229d0b7888fb681df5ec6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E6=B3=BD=E5=87=A1?= Date: Thu, 24 Apr 2025 02:33:02 +0000 Subject: [PATCH 094/145] update test/fuzztest/getcellulardatastate_fuzzer/getcellulardatastate_fuzzer.cpp. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 李泽凡 --- .../getcellulardatastate_fuzzer.cpp | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/test/fuzztest/getcellulardatastate_fuzzer/getcellulardatastate_fuzzer.cpp b/test/fuzztest/getcellulardatastate_fuzzer/getcellulardatastate_fuzzer.cpp index 22b45425..0d9d2a98 100644 --- a/test/fuzztest/getcellulardatastate_fuzzer/getcellulardatastate_fuzzer.cpp +++ b/test/fuzztest/getcellulardatastate_fuzzer/getcellulardatastate_fuzzer.cpp @@ -250,6 +250,11 @@ void RegisterSimAccountCallback(const uint8_t *data, size_t size) if (!dataMessageParcel.WriteInterfaceToken(GetDescriptor())) { return; } + sptr callback = new (std::nothrow) SimAccountCallback(); + if (callback == nullptr) { + return; + } + dataParcel.WriteRemoteObject(callback->AsObject()); dataMessageParcel.WriteBuffer(data, size); dataMessageParcel.RewindRead(0); uint32_t code = static_cast(ICellularDataManagerIpcCode::COMMAND_REGISTER_SIM_ACCOUNT_CALLBACK); @@ -267,6 +272,11 @@ void UnregisterSimAccountCallback(const uint8_t *data, size_t size) if (!dataMessageParcel.WriteInterfaceToken(GetDescriptor())) { return; } + sptr callback = new (std::nothrow) SimAccountCallback(); + if (callback == nullptr) { + return; + } + dataParcel.WriteRemoteObject(callback->AsObject()); dataMessageParcel.WriteBuffer(data, size); dataMessageParcel.RewindRead(0); uint32_t code = static_cast(ICellularDataManagerIpcCode::COMMAND_UNREGISTER_SIM_ACCOUNT_CALLBACK); -- Gitee From 911339879b0c9c90d16e4f58586e3b2ba5d67bb4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E6=B3=BD=E5=87=A1?= Date: Thu, 24 Apr 2025 02:37:57 +0000 Subject: [PATCH 095/145] update test/fuzztest/getcellulardatastate_fuzzer/getcellulardatastate_fuzzer.cpp. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 李泽凡 --- .../getcellulardatastate_fuzzer.cpp | 4 ---- 1 file changed, 4 deletions(-) diff --git a/test/fuzztest/getcellulardatastate_fuzzer/getcellulardatastate_fuzzer.cpp b/test/fuzztest/getcellulardatastate_fuzzer/getcellulardatastate_fuzzer.cpp index 0d9d2a98..319e934f 100644 --- a/test/fuzztest/getcellulardatastate_fuzzer/getcellulardatastate_fuzzer.cpp +++ b/test/fuzztest/getcellulardatastate_fuzzer/getcellulardatastate_fuzzer.cpp @@ -255,8 +255,6 @@ void RegisterSimAccountCallback(const uint8_t *data, size_t size) return; } dataParcel.WriteRemoteObject(callback->AsObject()); - dataMessageParcel.WriteBuffer(data, size); - dataMessageParcel.RewindRead(0); uint32_t code = static_cast(ICellularDataManagerIpcCode::COMMAND_REGISTER_SIM_ACCOUNT_CALLBACK); MessageParcel reply; MessageOption option(MessageOption::TF_SYNC); @@ -277,8 +275,6 @@ void UnregisterSimAccountCallback(const uint8_t *data, size_t size) return; } dataParcel.WriteRemoteObject(callback->AsObject()); - dataMessageParcel.WriteBuffer(data, size); - dataMessageParcel.RewindRead(0); uint32_t code = static_cast(ICellularDataManagerIpcCode::COMMAND_UNREGISTER_SIM_ACCOUNT_CALLBACK); MessageParcel reply; MessageOption option(MessageOption::TF_SYNC); -- Gitee From 1cfe986d5b3bd4de9b4b9890b344e222d3df0bf7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E6=B3=BD=E5=87=A1?= Date: Thu, 24 Apr 2025 03:49:29 +0000 Subject: [PATCH 096/145] update test/fuzztest/getcellulardatastate_fuzzer/getcellulardatastate_fuzzer.cpp. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 李泽凡 --- .../getcellulardatastate_fuzzer.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/test/fuzztest/getcellulardatastate_fuzzer/getcellulardatastate_fuzzer.cpp b/test/fuzztest/getcellulardatastate_fuzzer/getcellulardatastate_fuzzer.cpp index 319e934f..d10bf28f 100644 --- a/test/fuzztest/getcellulardatastate_fuzzer/getcellulardatastate_fuzzer.cpp +++ b/test/fuzztest/getcellulardatastate_fuzzer/getcellulardatastate_fuzzer.cpp @@ -22,6 +22,7 @@ #include "cellular_data_ipc_interface_code.h" #include "cellular_data_service.h" #include "cellular_data_manager_stub.h" +#include "data_sim_account_callback.h" #include "system_ability_definition.h" #include #include "icellular_data_manager.h" @@ -250,7 +251,7 @@ void RegisterSimAccountCallback(const uint8_t *data, size_t size) if (!dataMessageParcel.WriteInterfaceToken(GetDescriptor())) { return; } - sptr callback = new (std::nothrow) SimAccountCallback(); + sptr callback = new (std::nothrow) DataSimAccountCallback(); if (callback == nullptr) { return; } @@ -270,7 +271,7 @@ void UnregisterSimAccountCallback(const uint8_t *data, size_t size) if (!dataMessageParcel.WriteInterfaceToken(GetDescriptor())) { return; } - sptr callback = new (std::nothrow) SimAccountCallback(); + sptr callback = new (std::nothrow) DataSimAccountCallback(); if (callback == nullptr) { return; } -- Gitee From 15a80d6b31430d6af1506685b6e888f1a3b87515 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E6=B3=BD=E5=87=A1?= Date: Thu, 24 Apr 2025 06:07:18 +0000 Subject: [PATCH 097/145] update test/fuzztest/getcellulardatastate_fuzzer/getcellulardatastate_fuzzer.cpp. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 李泽凡 --- .../getcellulardatastate_fuzzer.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/test/fuzztest/getcellulardatastate_fuzzer/getcellulardatastate_fuzzer.cpp b/test/fuzztest/getcellulardatastate_fuzzer/getcellulardatastate_fuzzer.cpp index d10bf28f..35647ef6 100644 --- a/test/fuzztest/getcellulardatastate_fuzzer/getcellulardatastate_fuzzer.cpp +++ b/test/fuzztest/getcellulardatastate_fuzzer/getcellulardatastate_fuzzer.cpp @@ -255,7 +255,7 @@ void RegisterSimAccountCallback(const uint8_t *data, size_t size) if (callback == nullptr) { return; } - dataParcel.WriteRemoteObject(callback->AsObject()); + dataMessageParcel.WriteRemoteObject(callback->AsObject()); uint32_t code = static_cast(ICellularDataManagerIpcCode::COMMAND_REGISTER_SIM_ACCOUNT_CALLBACK); MessageParcel reply; MessageOption option(MessageOption::TF_SYNC); @@ -275,7 +275,7 @@ void UnregisterSimAccountCallback(const uint8_t *data, size_t size) if (callback == nullptr) { return; } - dataParcel.WriteRemoteObject(callback->AsObject()); + dataMessageParcel.WriteRemoteObject(callback->AsObject()); uint32_t code = static_cast(ICellularDataManagerIpcCode::COMMAND_UNREGISTER_SIM_ACCOUNT_CALLBACK); MessageParcel reply; MessageOption option(MessageOption::TF_SYNC); -- Gitee From e6e4ab427cac2f7e5371fc73eeb3149ac836a663 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E6=B3=BD=E5=87=A1?= Date: Thu, 24 Apr 2025 06:44:49 +0000 Subject: [PATCH 098/145] update interfaces/innerkits/libtel_cellular_data_api.versionscript. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 李泽凡 --- interfaces/innerkits/libtel_cellular_data_api.versionscript | 1 + 1 file changed, 1 insertion(+) diff --git a/interfaces/innerkits/libtel_cellular_data_api.versionscript b/interfaces/innerkits/libtel_cellular_data_api.versionscript index 4fe0de0e..7a2a256e 100644 --- a/interfaces/innerkits/libtel_cellular_data_api.versionscript +++ b/interfaces/innerkits/libtel_cellular_data_api.versionscript @@ -15,6 +15,7 @@ global: extern "C++" { *OHOS::Telephony::CellularDataClient*; + *OHOS::Telephony::DataSimAccountCallback*; *ApnInfo*; }; local: -- Gitee From aa9312ae6a3823ea159c9d975df3053e1bf306e9 Mon Sep 17 00:00:00 2001 From: wwz99 Date: Thu, 24 Apr 2025 09:28:34 +0000 Subject: [PATCH 099/145] update test/BUILD.gn. Signed-off-by: wwz99 --- test/BUILD.gn | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/BUILD.gn b/test/BUILD.gn index 8caae8f4..6bd39b9c 100644 --- a/test/BUILD.gn +++ b/test/BUILD.gn @@ -41,7 +41,6 @@ ohos_unittest("tel_cellular_data_test") { "$SOURCE_DIR:tel_cellular_data_static", "$SOURCE_DIR/frameworks/native:cellulardata_interface_stub", "$SOURCE_DIR/frameworks/native:tel_cellular_data_api", - "//third_party/googletest:gmock_main", ] external_deps = [ @@ -73,6 +72,7 @@ ohos_unittest("tel_cellular_data_test") { "safwk:system_ability_fwk", "samgr:samgr_proxy", "telephony_data:tel_telephony_data", + "googletest:gmock_main", ] defines = [ "TELEPHONY_LOG_TAG = \"CelllularDataTest\"", -- Gitee From 533834dc574921cba19530f35a1467d039c8ef32 Mon Sep 17 00:00:00 2001 From: wwz99 Date: Thu, 24 Apr 2025 10:18:53 +0000 Subject: [PATCH 100/145] update test/cellular_data_test.cpp. Signed-off-by: wwz99 --- test/cellular_data_test.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/cellular_data_test.cpp b/test/cellular_data_test.cpp index 9c92abec..fdc2d596 100644 --- a/test/cellular_data_test.cpp +++ b/test/cellular_data_test.cpp @@ -129,7 +129,7 @@ public: NiceMock *mockDlsym; -extern "c" { +extern "C" { // mock dlopen void *dlopen(const char *fileName, int flag) { -- Gitee From bf2baa65cca6185351cc4fc4b248f81e23d73bba Mon Sep 17 00:00:00 2001 From: wwz99 Date: Thu, 24 Apr 2025 12:38:25 +0000 Subject: [PATCH 101/145] update test/BUILD.gn. Signed-off-by: wwz99 --- test/BUILD.gn | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/BUILD.gn b/test/BUILD.gn index 6bd39b9c..3a5bf97d 100644 --- a/test/BUILD.gn +++ b/test/BUILD.gn @@ -59,6 +59,7 @@ ohos_unittest("tel_cellular_data_test") { "data_share:datashare_common", "data_share:datashare_consumer", "eventhandler:libeventhandler", + "googletest:gmock_main", "hilog:libhilog", "hisysevent:libhisysevent", "init:libbegetutil", @@ -72,7 +73,6 @@ ohos_unittest("tel_cellular_data_test") { "safwk:system_ability_fwk", "samgr:samgr_proxy", "telephony_data:tel_telephony_data", - "googletest:gmock_main", ] defines = [ "TELEPHONY_LOG_TAG = \"CelllularDataTest\"", -- Gitee From 320fe03f5d2d5234eb0ea682bb3574d52abfa838 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=BE=99=E7=8C=AB=E8=83=96=E8=83=96?= Date: Fri, 25 Apr 2025 15:01:49 +0800 Subject: [PATCH 102/145] fix default cellular data enable MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 龙猫胖胖 --- services/src/cellular_data_handler.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/services/src/cellular_data_handler.cpp b/services/src/cellular_data_handler.cpp index 6989591e..08413d5c 100644 --- a/services/src/cellular_data_handler.cpp +++ b/services/src/cellular_data_handler.cpp @@ -2007,7 +2007,7 @@ void CellularDataHandler::GetDefaultDataEnableConfig() bool dataEnbaled = true; int32_t ret = dataSwitchSettings_->QueryUserDataStatus(dataEnbaled); const int32_t defSlotId = CoreManagerInner::GetInstance().GetDefaultCellularDataSlotId(); - if (ret == TELEPHONY_ERR_SUCESS && defSlotId == slotId_) { + if (ret == TELEPHONY_ERR_SUCESS || defSlotId == slotId_) { return; } OperatorConfig config; -- Gitee From 5222da1fb93675fc574fd88bfa79634a4d9b9e01 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=BE=99=E7=8C=AB=E8=83=96=E8=83=96?= Date: Fri, 25 Apr 2025 16:11:25 +0800 Subject: [PATCH 103/145] fix default cellular data enable MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 龙猫胖胖 --- services/src/cellular_data_handler.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/services/src/cellular_data_handler.cpp b/services/src/cellular_data_handler.cpp index 2ddba7b0..957d9157 100644 --- a/services/src/cellular_data_handler.cpp +++ b/services/src/cellular_data_handler.cpp @@ -2007,7 +2007,7 @@ void CellularDataHandler::GetDefaultDataEnableConfig() bool dataEnbaled = true; int32_t ret = dataSwitchSettings_->QueryUserDataStatus(dataEnbaled); const int32_t defSlotId = CoreManagerInner::GetInstance().GetDefaultCellularDataSlotId(); - if (ret == TELEPHONY_ERR_SUCESS || defSlotId == slotId_) { + if (ret == TELEPHONY_ERR_SUCCESS || defSlotId == slotId_) { return; } OperatorConfig config; -- Gitee From 2d4f90ac501bf5212f4043dac86cbcfa11416d0c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=BE=99=E7=8C=AB=E8=83=96=E8=83=96?= Date: Fri, 25 Apr 2025 16:14:50 +0800 Subject: [PATCH 104/145] fix default cellular data enable MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 龙猫胖胖 --- services/src/cellular_data_handler.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/services/src/cellular_data_handler.cpp b/services/src/cellular_data_handler.cpp index 957d9157..78f185ae 100644 --- a/services/src/cellular_data_handler.cpp +++ b/services/src/cellular_data_handler.cpp @@ -2007,7 +2007,7 @@ void CellularDataHandler::GetDefaultDataEnableConfig() bool dataEnbaled = true; int32_t ret = dataSwitchSettings_->QueryUserDataStatus(dataEnbaled); const int32_t defSlotId = CoreManagerInner::GetInstance().GetDefaultCellularDataSlotId(); - if (ret == TELEPHONY_ERR_SUCCESS || defSlotId == slotId_) { + if (ret == TELEPHONY_ERR_SUCCESS || defSlotId != slotId_) { return; } OperatorConfig config; -- Gitee From 7699737155402c77a533f496bcb9f714a7f25615 Mon Sep 17 00:00:00 2001 From: wwz99 Date: Sun, 27 Apr 2025 01:45:47 +0000 Subject: [PATCH 105/145] update test/cellular_data_test.cpp. Signed-off-by: wwz99 --- test/cellular_data_test.cpp | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/test/cellular_data_test.cpp b/test/cellular_data_test.cpp index fdc2d596..65b51ba3 100644 --- a/test/cellular_data_test.cpp +++ b/test/cellular_data_test.cpp @@ -1130,6 +1130,8 @@ HWTEST_F(CellularDataTest, Telephony_Cellulardata_InitTelephonyExtService_0101, HWTEST_F(CellularDataTest, Telephony_Cellulardata_InitTelephonyExtService_0102, Function | MediumTest | Level1) { mockDlsym = new NiceMock(); + EXPECT_CALL(*mockDlsym, dlopen(_, _)) + .WillRepeatedly(Return(reinterpret_cast(0x1234))); EXPECT_CALL(*mockDlsym, dlsym(_, _)) .WillRepeatedly(Return(nullptr)); TELEPHONY_EXT_WRAPPER.InitTelephonyExtWrapperForDynamicLoad(); @@ -1147,6 +1149,8 @@ HWTEST_F(CellularDataTest, Telephony_Cellulardata_InitTelephonyExtService_0102, HWTEST_F(CellularDataTest, Telephony_Cellulardata_InitTelephonyExtService_0103, Function | MediumTest | Level1) { mockDlsym = new NiceMock(); + EXPECT_CALL(*mockDlsym, dlopen(_, _)) + .WillRepeatedly(Return(reinterpret_cast(0x1234))); EXPECT_CALL(*mockDlsym, dlsym(_, _)) .WillOnce(Return(reinterpret_cast(0x1234))) .WillOnce(Return(nullptr)); @@ -1171,6 +1175,11 @@ HWTEST_F(CellularDataTest, Telephony_Cellulardata_InitTelephonyExtService_0103, */ HWTEST_F(CellularDataTest, Telephony_Cellulardata_InitTelephonyExtService_0104, Function | MediumTest | Level1) { + mockDlsym = new NiceMock(); + EXPECT_CALL(*mockDlsym, dlopen(_, _)) + .WillRepeatedly(Return(reinterpret_cast(0x1234))); + EXPECT_CALL(*mockDlsym, dlsym(_, _)) + .WillRepeatedly(Return(reinterpret_cast(0x12345))); auto controller = std::make_shared(DEFAULT_SIM_SLOT_ID); controller->Init(); ASSERT_TRUE(controller->cellularDataHandler_ != nullptr); -- Gitee From 812ffe95ace9b1f40befeed8dbcaa364b839f787 Mon Sep 17 00:00:00 2001 From: wwz99 Date: Sun, 27 Apr 2025 01:47:54 +0000 Subject: [PATCH 106/145] update test/cellular_data_test.cpp. Signed-off-by: wwz99 --- test/cellular_data_test.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/cellular_data_test.cpp b/test/cellular_data_test.cpp index 65b51ba3..bd39cd3f 100644 --- a/test/cellular_data_test.cpp +++ b/test/cellular_data_test.cpp @@ -1152,7 +1152,7 @@ HWTEST_F(CellularDataTest, Telephony_Cellulardata_InitTelephonyExtService_0103, EXPECT_CALL(*mockDlsym, dlopen(_, _)) .WillRepeatedly(Return(reinterpret_cast(0x1234))); EXPECT_CALL(*mockDlsym, dlsym(_, _)) - .WillOnce(Return(reinterpret_cast(0x1234))) + .WillOnce(Return(reinterpret_cast(0x12345))) .WillOnce(Return(nullptr)); auto controller = std::make_shared(DEFAULT_SIM_SLOT_ID); controller->Init(); -- Gitee From 849513725939ad0e47c4eebd11b0efddd4cb42a7 Mon Sep 17 00:00:00 2001 From: zhengsiwen960323 Date: Mon, 28 Apr 2025 12:54:43 +0000 Subject: [PATCH 107/145] update test/fuzztest/getcellulardatastate_fuzzer/getcellulardatastate_fuzzer.cpp. Signed-off-by: zhengsiwen960323 --- .../getcellulardatastate_fuzzer.cpp | 220 ++++++++++++++++++ 1 file changed, 220 insertions(+) diff --git a/test/fuzztest/getcellulardatastate_fuzzer/getcellulardatastate_fuzzer.cpp b/test/fuzztest/getcellulardatastate_fuzzer/getcellulardatastate_fuzzer.cpp index 35647ef6..080dd292 100644 --- a/test/fuzztest/getcellulardatastate_fuzzer/getcellulardatastate_fuzzer.cpp +++ b/test/fuzztest/getcellulardatastate_fuzzer/getcellulardatastate_fuzzer.cpp @@ -316,6 +316,216 @@ void GetInternalActReportInfo(const uint8_t *data, size_t size) DelayedSingleton::GetInstance()->OnRemoteRequest(code, dataMessageParcel, reply, option); } +void HandleApnChanged(const uint8_t *data, size_t size) +{ + if (!IsServiceInited()) { + return; + } + + FuzzedDataProvider fdp(data, size); + int32_t slotId = fdp.ConsumeIntegralInRange(0, SLOT_NUM_MAX); + MessageParcel dataMessageParcel; + if (!dataMessageParcel.WriteInterfaceToken(GetDescriptor())) { + return; + } + dataMessageParcel.WriteInt32(slotId); + dataMessageParcel.WriteBuffer(data, size); + dataMessageParcel.RewindRead(0); + uint32_t code = static_cast(ICellularDataManagerIpcCode::COMMAND_HANDLE_APN_CHANGED); + MessageParcel reply; + MessageOption option(MessageOption::TF_SYNC); + DelayedSingleton::GetInstance()->OnRemoteRequest(code, dataMessageParcel, reply, option); +} + +void GetDefaultCellularDataSimId(const uint8_t *data, size_t size) +{ + if (!IsServiceInited()) { + return; + } + + MessageParcel dataMessageParcel; + if (!dataMessageParcel.WriteInterfaceToken(GetDescriptor())) { + return; + } + dataMessageParcel.WriteBuffer(data, size); + dataMessageParcel.RewindRead(0); + uint32_t code = static_cast(ICellularDataManagerIpcCode::COMMAND_GET_DEFAULT_CELLULAR_DATA_SIM_ID); + MessageParcel reply; + MessageOption option(MessageOption::TF_SYNC); + DelayedSingleton::GetInstance()->OnRemoteRequest(code, dataMessageParcel, reply, option); +} + +void ClearAllConnections(const uint8_t *data, size_t size) +{ + if (!IsServiceInited()) { + return; + } + + FuzzedDataProvider fdp(data, size); + int32_t slotId = fdp.ConsumeIntegralInRange(0, SLOT_NUM_MAX); + int32_t reason = fdp.ConsumeIntegralInRange( + 0, static_cast(DisConnectionReason::REASON_PERMANENT_REJECT)); + MessageParcel dataMessageParcel; + if (!dataMessageParcel.WriteInterfaceToken(GetDescriptor())) { + return; + } + dataMessageParcel.WriteInt32(slotId); + dataMessageParcel.WriteInt32(reason); + dataMessageParcel.WriteBuffer(data, size); + dataMessageParcel.RewindRead(0); + uint32_t code = static_cast(ICellularDataManagerIpcCode::COMMAND_CLEAR_ALL_CONNECTIONS); + MessageParcel reply; + MessageOption option(MessageOption::TF_SYNC); + DelayedSingleton::GetInstance()->OnRemoteRequest(code, dataMessageParcel, reply, option); +} + +void GetDataConnApnAttr(const uint8_t *data, size_t size) +{ + if (!IsServiceInited()) { + return; + } + + FuzzedDataProvider fdp(data, size); + int32_t slotId = fdp.ConsumeIntegralInRange(0, SLOT_NUM_MAX); + MessageParcel dataMessageParcel; + if (!dataMessageParcel.WriteInterfaceToken(GetDescriptor())) { + return; + } + dataMessageParcel.WriteInt32(slotId); + dataMessageParcel.WriteBuffer(data, size); + dataMessageParcel.RewindRead(0); + uint32_t code = static_cast(ICellularDataManagerIpcCode::COMMAND_GET_DATA_CONN_APN_ATTR); + MessageParcel reply; + MessageOption option(MessageOption::TF_SYNC); + DelayedSingleton::GetInstance()->OnRemoteRequest(code, dataMessageParcel, reply, option); +} + +void GetDataConnIpType(const uint8_t *data, size_t size) +{ + if (!IsServiceInited()) { + return; + } + + FuzzedDataProvider fdp(data, size); + int32_t slotId = fdp.ConsumeIntegralInRange(0, SLOT_NUM_MAX); + MessageParcel dataMessageParcel; + if (!dataMessageParcel.WriteInterfaceToken(GetDescriptor())) { + return; + } + dataMessageParcel.WriteInt32(slotId); + dataMessageParcel.WriteBuffer(data, size); + dataMessageParcel.RewindRead(0); + uint32_t code = static_cast(ICellularDataManagerIpcCode::COMMAND_GET_DATA_CONN_IP_TYPE); + MessageParcel reply; + MessageOption option(MessageOption::TF_SYNC); + DelayedSingleton::GetInstance()->OnRemoteRequest(code, dataMessageParcel, reply, option); +} + +void IsNeedDoRecovery(const uint8_t *data, size_t size) +{ + if (!IsServiceInited()) { + return; + } + + FuzzedDataProvider fdp(data, size); + int32_t slotId = fdp.ConsumeIntegralInRange(0, SLOT_NUM_MAX); + MessageParcel dataMessageParcel; + if (!dataMessageParcel.WriteInterfaceToken(GetDescriptor())) { + return; + } + dataMessageParcel.WriteInt32(slotId); + dataMessageParcel.WriteBuffer(data, size); + dataMessageParcel.RewindRead(0); + uint32_t code = static_cast(ICellularDataManagerIpcCode::COMMAND_IS_NEED_DO_RECOVERY); + MessageParcel reply; + MessageOption option(MessageOption::TF_SYNC); + DelayedSingleton::GetInstance()->OnRemoteRequest(code, dataMessageParcel, reply, option); +} + +void InitCellularDataController(const uint8_t *data, size_t size) +{ + if (!IsServiceInited()) { + return; + } + + FuzzedDataProvider fdp(data, size); + int32_t slotId = fdp.ConsumeIntegralInRange(0, SLOT_NUM_MAX); + MessageParcel dataMessageParcel; + if (!dataMessageParcel.WriteInterfaceToken(GetDescriptor())) { + return; + } + dataMessageParcel.WriteInt32(slotId); + dataMessageParcel.WriteBuffer(data, size); + dataMessageParcel.RewindRead(0); + uint32_t code = static_cast(ICellularDataManagerIpcCode::COMMAND_INIT_CELLULAR_DATA_CONTROLLER); + MessageParcel reply; + MessageOption option(MessageOption::TF_SYNC); + DelayedSingleton::GetInstance()->OnRemoteRequest(code, dataMessageParcel, reply, option); +} + +void EstablishAllApnsIfConnectable(const uint8_t *data, size_t size) +{ + if (!IsServiceInited()) { + return; + } + + FuzzedDataProvider fdp(data, size); + int32_t slotId = fdp.ConsumeIntegralInRange(0, SLOT_NUM_MAX); + MessageParcel dataMessageParcel; + if (!dataMessageParcel.WriteInterfaceToken(GetDescriptor())) { + return; + } + dataMessageParcel.WriteInt32(slotId); + dataMessageParcel.WriteBuffer(data, size); + dataMessageParcel.RewindRead(0); + uint32_t code = static_cast(ICellularDataManagerIpcCode::COMMAND_ESTABLISH_ALL_APNS_IF_CONNECTABLE); + MessageParcel reply; + MessageOption option(MessageOption::TF_SYNC); + DelayedSingleton::GetInstance()->OnRemoteRequest(code, dataMessageParcel, reply, option); +} + +void ReleaseCellularDataConnection(const uint8_t *data, size_t size) +{ + if (!IsServiceInited()) { + return; + } + + FuzzedDataProvider fdp(data, size); + int32_t slotId = fdp.ConsumeIntegralInRange(0, SLOT_NUM_MAX); + MessageParcel dataMessageParcel; + if (!dataMessageParcel.WriteInterfaceToken(GetDescriptor())) { + return; + } + dataMessageParcel.WriteInt32(slotId); + dataMessageParcel.WriteBuffer(data, size); + dataMessageParcel.RewindRead(0); + uint32_t code = static_cast(ICellularDataManagerIpcCode::COMMAND_RELEASE_CELLULAR_DATA_CONNECTION); + MessageParcel reply; + MessageOption option(MessageOption::TF_SYNC); + DelayedSingleton::GetInstance()->OnRemoteRequest(code, dataMessageParcel, reply, option); +} + +void GetSupplierRegisterState(const uint8_t *data, size_t size) +{ + if (!IsServiceInited()) { + return; + } + + FuzzedDataProvider fdp(data, size); + int32_t slotId = fdp.ConsumeIntegralInRange(0, SLOT_NUM_MAX); + MessageParcel dataMessageParcel; + if (!dataMessageParcel.WriteInterfaceToken(GetDescriptor())) { + return; + } + dataMessageParcel.WriteInt32(slotId); + dataMessageParcel.WriteBuffer(data, size); + dataMessageParcel.RewindRead(0); + uint32_t code = static_cast(ICellularDataManagerIpcCode::COMMAND_GET_SUPPLIER_REGISTER_STATE); + MessageParcel reply; + MessageOption option(MessageOption::TF_SYNC); + DelayedSingleton::GetInstance()->OnRemoteRequest(code, dataMessageParcel, reply, option); +} + void DoSomethingInterestingWithMyAPI(const uint8_t *data, size_t size) { if (data == nullptr || size == 0) { @@ -336,6 +546,16 @@ void DoSomethingInterestingWithMyAPI(const uint8_t *data, size_t size) UnregisterSimAccountCallback(data, size); GetDefaultActReportInfo(data, size); GetInternalActReportInfo(data, size); + HandleApnChanged(data, size); + GetDefaultCellularDataSimId(data, size); + ClearAllConnections(data, size); + GetDataConnApnAttr(data, size); + GetDataConnIpType(data, size); + IsNeedDoRecovery(data, size); + InitCellularDataController(data, size); + EstablishAllApnsIfConnectable(data, size); + ReleaseCellularDataConnection(data, size); + GetSupplierRegisterState(data, size); } } // namespace OHOS -- Gitee From a0f73f19fbf334ddb3433b61099cbf3a8cae8f14 Mon Sep 17 00:00:00 2001 From: HuuuuDaxia <2443930064@qq.com> Date: Tue, 29 Apr 2025 17:42:25 +0800 Subject: [PATCH 108/145] add nullptr check Signed-off-by: HuuuuDaxia <2443930064@qq.com> --- services/src/state_machine/inactive.cpp | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/services/src/state_machine/inactive.cpp b/services/src/state_machine/inactive.cpp index 3e212a0e..4dfba4c3 100644 --- a/services/src/state_machine/inactive.cpp +++ b/services/src/state_machine/inactive.cpp @@ -88,7 +88,12 @@ bool Inactive::StateProcess(const AppExecFwk::InnerEvent::Pointer &event) switch (eventCode) { case CellularDataEventCode::MSG_SM_CONNECT: { TELEPHONY_LOGD("Inactive::MSG_SM_CONNECT"); - stateMachine->DoConnect(*(event->GetUniqueObject())); + std::unique_ptr params = event->GetUniqueObject(); + if (params == nullptr) { + TELEPHONY_LOGE("Failed to get DataConnectionParams"); + return false; + } + stateMachine->DoConnect(*params); stateMachine->TransitionTo(stateMachine->activatingState_); retVal = PROCESSED; break; -- Gitee From 9e6979f158356f8304b43db83b675005ed7122c6 Mon Sep 17 00:00:00 2001 From: lizefan Date: Wed, 30 Apr 2025 14:09:53 +0800 Subject: [PATCH 109/145] dd fuzz tess Signed-off-by: lizefan --- .../getcellulardatastate_fuzzer.cpp | 174 +++++++++++++++++- 1 file changed, 173 insertions(+), 1 deletion(-) diff --git a/test/fuzztest/getcellulardatastate_fuzzer/getcellulardatastate_fuzzer.cpp b/test/fuzztest/getcellulardatastate_fuzzer/getcellulardatastate_fuzzer.cpp index 080dd292..3b67ab0b 100644 --- a/test/fuzztest/getcellulardatastate_fuzzer/getcellulardatastate_fuzzer.cpp +++ b/test/fuzztest/getcellulardatastate_fuzzer/getcellulardatastate_fuzzer.cpp @@ -21,6 +21,7 @@ #include "adddatatoken_fuzzer.h" #include "cellular_data_ipc_interface_code.h" #include "cellular_data_service.h" +#include "cellular_data_types.h" #include "cellular_data_manager_stub.h" #include "data_sim_account_callback.h" #include "system_ability_definition.h" @@ -31,6 +32,9 @@ using namespace OHOS::Telephony; namespace OHOS { static bool g_isInited = false; constexpr int32_t SLOT_NUM_MAX = 3; +constexpr int32_t APN_ID_MAX = 5; +constexpr int32_t APN_STRING_LENGTH = 10; +constexpr int32_t NET_CAPABILITY_MAX = 32; static constexpr const char16_t *DESCRIPTOR = u"OHOS.Telephony.ICellularDataManager"; static inline const std::u16string GetDescriptor() { @@ -66,6 +70,24 @@ void EnableCellularData(const uint8_t *data, size_t size) DelayedSingleton::GetInstance()->OnRemoteRequest(code, dataMessageParcel, reply, option); } +void EnableIntelligenceSwitch(const uint8_t *data, size_t size) +{ + if (!IsServiceInited()) { + return; + } + + MessageParcel dataMessageParcel; + if (!dataMessageParcel.WriteInterfaceToken(GetDescriptor())) { + return; + } + dataMessageParcel.WriteBuffer(data, size); + dataMessageParcel.RewindRead(0); + uint32_t code = static_cast(ICellularDataManagerIpcCode::COMMAND_ENABLE_INTELLIGENCE_SWITCH); + MessageParcel reply; + MessageOption option(MessageOption::TF_SYNC); + DelayedSingleton::GetInstance()->OnRemoteRequest(code, dataMessageParcel, reply, option); +} + void GetCellularDataState(const uint8_t *data, size_t size) { if (!IsServiceInited()) { @@ -134,7 +156,7 @@ void GetDefaultCellularDataSlotId(const uint8_t *data, size_t size) } dataMessageParcel.WriteBuffer(data, size); dataMessageParcel.RewindRead(0); - uint32_t code = static_cast(ICellularDataManagerIpcCode::COMMAND_IS_CELLULAR_DATA_ROAMING_ENABLED); + uint32_t code = static_cast(ICellularDataManagerIpcCode::COMMAND_GET_DEFAULT_CELLULAR_DATA_SLOT_ID); MessageParcel reply; MessageOption option(MessageOption::TF_SYNC); DelayedSingleton::GetInstance()->OnRemoteRequest(code, dataMessageParcel, reply, option); @@ -421,6 +443,70 @@ void GetDataConnIpType(const uint8_t *data, size_t size) DelayedSingleton::GetInstance()->OnRemoteRequest(code, dataMessageParcel, reply, option); } +void GetApnState(const uint8_t *data, size_t size) +{ + if (!IsServiceInited()) { + return; + } + + FuzzedDataProvider fdp(data, size); + int32_t slotId = fdp.ConsumeIntegralInRange(0, SLOT_NUM_MAX); + MessageParcel dataMessageParcel; + if (!dataMessageParcel.WriteInterfaceToken(GetDescriptor())) { + return; + } + dataMessageParcel.WriteInt32(slotId); + std::string apnType = fdp.ConsumeRandomLengthString(APN_STRING_LENGTH); + if (!dataMessageParcel.WriteString16(Str8ToStr16(apnType))) { + return; + } + dataMessageParcel.RewindRead(0); + uint32_t code = static_cast(ICellularDataManagerIpcCode::COMMAND_GET_APN_STATE); + MessageParcel reply; + MessageOption option(MessageOption::TF_SYNC); + DelayedSingleton::GetInstance()->OnRemoteRequest(code, dataMessageParcel, reply, option); +} + +void GetDataRecoveryState(const uint8_t *data, size_t size) +{ + if (!IsServiceInited()) { + return; + } + + MessageParcel dataMessageParcel; + if (!dataMessageParcel.WriteInterfaceToken(GetDescriptor())) { + return; + } + dataMessageParcel.WriteBuffer(data, size); + dataMessageParcel.RewindRead(0); + uint32_t code = static_cast(ICellularDataManagerIpcCode::COMMAND_GET_DATA_RECOVERY_STATE); + MessageParcel reply; + MessageOption option(MessageOption::TF_SYNC); + DelayedSingleton::GetInstance()->OnRemoteRequest(code, dataMessageParcel, reply, option); +} + +void GetCellularDataSupplierId(const uint8_t *data, size_t size) +{ + if (!IsServiceInited()) { + return; + } + + MessageParcel dataMessageParcel; + if (!dataMessageParcel.WriteInterfaceToken(GetDescriptor())) { + return; + } + FuzzedDataProvider fdp(data, size); + int32_t slotId = fdp.ConsumeIntegralInRange(0, SLOT_NUM_MAX); + dataMessageParcel.WriteInt32(slotId); + uint64_t capability = fdp.ConsumeIntegralInRange(0, NET_CAPABILITY_MAX); + dataMessageParcel.WriteUint64(slotId); + dataMessageParcel.RewindRead(0); + uint32_t code = static_cast(ICellularDataManagerIpcCode::COMMAND_GET_CELLULAR_DATA_SUPPLIER_ID); + MessageParcel reply; + MessageOption option(MessageOption::TF_SYNC); + DelayedSingleton::GetInstance()->OnRemoteRequest(code, dataMessageParcel, reply, option); +} + void IsNeedDoRecovery(const uint8_t *data, size_t size) { if (!IsServiceInited()) { @@ -442,6 +528,85 @@ void IsNeedDoRecovery(const uint8_t *data, size_t size) DelayedSingleton::GetInstance()->OnRemoteRequest(code, dataMessageParcel, reply, option); } +void CorrectNetSupplierNoAvailable(const uint8_t *data, size_t size) +{ + if (!IsServiceInited()) { + return; + } + + FuzzedDataProvider fdp(data, size); + int32_t slotId = fdp.ConsumeIntegralInRange(0, SLOT_NUM_MAX); + MessageParcel dataMessageParcel; + if (!dataMessageParcel.WriteInterfaceToken(GetDescriptor())) { + return; + } + dataMessageParcel.WriteInt32(slotId); + dataMessageParcel.WriteBuffer(data, size); + dataMessageParcel.RewindRead(0); + uint32_t code = static_cast(ICellularDataManagerIpcCode::COMMAND_CORRECT_NET_SUPPLIER_NO_AVAILABLE); + MessageParcel reply; + MessageOption option(MessageOption::TF_SYNC); + DelayedSingleton::GetInstance()->OnRemoteRequest(code, dataMessageParcel, reply, option); +} + +void GetIfSupportDunApn(const uint8_t *data, size_t size) +{ + if (!IsServiceInited()) { + return; + } + + MessageParcel dataMessageParcel; + if (!dataMessageParcel.WriteInterfaceToken(GetDescriptor())) { + return; + } + dataMessageParcel.WriteBuffer(data, size); + dataMessageParcel.RewindRead(0); + uint32_t code = static_cast(ICellularDataManagerIpcCode::COMMAND_GET_IF_SUPPORT_DUN_APN); + MessageParcel reply; + MessageOption option(MessageOption::TF_SYNC); + DelayedSingleton::GetInstance()->OnRemoteRequest(code, dataMessageParcel, reply, option); +} + +void QueryApnIds(const uint8_t *data, size_t size) +{ + if (!IsServiceInited()) { + return; + } + + MessageParcel dataMessageParcel; + if (!dataMessageParcel.WriteInterfaceToken(GetDescriptor())) { + return; + } + ApnInfo apnInfo; + dataMessageParcel.WriteParcelable(&apnInfo); + dataMessageParcel.WriteBuffer(data, size); + dataMessageParcel.RewindRead(0); + uint32_t code = static_cast(ICellularDataManagerIpcCode::COMMAND_QUERY_APN_ID); + MessageParcel reply; + MessageOption option(MessageOption::TF_SYNC); + DelayedSingleton::GetInstance()->OnRemoteRequest(code, dataMessageParcel, reply, option); +} + +void SetPreferApn(const uint8_t *data, size_t size) +{ + if (!IsServiceInited()) { + return; + } + + MessageParcel dataMessageParcel; + if (!dataMessageParcel.WriteInterfaceToken(GetDescriptor())) { + return; + } + FuzzedDataProvider fdp(data, size); + int32_t apnId = fdp.ConsumeIntegralInRange(0, APN_ID_MAX); + dataMessageParcel.WriteInt32(apnId); + dataMessageParcel.RewindRead(0); + uint32_t code = static_cast(ICellularDataManagerIpcCode::COMMAND_SET_PREFER_APN); + MessageParcel reply; + MessageOption option(MessageOption::TF_SYNC); + DelayedSingleton::GetInstance()->OnRemoteRequest(code, dataMessageParcel, reply, option); +} + void InitCellularDataController(const uint8_t *data, size_t size) { if (!IsServiceInited()) { @@ -533,6 +698,7 @@ void DoSomethingInterestingWithMyAPI(const uint8_t *data, size_t size) } EnableCellularData(data, size); + EnableIntelligenceSwitch(data, size); GetCellularDataState(data, size); IsCellularDataEnabled(data, size); IsCellularDataRoamingEnabled(data, size); @@ -551,11 +717,17 @@ void DoSomethingInterestingWithMyAPI(const uint8_t *data, size_t size) ClearAllConnections(data, size); GetDataConnApnAttr(data, size); GetDataConnIpType(data, size); + GetApnState(data, size); + GetDataRecoveryState(data, size); IsNeedDoRecovery(data, size); InitCellularDataController(data, size); EstablishAllApnsIfConnectable(data, size); ReleaseCellularDataConnection(data, size); GetSupplierRegisterState(data, size); + GetCellularDataSupplierId(data, size); + CorrectNetSupplierNoAvailable(data, size); + GetIfSupportDunApn(data, size); + QueryApnIds(data, size); } } // namespace OHOS -- Gitee From fe09a18ae557c4c65feb0c8969a3bb83945e4c1f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E6=B3=BD=E5=87=A1?= Date: Wed, 30 Apr 2025 06:12:42 +0000 Subject: [PATCH 110/145] update test/fuzztest/getcellulardatastate_fuzzer/getcellulardatastate_fuzzer.cpp. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 李泽凡 --- .../getcellulardatastate_fuzzer/getcellulardatastate_fuzzer.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/test/fuzztest/getcellulardatastate_fuzzer/getcellulardatastate_fuzzer.cpp b/test/fuzztest/getcellulardatastate_fuzzer/getcellulardatastate_fuzzer.cpp index 3b67ab0b..fdf7777a 100644 --- a/test/fuzztest/getcellulardatastate_fuzzer/getcellulardatastate_fuzzer.cpp +++ b/test/fuzztest/getcellulardatastate_fuzzer/getcellulardatastate_fuzzer.cpp @@ -728,6 +728,7 @@ void DoSomethingInterestingWithMyAPI(const uint8_t *data, size_t size) CorrectNetSupplierNoAvailable(data, size); GetIfSupportDunApn(data, size); QueryApnIds(data, size); + SetPreferApn(data, size); } } // namespace OHOS -- Gitee From 9bd9dd23302d44a944e9c9fa2b68ed043447aefa Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E6=B3=BD=E5=87=A1?= Date: Wed, 30 Apr 2025 06:36:24 +0000 Subject: [PATCH 111/145] update test/fuzztest/getcellulardatastate_fuzzer/getcellulardatastate_fuzzer.cpp. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 李泽凡 --- .../getcellulardatastate_fuzzer.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/test/fuzztest/getcellulardatastate_fuzzer/getcellulardatastate_fuzzer.cpp b/test/fuzztest/getcellulardatastate_fuzzer/getcellulardatastate_fuzzer.cpp index fdf7777a..fb50edbd 100644 --- a/test/fuzztest/getcellulardatastate_fuzzer/getcellulardatastate_fuzzer.cpp +++ b/test/fuzztest/getcellulardatastate_fuzzer/getcellulardatastate_fuzzer.cpp @@ -499,7 +499,7 @@ void GetCellularDataSupplierId(const uint8_t *data, size_t size) int32_t slotId = fdp.ConsumeIntegralInRange(0, SLOT_NUM_MAX); dataMessageParcel.WriteInt32(slotId); uint64_t capability = fdp.ConsumeIntegralInRange(0, NET_CAPABILITY_MAX); - dataMessageParcel.WriteUint64(slotId); + dataMessageParcel.WriteUint64(capability); dataMessageParcel.RewindRead(0); uint32_t code = static_cast(ICellularDataManagerIpcCode::COMMAND_GET_CELLULAR_DATA_SUPPLIER_ID); MessageParcel reply; @@ -581,7 +581,7 @@ void QueryApnIds(const uint8_t *data, size_t size) dataMessageParcel.WriteParcelable(&apnInfo); dataMessageParcel.WriteBuffer(data, size); dataMessageParcel.RewindRead(0); - uint32_t code = static_cast(ICellularDataManagerIpcCode::COMMAND_QUERY_APN_ID); + uint32_t code = static_cast(ICellularDataManagerIpcCode::COMMAND_QUERY_APN_IDS); MessageParcel reply; MessageOption option(MessageOption::TF_SYNC); DelayedSingleton::GetInstance()->OnRemoteRequest(code, dataMessageParcel, reply, option); -- Gitee From cb327e34ba7f4733422beaca70c6b39e6e983403 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=BE=99=E7=8C=AB=E8=83=96=E8=83=96?= Date: Mon, 5 May 2025 10:58:00 +0800 Subject: [PATCH 112/145] fix watch default cellular data MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 龙猫胖胖 --- interfaces/innerkits/cellular_data_types.h | 6 +++++ .../include/common/cellular_data_constant.h | 3 +++ services/include/data_switch_settings.h | 2 ++ services/src/cellular_data_handler.cpp | 16 +++++++----- services/src/data_switch_settings.cpp | 26 +++++++++++++++++++ .../cellular_data_settings_rdb_helper.cpp | 2 +- 6 files changed, 48 insertions(+), 7 deletions(-) diff --git a/interfaces/innerkits/cellular_data_types.h b/interfaces/innerkits/cellular_data_types.h index 4add62b2..31fe70f6 100644 --- a/interfaces/innerkits/cellular_data_types.h +++ b/interfaces/innerkits/cellular_data_types.h @@ -40,6 +40,12 @@ enum class DataSwitchCode : int32_t { CELLULAR_DATA_ENABLED = 1 }; +// +enum class DataSwitchCode : int32_t { + CELLULAR_DATA_DISABLED = 0, + CELLULAR_DATA_ENABLED = 1 +}; + enum class IntelligenceSwitchCode : int32_t { INTELLIGENCE_SWITCH_DISABLED = 0, INTELLIGENCE_SWITCH_ENABLED = 1 diff --git a/services/include/common/cellular_data_constant.h b/services/include/common/cellular_data_constant.h index 44296f97..be91167d 100644 --- a/services/include/common/cellular_data_constant.h +++ b/services/include/common/cellular_data_constant.h @@ -233,6 +233,8 @@ static constexpr const char *CELLULAR_DATA_SETTING_URI = static constexpr const char *CELLULAR_DATA_SETTING_EXT_URI = "datashare:///com.ohos.settingsdata.DataAbility"; static constexpr const char *CELLULAR_DATA_SETTING_DATA_ENABLE_URI = "datashare:///com.ohos.settingsdata/entry/settingsdata/SETTINGSDATA?Proxy=true&key=cellular_data_enable"; +static constexpr const char *CELLULAR_DATA_SETTING_ANY_SIM_DETECTED_URI = + "datashare:///com.ohos.settingsdata/entry/settingsdata/SETTINGSDATA?Proxy=true&key=any_sim_detected"; static constexpr const char *CELLULAR_DATA_SETTING_DATA_ROAMING_URI = "datashare:///com.ohos.settingsdata/entry/settingsdata/SETTINGSDATA?Proxy=true&key=cellular_data_roaming_enable"; static constexpr const char *CELLULAR_DATA_SETTING_DATA_INCALL_URI = @@ -300,6 +302,7 @@ static const int32_t VALID_VECTOR_SIZE = 2; static const int32_t DELAY_SET_RIL_BANDWIDTH_MS = 3000; static const int32_t DELAY_SET_RIL_UP_DOWN_BANDWIDTH_MS = 50; static constexpr const char *CELLULAR_DATA_COLUMN_ENABLE = "cellular_data_enable"; +static constexpr const char *SIM_DETECTED_COLUMN_ENABLE = "any_sim_detected"; static constexpr const char *CELLULAR_DATA_COLUMN_ROAMING = "cellular_data_roaming_enable"; static constexpr const char *CELLULAR_DATA_COLUMN_INCALL = "cellular_data_incall_enable"; static constexpr const char *INTELLIGENCE_SWITCH_COLUMN_ENABLE = "intelligence_card_switch_enable"; diff --git a/services/include/data_switch_settings.h b/services/include/data_switch_settings.h index b82b70e8..adda38a5 100644 --- a/services/include/data_switch_settings.h +++ b/services/include/data_switch_settings.h @@ -36,10 +36,12 @@ public: bool IsUserDataRoamingOn(); void UpdateUserDataRoamingOn(bool dataRoaming); int32_t SetUserDataOn(bool userDataOn); + int32_t SetAnySimDetected(int32_t simDetected); int32_t SetIntelliSwitchOn(bool userSwitchOn); int32_t SetUserDataRoamingOn(bool dataRoamingEnabled); int32_t QueryIntelligenceSwitchStatus(bool &switchEnabled); int32_t QueryUserDataStatus(bool &dataEnabled); + int32_t QueryAnySimDetected(int32_t simDetected); int32_t QueryUserDataRoamingStatus(bool &dataRoamingEnabled); private: diff --git a/services/src/cellular_data_handler.cpp b/services/src/cellular_data_handler.cpp index 78f185ae..026ee3ac 100644 --- a/services/src/cellular_data_handler.cpp +++ b/services/src/cellular_data_handler.cpp @@ -2005,17 +2005,21 @@ void CellularDataHandler::GetDefaultDataEnableConfig() return; } bool dataEnbaled = true; - int32_t ret = dataSwitchSettings_->QueryUserDataStatus(dataEnbaled); + int32_t ret = dataSwitchSettings_->QueryAnySimDetectedStatus( + static_cast(DataSimDetectedCode::SIM_DETECTED_DISABLED)); const int32_t defSlotId = CoreManagerInner::GetInstance().GetDefaultCellularDataSlotId(); if (ret == TELEPHONY_ERR_SUCCESS || defSlotId != slotId_) { return; } OperatorConfig config; - CoreManagerInner::GetInstance().GetOperatorConfigs(slotId_, config); - if (config.boolValue.find(KEY_DEFAULT_DATA_ENABLE_BOOL) != config.boolValue.end()) { - dataEnbaled = config.boolValue[KEY_DEFAULT_DATA_ENABLE_BOOL]; - TELEPHONY_LOGI("Slot%{public}d: OperatorConfig dataEnable_ = %{public}d", slotId_, dataEnbaled); - dataSwitchSettings_->SetUserDataOn(dataEnbaled); + if (ret == TELEPHONY_ERR_DATABASE_READ_EMPTY) { + CoreManagerInner::GetInstance().GetOperatorConfigs(slotId_, config); + if (config.boolValue.find(KEY_DEFAULT_DATA_ENABLE_BOOL) != config.boolValue.end()) { + dataEnbaled = config.boolValue[KEY_DEFAULT_DATA_ENABLE_BOOL]; + TELEPHONY_LOGI("Slot%{public}d: OperatorConfig dataEnable_ = %{public}d", slotId_, dataEnbaled); + dataSwitchSettings_->SetUserDataOn(dataEnbaled); + } + dataSwitchSettings_->SetAnySimDetected(static_castDataSimDetectedCode::SIM_DETECTED_ENABLED); } } diff --git a/services/src/data_switch_settings.cpp b/services/src/data_switch_settings.cpp index 787e9687..3c558d25 100644 --- a/services/src/data_switch_settings.cpp +++ b/services/src/data_switch_settings.cpp @@ -69,6 +69,19 @@ int32_t DataSwitchSettings::SetUserDataOn(bool userDataOn) return result; } +int32_t DataSwitchSettings::SetAnySimDetected(int32_t simDetected) +{ + std::shared_ptr settingsRdbHelper = CellularDataSettingsRdbHelper::GetInstance(); + if (settingsRdbHelper == nullptr) { + TELEPHONY_LOGE("settingsRdbHelper == nullptr!"); + return TELEPHONY_ERR_LOCAL_PTR_NULL; + } + Uri anySimDetectedUri(CELLULAR_DATA_SETTING_ANY_SIM_DETECTED_URI); + int32_t result = settingsRdbHelper->PutValue(anySimDetectedUri, SIM_DETECTED_COLUMN_ENABLE, simDetected); + TELEPHONY_LOGI("DataSwitchSettings::SetAnySimDetected result:%{public}d", result); + return result; +} + int32_t DataSwitchSettings::SetIntelliSwitchOn(bool userSwitchOn) { std::shared_ptr settingsRdbHelper = CellularDataSettingsRdbHelper::GetInstance(); @@ -112,6 +125,19 @@ int32_t DataSwitchSettings::QueryUserDataStatus(bool &dataEnabled) return TELEPHONY_ERR_SUCCESS; } +int32_t DataSwitchSettings::QueryAnySimDetected(int32_t simDetected) +{ + std::shared_ptr settingsRdbHelper = CellularDataSettingsRdbHelper::GetInstance(); + if (settingsRdbHelper == nullptr) { + TELEPHONY_LOGE("settingsRdbHelper is nullptr!"); + return TELEPHONY_ERR_LOCAL_PTR_NULL; + } + Uri anySimDetectedUri(CELLULAR_DATA_SETTING_ANY_SIM_DETECTED_URI); + int32_t ret = settingsRdbHelper->GetValue(anySimDetectedUri, SIM_DETECTED_COLUMN_ENABLE, simDetected); + TELEPHONY_LOGI("DataSwitchSettings::QueryAnySimDetected ret:%{public}d", ret); + return ret; +} + int32_t DataSwitchSettings::QueryIntelligenceSwitchStatus(bool &switchEnabled) { std::shared_ptr settingsRdbHelper = CellularDataSettingsRdbHelper::GetInstance(); diff --git a/services/src/utils/cellular_data_settings_rdb_helper.cpp b/services/src/utils/cellular_data_settings_rdb_helper.cpp index ce8e6c74..ffaa7445 100644 --- a/services/src/utils/cellular_data_settings_rdb_helper.cpp +++ b/services/src/utils/cellular_data_settings_rdb_helper.cpp @@ -121,7 +121,7 @@ int32_t CellularDataSettingsRdbHelper::GetValue(Uri &uri, const std::string &col TELEPHONY_LOGD("Query end resultValue is %{public}s", resultValue.c_str()); if (resultValue.empty()) { TELEPHONY_LOGE("resultValue is empty"); - return TELEPHONY_ERR_DATABASE_READ_FAIL; + return TELEPHONY_ERR_DATABASE_READ_EMPTY; } value = atoi(resultValue.c_str()); return TELEPHONY_ERR_SUCCESS; -- Gitee From b2b96b805affd8c9d8a959cb68ff588ad32237ed Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=BE=99=E7=8C=AB=E8=83=96=E8=83=96?= Date: Mon, 5 May 2025 11:37:56 +0800 Subject: [PATCH 113/145] fix watch default cellular data MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 龙猫胖胖 --- interfaces/innerkits/cellular_data_types.h | 5 ++++ .../include/common/cellular_data_constant.h | 3 +++ services/include/data_switch_settings.h | 2 ++ services/src/cellular_data_handler.cpp | 16 +++++++----- services/src/data_switch_settings.cpp | 26 +++++++++++++++++++ .../cellular_data_settings_rdb_helper.cpp | 2 +- 6 files changed, 47 insertions(+), 7 deletions(-) diff --git a/interfaces/innerkits/cellular_data_types.h b/interfaces/innerkits/cellular_data_types.h index 4add62b2..374ae067 100644 --- a/interfaces/innerkits/cellular_data_types.h +++ b/interfaces/innerkits/cellular_data_types.h @@ -40,6 +40,11 @@ enum class DataSwitchCode : int32_t { CELLULAR_DATA_ENABLED = 1 }; +enum class DataSimDetectedCode : int32_t { + SIM_DETECTED_DISABLED = 0, + SIM_DETECTED_ENABLED = 1 +}; + enum class IntelligenceSwitchCode : int32_t { INTELLIGENCE_SWITCH_DISABLED = 0, INTELLIGENCE_SWITCH_ENABLED = 1 diff --git a/services/include/common/cellular_data_constant.h b/services/include/common/cellular_data_constant.h index 44296f97..be91167d 100644 --- a/services/include/common/cellular_data_constant.h +++ b/services/include/common/cellular_data_constant.h @@ -233,6 +233,8 @@ static constexpr const char *CELLULAR_DATA_SETTING_URI = static constexpr const char *CELLULAR_DATA_SETTING_EXT_URI = "datashare:///com.ohos.settingsdata.DataAbility"; static constexpr const char *CELLULAR_DATA_SETTING_DATA_ENABLE_URI = "datashare:///com.ohos.settingsdata/entry/settingsdata/SETTINGSDATA?Proxy=true&key=cellular_data_enable"; +static constexpr const char *CELLULAR_DATA_SETTING_ANY_SIM_DETECTED_URI = + "datashare:///com.ohos.settingsdata/entry/settingsdata/SETTINGSDATA?Proxy=true&key=any_sim_detected"; static constexpr const char *CELLULAR_DATA_SETTING_DATA_ROAMING_URI = "datashare:///com.ohos.settingsdata/entry/settingsdata/SETTINGSDATA?Proxy=true&key=cellular_data_roaming_enable"; static constexpr const char *CELLULAR_DATA_SETTING_DATA_INCALL_URI = @@ -300,6 +302,7 @@ static const int32_t VALID_VECTOR_SIZE = 2; static const int32_t DELAY_SET_RIL_BANDWIDTH_MS = 3000; static const int32_t DELAY_SET_RIL_UP_DOWN_BANDWIDTH_MS = 50; static constexpr const char *CELLULAR_DATA_COLUMN_ENABLE = "cellular_data_enable"; +static constexpr const char *SIM_DETECTED_COLUMN_ENABLE = "any_sim_detected"; static constexpr const char *CELLULAR_DATA_COLUMN_ROAMING = "cellular_data_roaming_enable"; static constexpr const char *CELLULAR_DATA_COLUMN_INCALL = "cellular_data_incall_enable"; static constexpr const char *INTELLIGENCE_SWITCH_COLUMN_ENABLE = "intelligence_card_switch_enable"; diff --git a/services/include/data_switch_settings.h b/services/include/data_switch_settings.h index b82b70e8..adda38a5 100644 --- a/services/include/data_switch_settings.h +++ b/services/include/data_switch_settings.h @@ -36,10 +36,12 @@ public: bool IsUserDataRoamingOn(); void UpdateUserDataRoamingOn(bool dataRoaming); int32_t SetUserDataOn(bool userDataOn); + int32_t SetAnySimDetected(int32_t simDetected); int32_t SetIntelliSwitchOn(bool userSwitchOn); int32_t SetUserDataRoamingOn(bool dataRoamingEnabled); int32_t QueryIntelligenceSwitchStatus(bool &switchEnabled); int32_t QueryUserDataStatus(bool &dataEnabled); + int32_t QueryAnySimDetected(int32_t simDetected); int32_t QueryUserDataRoamingStatus(bool &dataRoamingEnabled); private: diff --git a/services/src/cellular_data_handler.cpp b/services/src/cellular_data_handler.cpp index 78f185ae..026ee3ac 100644 --- a/services/src/cellular_data_handler.cpp +++ b/services/src/cellular_data_handler.cpp @@ -2005,17 +2005,21 @@ void CellularDataHandler::GetDefaultDataEnableConfig() return; } bool dataEnbaled = true; - int32_t ret = dataSwitchSettings_->QueryUserDataStatus(dataEnbaled); + int32_t ret = dataSwitchSettings_->QueryAnySimDetectedStatus( + static_cast(DataSimDetectedCode::SIM_DETECTED_DISABLED)); const int32_t defSlotId = CoreManagerInner::GetInstance().GetDefaultCellularDataSlotId(); if (ret == TELEPHONY_ERR_SUCCESS || defSlotId != slotId_) { return; } OperatorConfig config; - CoreManagerInner::GetInstance().GetOperatorConfigs(slotId_, config); - if (config.boolValue.find(KEY_DEFAULT_DATA_ENABLE_BOOL) != config.boolValue.end()) { - dataEnbaled = config.boolValue[KEY_DEFAULT_DATA_ENABLE_BOOL]; - TELEPHONY_LOGI("Slot%{public}d: OperatorConfig dataEnable_ = %{public}d", slotId_, dataEnbaled); - dataSwitchSettings_->SetUserDataOn(dataEnbaled); + if (ret == TELEPHONY_ERR_DATABASE_READ_EMPTY) { + CoreManagerInner::GetInstance().GetOperatorConfigs(slotId_, config); + if (config.boolValue.find(KEY_DEFAULT_DATA_ENABLE_BOOL) != config.boolValue.end()) { + dataEnbaled = config.boolValue[KEY_DEFAULT_DATA_ENABLE_BOOL]; + TELEPHONY_LOGI("Slot%{public}d: OperatorConfig dataEnable_ = %{public}d", slotId_, dataEnbaled); + dataSwitchSettings_->SetUserDataOn(dataEnbaled); + } + dataSwitchSettings_->SetAnySimDetected(static_castDataSimDetectedCode::SIM_DETECTED_ENABLED); } } diff --git a/services/src/data_switch_settings.cpp b/services/src/data_switch_settings.cpp index 787e9687..3c558d25 100644 --- a/services/src/data_switch_settings.cpp +++ b/services/src/data_switch_settings.cpp @@ -69,6 +69,19 @@ int32_t DataSwitchSettings::SetUserDataOn(bool userDataOn) return result; } +int32_t DataSwitchSettings::SetAnySimDetected(int32_t simDetected) +{ + std::shared_ptr settingsRdbHelper = CellularDataSettingsRdbHelper::GetInstance(); + if (settingsRdbHelper == nullptr) { + TELEPHONY_LOGE("settingsRdbHelper == nullptr!"); + return TELEPHONY_ERR_LOCAL_PTR_NULL; + } + Uri anySimDetectedUri(CELLULAR_DATA_SETTING_ANY_SIM_DETECTED_URI); + int32_t result = settingsRdbHelper->PutValue(anySimDetectedUri, SIM_DETECTED_COLUMN_ENABLE, simDetected); + TELEPHONY_LOGI("DataSwitchSettings::SetAnySimDetected result:%{public}d", result); + return result; +} + int32_t DataSwitchSettings::SetIntelliSwitchOn(bool userSwitchOn) { std::shared_ptr settingsRdbHelper = CellularDataSettingsRdbHelper::GetInstance(); @@ -112,6 +125,19 @@ int32_t DataSwitchSettings::QueryUserDataStatus(bool &dataEnabled) return TELEPHONY_ERR_SUCCESS; } +int32_t DataSwitchSettings::QueryAnySimDetected(int32_t simDetected) +{ + std::shared_ptr settingsRdbHelper = CellularDataSettingsRdbHelper::GetInstance(); + if (settingsRdbHelper == nullptr) { + TELEPHONY_LOGE("settingsRdbHelper is nullptr!"); + return TELEPHONY_ERR_LOCAL_PTR_NULL; + } + Uri anySimDetectedUri(CELLULAR_DATA_SETTING_ANY_SIM_DETECTED_URI); + int32_t ret = settingsRdbHelper->GetValue(anySimDetectedUri, SIM_DETECTED_COLUMN_ENABLE, simDetected); + TELEPHONY_LOGI("DataSwitchSettings::QueryAnySimDetected ret:%{public}d", ret); + return ret; +} + int32_t DataSwitchSettings::QueryIntelligenceSwitchStatus(bool &switchEnabled) { std::shared_ptr settingsRdbHelper = CellularDataSettingsRdbHelper::GetInstance(); diff --git a/services/src/utils/cellular_data_settings_rdb_helper.cpp b/services/src/utils/cellular_data_settings_rdb_helper.cpp index ce8e6c74..ffaa7445 100644 --- a/services/src/utils/cellular_data_settings_rdb_helper.cpp +++ b/services/src/utils/cellular_data_settings_rdb_helper.cpp @@ -121,7 +121,7 @@ int32_t CellularDataSettingsRdbHelper::GetValue(Uri &uri, const std::string &col TELEPHONY_LOGD("Query end resultValue is %{public}s", resultValue.c_str()); if (resultValue.empty()) { TELEPHONY_LOGE("resultValue is empty"); - return TELEPHONY_ERR_DATABASE_READ_FAIL; + return TELEPHONY_ERR_DATABASE_READ_EMPTY; } value = atoi(resultValue.c_str()); return TELEPHONY_ERR_SUCCESS; -- Gitee From c5b5117323c54d1cffb414d7fa82230145f8d69a Mon Sep 17 00:00:00 2001 From: Henry Date: Mon, 5 May 2025 06:16:25 +0000 Subject: [PATCH 114/145] update services/include/data_switch_settings.h. Signed-off-by: Henry --- services/include/data_switch_settings.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/services/include/data_switch_settings.h b/services/include/data_switch_settings.h index adda38a5..654cbf65 100644 --- a/services/include/data_switch_settings.h +++ b/services/include/data_switch_settings.h @@ -41,7 +41,7 @@ public: int32_t SetUserDataRoamingOn(bool dataRoamingEnabled); int32_t QueryIntelligenceSwitchStatus(bool &switchEnabled); int32_t QueryUserDataStatus(bool &dataEnabled); - int32_t QueryAnySimDetected(int32_t simDetected); + int32_t QueryAnySimDetectedStatus(int32_t simDetected); int32_t QueryUserDataRoamingStatus(bool &dataRoamingEnabled); private: -- Gitee From c3c93c334f6a3ac7f015109b3cb11a078b0ff410 Mon Sep 17 00:00:00 2001 From: Henry Date: Tue, 6 May 2025 07:14:26 +0000 Subject: [PATCH 115/145] update test/data_switch_settings_test.cpp. Signed-off-by: Henry --- test/data_switch_settings_test.cpp | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/test/data_switch_settings_test.cpp b/test/data_switch_settings_test.cpp index 1bb94736..f1e5d375 100644 --- a/test/data_switch_settings_test.cpp +++ b/test/data_switch_settings_test.cpp @@ -131,12 +131,10 @@ HWTEST_F(DataSwitchSettingTest, DataSwitchSetting_07, Function | MediumTest | Le DataSwitchSettings sets(2); std::cout << "DataSwitchSetting_07 slotId: " << sets.slotId_ << std::endl; int32_t simDetected = 0; - ASSERT_TRUE(sets.QueryUserDataStatus(dataEnabled) == TELEPHONY_ERR_SUCCESS); - ASSERT_TRUE(dataEnabled); + ASSERT_TRUE(sets.QueryUserDataStatus(simDetected) == TELEPHONY_ERR_SUCCESS); DataSwitchSettings sets1(0); - ASSERT_TRUE(sets1.QueryUserDataStatus(dataEnabled) == TELEPHONY_ERR_SUCCESS); - ASSERT_TRUE(dataEnabled); + ASSERT_TRUE(sets1.QueryUserDataStatus(simDetected) == TELEPHONY_ERR_SUCCESS); } } // namespace Telephony -- Gitee From 667ebc108a0a260f9eb109299aea4c3e0b332b51 Mon Sep 17 00:00:00 2001 From: Henry Date: Tue, 6 May 2025 07:33:39 +0000 Subject: [PATCH 116/145] update test/data_switch_settings_test.cpp. Signed-off-by: Henry --- test/data_switch_settings_test.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/test/data_switch_settings_test.cpp b/test/data_switch_settings_test.cpp index f1e5d375..214c0735 100644 --- a/test/data_switch_settings_test.cpp +++ b/test/data_switch_settings_test.cpp @@ -120,10 +120,10 @@ HWTEST_F(DataSwitchSettingTest, DataSwitchSetting_06, Function | MediumTest | Le DataSwitchSettings sets(2); std::cout << "DataSwitchSetting_06 slotId: " << sets.slotId_ << std::endl; int32_t simDetected = 1; - ASSERT_TRUE(sets.SetAnySimDetected(true) == TELEPHONY_ERR_SUCCESS); + ASSERT_TRUE(sets.SetAnySimDetected(simDetected) == TELEPHONY_ERR_SUCCESS); DataSwitchSettings sets1(0); - ASSERT_TRUE(sets.SetAnySimDetected(true) == TELEPHONY_ERR_SUCCESS); + ASSERT_TRUE(sets.SetAnySimDetected(simDetected) == TELEPHONY_ERR_SUCCESS); } HWTEST_F(DataSwitchSettingTest, DataSwitchSetting_07, Function | MediumTest | Level1) -- Gitee From fc68d8ac7369033caf1539a973e0e6aad1da1424 Mon Sep 17 00:00:00 2001 From: zhengsiwen960323 Date: Tue, 6 May 2025 07:54:32 +0000 Subject: [PATCH 117/145] update test/cellular_data_test.cpp. Signed-off-by: zhengsiwen960323 --- test/cellular_data_test.cpp | 13 ------------- 1 file changed, 13 deletions(-) diff --git a/test/cellular_data_test.cpp b/test/cellular_data_test.cpp index bd39cd3f..074892a8 100644 --- a/test/cellular_data_test.cpp +++ b/test/cellular_data_test.cpp @@ -2095,19 +2095,6 @@ HWTEST_F(CellularDataTest, ControllerReleaseCellularDataConnection_Test_1, TestS controller->cellularDataHandler_ = nullptr; ASSERT_FALSE(controller->ReleaseCellularDataConnection()); } -/** - * @tc.number ControllerReleaseCellularDataConnection_Test_02 - * @tc.name Test the Controller ReleaseCellularDataConnection function - * @tc.desc Function test - */ -HWTEST_F(CellularDataTest, ControllerReleaseCellularDataConnection_Test_2, TestSize.Level3) -{ - auto controller = std::make_shared(DEFAULT_SIM_SLOT_ID); - controller->Init(); - ASSERT_TRUE(controller->cellularDataHandler_ != nullptr); - NetRequest request; - ASSERT_TRUE(controller->ReleaseCellularDataConnection()); -} /** * @tc.number ControllerUpdateNetworkInfo_Test_01 -- Gitee From aa7260284bca144d1b5a866cea36bc41f54c1bc8 Mon Sep 17 00:00:00 2001 From: Henry Date: Tue, 6 May 2025 07:54:56 +0000 Subject: [PATCH 118/145] update test/data_switch_settings_test.cpp. Signed-off-by: Henry --- test/data_switch_settings_test.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/test/data_switch_settings_test.cpp b/test/data_switch_settings_test.cpp index 214c0735..dccc56c1 100644 --- a/test/data_switch_settings_test.cpp +++ b/test/data_switch_settings_test.cpp @@ -131,10 +131,10 @@ HWTEST_F(DataSwitchSettingTest, DataSwitchSetting_07, Function | MediumTest | Le DataSwitchSettings sets(2); std::cout << "DataSwitchSetting_07 slotId: " << sets.slotId_ << std::endl; int32_t simDetected = 0; - ASSERT_TRUE(sets.QueryUserDataStatus(simDetected) == TELEPHONY_ERR_SUCCESS); + ASSERT_TRUE(sets.QueryAnySimDetectedStatus(simDetected) == TELEPHONY_ERR_SUCCESS); DataSwitchSettings sets1(0); - ASSERT_TRUE(sets1.QueryUserDataStatus(simDetected) == TELEPHONY_ERR_SUCCESS); + ASSERT_TRUE(sets1.QueryAnySimDetectedStatus(simDetected) == TELEPHONY_ERR_SUCCESS); } } // namespace Telephony -- Gitee From fd548fa113cf9ae16086a41814a6dd998d61cbaf Mon Sep 17 00:00:00 2001 From: Henry Date: Tue, 6 May 2025 07:59:36 +0000 Subject: [PATCH 119/145] update test/data_switch_settings_test.cpp. Signed-off-by: Henry --- test/data_switch_settings_test.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/data_switch_settings_test.cpp b/test/data_switch_settings_test.cpp index dccc56c1..be909deb 100644 --- a/test/data_switch_settings_test.cpp +++ b/test/data_switch_settings_test.cpp @@ -123,7 +123,7 @@ HWTEST_F(DataSwitchSettingTest, DataSwitchSetting_06, Function | MediumTest | Le ASSERT_TRUE(sets.SetAnySimDetected(simDetected) == TELEPHONY_ERR_SUCCESS); DataSwitchSettings sets1(0); - ASSERT_TRUE(sets.SetAnySimDetected(simDetected) == TELEPHONY_ERR_SUCCESS); + ASSERT_TRUE(sets1.SetAnySimDetected(simDetected) == TELEPHONY_ERR_SUCCESS); } HWTEST_F(DataSwitchSettingTest, DataSwitchSetting_07, Function | MediumTest | Level1) -- Gitee From 4d4957e218c7820f87449977712bb98f383f4b87 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E6=B3=BD=E5=87=A1?= Date: Thu, 8 May 2025 08:01:37 +0000 Subject: [PATCH 120/145] update frameworks/native/apn_attribute.cpp. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 李泽凡 --- frameworks/native/apn_attribute.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/frameworks/native/apn_attribute.cpp b/frameworks/native/apn_attribute.cpp index 3e47af88..60b2bc40 100644 --- a/frameworks/native/apn_attribute.cpp +++ b/frameworks/native/apn_attribute.cpp @@ -101,7 +101,7 @@ static bool UnmarshallingExt(Parcel &parcel, ApnAttribute* attribute) ApnAttribute* ApnAttribute::Unmarshalling(Parcel &parcel) { - ApnAttribute* attribute = new (std::nothrow) ApnAttribute(); + std::unique_ptr attribute = std::make_unique(); if (attribute == nullptr) { return nullptr; } @@ -126,10 +126,10 @@ ApnAttribute* ApnAttribute::Unmarshalling(Parcel &parcel) if (!parcel.ReadString(attribute->apn_)) { return nullptr; } - if (!UnmarshallingExt(parcel, attribute)) { + if (!UnmarshallingExt(parcel, attribute.get())) { return nullptr; } - return attribute; + return attribute.release(); } void ApnAttribute::TransferApnAttributeBeforeIpc(ApnItem::Attribute &apnAttr, ApnAttribute &apnAfterTrans) @@ -170,4 +170,4 @@ void ApnAttribute::TransferApnAttributeAfterIpc(ApnItem::Attribute &apnAttr, Apn apnAttr.isEdited_ = apnAfterTrans.isEdited_; } } -} \ No newline at end of file +} -- Gitee From b18347562f85f521d776dde0a4f60dbcf70fe723 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E6=B3=BD=E5=87=A1?= Date: Thu, 8 May 2025 08:03:37 +0000 Subject: [PATCH 121/145] update frameworks/native/apn_activate_report_info.cpp. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 李泽凡 --- frameworks/native/apn_activate_report_info.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/frameworks/native/apn_activate_report_info.cpp b/frameworks/native/apn_activate_report_info.cpp index b3dc76b0..718775b5 100644 --- a/frameworks/native/apn_activate_report_info.cpp +++ b/frameworks/native/apn_activate_report_info.cpp @@ -36,7 +36,7 @@ bool ApnActivateReportInfoIpc::Marshalling(Parcel &parcel) const ApnActivateReportInfoIpc* ApnActivateReportInfoIpc::Unmarshalling(Parcel &parcel) { - ApnActivateReportInfoIpc* info = new (std::nothrow) ApnActivateReportInfoIpc(); + std::unique_ptr info = std::make_unique(); if (info == nullptr) { return nullptr; } @@ -52,7 +52,7 @@ ApnActivateReportInfoIpc* ApnActivateReportInfoIpc::Unmarshalling(Parcel &parcel if (!parcel.ReadUint32(info->actSuccTimes)) { return nullptr; } - return info; + return info.release(); } void ApnActivateReportInfoIpc::transferToReportInfo(ApnActivateReportInfoIpc infoIpc, ApnActivateReportInfo &info) @@ -63,4 +63,4 @@ void ApnActivateReportInfoIpc::transferToReportInfo(ApnActivateReportInfoIpc inf info.actSuccTimes = infoIpc.actSuccTimes; } } -} \ No newline at end of file +} -- Gitee From bea42886477cd95abc0602913a3a1301dba75b18 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E6=B3=BD=E5=87=A1?= Date: Thu, 8 May 2025 08:05:38 +0000 Subject: [PATCH 122/145] update frameworks/native/apn_activate_report_info.cpp. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 李泽凡 --- frameworks/native/apn_activate_report_info.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/frameworks/native/apn_activate_report_info.cpp b/frameworks/native/apn_activate_report_info.cpp index 718775b5..543c0cc6 100644 --- a/frameworks/native/apn_activate_report_info.cpp +++ b/frameworks/native/apn_activate_report_info.cpp @@ -63,4 +63,4 @@ void ApnActivateReportInfoIpc::transferToReportInfo(ApnActivateReportInfoIpc inf info.actSuccTimes = infoIpc.actSuccTimes; } } -} +} \ No newline at end of file -- Gitee From 02edbab2e75c74e16c456c091722920098ae3aba Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E6=B3=BD=E5=87=A1?= Date: Thu, 8 May 2025 08:06:26 +0000 Subject: [PATCH 123/145] update frameworks/native/apn_attribute.cpp. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 李泽凡 --- frameworks/native/apn_attribute.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/frameworks/native/apn_attribute.cpp b/frameworks/native/apn_attribute.cpp index 60b2bc40..948ddfb6 100644 --- a/frameworks/native/apn_attribute.cpp +++ b/frameworks/native/apn_attribute.cpp @@ -170,4 +170,4 @@ void ApnAttribute::TransferApnAttributeAfterIpc(ApnItem::Attribute &apnAttr, Apn apnAttr.isEdited_ = apnAfterTrans.isEdited_; } } -} +} \ No newline at end of file -- Gitee From 174a4b9a8f54671814538be5f52dc1a6e5be5fb9 Mon Sep 17 00:00:00 2001 From: cavalier Date: Thu, 8 May 2025 16:04:14 +0800 Subject: [PATCH 124/145] fix screen state abnormal problem when slot changed Signed-off-by: cavalier --- services/include/data_connection_monitor.h | 1 + services/src/cellular_data_handler.cpp | 7 ------ services/src/data_connection_monitor.cpp | 21 ++++++++++++++++- test/zero_branch_test.cpp | 26 ++++++++++++++++++++++ 4 files changed, 47 insertions(+), 8 deletions(-) diff --git a/services/include/data_connection_monitor.h b/services/include/data_connection_monitor.h index f846a795..0526d60b 100644 --- a/services/include/data_connection_monitor.h +++ b/services/include/data_connection_monitor.h @@ -114,6 +114,7 @@ private: bool IsAggressiveRecovery(); int32_t GetStallDetectionPeriod(); bool IsScreenOn(); + bool IsVsimEnabled(); std::unique_ptr trafficManager_; std::unique_ptr stallDetectionTrafficManager_; diff --git a/services/src/cellular_data_handler.cpp b/services/src/cellular_data_handler.cpp index 96cd022f..381a4af3 100644 --- a/services/src/cellular_data_handler.cpp +++ b/services/src/cellular_data_handler.cpp @@ -1312,7 +1312,6 @@ void CellularDataHandler::OnReceiveEvent(const EventFwk::CommonEventData &data) { const AAFwk::Want &want = data.GetWant(); std::string action = want.GetAction(); - const int32_t defSlotId = CoreManagerInner::GetInstance().GetDefaultCellularDataSlotId(); int32_t slotId = want.GetIntParam("slotId", 0); TELEPHONY_LOGI("[slot%{public}d] action=%{public}s code=%{public}d", slotId_, action.c_str(), data.GetCode()); if (EventFwk::CommonEventSupport::COMMON_EVENT_CALL_STATE_CHANGED == action) { @@ -1333,14 +1332,8 @@ void CellularDataHandler::OnReceiveEvent(const EventFwk::CommonEventData &data) } GetConfigurationFor5G(); } else if (action == CommonEventSupport::COMMON_EVENT_SCREEN_ON) { - if (slotId_ != defSlotId) { - return; - } HandleScreenStateChanged(true); } else if (action == CommonEventSupport::COMMON_EVENT_SCREEN_OFF) { - if (slotId_ != defSlotId) { - return; - } HandleScreenStateChanged(false); } else if (action == CommonEventSupport::COMMON_EVENT_DATA_SHARE_READY) { RegisterDataSettingObserver(); diff --git a/services/src/data_connection_monitor.cpp b/services/src/data_connection_monitor.cpp index 1a3cdbb1..837978e6 100644 --- a/services/src/data_connection_monitor.cpp +++ b/services/src/data_connection_monitor.cpp @@ -25,7 +25,8 @@ #include "cellular_data_types.h" #include "cellular_data_constant.h" #include "data_service_ext_wrapper.h" - +#include "telephony_ext_wrapper.h" + #ifdef ABILITY_POWER_SUPPORT #include "power_mgr_client.h" #endif @@ -47,10 +48,28 @@ void DataConnectionMonitor::HandleScreenStateChanged(bool isScreenOn) return; } isScreenOn_ = isScreenOn; + const int32_t defSlotId = CoreManagerInner::GetInstance().GetDefaultCellularDataSlotId(); + if (slotId_ != defSlotId && !IsVsimEnabled()) { + return; + } StopStallDetectionTimer(); StartStallDetectionTimer(); } +bool DataConnectionMonitor::IsVsimEnabled() +{ +#ifdef OHOS_BUILD_ENABLE_TELEPHONY_EXT + if (TELEPHONY_EXT_WRAPPER.getVSimSlotId_ && TELEPHONY_EXT_WRAPPER.isVSimEnabled_) { + int vSimSlotId = INVALID_SLOT_ID; + TELEPHONY_EXT_WRAPPER.getVSimSlotId_(vSimSlotId); + if (vSimSlotId == slotId_ && TELEPHONY_EXT_WRAPPER.isVSimEnabled_()) { + return true; + } + } +#endif + return false; +} + bool DataConnectionMonitor::IsAggressiveRecovery() { return (dataRecoveryState_ == RecoveryState::STATE_CLEANUP_CONNECTIONS) || diff --git a/test/zero_branch_test.cpp b/test/zero_branch_test.cpp index 68c55e9b..27874751 100644 --- a/test/zero_branch_test.cpp +++ b/test/zero_branch_test.cpp @@ -1221,6 +1221,32 @@ HWTEST_F(BranchTest, Telephony_DataConnectionMonitor_002, Function | MediumTest ASSERT_EQ(CellDataFlowType::DATA_FLOW_TYPE_NONE, con.connectionMonitor_->GetDataFlowType()); } +/** + +@tc.number DataConnectionMonitor_003 +@tc.name test error branch +@tc.desc Function test +*/ +HWTEST_F(BranchTest, Telephony_DataConnectionMonitor_003, Function | MediumTest | Level3) +{ + std::shared_ptr dataConnectionMonitor = std::make_shared(0); + ASSERT_FALSE(dataConnectionMonitor == nullptr); + dataConnectionMonitor->HandleScreenStateChanged(false); + dataConnectionMonitor->HandleScreenStateChanged(true); + ASSERT_FALSE(dataConnectionMonitor->IsVsimEnabled()); +#ifdef OHOS_BUILD_ENABLE_TELEPHONY_EXT + auto getVSimSlotId = TELEPHONY_EXT_WRAPPER.getVSimSlotId_; + auto isVSimEnabled = TELEPHONY_EXT_WRAPPER.isVSimEnabled_; + TELEPHONY_EXT_WRAPPER.getVSimSlotId_ = nullptr; + ASSERT_FALSE(dataConnectionMonitor->IsVsimEnabled()); + TELEPHONY_EXT_WRAPPER.isVSimEnabled_ = nullptr; + ASSERT_FALSE(dataConnectionMonitor->IsVsimEnabled()); + TELEPHONY_EXT_WRAPPER.getVSimSlotId_ = getVSimSlotId; + ASSERT_FALSE(dataConnectionMonitor->IsVsimEnabled()); + TELEPHONY_EXT_WRAPPER.isVSimEnabled_ = isVSimEnabled; +#endif +} + /** * @tc.number CellularDataUtils_001 * @tc.name test error branch -- Gitee From 80ef755bbc07fb50b52f9f541c4dc92bb3f0020d Mon Sep 17 00:00:00 2001 From: zhangwuling1 Date: Sat, 10 May 2025 16:20:12 +0800 Subject: [PATCH 125/145] cellular_data_alarm Signed-off-by: zhangwuling1 --- .../src/state_machine/cellular_data_state_machine.cpp | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/services/src/state_machine/cellular_data_state_machine.cpp b/services/src/state_machine/cellular_data_state_machine.cpp index 8058b336..ff58bb15 100644 --- a/services/src/state_machine/cellular_data_state_machine.cpp +++ b/services/src/state_machine/cellular_data_state_machine.cpp @@ -17,6 +17,7 @@ #include #include +#include #include "activating.h" #include "active.h" @@ -519,7 +520,7 @@ void CellularDataStateMachine::GetNetworkSlicePara(const DataConnectionParams& c apnType.c_str(), dnn.c_str()); if (apnType.find("snssai") != std::string::npos) { int32_t apnId = ApnManager::FindApnIdByApnName(apnType); - int32_t netcap = ApnManager::FindCapabilityByApnId(apnId); + int32_t netcap = static_cast(ApnManager::FindCapabilityByApnId(apnId)); std::map networkSliceParas; DelayedSingleton::GetInstance()->GetRSDByNetCap( netcap, networkSliceParas); @@ -544,7 +545,10 @@ void CellularDataStateMachine::FillRSDFromNetCap( std::map networkSliceParas, sptr apn) { if (networkSliceParas["sscmode"] != "0") { - apn->attr_.sscMode_ = std::stoi(networkSliceParas["sscmode"]); + int sscMode = 0; + std::from_chars(networkSliceParas["sscmode"].data(), networkSliceParas["sscmode"].data() + + networkSliceParas["sscmode"].size(), sscMode); + apn->attr_.sscMode_ = sscMode; } if (networkSliceParas["snssai"] != "") { std::string snssai = networkSliceParas["snssai"]; -- Gitee From b4c6d4cbe188f85f06428617fd3e7ead86d9a182 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=AB=A0=E7=94=B3=E4=BA=91?= Date: Mon, 12 May 2025 09:01:02 +0000 Subject: [PATCH 126/145] update test/cellular_data_test.cpp. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 章申云 --- test/cellular_data_test.cpp | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/test/cellular_data_test.cpp b/test/cellular_data_test.cpp index 074892a8..34dd2164 100644 --- a/test/cellular_data_test.cpp +++ b/test/cellular_data_test.cpp @@ -1190,6 +1190,11 @@ HWTEST_F(CellularDataTest, Telephony_Cellulardata_InitTelephonyExtService_0104, controller->cellularDataHandler_->NotifyReqCellularData(true); #endif EXPECT_EQ(TELEPHONY_EXT_WRAPPER.dynamicLoadNotifyReqCellularDataStatus_ != nullptr, true); + delete mockDlsym; + mockDlsym = nullptr; + TELEPHONY_EXT_WRAPPER.telephonyDynamicLoadWrapperHandle_ = nullptr; + TELEPHONY_EXT_WRAPPER.dynamicLoadInit_ = nullptr; + TELEPHONY_EXT_WRAPPER.dynamicLoadNotifyReqCellularDataStatus_ = nullptr; } /** -- Gitee From ed365ec544ef42a37287445ad727bf2a7abfca2d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E6=B3=BD=E5=87=A1?= Date: Fri, 16 May 2025 03:46:53 +0000 Subject: [PATCH 127/145] update test/fuzztest/getcellulardatastate_fuzzer/BUILD.gn. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 李泽凡 --- test/fuzztest/getcellulardatastate_fuzzer/BUILD.gn | 1 + 1 file changed, 1 insertion(+) diff --git a/test/fuzztest/getcellulardatastate_fuzzer/BUILD.gn b/test/fuzztest/getcellulardatastate_fuzzer/BUILD.gn index b9d96e99..cdf9c905 100644 --- a/test/fuzztest/getcellulardatastate_fuzzer/BUILD.gn +++ b/test/fuzztest/getcellulardatastate_fuzzer/BUILD.gn @@ -59,6 +59,7 @@ ohos_fuzztest("GetCellularDataStateFuzzTest") { "netmanager_base:net_stats_manager_if", "preferences:native_preferences", "relational_store:native_rdb", + "safwk:system_ability_fwk", "telephony_data:tel_telephony_data", ] -- Gitee From 4cb068cd704ebfe07f9ecd5604c87c70d77bf356 Mon Sep 17 00:00:00 2001 From: zhengsiwen960323 Date: Mon, 19 May 2025 06:19:38 +0000 Subject: [PATCH 128/145] update test/cellular_data_service_test.cpp. Signed-off-by: zhengsiwen960323 --- test/cellular_data_service_test.cpp | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/test/cellular_data_service_test.cpp b/test/cellular_data_service_test.cpp index 6c6191cb..de6a0898 100644 --- a/test/cellular_data_service_test.cpp +++ b/test/cellular_data_service_test.cpp @@ -401,5 +401,33 @@ HWTEST_F(CellularDataServiceTest, EstablishAllApnsIfConnectableTest001, TestSize EXPECT_EQ(service->ReleaseCellularDataConnection(slotId), TELEPHONY_ERR_PERMISSION_ERR); } +/** + * @tc.number GetActReportInfoTest001 + * @tc.name test GetDefaultActReportInfo and GetInternalActReportInfo + * @tc.desc Function test + */ +HWTEST_F(CellularDataServiceTest, GetActReportInfoTest001, TestSize.Level0) +{ + ApnActivateReportInfoIpc infoIpc; + int32_t slotId = -1; + EXPECT_EQ(service->GetDefaultActReportInfo(slotId, infoIpc), TELEPHONY_ERR_PERMISSION_ERR); + EXPECT_EQ(service->GetInternalActReportInfo(slotId, infoIpc), TELEPHONY_ERR_PERMISSION_ERR); +} + +/** + * @tc.number ApnInfoTest001 + * @tc.name test QueryApnIds, SetPreferApn and QueryAllApnInfo + * @tc.desc Function test + */ +HWTEST_F(CellularDataServiceTest, ApnInfoTest001, TestSize.Level0) +{ + ApnInfo apnInfo; + std::vector apnIdList; + std::vector allApnInfoList; + int32_t apnId = 1; + EXPECT_EQ(service->QueryApnIds(apnInfo, apnIdList), TELEPHONY_ERR_PERMISSION_ERR); + EXPECT_EQ(service->SetPreferApn(apnId), TELEPHONY_ERR_PERMISSION_ERR); + EXPECT_EQ(service->QueryAllApnInfo(allApnInfoList), TELEPHONY_ERR_PERMISSION_ERR); +} } // namespace Telephony } // namespace OHOS \ No newline at end of file -- Gitee From 0d890ffedc99ad1be922dd0aafe73b9558a4d920 Mon Sep 17 00:00:00 2001 From: zhengsiwen960323 Date: Mon, 19 May 2025 06:20:30 +0000 Subject: [PATCH 129/145] update test/cellular_data_test.cpp. Signed-off-by: zhengsiwen960323 --- test/cellular_data_test.cpp | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/test/cellular_data_test.cpp b/test/cellular_data_test.cpp index 34dd2164..3857b50f 100644 --- a/test/cellular_data_test.cpp +++ b/test/cellular_data_test.cpp @@ -2131,5 +2131,27 @@ HWTEST_F(CellularDataTest, ControllerUpdateNetworkInfo_Test_02, TestSize.Level3) ASSERT_TRUE(controller->UpdateNetworkInfo()); } +/** + * @tc.number GetSimIdTest001 + * @tc.name Test the function + * @tc.desc Function test + */ +HWTEST_F(CellularDataTest, GetSimIdTest001, TestSize.Level3) +{ + CellularDataRdbHelper cellularDataRdbHelper; + int32_t result = cellularDataRdbHelper.GetSimId(); + ASSERT_EQ(result, -1); + + ApnInfo apnInfo; + std::vector apnIdList; + cellularDataRdbHelper.QueryApnIds(apnInfo, apnIdList); + + int32_t apnId = -1; + result = cellularDataRdbHelper.SetPreferApn(apnId); + ASSERT_EQ(result, -1); + + std::vector apnInfoList; + cellularDataRdbHelper.QueryAllApnInfo(apnInfoList); +} } // namespace Telephony } // namespace OHOS -- Gitee From 9fbae8969e40b571c3225c665e62b305f0aca1ef Mon Sep 17 00:00:00 2001 From: zhengsiwen960323 Date: Mon, 19 May 2025 06:21:04 +0000 Subject: [PATCH 130/145] update test/cellular_data_observer_test.cpp. Signed-off-by: zhengsiwen960323 --- test/cellular_data_observer_test.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/test/cellular_data_observer_test.cpp b/test/cellular_data_observer_test.cpp index a3a92528..0f9359bd 100644 --- a/test/cellular_data_observer_test.cpp +++ b/test/cellular_data_observer_test.cpp @@ -167,6 +167,8 @@ HWTEST_F(CellularDataObserverTest, CellularDataAirplaneObserver_05, Function | M EXPECT_TRUE(settingHelper->PutValue(uri, CELLULAR_DATA_COLUMN_AIRPLANE, 0) == TELEPHONY_ERR_SUCCESS); cellularDataAirplaneObserver->OnChange(); EXPECT_FALSE(cellularDataAirplaneObserver->IsAirplaneModeOn()); + + settingHelper->NotifyChange(uri); } } // namespace Telephony -- Gitee From 35472333ac37cc99a2bf6e47405f16343d4b48b8 Mon Sep 17 00:00:00 2001 From: zhengsiwen960323 Date: Mon, 19 May 2025 06:22:23 +0000 Subject: [PATCH 131/145] update test/cellular_data_handler_test.cpp. Signed-off-by: zhengsiwen960323 --- test/cellular_data_handler_test.cpp | 52 +++++++++++++++++++++++++++++ 1 file changed, 52 insertions(+) diff --git a/test/cellular_data_handler_test.cpp b/test/cellular_data_handler_test.cpp index 5ee3e8c0..b523efac 100644 --- a/test/cellular_data_handler_test.cpp +++ b/test/cellular_data_handler_test.cpp @@ -1064,5 +1064,57 @@ HWTEST_F(CellularDataHandlerTest, Telephony_ConnectIfNeed, Function | MediumTest cellularDataHandler->ConnectIfNeed(event2, apnHolder, request1); cellularDataHandler->ConnectIfNeed(event2, nullptr, request1); } + +HWTEST_F(CellularDataHandlerTest, Telephony_CellularDataHandler_003, Function | MediumTest | Level1) +{ + CellularDataController controller {0}; + controller.Init(); + ApnActivateReportInfo info1; + ApnActivateReportInfo info2; + EXPECT_TRUE(controller.GetDefaultActReportInfo(info1)); + EXPECT_TRUE(controller.GetInternalActReportInfo(info2)); + controller.cellularDataHandler_ = nullptr; + EXPECT_FALSE(controller.GetDefaultActReportInfo(info1)); + EXPECT_FALSE(controller.GetInternalActReportInfo(info2)); +} + +HWTEST_F(CellularDataHandlerTest, DataConnCompleteUpdateStateTest001, Function | MediumTest | Level1) +{ + int32_t slotId = 0; + EventFwk::MatchingSkills matchingSkills; + matchingSkills.AddEvent(EventFwk::CommonEventSupport::COMMON_EVENT_CALL_STATE_CHANGED); + EventFwk::CommonEventSubscribeInfo subscriberInfo(matchingSkills); + auto cellularDataHandler = std::make_shared(subscriberInfo, slotId); + std::string apnType = DATA_CONTEXT_ROLE_MMS; + sptr apnHolder = new ApnHolder(apnType, slotId); + apnHolder->cellularDataStateMachine_ = nullptr; + auto resultInfo = std::make_shared(); + cellularDataHandler->connectionManager_ = nullptr; + cellularDataHandler->physicalConnectionActiveState_ = true; + cellularDataHandler->incallDataStateMachine_ = nullptr; + cellularDataHandler->DataConnCompleteUpdateState(apnHolder, resultInfo); + EXPECT_FALSE(cellularDataHandler->isRilApnAttached_); + + sptr cdConnectionManager = nullptr; + std::shared_ptr telEventHandler = nullptr; + apnHolder->cellularDataStateMachine_ = std::make_shared + (cdConnectionManager, std::move(telEventHandler)); + apnHolder->cellularDataStateMachine_->netLinkInfo_ = new NetLinkInfo(); + apnHolder->cellularDataStateMachine_->netSupplierInfo_ = nullptr; + cellularDataHandler->apnManager_ = std::make_unique().release(); + cellularDataHandler->apnManager_->allApnItem_.clear(); + cellularDataHandler->connectionManager_ = std::make_unique(slotId).release(); + cellularDataHandler->physicalConnectionActiveState_ = false; + cellularDataHandler->incallDataStateMachine_ = + cellularDataHandler->CreateIncallDataStateMachine(TelCallStatus::CALL_STATUS_DIALING); + apnHolder->apnType_ = DATA_CONTEXT_ROLE_DEFAULT; + apnHolder->apnItem_ = new ApnItem(); + cellularDataHandler->DataConnCompleteUpdateState(apnHolder, resultInfo); + + cellularDataHandler->apnManager_->preferId_ = 1; + cellularDataHandler->apnManager_->allApnItem_.push_back(new ApnItem()); + cellularDataHandler->DataConnCompleteUpdateState(apnHolder, resultInfo); + EXPECT_FALSE(cellularDataHandler->isRilApnAttached_); +} } // namespace Telephony } // namespace OHOS \ No newline at end of file -- Gitee From 9cee7321c7f45616ac34e127ea4ff39fd4c0568b Mon Sep 17 00:00:00 2001 From: zhengsiwen960323 Date: Mon, 19 May 2025 06:23:08 +0000 Subject: [PATCH 132/145] update test/zero_branch_test.cpp. Signed-off-by: zhengsiwen960323 --- test/zero_branch_test.cpp | 121 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 121 insertions(+) diff --git a/test/zero_branch_test.cpp b/test/zero_branch_test.cpp index 27874751..530d803c 100644 --- a/test/zero_branch_test.cpp +++ b/test/zero_branch_test.cpp @@ -2329,5 +2329,126 @@ HWTEST_F(BranchTest, IsSupportDunApn_001, Function | MediumTest | Level1) EXPECT_FALSE(controller.IsSupportDunApn()); } +/** + * @tc.number CellularDataConnectionManager_003 + * @tc.name test error branch + * @tc.desc Function test + */ +HWTEST_F(BranchTest, Telephony_CellularDataConnectionManager_003, Function | MediumTest | Level3) +{ + DataConnectionManager con { 0 }; + con.Init(); + std::shared_ptr machine = std::make_shared(); + std::shared_ptr stateMachine = machine->CreateCellularDataConnect(0); + con.AddConnectionStateMachine(stateMachine); + con.RemoveConnectionStateMachine(stateMachine); + con.AddActiveConnectionByCid(stateMachine); + con.GetActiveConnectionByCid(1); + con.GetAllConnectionMachine(); + con.StartStallDetectionTimer(); + con.StopStallDetectionTimer(); + con.RegisterRadioObserver(); + con.UnRegisterRadioObserver(); + con.uplinkUseLte_ = true; + con.UpdateBandWidthsUseLte(); + con.GetActiveConnection(); + con.IsBandwidthSourceModem(); + ASSERT_NE(-1, con.GetDataRecoveryState()); + con.IsNeedDoRecovery(true); + con.GetActiveConnectionByCid(0); + con.isNoActiveConnection(); + auto event = AppExecFwk::InnerEvent::Get(0); + CcmDefaultState ccmDefaultState { con, "CcmDefaultState" }; + ASSERT_FALSE(ccmDefaultState.StateProcess(event)); + event = AppExecFwk::InnerEvent::Get(RadioEvent::RADIO_NETWORKSLICE_URSP_RPT); + ASSERT_TRUE(ccmDefaultState.StateProcess(event)); + event = AppExecFwk::InnerEvent::Get(RadioEvent::RADIO_NETWORKSLICE_ALLOWEDNSSAI_RPT); + ASSERT_TRUE(ccmDefaultState.StateProcess(event)); + event = AppExecFwk::InnerEvent::Get(RadioEvent::RADIO_NETWORKSLICE_EHPLMN_RPT); + ASSERT_TRUE(ccmDefaultState.StateProcess(event)); + event = AppExecFwk::InnerEvent::Get(0); + ASSERT_FALSE(ccmDefaultState.StateProcess(event)); + ccmDefaultState.RadioDataCallListChanged(event); + ccmDefaultState.UpdateNetworkInfo(event); + ccmDefaultState.RadioLinkCapabilityChanged(event); + ccmDefaultState.RadioNetworkSliceUrspRpt(event); + ccmDefaultState.RadioNetworkSliceAllowedNssaiRpt(event); + ccmDefaultState.RadioNetworkSliceEhplmnRpt(event); + con.GetDataFlowType(); + con.GetDefaultBandWidthsConfig(); + con.GetDefaultTcpBufferConfig(); + con.SetDataFlowType(CellDataFlowType::DATA_FLOW_TYPE_NONE); + con.UpdateCallState(0); + ASSERT_EQ("", con.GetTcpBufferByRadioTech(0)); + ASSERT_TRUE(con.GetBandwidthsByRadioTech(0).upBandwidth == DEFAULT_BANDWIDTH); +} + +/** + * @tc.number DataConnectionMonitor_003 + * @tc.name test error branch + * @tc.desc Function test + */ +HWTEST_F(BranchTest, Telephony_DataConnectionMonitor_003, Function | MediumTest | Level3) +{ + DataConnectionManager con { 0 }; + ASSERT_FALSE(con.connectionMonitor_ == nullptr); + con.connectionMonitor_->UpdateFlowInfo(); + con.connectionMonitor_->UpdateCallState(0); + con.connectionMonitor_->OnStallDetectionTimer(); + con.connectionMonitor_->StopStallDetectionTimer(); + con.connectionMonitor_->dataRecoveryState_ = RecoveryState::STATE_REQUEST_CONTEXT_LIST; + con.connectionMonitor_->HandleRecovery(); + con.connectionMonitor_->dataRecoveryState_ = RecoveryState::STATE_CLEANUP_CONNECTIONS; + con.connectionMonitor_->HandleRecovery(); + con.connectionMonitor_->dataRecoveryState_ = RecoveryState::STATE_REREGISTER_NETWORK; + con.connectionMonitor_->HandleRecovery(); + con.connectionMonitor_->dataRecoveryState_ = RecoveryState::STATE_RADIO_STATUS_RESTART; + con.connectionMonitor_->HandleRecovery(); + con.connectionMonitor_->BeginNetStatistics(); + con.connectionMonitor_->EndNetStatistics(); + con.connectionMonitor_->HandleScreenStateChanged(true); + con.connectionMonitor_->UpdateNetTrafficState(); + auto event = AppExecFwk::InnerEvent::Get(0); + con.connectionMonitor_->SetPreferredNetworkPara(event); + con.connectionMonitor_->UpdateDataFlowType(); + con.connectionMonitor_->ProcessEvent(event); + event = nullptr; + con.connectionMonitor_->ProcessEvent(event); + ASSERT_EQ(CellDataFlowType::DATA_FLOW_TYPE_NONE, con.connectionMonitor_->GetDataFlowType()); +} + +/** + * @tc.number DataConnectionMonitor_004 + * @tc.name test error branch + * @tc.desc Function test + */ +HWTEST_F(BranchTest, Telephony_DataConnectionMonitor_004, Function | MediumTest | Level3) +{ + DataConnectionManager con { 0 }; + ASSERT_FALSE(con.connectionMonitor_ == nullptr); + con.connectionMonitor_->UpdateFlowInfo(); + con.connectionMonitor_->UpdateCallState(0); + con.connectionMonitor_->OnStallDetectionTimer(); + con.connectionMonitor_->StopStallDetectionTimer(); + con.connectionMonitor_->dataRecoveryState_ = RecoveryState::STATE_REQUEST_CONTEXT_LIST; + con.connectionMonitor_->HandleRecovery(); + con.connectionMonitor_->dataRecoveryState_ = RecoveryState::STATE_CLEANUP_CONNECTIONS; + con.connectionMonitor_->HandleRecovery(); + con.connectionMonitor_->dataRecoveryState_ = RecoveryState::STATE_REREGISTER_NETWORK; + con.connectionMonitor_->HandleRecovery(); + con.connectionMonitor_->dataRecoveryState_ = RecoveryState::STATE_RADIO_STATUS_RESTART; + con.connectionMonitor_->HandleRecovery(); + con.connectionMonitor_->BeginNetStatistics(); + con.connectionMonitor_->BeginNetStatistics(); + con.connectionMonitor_->HandleScreenStateChanged(true); + con.connectionMonitor_->UpdateNetTrafficState(); + auto event = AppExecFwk::InnerEvent::Get(0); + con.connectionMonitor_->SetPreferredNetworkPara(event); + con.connectionMonitor_->UpdateDataFlowType(); + con.connectionMonitor_->ProcessEvent(event); + event = nullptr; + con.connectionMonitor_->ProcessEvent(event); + ASSERT_EQ(CellDataFlowType::DATA_FLOW_TYPE_NONE, con.connectionMonitor_->GetDataFlowType()); +} } // namespace Telephony } // namespace OHOS -- Gitee From 25c06cd5da2067f879a3ecfb7e199bd7cd17fd00 Mon Sep 17 00:00:00 2001 From: zhengsiwen960323 Date: Mon, 19 May 2025 07:31:57 +0000 Subject: [PATCH 133/145] update test/zero_branch_test.cpp. Signed-off-by: zhengsiwen960323 --- test/zero_branch_test.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/test/zero_branch_test.cpp b/test/zero_branch_test.cpp index 530d803c..5b0425fb 100644 --- a/test/zero_branch_test.cpp +++ b/test/zero_branch_test.cpp @@ -2388,7 +2388,7 @@ HWTEST_F(BranchTest, Telephony_CellularDataConnectionManager_003, Function | Med * @tc.name test error branch * @tc.desc Function test */ -HWTEST_F(BranchTest, Telephony_DataConnectionMonitor_003, Function | MediumTest | Level3) +HWTEST_F(BranchTest, Telephony_DataConnectionMonitor_004, Function | MediumTest | Level3) { DataConnectionManager con { 0 }; ASSERT_FALSE(con.connectionMonitor_ == nullptr); @@ -2422,7 +2422,7 @@ HWTEST_F(BranchTest, Telephony_DataConnectionMonitor_003, Function | MediumTest * @tc.name test error branch * @tc.desc Function test */ -HWTEST_F(BranchTest, Telephony_DataConnectionMonitor_004, Function | MediumTest | Level3) +HWTEST_F(BranchTest, Telephony_DataConnectionMonitor_005, Function | MediumTest | Level3) { DataConnectionManager con { 0 }; ASSERT_FALSE(con.connectionMonitor_ == nullptr); -- Gitee From 04a54fd88ce6688457b23d5c0c1b6aed7b8245f1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=BC=A0=E6=96=87=E6=9D=B0?= Date: Wed, 21 May 2025 08:32:42 +0000 Subject: [PATCH 134/145] =?UTF-8?q?update=20services/src/cellular=5Fdata?= =?UTF-8?q?=5Fservice.cpp.=20GetDefaultCellularDataSlotId,=20GetCellularDa?= =?UTF-8?q?taFlowType,GetCellularDataState,GetDefaultCellularDataSimId?= =?UTF-8?q?=E5=A2=9E=E5=8A=A0GET=5FNETWORK=5FINFO=E6=9D=83=E9=99=90?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 张文杰 --- services/src/cellular_data_service.cpp | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/services/src/cellular_data_service.cpp b/services/src/cellular_data_service.cpp index 3509e768..9209cc72 100644 --- a/services/src/cellular_data_service.cpp +++ b/services/src/cellular_data_service.cpp @@ -206,6 +206,11 @@ int32_t CellularDataService::EnableIntelligenceSwitch(bool enable) int32_t CellularDataService::GetCellularDataState(int32_t &state) { + if (!TelephonyPermission::CheckPermission(Permission::GET_NETWORK_INFO)) { + TELEPHONY_LOGE("permission denied!"); + return TELEPHONY_ERR_PERMISSION_ERR; + } + int32_t slotId; CellularDataService::GetDefaultCellularDataSlotId(slotId); #ifdef OHOS_BUILD_ENABLE_TELEPHONY_EXT @@ -489,12 +494,22 @@ int32_t CellularDataService::HandleApnChanged(const int32_t slotId) int32_t CellularDataService::GetDefaultCellularDataSlotId(int32_t &slotId) { + if (!TelephonyPermission::CheckPermission(Permission::GET_NETWORK_INFO)) { + TELEPHONY_LOGE("permission denied!"); + return TELEPHONY_ERR_PERMISSION_ERR; + } + slotId = CoreManagerInner::GetInstance().GetDefaultCellularDataSlotId(); return TELEPHONY_ERR_SUCCESS; } int32_t CellularDataService::GetDefaultCellularDataSimId(int32_t &simId) { + if (!TelephonyPermission::CheckPermission(Permission::GET_NETWORK_INFO)) { + TELEPHONY_LOGE("permission denied!"); + return TELEPHONY_ERR_PERMISSION_ERR; + } + return CoreManagerInner::GetInstance().GetDefaultCellularDataSimId(simId); } @@ -532,6 +547,11 @@ int32_t CellularDataService::SetDefaultCellularDataSlotId(const int32_t slotId) int32_t CellularDataService::GetCellularDataFlowType(int32_t &type) { + if (!TelephonyPermission::CheckPermission(Permission::GET_NETWORK_INFO)) { + TELEPHONY_LOGE("permission denied!"); + return TELEPHONY_ERR_PERMISSION_ERR; + } + int32_t slotId; CellularDataService::GetDefaultCellularDataSlotId(slotId); std::shared_ptr cellularDataController = GetCellularDataController(slotId); -- Gitee From 0f916db7d4fcdaeaa672a54f243530222deef052 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=BC=A0=E6=96=87=E6=9D=B0?= Date: Thu, 22 May 2025 09:15:15 +0000 Subject: [PATCH 135/145] update services/src/cellular_data_service.cpp. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 张文杰 --- services/src/cellular_data_service.cpp | 20 -------------------- 1 file changed, 20 deletions(-) diff --git a/services/src/cellular_data_service.cpp b/services/src/cellular_data_service.cpp index 9209cc72..3509e768 100644 --- a/services/src/cellular_data_service.cpp +++ b/services/src/cellular_data_service.cpp @@ -206,11 +206,6 @@ int32_t CellularDataService::EnableIntelligenceSwitch(bool enable) int32_t CellularDataService::GetCellularDataState(int32_t &state) { - if (!TelephonyPermission::CheckPermission(Permission::GET_NETWORK_INFO)) { - TELEPHONY_LOGE("permission denied!"); - return TELEPHONY_ERR_PERMISSION_ERR; - } - int32_t slotId; CellularDataService::GetDefaultCellularDataSlotId(slotId); #ifdef OHOS_BUILD_ENABLE_TELEPHONY_EXT @@ -494,22 +489,12 @@ int32_t CellularDataService::HandleApnChanged(const int32_t slotId) int32_t CellularDataService::GetDefaultCellularDataSlotId(int32_t &slotId) { - if (!TelephonyPermission::CheckPermission(Permission::GET_NETWORK_INFO)) { - TELEPHONY_LOGE("permission denied!"); - return TELEPHONY_ERR_PERMISSION_ERR; - } - slotId = CoreManagerInner::GetInstance().GetDefaultCellularDataSlotId(); return TELEPHONY_ERR_SUCCESS; } int32_t CellularDataService::GetDefaultCellularDataSimId(int32_t &simId) { - if (!TelephonyPermission::CheckPermission(Permission::GET_NETWORK_INFO)) { - TELEPHONY_LOGE("permission denied!"); - return TELEPHONY_ERR_PERMISSION_ERR; - } - return CoreManagerInner::GetInstance().GetDefaultCellularDataSimId(simId); } @@ -547,11 +532,6 @@ int32_t CellularDataService::SetDefaultCellularDataSlotId(const int32_t slotId) int32_t CellularDataService::GetCellularDataFlowType(int32_t &type) { - if (!TelephonyPermission::CheckPermission(Permission::GET_NETWORK_INFO)) { - TELEPHONY_LOGE("permission denied!"); - return TELEPHONY_ERR_PERMISSION_ERR; - } - int32_t slotId; CellularDataService::GetDefaultCellularDataSlotId(slotId); std::shared_ptr cellularDataController = GetCellularDataController(slotId); -- Gitee From 00f2dd88b9febf99788fa50f3240aa6c10bb3d7d Mon Sep 17 00:00:00 2001 From: liwang Date: Fri, 16 May 2025 14:28:30 +0800 Subject: [PATCH 136/145] =?UTF-8?q?MDM=E5=BC=BA=E5=88=B6=E5=BC=80=E5=90=AF?= =?UTF-8?q?=E7=A7=BB=E5=8A=A8=E6=95=B0=E6=8D=AE=E7=BD=91=E7=BB=9C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: liwang --- services/src/cellular_data_handler.cpp | 7 ++++ services/src/cellular_data_service.cpp | 7 ++++ test/zero_branch_test.cpp | 44 ++++++++++++++++++++++++++ 3 files changed, 58 insertions(+) diff --git a/services/src/cellular_data_handler.cpp b/services/src/cellular_data_handler.cpp index 381a4af3..750e3254 100644 --- a/services/src/cellular_data_handler.cpp +++ b/services/src/cellular_data_handler.cpp @@ -44,6 +44,8 @@ using namespace OHOS::EventFwk; using namespace NetManagerStandard; static const int32_t ESM_FLAG_INVALID = -1; const std::string DEFAULT_DATA_ROAMING = "persist.telephony.defaultdataroaming"; +constexpr const char *PERSIST_EDM_MOBILE_DATA_POLICY = "persist.edm.mobile_data_policy"; +constexpr const char *MOBILE_DATA_POLICY_FORCE_OPEN = "force_open"; CellularDataHandler::CellularDataHandler(const EventFwk::CommonEventSubscribeInfo &sp, int32_t slotId) : TelEventHandler("CellularDataHandler"), CommonEventSubscriber(sp), slotId_(slotId) {} @@ -2280,9 +2282,14 @@ void CellularDataHandler::HandleDBSettingEnableChanged(const AppExecFwk::InnerEv dataSwitchSettings_->QueryUserDataStatus(dataEnabled); CoreManagerInner &coreInner = CoreManagerInner::GetInstance(); const int32_t defSlotId = coreInner.GetDefaultCellularDataSlotId(); + std::string dataPolicy = system::GetParameter(PERSIST_EDM_MOBILE_DATA_POLICY, ""); if (dataEnabled && defSlotId == slotId_) { EstablishAllApnsIfConnectable(); } else { + if (dataPolicy == MOBILE_DATA_POLICY_FORCE_OPEN) { + TELEPHONY_LOGE("Slot%{public}d: policy is force_open, not allow clear connections", slotId_); + return; + } ClearAllConnections(DisConnectionReason::REASON_CLEAR_CONNECTION); } } diff --git a/services/src/cellular_data_service.cpp b/services/src/cellular_data_service.cpp index 3509e768..d7b162c9 100644 --- a/services/src/cellular_data_service.cpp +++ b/services/src/cellular_data_service.cpp @@ -38,6 +38,8 @@ namespace OHOS { namespace Telephony { using namespace NetManagerStandard; +constexpr const char *PERSIST_EDM_MOBILE_DATA_POLICY = "persist.edm.mobile_data_policy"; +constexpr const char *MOBILE_DATA_POLICY_FORCE_OPEN = "force_open"; bool g_registerResult = SystemAbility::MakeAndRegisterAbility(&DelayedRefSingleton::GetInstance()); CellularDataService::CellularDataService() : SystemAbility(TELEPHONY_CELLULAR_DATA_SYS_ABILITY_ID, true), registerToService_(false), @@ -180,6 +182,11 @@ int32_t CellularDataService::EnableCellularData(bool enable) TELEPHONY_LOGE("cellularDataControllers is null, slotId=%{public}d", DEFAULT_SIM_SLOT_ID); return TELEPHONY_ERR_LOCAL_PTR_NULL; } + std::string dataPolicy = system::GetParameter(PERSIST_EDM_MOBILE_DATA_POLICY, ""); + if (dataPolicy == MOBILE_DATA_POLICY_FORCE_OPEN && !enable) { + TELEPHONY_LOGE("cellular data policy is force_open"); + return TELEPHONY_ERR_POLICY_DISABLED; + } return cellularDataController->SetCellularDataEnable(enable); } diff --git a/test/zero_branch_test.cpp b/test/zero_branch_test.cpp index 27874751..2909afa9 100644 --- a/test/zero_branch_test.cpp +++ b/test/zero_branch_test.cpp @@ -36,6 +36,7 @@ #include "cellular_data_utils.h" #include "common_event_manager.h" #include "common_event_support.h" +#include "core_service_client.h" #include "data_access_token.h" #include "data_connection_manager.h" #include "data_connection_monitor.h" @@ -655,6 +656,25 @@ HWTEST_F(BranchTest, Telephony_CellularDataHandler_013, Function | MediumTest | ASSERT_FALSE(cellularDataHandler.HasInnerEvent(CellularDataEventCode::MSG_ESTABLISH_DATA_CONNECTION)); } +/** + * @tc.number Telephony_CellularDataHandler_014 + * @tc.name test error branch + * @tc.desc Function test + */ +HWTEST_F(BranchTest, Telephony_CellularDataHandler_014, Function | MediumTest | Level1) +{ + CellularDataController controller { 0 }; + controller.Init(); + ASSERT_FALSE(controller.cellularDataHandler_ == nullptr); + auto event = AppExecFwk::InnerEvent::Get(0); + system::SetParameter("persist.edm.mobile_data_policy", "force_open"); + controller.cellularDataHandler_->HandleDBSettingEnableChanged(event); + controller.cellularDataHandler_->UnRegisterDataSettingObserver(); + controller.cellularDataHandler_->RemoveAllEvents(); + system::SetParameter("persist.edm.mobile_data_policy", "none"); + sleep(SLEEP_TIME_SECONDS); +} + /** * @tc.number Telephony_CellularDataService_001 * @tc.name test error branch @@ -914,6 +934,30 @@ HWTEST_F(BranchTest, Telephony_CellularDataService_006, Function | MediumTest | ASSERT_NE(TELEPHONY_ERR_FAIL, service.GetSupplierRegisterState(0, regState)); } +/** + * @tc.number Telephony_CellularDataService_007 + * @tc.name test error branch + * @tc.desc Function test + */ +HWTEST_F(BranchTest, Telephony_CellularDataService_007, Function | MediumTest | Level3) +{ + CellularDataService service; + std::vector strV; + ASSERT_EQ(TELEPHONY_ERR_FAIL, service.Dump(INVALID_FD, strV)); + service.state_ = ServiceRunningState::STATE_RUNNING; + service.OnStart(); + service.InitModule(); + system::SetParameter("persist.edm.mobile_data_policy", "none"); + ASSERT_NE(TELEPHONY_ERR_SUCCESS, service.EnableCellularData(false)); + ASSERT_NE(TELEPHONY_ERR_SUCCESS, service.EnableCellularData(true)); + system::SetParameter("persist.edm.mobile_data_policy", "force_open"); + ASSERT_NE(TELEPHONY_ERR_SUCCESS, service.EnableCellularData(false)); + ASSERT_NE(TELEPHONY_ERR_SUCCESS, service.EnableCellularData(true)); + service.GetFlowDataInfoDump(); + service.OnStop(); + system::SetParameter("persist.edm.mobile_data_policy", "none"); +} + /** * @tc.number CellularDataController_001 * @tc.name test error branch -- Gitee From f8f7abddc3aed9d63c36c4b4b771ca6785deff41 Mon Sep 17 00:00:00 2001 From: jxw Date: Thu, 22 May 2025 14:45:29 +0000 Subject: [PATCH 137/145] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E6=BC=AB=E6=B8=B8?= =?UTF-8?q?=E5=BC=80=E5=85=B3=E6=94=B9=E5=8F=98=E7=BB=B4=E6=B5=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: jxw --- services/src/cellular_data_handler.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/services/src/cellular_data_handler.cpp b/services/src/cellular_data_handler.cpp index 750e3254..60b30365 100644 --- a/services/src/cellular_data_handler.cpp +++ b/services/src/cellular_data_handler.cpp @@ -2305,6 +2305,8 @@ void CellularDataHandler::HandleDBSettingRoamingChanged(const AppExecFwk::InnerE if (CoreManagerInner::GetInstance().GetPsRoamingState(slotId_) > 0) { roamingState = true; } + TELEPHONY_LOGI("Slot%{public}d: roamingState%{public}d, dataRoamingEnabled%{public}d.", + slotId_, roamingState, dataRoamingEnabled); if (roamingState) { if (dataRoamingEnabled) { EstablishAllApnsIfConnectable(); -- Gitee From b53baef9b47faa4d7618793766f3067fe440bb19 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=88=98=E5=B3=BB=E6=9C=8B?= Date: Fri, 23 May 2025 02:51:42 +0000 Subject: [PATCH 138/145] =?UTF-8?q?Vsim=E8=87=AA=E6=84=88?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 刘峻朋 --- test/mock/mock_network_search.h | 1 + 1 file changed, 1 insertion(+) diff --git a/test/mock/mock_network_search.h b/test/mock/mock_network_search.h index ae9c4e76..fafb7ea0 100644 --- a/test/mock/mock_network_search.h +++ b/test/mock/mock_network_search.h @@ -55,6 +55,7 @@ public: MOCK_METHOD2(GetPreferredNetwork, int32_t(int32_t slotId, NSCALLBACK &callback)); MOCK_METHOD3(SetPreferredNetwork, int32_t(int32_t slotId, int32_t networkMode, NSCALLBACK &callback)); MOCK_METHOD2(SetPreferredNetwork, bool(int32_t, int32_t)); + MOCK_METHOD2(SetForcePreferredNetwork, bool(int32_t, int32_t)); MOCK_METHOD1(GetPsRegState, int32_t(int32_t slotId)); MOCK_METHOD1(GetCsRegState, int32_t(int32_t slotId)); MOCK_METHOD1(GetPsRoamingState, int32_t(int32_t slotId)); -- Gitee From a69bc049bb4e5ff57fd3cc44617ec2caa2a04532 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=BC=A0=E6=96=87=E6=9D=B0?= Date: Mon, 26 May 2025 08:34:33 +0000 Subject: [PATCH 139/145] update README_zh.md. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 张文杰 --- README_zh.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README_zh.md b/README_zh.md index a1766b11..276cbc67 100644 --- a/README_zh.md +++ b/README_zh.md @@ -57,7 +57,7 @@ base/telephony/cellular_data/ | 接口名称 | 接口描述 | 所需权限 | | ------------------------------------------------------------ | ------------------------------------------------------------ | -------------------------------- | | function isCellularDataEnabled(callback: AsyncCallback\): void; | 获取蜂窝数据开关是否打开 | ohos.permission.GET_NETWORK_INFO | -| function getCellularDataState(callback: AsyncCallback\): void; | 获取蜂窝数据状态 | ohos.permission.GET_NETWORK_INFO | +| function getCellularDataState(callback: AsyncCallback\): void; | 获取蜂窝数据状态 | 无 | | function isCellularDataEnabledSync(): boolean; | 获取蜂窝移动数据服务是否启用 | ohos.permission.GET_NETWORK_INFO | | function isCellularDataRoamingEnabledSync(slotId: number): boolean; | 获取蜂窝数据漫游服务是否启用(参数slotId为SIM卡id,0表示卡一,1表示卡二) | ohos.permission.GET_NETWORK_INFO | -- Gitee From fc48d797aa537d12cd19f50a4bcb89b58aa5e7f0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=BC=A0=E6=96=87=E6=9D=B0?= Date: Mon, 26 May 2025 08:35:11 +0000 Subject: [PATCH 140/145] update README.md. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 张文杰 --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 45af3ef1..da55bf9b 100644 --- a/README.md +++ b/README.md @@ -66,7 +66,7 @@ base/telephony/cellular_data/ | API | Description | Required Permission | | ------------------------------------------------------------ | ------------------------------------------------------------ | -------------------------------- | | function isCellularDataEnabled(callback: AsyncCallback\): void; | Checks whether the cellular data is enabled | ohos.permission.GET_NETWORK_INFO | -| function getCellularDataState(callback: AsyncCallback\): void; | Obtains the cellular data status. | ohos.permission.GET_NETWORK_INFO | +| function getCellularDataState(callback: AsyncCallback\): void; | Obtains the cellular data status. | void; | | function isCellularDataEnabledSync(): boolean; | Checks if cellular mobile data service is enabled. | ohos.permission.GET_NETWORK_INFO | | function isCellularDataRoamingEnabledSync(slotId: number): boolean; | Checks if cellular data roaming is enabled(The parameter slotId is the SIM card id, 0 represents card one, and 1 represents card two). | ohos.permission.GET_NETWORK_INFO | -- Gitee From 347c0458cbb2107495a4d72e900f1eeffdd6a954 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=BC=A0=E6=96=87=E6=9D=B0?= Date: Mon, 26 May 2025 08:35:38 +0000 Subject: [PATCH 141/145] update README.md. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 张文杰 --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index da55bf9b..07ed8cbc 100644 --- a/README.md +++ b/README.md @@ -66,7 +66,7 @@ base/telephony/cellular_data/ | API | Description | Required Permission | | ------------------------------------------------------------ | ------------------------------------------------------------ | -------------------------------- | | function isCellularDataEnabled(callback: AsyncCallback\): void; | Checks whether the cellular data is enabled | ohos.permission.GET_NETWORK_INFO | -| function getCellularDataState(callback: AsyncCallback\): void; | Obtains the cellular data status. | void; | +| function getCellularDataState(callback: AsyncCallback\): void; | Obtains the cellular data status. | void | | function isCellularDataEnabledSync(): boolean; | Checks if cellular mobile data service is enabled. | ohos.permission.GET_NETWORK_INFO | | function isCellularDataRoamingEnabledSync(slotId: number): boolean; | Checks if cellular data roaming is enabled(The parameter slotId is the SIM card id, 0 represents card one, and 1 represents card two). | ohos.permission.GET_NETWORK_INFO | -- Gitee From 69c1ed51208ae984d52ddfb8126a5d26b3b7aabf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=BC=A0=E6=96=87=E6=9D=B0?= Date: Mon, 26 May 2025 08:36:37 +0000 Subject: [PATCH 142/145] update README.md. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 张文杰 --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 07ed8cbc..3963ac71 100644 --- a/README.md +++ b/README.md @@ -66,7 +66,7 @@ base/telephony/cellular_data/ | API | Description | Required Permission | | ------------------------------------------------------------ | ------------------------------------------------------------ | -------------------------------- | | function isCellularDataEnabled(callback: AsyncCallback\): void; | Checks whether the cellular data is enabled | ohos.permission.GET_NETWORK_INFO | -| function getCellularDataState(callback: AsyncCallback\): void; | Obtains the cellular data status. | void | +| function getCellularDataState(callback: AsyncCallback\): void; | Obtains the cellular data status. | None | | function isCellularDataEnabledSync(): boolean; | Checks if cellular mobile data service is enabled. | ohos.permission.GET_NETWORK_INFO | | function isCellularDataRoamingEnabledSync(slotId: number): boolean; | Checks if cellular data roaming is enabled(The parameter slotId is the SIM card id, 0 represents card one, and 1 represents card two). | ohos.permission.GET_NETWORK_INFO | -- Gitee From e93bc2d13a6936a961520387ef9b17f8e9d80263 Mon Sep 17 00:00:00 2001 From: benlau Date: Fri, 30 May 2025 17:07:28 +0800 Subject: [PATCH 143/145] dd log Signed-off-by: benlau --- services/src/cellular_data_handler.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/services/src/cellular_data_handler.cpp b/services/src/cellular_data_handler.cpp index 60b30365..001baeaf 100644 --- a/services/src/cellular_data_handler.cpp +++ b/services/src/cellular_data_handler.cpp @@ -2274,6 +2274,7 @@ void CellularDataHandler::SetRilLinkBandwidths() void CellularDataHandler::HandleDBSettingEnableChanged(const AppExecFwk::InnerEvent::Pointer &event) { + TELEPHONY_LOGI("Slot%{public}d: HandleDBSettingEnableChanged enter.", slotId_); if (dataSwitchSettings_ == nullptr) { TELEPHONY_LOGE("Slot%{public}d: dataSwitchSettings_ is null.", slotId_); return; -- Gitee From 646e02e66983e97f7830e25f6b06556161fa2fe7 Mon Sep 17 00:00:00 2001 From: zhouyan Date: Tue, 3 Jun 2025 20:48:54 +0800 Subject: [PATCH 144/145] create default apn for distributed network Signed-off-by: zhouyan --- services/src/cellular_data_handler.cpp | 16 ++++++++++++++++ .../include/telephony_ext_wrapper.h | 3 +++ .../src/telephony_ext_wrapper.cpp | 12 ++++++++++++ 3 files changed, 31 insertions(+) diff --git a/services/src/cellular_data_handler.cpp b/services/src/cellular_data_handler.cpp index 001baeaf..0c4c8e04 100644 --- a/services/src/cellular_data_handler.cpp +++ b/services/src/cellular_data_handler.cpp @@ -671,8 +671,24 @@ bool CellularDataHandler::CheckApnState(sptr &apnHolder) } std::vector> matchedApns = apnManager_->FilterMatchedApns(apnHolder->GetApnType(), slotId_); if (matchedApns.empty()) { +#ifdef OHOS_BUILD_ENABLE_TELEPHONY_EXT + sptr extraApnItem = ApnItem::MakeDefaultApn("default"); + if (TELEPHONY_EXT_WRAPPER.createDcApnItemExt_ && + TELEPHONY_EXT_WRAPPER.createDcApnItemExt_(slotId_, extraApnItem)) { + TELEPHONY_LOGI("Slot%{public}d: create extra apn item", slotId_); + if (extraApnItem == nullptr) { + TELEPHONY_LOGE("Slot%{public}d: AttemptEstablishDataConnection:matchedApns is empty", slotId_); + return false; + } + matchedApns.push_back(extraApnItem); + } else { + TELEPHONY_LOGE("Slot%{public}d: AttemptEstablishDataConnection:matchedApns is empty", slotId_); + return false; + } +#else TELEPHONY_LOGE("Slot%{public}d: AttemptEstablishDataConnection:matchedApns is empty", slotId_); return false; +#endif } apnHolder->SetAllMatchedApns(matchedApns); return true; diff --git a/services/telephony_ext_wrapper/include/telephony_ext_wrapper.h b/services/telephony_ext_wrapper/include/telephony_ext_wrapper.h index 3582c2b7..86f41fe7 100644 --- a/services/telephony_ext_wrapper/include/telephony_ext_wrapper.h +++ b/services/telephony_ext_wrapper/include/telephony_ext_wrapper.h @@ -54,6 +54,7 @@ public: typedef bool (*JUDGE_OTHER_REQUEST_HOLDING)(const NetRequest &, const HasSystemUse hasSystemUse); typedef void (*DynamicLoadInit)(void); typedef void (*NotifyReqCellularData)(bool isReqCellularData); + typedef bool (*CREATE_DC_APN_ITEM_EXT)(int32_t slotId, sptr &apnItem); DATA_EDN_SELF_CURE dataEndSelfCure_ = nullptr; IS_APN_ALLOWED_ACTIVE isApnAllowedActive_ = nullptr; @@ -73,6 +74,7 @@ public: JUDGE_OTHER_REQUEST_HOLDING judgeOtherRequestHolding_ = nullptr; DynamicLoadInit dynamicLoadInit_ = nullptr; NotifyReqCellularData dynamicLoadNotifyReqCellularDataStatus_ = nullptr; + CREATE_DC_APN_ITEM_EXT createDcApnItemExt_ = nullptr; private: void* telephonyExtWrapperHandle_ = nullptr; @@ -92,6 +94,7 @@ private: void InitSendApnNeedRetryInfo(); void InitJudgeOtherRequestHolding(); void InitTelephonyExtWrapperForDynamicLoad(); + void InitCreateDcApnItemExt(); }; #define TELEPHONY_EXT_WRAPPER ::OHOS::DelayedRefSingleton::GetInstance() diff --git a/services/telephony_ext_wrapper/src/telephony_ext_wrapper.cpp b/services/telephony_ext_wrapper/src/telephony_ext_wrapper.cpp index fa4de0f2..88013cc1 100644 --- a/services/telephony_ext_wrapper/src/telephony_ext_wrapper.cpp +++ b/services/telephony_ext_wrapper/src/telephony_ext_wrapper.cpp @@ -69,6 +69,7 @@ void TelephonyExtWrapper::InitTelephonyExtWrapperForCellularData() InitRestartRadioIfRequired(); InitSendApnNeedRetryInfo(); InitJudgeOtherRequestHolding(); + InitCreateDcApnItemExt(); } void TelephonyExtWrapper::InitJudgeOtherRequestHolding() @@ -218,5 +219,16 @@ void TelephonyExtWrapper::InitTelephonyExtWrapperForDynamicLoad() } TELEPHONY_LOGI("[DynamicLoad]telephony ext wrapper dynamic load init success"); } + +void TelephonyExtWrapper::InitCreateDcApnItemExt() +{ + createDcApnItemExt_ = + (CREATE_DC_APN_ITEM_EXT)dlsym(telephonyExtWrapperHandle_, "CreateDcApnItemExt"); + if (createDcApnItemExt_ == nullptr) { + TELEPHONY_LOGE("telephony ext wrapper symbol CreateDcApnItemExt failed, error: %{public}s", dlerror()); + return; + } + TELEPHONY_LOGI("telephony ext wrapper init CreateDcApnItemExt success"); +} } // namespace Telephony } // namespace OHOS \ No newline at end of file -- Gitee From 334eaf6e04814f90091d3e53f36fa1ee5f2fa428 Mon Sep 17 00:00:00 2001 From: zhouyan Date: Sat, 12 Jul 2025 18:01:43 +0800 Subject: [PATCH 145/145] change founction to trigger createDcApnItem Signed-off-by: zhouyan --- services/src/apn_manager/apn_manager.cpp | 9 +++++++- services/src/cellular_data_handler.cpp | 16 ------------- test/apn_manager_test.cpp | 29 ++++++++++++++++++++++++ 3 files changed, 37 insertions(+), 17 deletions(-) diff --git a/services/src/apn_manager/apn_manager.cpp b/services/src/apn_manager/apn_manager.cpp index 93f6bf7a..0f550b79 100644 --- a/services/src/apn_manager/apn_manager.cpp +++ b/services/src/apn_manager/apn_manager.cpp @@ -295,8 +295,8 @@ std::vector> ApnManager::GetSortApnHolder() const int32_t ApnManager::CreateAllApnItemByDatabase(int32_t slotId) { int32_t count = 0; + sptr extraApnItem = ApnItem::MakeDefaultApn("default"); if (TELEPHONY_EXT_WRAPPER.createAllApnItemExt_) { - sptr extraApnItem = ApnItem::MakeDefaultApn("default"); if (TELEPHONY_EXT_WRAPPER.createAllApnItemExt_(slotId, extraApnItem)) { std::lock_guard lock(mutex_); allApnItem_.clear(); @@ -304,6 +304,13 @@ int32_t ApnManager::CreateAllApnItemByDatabase(int32_t slotId) return ++count; } } + if (TELEPHONY_EXT_WRAPPER.createDcApnItemExt_ && + TELEPHONY_EXT_WRAPPER.createDcApnItemExt_(slotId_, extraApnItem)) { + std::lock_guard lock(mutex_); + allApnItem_.clear(); + allApnItem_.push_back(extraApnItem); + return ++count; + } std::u16string operatorNumeric; CoreManagerInner::GetInstance().GetSimOperatorNumeric(slotId, operatorNumeric); std::string numeric = Str16ToStr8(operatorNumeric); diff --git a/services/src/cellular_data_handler.cpp b/services/src/cellular_data_handler.cpp index 0c4c8e04..001baeaf 100644 --- a/services/src/cellular_data_handler.cpp +++ b/services/src/cellular_data_handler.cpp @@ -671,24 +671,8 @@ bool CellularDataHandler::CheckApnState(sptr &apnHolder) } std::vector> matchedApns = apnManager_->FilterMatchedApns(apnHolder->GetApnType(), slotId_); if (matchedApns.empty()) { -#ifdef OHOS_BUILD_ENABLE_TELEPHONY_EXT - sptr extraApnItem = ApnItem::MakeDefaultApn("default"); - if (TELEPHONY_EXT_WRAPPER.createDcApnItemExt_ && - TELEPHONY_EXT_WRAPPER.createDcApnItemExt_(slotId_, extraApnItem)) { - TELEPHONY_LOGI("Slot%{public}d: create extra apn item", slotId_); - if (extraApnItem == nullptr) { - TELEPHONY_LOGE("Slot%{public}d: AttemptEstablishDataConnection:matchedApns is empty", slotId_); - return false; - } - matchedApns.push_back(extraApnItem); - } else { - TELEPHONY_LOGE("Slot%{public}d: AttemptEstablishDataConnection:matchedApns is empty", slotId_); - return false; - } -#else TELEPHONY_LOGE("Slot%{public}d: AttemptEstablishDataConnection:matchedApns is empty", slotId_); return false; -#endif } apnHolder->SetAllMatchedApns(matchedApns); return true; diff --git a/test/apn_manager_test.cpp b/test/apn_manager_test.cpp index e125797f..983060e4 100644 --- a/test/apn_manager_test.cpp +++ b/test/apn_manager_test.cpp @@ -24,6 +24,7 @@ #include "gtest/gtest.h" #include "tel_event_handler.h" #include "pdp_profile_data.h" +#include "telephony_ext_wrapper.h" namespace OHOS { namespace Telephony { @@ -1511,5 +1512,33 @@ HWTEST_F(ApnManagerTest, FetchBipApns_001, TestSize.Level0) EXPECT_NE(bipApn, nullptr); } +bool CreateDcApnItemExtMock() { + return true; +} + +/** + * @tc.name : ApnItem_CreateDcApnItemExt_001 + * @tc.number: ApnItem_CreateDcApnItemExt_001 + * @tc.desc : Test create Dc apn item 001 + */ +HWTEST_F(ApnManagerTest, ApnItem_CreateDcApnItemExt_001, TestSize.Level0) +{ + TELEPHONY_EXT_WRAPPER.createAllApnItemExt_ = nullptr; + TELEPHONY_EXT_WRAPPER.createDcApnItemExt_ = CreateDcApnItemExtMock; + int32_t ret = apnManager->CreateAllApnItemByDatabase(0); + EXPECT_EQ(ret, 1); +} + +/** + * @tc.name : ApnItem_CreateDcApnItemExt_002 + * @tc.number: ApnItem_CreateDcApnItemExt_002 + * @tc.desc : Test create Dc apn item 002 + */ +HWTEST_F(ApnManagerTest, ApnItem_CreateDcApnItemExt_002, TestSize.Level0) +{ + int32_t ret = apnManager->CreateAllApnItemByDatabase(0); + EXPECT_EQ(ret, 1); +} + } // namespace Telephony } // namespace OHOS \ No newline at end of file -- Gitee