From e8c72f673454439445a3600eceee2079dce7e804 Mon Sep 17 00:00:00 2001 From: zhangwuling1 Date: Wed, 19 Mar 2025 17:45:30 +0800 Subject: [PATCH 01/22] 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 02/22] 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 03/22] 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 04/22] 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 cd85f86f820ae316c9b1932c62eefca046035517 Mon Sep 17 00:00:00 2001 From: zhangwuling1 Date: Fri, 21 Mar 2025 02:17:23 +0000 Subject: [PATCH 05/22] 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 06/22] 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 c1f60218964f712684107b83140de9b5e9823a8e Mon Sep 17 00:00:00 2001 From: zhangwuling1 Date: Fri, 21 Mar 2025 02:50:39 +0000 Subject: [PATCH 07/22] 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 08/22] 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 09/22] 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 10/22] 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 11/22] 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 12/22] 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 13/22] 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 14/22] 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 15/22] 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 16/22] 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 17/22] 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 18/22] 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 19/22] 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 20/22] 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 21/22] 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 22/22] 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