diff --git a/BUILD.gn b/BUILD.gn index ef84a838fc336a9a97d1a89fafd57809128a1529..67d967d9e5d896cc47c9d56ca7695eb442f79470 100644 --- a/BUILD.gn +++ b/BUILD.gn @@ -97,6 +97,7 @@ 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", @@ -213,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", diff --git a/bundle.json b/bundle.json index a3b55ab920263f55aede81b104fddbdcabe234b1..31ab5182fff13d67c915a76269e6644474c5f775 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 e2c81b9041286f86eeffa802d43a0e49e2686d43..d5b61571010ce93b8a1f47bc6edf33ac835623fd 100644 --- a/frameworks/native/cellular_data_client.cpp +++ b/frameworks/native/cellular_data_client.cpp @@ -513,5 +513,60 @@ int32_t CellularDataClient::QueryAllApnInfo(std::vector &apnInfoList) TELEPHONY_LOGI("QueryAllApnInfo"); return proxy->QueryAllApnInfo(apnInfoList); } + +int32_t CellularDataClient::SendUrspDecodeResult(int32_t slotId, std::vector buffer) +{ + 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) +{ + 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) +{ + 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) +{ + 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) +{ + 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 c9d16005b9d0d56020fb528214637b81c051a55d..d216b96b4fcff65c7d6e9ef57affaa5bcf63a0fa 100644 --- a/frameworks/native/cellular_data_service_proxy.cpp +++ b/frameworks/native/cellular_data_service_proxy.cpp @@ -25,6 +25,7 @@ namespace OHOS { namespace Telephony { +constexpr int32_t BUFFER_MAX = 65538; int32_t CellularDataServiceProxy::IsCellularDataEnabled(bool &dataEnabled) { MessageParcel data; @@ -909,5 +910,166 @@ int32_t CellularDataServiceProxy::QueryAllApnInfo(std::vector &apnInfoL 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 index 33aaaa2254a42648bd0ecd7016055cf6d8dadfec..72b7e375fe33a4917ac69690e6411de511e2a66f 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 8c88be4a8b48d151b8f1ce72875cfa6948a3eedb..bf199cde360f3462543ee2af37942dbbd43313a1 100644 --- a/interfaces/innerkits/cellular_data_client.h +++ b/interfaces/innerkits/cellular_data_client.h @@ -296,6 +296,50 @@ 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. + * @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 cef061a8d13379b4d0d68357c6c71ef5485166c5..bededf75cd3307905647d154465e815cc448200c 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 ed30e041f3ae8af79f056d51993cb0cdb3f6d2d7..de5ec728ab591bc6ce72c12edaff0bb020ef2297 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 4456a6b8fd5268183ae68c08a1535dfeb49d0fc4..69d383d99faea91b59d227663b41d671a44b4125 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 30430dbb713cef27c7964fec023be97bb65d3060..0c44c8612c5a815bde6c82b51767666b2d436b56 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 3eb5c2c0380a81893b6bc6360388878a5def24eb..44b456a110aacc8bd7a16ef0960b37db3e38f1bb 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 7502320018e9dd15b4157572f62a76af5bd41c90..85441562ca054351387f463ead7cd262b52fe465 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 394f8ac52d85c3995a4153f293d38b09b1a9a088..797d0065fdeb1234c7d227e9d307a5646ea47abc 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 9c9af80955b552af016252511a04059821d38a17..0a40a9e04e42225bf3eacdd7d25fbf7d0d7672da 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 cc4660c495fb3b2a5fbc0ca994cae94d3fa2dc85..92817864359f55d5f67ff2079c63fe58853f5c67 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 6ac6e89bd75bee140f3a2aec7f260a129f115f28..0264cb73b74c5a6996a76d753aa591aa777630f2 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 1d1e9e95d21d3bd76cf6bccf78e9e21d099031c4..9a4dff63caf29ffc8a7e068df934709770444667 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 60ef103eabfd9ca557dd3d52ee30788e5d580bbc..12b1f5c8d6a8932693e36ffe8048442c91a4e962 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; } @@ -406,7 +454,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 +733,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 70ea8b1b55d2410172fa1e81977735c11b8a3051..c9bafdd74313392831695224f9862b8c785e934a 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 4a616802b47819a4bdf33f0e2c709b2f0aa7b853..5bddccf75f272107e2e6dd19bcc78458f1f55b7f 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 BUFFER_MAX = 65538; CellularDataServiceStub::CellularDataServiceStub() = default; CellularDataServiceStub::~CellularDataServiceStub() = default; @@ -578,5 +579,101 @@ int32_t CellularDataServiceStub::OnQueryAllApnInfo(MessageParcel &data, MessageP } 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_manager.cpp b/services/src/data_connection_manager.cpp index a889bbe65e440944980a5dbe09be7ca9cb134eeb..f7b8c10642d4fb91fc9d5731f50fb189be875e7d 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,41 @@ void DataConnectionManager::HandleScreenStateChanged(bool isScreenOn) const } connectionMonitor_->HandleScreenStateChanged(isScreenOn); } + +void CcmDefaultState::RadioNetworkSliceUrspRpt(const AppExecFwk::InnerEvent::Pointer &event) +{ + 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) +{ + 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) +{ + 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 6c736099c6781ce99e17c4ca2c45e066a788edd0..8058b336130045e6e21e31448635ed5998ed1f41 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 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) { + isNrSa = true; + } + if (!isNrSa) { + 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 d3806da455c2da86f007abd914d3f4f801a4910f..45c985ea08285b81fbacbc28d0635cf028f2e793 100644 --- a/services/src/utils/cellular_data_net_agent.cpp +++ b/services/src/utils/cellular_data_net_agent.cpp @@ -50,7 +50,7 @@ bool CellularDataNetAgent::RegisterNetSupplier(const int32_t 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 05be700138ebfcfc74a78e868ae6d59afe02078b..964f35b02d99fecc7bcdda195834c3dac8901250 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 ab7e240b026aeac12494c46ddc97ef0ea908eb9d..4205a2b0db3c30f25e989405048db56721af1751 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 14370537b012fb207f85ad47af55358d3c71c221..9347c29cd3c38d4689eec91764954c42f855da83 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->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; service->GetSupplierRegisterState(supplierId, regState); bool isSupportDun = false;