diff --git a/BUILD.gn b/BUILD.gn index ef84a838fc336a9a97d1a89fafd57809128a1529..c5831b29e33265df68e2611d1438fc1aa9f5c3fb 100644 --- a/BUILD.gn +++ b/BUILD.gn @@ -27,6 +27,8 @@ ohos_shared_library("tel_cellular_data") { sources = [ "$DATA_SERVICE_EXT_WRAPPER_ROOT/src/data_service_ext_wrapper.cpp", "$TELEPHONY_EXT_WRAPPER_ROOT/src/telephony_ext_wrapper.cpp", + "frameworks/native/apn_activate_report_info.cpp", + "frameworks/native/apn_attribute.cpp", "services/src/apn_manager/apn_holder.cpp", "services/src/apn_manager/apn_item.cpp", "services/src/apn_manager/apn_manager.cpp", @@ -39,7 +41,6 @@ ohos_shared_library("tel_cellular_data") { "services/src/cellular_data_rdb_observer.cpp", "services/src/cellular_data_roaming_observer.cpp", "services/src/cellular_data_service.cpp", - "services/src/cellular_data_service_stub.cpp", "services/src/cellular_data_setting_observer.cpp", "services/src/data_connection_manager.cpp", "services/src/data_connection_monitor.cpp", @@ -75,6 +76,8 @@ ohos_shared_library("tel_cellular_data") { "interfaces/innerkits", ] + deps = [ "frameworks/native:cellulardata_interface_stub" ] + external_deps = [ "ability_base:want", "ability_base:zuri", @@ -97,6 +100,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", @@ -143,6 +147,8 @@ ohos_static_library("tel_cellular_data_static") { sources = [ "$DATA_SERVICE_EXT_WRAPPER_ROOT/src/data_service_ext_wrapper.cpp", "$TELEPHONY_EXT_WRAPPER_ROOT/src/telephony_ext_wrapper.cpp", + "frameworks/native/apn_activate_report_info.cpp", + "frameworks/native/apn_attribute.cpp", "services/src/apn_manager/apn_holder.cpp", "services/src/apn_manager/apn_item.cpp", "services/src/apn_manager/apn_manager.cpp", @@ -155,7 +161,6 @@ ohos_static_library("tel_cellular_data_static") { "services/src/cellular_data_rdb_observer.cpp", "services/src/cellular_data_roaming_observer.cpp", "services/src/cellular_data_service.cpp", - "services/src/cellular_data_service_stub.cpp", "services/src/cellular_data_setting_observer.cpp", "services/src/data_connection_manager.cpp", "services/src/data_connection_monitor.cpp", @@ -191,6 +196,8 @@ ohos_static_library("tel_cellular_data_static") { "interfaces/innerkits", ] + deps = [ "frameworks/native:cellulardata_interface_stub" ] + external_deps = [ "ability_base:want", "ability_base:zuri", @@ -213,6 +220,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/README.md b/README.md index 45af3ef1188eb22d10c7063d39819c20f0642853..3963ac71194ce369c43c2a0b0b8ab4cb575f8587 100644 --- a/README.md +++ b/README.md @@ -66,7 +66,7 @@ base/telephony/cellular_data/ | API | Description | Required Permission | | ------------------------------------------------------------ | ------------------------------------------------------------ | -------------------------------- | | function isCellularDataEnabled(callback: AsyncCallback\): void; | Checks whether the cellular data is enabled | ohos.permission.GET_NETWORK_INFO | -| function getCellularDataState(callback: AsyncCallback\): void; | Obtains the cellular data status. | ohos.permission.GET_NETWORK_INFO | +| function getCellularDataState(callback: AsyncCallback\): void; | Obtains the cellular data status. | None | | function isCellularDataEnabledSync(): boolean; | Checks if cellular mobile data service is enabled. | ohos.permission.GET_NETWORK_INFO | | function isCellularDataRoamingEnabledSync(slotId: number): boolean; | Checks if cellular data roaming is enabled(The parameter slotId is the SIM card id, 0 represents card one, and 1 represents card two). | ohos.permission.GET_NETWORK_INFO | diff --git a/README_zh.md b/README_zh.md index a1766b11fae5c56d56eee0eeb936daad730b392e..276cbc675d70bdeb1d5a005cd07342bbff6b341d 100644 --- a/README_zh.md +++ b/README_zh.md @@ -57,7 +57,7 @@ base/telephony/cellular_data/ | 接口名称 | 接口描述 | 所需权限 | | ------------------------------------------------------------ | ------------------------------------------------------------ | -------------------------------- | | function isCellularDataEnabled(callback: AsyncCallback\): void; | 获取蜂窝数据开关是否打开 | ohos.permission.GET_NETWORK_INFO | -| function getCellularDataState(callback: AsyncCallback\): void; | 获取蜂窝数据状态 | ohos.permission.GET_NETWORK_INFO | +| function getCellularDataState(callback: AsyncCallback\): void; | 获取蜂窝数据状态 | 无 | | function isCellularDataEnabledSync(): boolean; | 获取蜂窝移动数据服务是否启用 | ohos.permission.GET_NETWORK_INFO | | function isCellularDataRoamingEnabledSync(slotId: number): boolean; | 获取蜂窝数据漫游服务是否启用(参数slotId为SIM卡id,0表示卡一,1表示卡二) | ohos.permission.GET_NETWORK_INFO | diff --git a/bundle.json b/bundle.json index fd92654f7f8b5d8b9fcb992aa94615043a0d11bf..1bed29ca4e4a22675e01521f11655ed983b47f63 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/js/napi/src/napi_cellular_data.cpp b/frameworks/js/napi/src/napi_cellular_data.cpp index 42f3761d46544242ff937e0e4c146ec054071cde..b2919cbcafda13cff54300861e4b75108f6d9db3 100644 --- a/frameworks/js/napi/src/napi_cellular_data.cpp +++ b/frameworks/js/napi/src/napi_cellular_data.cpp @@ -265,6 +265,9 @@ static napi_value IsCellularDataEnabledSync(napi_env env, napi_callback_info inf if (IsCellularDataManagerInited()) { auto errorCode = CellularDataClient::GetInstance().IsCellularDataEnabled(isEnabled); if (errorCode != TELEPHONY_SUCCESS) { + JsError error = NapiUtil::ConverErrorMessageWithPermissionForJs( + errorCode, "isCellularDataEnabledSync", GET_NETWORK_INFO); + NapiUtil::ThrowError(env, error.errorCode, error.errorMessage); return value; } } else { @@ -632,12 +635,16 @@ static napi_value IsCellularDataRoamingEnabledSync(napi_env env, napi_callback_i napi_get_value_int32(env, parameters[0], &slotId); if (!IsValidSlotId(slotId)) { TELEPHONY_LOGE("IsCellularDataRoamingEnabledSync slotId is invalid"); + NapiUtil::ThrowParameterError(env); return value; } if (IsCellularDataManagerInited()) { auto &dataManager = CellularDataClient::GetInstance(); auto errorCode = dataManager.IsCellularDataRoamingEnabled(slotId, dataRoamingEnabled); if (errorCode != TELEPHONY_SUCCESS) { + JsError error = NapiUtil::ConverErrorMessageWithPermissionForJs( + errorCode, "isCellularDataRoamingEnabledSync", GET_NETWORK_INFO); + NapiUtil::ThrowError(env, error.errorCode, error.errorMessage); return value; } } else { diff --git a/frameworks/native/BUILD.gn b/frameworks/native/BUILD.gn index 93b81ef6a03c538a64824023767dca16a8ba7278..7e7b493b31a71197d33b5d7210ca27d12f506022 100644 --- a/frameworks/native/BUILD.gn +++ b/frameworks/native/BUILD.gn @@ -10,6 +10,7 @@ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. +import("//build/config/components/idl_tool/idl.gni") import("//build/ohos.gni") SUBSYSTEM_DIR = "../.." @@ -17,6 +18,7 @@ TELEPHONY_DATA_DIR = "../../../telephony_data" config("cellular_data_util_config") { # header file path include_dirs = [ + "${target_gen_dir}", "$SUBSYSTEM_DIR/interfaces/innerkits", "$SUBSYSTEM_DIR/services/include/apn_manager", "$SUBSYSTEM_DIR/services/include/common", @@ -38,6 +40,48 @@ config("cellular_data_util_config") { } } +config("cellulardata_interface_config") { + include_dirs = [ + "${target_gen_dir}", + "${target_gen_dir}/callback", + "${target_gen_dir}/type", + "$SUBSYSTEM_DIR/interfaces/innerkits", + "$SUBSYSTEM_DIR/services/include", + "$SUBSYSTEM_DIR/services/include/apn_manager", + "$SUBSYSTEM_DIR/services/include/common", + "$SUBSYSTEM_DIR/services/include/state_machine", + "$SUBSYSTEM_DIR/services/include/utils", + ] +} + +idl_gen_interface("cellulardata_interface") { + sources = [ "ICellularDataManager.idl" ] + log_domainid = "0xD001F03" + log_tag = "CellularDataApi" +} + +ohos_source_set("cellulardata_interface_stub") { + sanitize = { + cfi = true + cfi_cross_dso = true + debug = false + } + public_configs = [ ":cellulardata_interface_config" ] + output_values = get_target_outputs(":cellulardata_interface") + sources = [] + sources += filter_include(output_values, [ "*_stub.cpp" ]) + deps = [ ":cellulardata_interface" ] + external_deps = [ + "core_service:libtel_common", + "core_service:tel_core_service_api", + "hilog:libhilog", + "samgr:samgr_proxy", + "telephony_data:tel_telephony_data", + ] + part_name = "cellular_data" + subsystem_name = "telephony" +} + ohos_shared_library("tel_cellular_data_api") { sanitize = { cfi = true @@ -46,16 +90,20 @@ ohos_shared_library("tel_cellular_data_api") { } branch_protector_ret = "pac_ret" sources = [ + "$SUBSYSTEM_DIR/frameworks/native/apn_activate_report_info.cpp", + "$SUBSYSTEM_DIR/frameworks/native/apn_attribute.cpp", "$SUBSYSTEM_DIR/frameworks/native/cellular_data_client.cpp", - "$SUBSYSTEM_DIR/frameworks/native/cellular_data_service_proxy.cpp", - "$SUBSYSTEM_DIR/frameworks/native/data_sim_account_call_back.cpp", + "$SUBSYSTEM_DIR/frameworks/native/data_sim_account_callback.cpp", "$SUBSYSTEM_DIR/frameworks/native/sim_account_callback_stub.cpp", ] - + output_values = get_target_outputs(":cellulardata_interface") + sources += filter_include(output_values, [ "*_proxy.cpp" ]) version_script = "$SUBSYSTEM_DIR/interfaces/innerkits/libtel_cellular_data_api.versionscript" public_configs = [ ":cellular_data_util_config" ] + deps = [ ":cellulardata_interface" ] + external_deps = [ "c_utils:utils", "core_service:libtel_common", diff --git a/frameworks/native/ICellularDataManager.idl b/frameworks/native/ICellularDataManager.idl new file mode 100644 index 0000000000000000000000000000000000000000..80ce10a411777d88364b668a98e62e0e36c9f11e --- /dev/null +++ b/frameworks/native/ICellularDataManager.idl @@ -0,0 +1,60 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +sequenceable ApnAttribute..OHOS.Telephony.ApnAttribute; +sequenceable ApnActivateReportInfo..OHOS.Telephony.ApnActivateReportInfoIpc; +sequenceable CellularDataTypes..OHOS.Telephony.ApnInfo; +interface OHOS.Telephony.SimAccountCallback; +interface OHOS.Telephony.ICellularDataManager { + void IsCellularDataEnabled([out] boolean dataEnabled); + void EnableCellularData([in] boolean enable); + void EnableIntelligenceSwitch([in] boolean enable); + void GetCellularDataState([out] int state); + void IsCellularDataRoamingEnabled([in] int slotId, [inout] boolean dataRoamingEnabled); + void EnableCellularDataRoaming([in] int slotId, [in] boolean enable); + void HandleApnChanged([in] int slotId); + void GetDefaultCellularDataSlotId([out] int slotId); + void GetDefaultCellularDataSimId([out] int simId); + void SetDefaultCellularDataSlotId([in] int slotId); + void GetCellularDataFlowType([out] int type); + void HasInternetCapability([in] int slotId, [in] int cid, [out] int capability); + void ClearCellularDataConnections([in] int slotId); + void ClearAllConnections([in] int slotId, [in] int reason); + void RegisterSimAccountCallback([in] SimAccountCallback callbackparam); + void UnregisterSimAccountCallback([in] SimAccountCallback callbackparam); + void GetDataConnApnAttr([in] int slotId, [out] ApnAttribute apnAttr); + void GetDataConnIpType([in] int slotId, [out] String ipType); + void GetApnState([in] int slotId, [in] String apnType, [out] int state); + void GetDataRecoveryState([out] int state); + void IsNeedDoRecovery([in] int slotId, [in] boolean needDoRecovery); + void InitCellularDataController([in] int slotId); + void EstablishAllApnsIfConnectable([in] int slotId); + void ReleaseCellularDataConnection([in] int slotId); + void GetCellularDataSupplierId([in] int slotId, [in] unsigned long capability, [out] unsigned int supplierId); + void CorrectNetSupplierNoAvailable([in] int slotId); + void GetSupplierRegisterState([in] unsigned int supplierId, [out] int regState); + void GetIfSupportDunApn([out] boolean isSupportDun); + void GetDefaultActReportInfo([in] int slotId, [out] ApnActivateReportInfoIpc info); + void GetInternalActReportInfo([in] int slotId, [out] ApnActivateReportInfoIpc info); + void GetIntelligenceSwitchState([out] boolean switchState); + void QueryApnIds([in] ApnInfo apnInfo, [out] List apnIdList); + void SetPreferApn([in] int apnId); + void QueryAllApnInfo([out] List apnInfoList); + void SendUrspDecodeResult([in] int slotId, [in] List buffer); + void SendUePolicySectionIdentifier([in] int slotId, [in] List buffer); + void SendImsRsdList([in] int slotId, [in] List buffer); + void GetNetworkSliceAllowedNssai([in] int slotId, [in] List buffer); + void GetNetworkSliceEhplmn([in] int slotId); +}; diff --git a/frameworks/native/apn_activate_report_info.cpp b/frameworks/native/apn_activate_report_info.cpp new file mode 100644 index 0000000000000000000000000000000000000000..543c0cc6364e0d5252771ef0ea0cca049e9225f5 --- /dev/null +++ b/frameworks/native/apn_activate_report_info.cpp @@ -0,0 +1,66 @@ +/* + * Copyright (C) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +#include "apn_item.h" +#include "apn_activate_report_info.h" + +namespace OHOS { +namespace Telephony { +bool ApnActivateReportInfoIpc::Marshalling(Parcel &parcel) const +{ + if (!parcel.WriteUint32(actTimes)) { + return false; + } + if (!parcel.WriteUint32(averDuration)) { + return false; + } + if (!parcel.WriteUint32(topReason)) { + return false; + } + if (!parcel.WriteUint32(actSuccTimes)) { + return false; + } + return true; +} + +ApnActivateReportInfoIpc* ApnActivateReportInfoIpc::Unmarshalling(Parcel &parcel) +{ + std::unique_ptr info = std::make_unique(); + if (info == nullptr) { + return nullptr; + } + if (!parcel.ReadUint32(info->actTimes)) { + return nullptr; + } + if (!parcel.ReadUint32(info->averDuration)) { + return nullptr; + } + if (!parcel.ReadUint32(info->topReason)) { + return nullptr; + } + if (!parcel.ReadUint32(info->actSuccTimes)) { + return nullptr; + } + return info.release(); +} + +void ApnActivateReportInfoIpc::transferToReportInfo(ApnActivateReportInfoIpc infoIpc, ApnActivateReportInfo &info) +{ + info.actTimes = infoIpc.actTimes; + info.averDuration = infoIpc.averDuration; + info.topReason = infoIpc.topReason; + info.actSuccTimes = infoIpc.actSuccTimes; +} +} +} \ No newline at end of file diff --git a/frameworks/native/apn_attribute.cpp b/frameworks/native/apn_attribute.cpp new file mode 100644 index 0000000000000000000000000000000000000000..948ddfb680d6a28875cc5c349edd2c232c093af4 --- /dev/null +++ b/frameworks/native/apn_attribute.cpp @@ -0,0 +1,173 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "apn_item.h" +#include "apn_attribute.h" +#include "parcel.h" + +namespace OHOS { +namespace Telephony { + +bool ApnAttribute::Marshalling(Parcel &parcel) const +{ + if (!parcel.WriteString(types_)) { + return false; + } + if (!parcel.WriteString(numeric_)) { + return false; + } + if (!parcel.WriteInt32(profileId_)) { + return false; + } + if (!parcel.WriteString(protocol_)) { + return false; + } + if (!parcel.WriteString(roamingProtocol_)) { + return false; + } + if (!parcel.WriteInt32(authType_)) { + return false; + } + if (!parcel.WriteString(apn_)) { + return false; + } + if (!parcel.WriteString(apnName_)) { + return false; + } + if (!parcel.WriteString(user_)) { + return false; + } + if (!parcel.WriteString(password_)) { + return false; + } + if (!parcel.WriteBool(isRoamingApn_)) { + return false; + } + if (!parcel.WriteString(homeUrl_)) { + return false; + } + if (!parcel.WriteString(proxyIpAddress_)) { + return false; + } + if (!parcel.WriteString(mmsIpAddress_)) { + return false; + } + if (!parcel.WriteBool(isEdited_)) { + return false; + } + return true; +} + +static bool UnmarshallingExt(Parcel &parcel, ApnAttribute* attribute) +{ + if (!parcel.ReadString(attribute->apnName_)) { + return false; + } + if (!parcel.ReadString(attribute->user_)) { + return false; + } + if (!parcel.ReadString(attribute->password_)) { + return false; + } + if (!parcel.ReadBool(attribute->isRoamingApn_)) { + return false; + } + if (!parcel.ReadString(attribute->homeUrl_)) { + return false; + } + if (!parcel.ReadString(attribute->proxyIpAddress_)) { + return false; + } + if (!parcel.ReadString(attribute->mmsIpAddress_)) { + return false; + } + if (!parcel.ReadBool(attribute->isEdited_)) { + return false; + } + return true; +} + +ApnAttribute* ApnAttribute::Unmarshalling(Parcel &parcel) +{ + std::unique_ptr attribute = std::make_unique(); + if (attribute == nullptr) { + return nullptr; + } + if (!parcel.ReadString(attribute->types_)) { + return nullptr; + } + if (!parcel.ReadString(attribute->numeric_)) { + return nullptr; + } + if (!parcel.ReadInt32(attribute->profileId_)) { + return nullptr; + } + if (!parcel.ReadString(attribute->protocol_)) { + return nullptr; + } + if (!parcel.ReadString(attribute->roamingProtocol_)) { + return nullptr; + } + if (!parcel.ReadInt32(attribute->authType_)) { + return nullptr; + } + if (!parcel.ReadString(attribute->apn_)) { + return nullptr; + } + if (!UnmarshallingExt(parcel, attribute.get())) { + return nullptr; + } + return attribute.release(); +} + +void ApnAttribute::TransferApnAttributeBeforeIpc(ApnItem::Attribute &apnAttr, ApnAttribute &apnAfterTrans) +{ + apnAfterTrans.types_ = apnAttr.types_; + apnAfterTrans.numeric_ = apnAttr.numeric_; + apnAfterTrans.profileId_ = apnAttr.profileId_; + apnAfterTrans.protocol_ = apnAttr.protocol_; + apnAfterTrans.roamingProtocol_ = apnAttr.roamingProtocol_; + apnAfterTrans.authType_ = apnAttr.authType_; + apnAfterTrans.apn_ = apnAttr.apn_; + apnAfterTrans.apnName_ = apnAttr.apnName_; + apnAfterTrans.user_ = apnAttr.user_; + apnAfterTrans.password_ = apnAttr.password_; + apnAfterTrans.isRoamingApn_ = apnAttr.isRoamingApn_; + apnAfterTrans.homeUrl_ = apnAttr.homeUrl_; + apnAfterTrans.proxyIpAddress_ = apnAttr.proxyIpAddress_; + apnAfterTrans.mmsIpAddress_ = apnAttr.mmsIpAddress_; + apnAfterTrans.isEdited_ = apnAttr.isEdited_; +} + +void ApnAttribute::TransferApnAttributeAfterIpc(ApnItem::Attribute &apnAttr, ApnAttribute &apnAfterTrans) +{ + apnAfterTrans.types_.copy(apnAttr.types_, apnAfterTrans.types_.size(), 0); + apnAfterTrans.numeric_.copy(apnAttr.numeric_, apnAfterTrans.numeric_.size(), 0); + apnAttr.profileId_ = apnAfterTrans.profileId_; + apnAfterTrans.protocol_.copy(apnAttr.protocol_, apnAfterTrans.protocol_.size(), 0); + apnAfterTrans.roamingProtocol_.copy(apnAttr.roamingProtocol_, apnAfterTrans.roamingProtocol_.size(), 0); + apnAttr.authType_ = apnAfterTrans.authType_; + apnAfterTrans.apn_.copy(apnAttr.apn_, apnAfterTrans.apn_.size(), 0); + apnAfterTrans.apnName_.copy(apnAttr.apnName_, apnAfterTrans.apnName_.size(), 0); + apnAfterTrans.user_.copy(apnAttr.user_, apnAfterTrans.user_.size(), 0); + apnAfterTrans.password_.copy(apnAttr.password_, apnAfterTrans.password_.size(), 0); + apnAttr.isRoamingApn_ = apnAfterTrans.isRoamingApn_; + apnAfterTrans.homeUrl_.copy(apnAttr.homeUrl_, apnAfterTrans.homeUrl_.size(), 0); + apnAfterTrans.proxyIpAddress_.copy(apnAttr.proxyIpAddress_, apnAfterTrans.proxyIpAddress_.size(), 0); + apnAfterTrans.mmsIpAddress_.copy(apnAttr.mmsIpAddress_, apnAfterTrans.mmsIpAddress_.size(), 0); + apnAttr.isEdited_ = apnAfterTrans.isEdited_; +} +} +} \ No newline at end of file diff --git a/frameworks/native/cellular_data_client.cpp b/frameworks/native/cellular_data_client.cpp index e2c81b9041286f86eeffa802d43a0e49e2686d43..57b3d1800651b6f402c983f61cc6537bef87a4e7 100644 --- a/frameworks/native/cellular_data_client.cpp +++ b/frameworks/native/cellular_data_client.cpp @@ -16,8 +16,10 @@ #include "cellular_data_client.h" #include "__mutex_base" +#include "apn_activate_report_info.h" +#include "cellular_data_manager_proxy.h" #include "cellular_data_types.h" -#include "i_cellular_data_manager.h" +#include "icellular_data_manager.h" #include "if_system_ability_manager.h" #include "iremote_broker.h" #include "iremote_object.h" @@ -149,7 +151,13 @@ int32_t CellularDataClient::GetDefaultCellularDataSlotId() TELEPHONY_LOGE("proxy is null"); return TELEPHONY_ERR_IPC_CONNECT_STUB_FAIL; } - defaultCellularDataSlotId_ = proxy->GetDefaultCellularDataSlotId(); + int32_t slotId; + int32_t ret = proxy->GetDefaultCellularDataSlotId(slotId); + if (ret != TELEPHONY_ERR_SUCCESS) { + TELEPHONY_LOGE("GetDefaultCellularDataSlotId IPC error, %{public}d", ret); + return ret; + } + defaultCellularDataSlotId_ = slotId; return defaultCellularDataSlotId_; } @@ -201,7 +209,7 @@ int32_t CellularDataClient::UpdateDefaultCellularDataSlotId() TELEPHONY_LOGE("proxy is null"); return TELEPHONY_ERR_IPC_CONNECT_STUB_FAIL; } - defaultCellularDataSlotId_ = proxy->GetDefaultCellularDataSlotId(); + proxy->GetDefaultCellularDataSlotId(defaultCellularDataSlotId_); proxy->GetDefaultCellularDataSimId(defaultCellularDataSimId_); return defaultCellularDataSlotId_; } @@ -243,7 +251,12 @@ int32_t CellularDataClient::GetCellularDataState() TELEPHONY_LOGE("proxy is null"); return TELEPHONY_ERR_IPC_CONNECT_STUB_FAIL; } - return proxy->GetCellularDataState(); + int32_t state; + int32_t ret = proxy->GetCellularDataState(state); + if (ret != TELEPHONY_ERR_SUCCESS) { + return ret; + } + return state; } int32_t CellularDataClient::GetApnState(int32_t slotId, const std::string &apnType) @@ -253,7 +266,12 @@ int32_t CellularDataClient::GetApnState(int32_t slotId, const std::string &apnTy TELEPHONY_LOGE("proxy is null"); return TELEPHONY_ERR_IPC_CONNECT_STUB_FAIL; } - return proxy->GetApnState(slotId, apnType); + int32_t state; + int32_t ret = proxy->GetApnState(slotId, apnType, state); + if (ret != TELEPHONY_ERR_SUCCESS) { + return ret; + } + return state; } int32_t CellularDataClient::GetDataRecoveryState() @@ -263,7 +281,12 @@ int32_t CellularDataClient::GetDataRecoveryState() TELEPHONY_LOGE("proxy is null"); return TELEPHONY_ERR_IPC_CONNECT_STUB_FAIL; } - return proxy->GetDataRecoveryState(); + int32_t state; + int32_t ret = proxy->GetDataRecoveryState(state); + if (ret != TELEPHONY_ERR_SUCCESS) { + return ret; + } + return state; } int32_t CellularDataClient::IsCellularDataRoamingEnabled(int32_t slotId, bool &dataRoamingEnabled) @@ -293,7 +316,12 @@ int32_t CellularDataClient::GetCellularDataFlowType() TELEPHONY_LOGE("proxy is null"); return TELEPHONY_ERR_IPC_CONNECT_STUB_FAIL; } - return proxy->GetCellularDataFlowType(); + int32_t type; + int32_t ret = proxy->GetCellularDataFlowType(type); + if (ret != TELEPHONY_ERR_SUCCESS) { + return ret; + } + return type; } int32_t CellularDataClient::HasInternetCapability(int32_t slotId, int32_t cid) @@ -303,7 +331,12 @@ int32_t CellularDataClient::HasInternetCapability(int32_t slotId, int32_t cid) TELEPHONY_LOGE("proxy is null"); return TELEPHONY_ERR_IPC_CONNECT_STUB_FAIL; } - return proxy->HasInternetCapability(slotId, cid); + int32_t capability; + int32_t ret = proxy->HasInternetCapability(slotId, cid, capability); + if (ret != TELEPHONY_ERR_SUCCESS) { + return ret; + } + return capability; } int32_t CellularDataClient::ClearCellularDataConnections(int32_t slotId) @@ -323,7 +356,11 @@ int32_t CellularDataClient::GetDataConnApnAttr(int32_t slotId, ApnItem::Attribut TELEPHONY_LOGE("proxy is null"); return TELEPHONY_ERR_IPC_CONNECT_STUB_FAIL; } - return proxy->GetDataConnApnAttr(slotId, apnAttr); + ApnAttribute apnAfterTrans; + ApnAttribute::TransferApnAttributeBeforeIpc(apnAttr, apnAfterTrans); + int32_t ret = proxy->GetDataConnApnAttr(slotId, apnAfterTrans); + ApnAttribute::TransferApnAttributeAfterIpc(apnAttr, apnAfterTrans); + return ret; } int32_t CellularDataClient::GetDataConnIpType(int32_t slotId, std::string &ipType) @@ -343,7 +380,8 @@ int32_t CellularDataClient::ClearAllConnections(int32_t slotId, DisConnectionRea TELEPHONY_LOGE("proxy is null"); return TELEPHONY_ERR_IPC_CONNECT_STUB_FAIL; } - return proxy->ClearAllConnections(slotId, reason); + int32_t reasonIpc = static_cast (reason); + return proxy->ClearAllConnections(slotId, reasonIpc); } int32_t CellularDataClient::HandleApnChanged(int32_t slotId) @@ -468,7 +506,10 @@ int32_t CellularDataClient::GetDefaultActReportInfo(int32_t slotId, ApnActivateR TELEPHONY_LOGE("proxy is null"); return TELEPHONY_ERR_IPC_CONNECT_STUB_FAIL; } - return proxy->GetDefaultActReportInfo(slotId, info); + ApnActivateReportInfoIpc infoIpc = info; + int32_t ret = proxy->GetDefaultActReportInfo(slotId, infoIpc); + ApnActivateReportInfoIpc::transferToReportInfo(infoIpc, info); + return ret; } int32_t CellularDataClient::GetInternalActReportInfo(int32_t slotId, ApnActivateReportInfo &info) @@ -478,7 +519,10 @@ int32_t CellularDataClient::GetInternalActReportInfo(int32_t slotId, ApnActivate TELEPHONY_LOGE("proxy is null"); return TELEPHONY_ERR_IPC_CONNECT_STUB_FAIL; } - return proxy->GetInternalActReportInfo(slotId, info); + ApnActivateReportInfoIpc infoIpc = info; + int32_t ret = proxy->GetInternalActReportInfo(slotId, infoIpc); + ApnActivateReportInfoIpc::transferToReportInfo(infoIpc, info); + return ret; } int32_t CellularDataClient::QueryApnIds(ApnInfo apnInfo, std::vector &apnIdList) @@ -513,5 +557,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 deleted file mode 100644 index c9d16005b9d0d56020fb528214637b81c051a55d..0000000000000000000000000000000000000000 --- a/frameworks/native/cellular_data_service_proxy.cpp +++ /dev/null @@ -1,913 +0,0 @@ -/* - * Copyright (C) 2021-2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "cellular_data_service_proxy.h" - -#include "iremote_object.h" -#include "message_option.h" -#include "message_parcel.h" -#include "telephony_errors.h" -#include "telephony_log_wrapper.h" -#include "securec.h" -#include "string_ex.h" - -namespace OHOS { -namespace Telephony { -int32_t CellularDataServiceProxy::IsCellularDataEnabled(bool &dataEnabled) -{ - MessageParcel data; - MessageParcel reply; - MessageOption option; - data.WriteInterfaceToken(CellularDataServiceProxy::GetDescriptor()); - if (Remote() == nullptr) { - TELEPHONY_LOGE("remote is null"); - return TELEPHONY_ERR_IPC_CONNECT_STUB_FAIL; - } - int32_t error = Remote()->SendRequest((uint32_t)CellularDataInterfaceCode::IS_CELLULAR_DATA_ENABLED, data, - reply, option); - if (error != TELEPHONY_SUCCESS) { - TELEPHONY_LOGE("call failed! errCode:%{public}d", error); - return TELEPHONY_ERR_IPC_CONNECT_STUB_FAIL; - } - int32_t result = reply.ReadInt32(); - if (result == TELEPHONY_SUCCESS) { - dataEnabled = reply.ReadBool(); - } - - return result; -} - -int32_t CellularDataServiceProxy::EnableCellularData(bool enable) -{ - MessageParcel data; - MessageParcel reply; - MessageOption option; - data.WriteInterfaceToken(CellularDataServiceProxy::GetDescriptor()); - data.WriteBool(enable); - if (Remote() == nullptr) { - TELEPHONY_LOGE("remote is null"); - return TELEPHONY_ERR_IPC_CONNECT_STUB_FAIL; - } - int32_t error = Remote()->SendRequest((uint32_t)CellularDataInterfaceCode::ENABLE_CELLULAR_DATA, data, - reply, option); - if (error != TELEPHONY_SUCCESS) { - TELEPHONY_LOGE("call failed! errCode:%{public}d", error); - return TELEPHONY_ERR_IPC_CONNECT_STUB_FAIL; - } - int32_t result = reply.ReadInt32(); - return result; -} - -int32_t CellularDataServiceProxy::GetIntelligenceSwitchState(bool &state) -{ - MessageParcel data; - MessageParcel reply; - MessageOption option; - data.WriteInterfaceToken(CellularDataServiceProxy::GetDescriptor()); - if (Remote() == nullptr) { - TELEPHONY_LOGE("remote is null"); - return TELEPHONY_ERR_IPC_CONNECT_STUB_FAIL; - } - int32_t error = Remote()->SendRequest((uint32_t)CellularDataInterfaceCode::GET_INTELLIGENCE_SWITCH_STATE, data, - reply, option); - if (error != TELEPHONY_SUCCESS) { - TELEPHONY_LOGE("call failed! errCode:%{public}d", error); - return TELEPHONY_ERR_IPC_CONNECT_STUB_FAIL; - } - int32_t result = reply.ReadInt32(); - state = reply.ReadBool(); - return result; -} - -int32_t CellularDataServiceProxy::EnableIntelligenceSwitch(bool enable) -{ - MessageParcel data; - MessageParcel reply; - MessageOption option; - data.WriteInterfaceToken(CellularDataServiceProxy::GetDescriptor()); - data.WriteBool(enable); - if (Remote() == nullptr) { - TELEPHONY_LOGE("remote is null"); - return TELEPHONY_ERR_IPC_CONNECT_STUB_FAIL; - } - int32_t error = Remote()->SendRequest((uint32_t)CellularDataInterfaceCode::ENABLE_INTELLIGENCE_SWITCH, data, - reply, option); - if (error != TELEPHONY_SUCCESS) { - TELEPHONY_LOGE("call failed! errCode:%{public}d", error); - return TELEPHONY_ERR_IPC_CONNECT_STUB_FAIL; - } - int32_t result = reply.ReadInt32(); - return result; -} - -int32_t CellularDataServiceProxy::GetCellularDataState() -{ - MessageParcel data; - MessageParcel reply; - MessageOption option; - data.WriteInterfaceToken(CellularDataServiceProxy::GetDescriptor()); - if (Remote() == nullptr) { - TELEPHONY_LOGE("remote is null"); - return TELEPHONY_ERR_IPC_CONNECT_STUB_FAIL; - } - int32_t error = Remote()->SendRequest((uint32_t)CellularDataInterfaceCode::GET_CELLULAR_DATA_STATE, data, - reply, option); - if (error != TELEPHONY_SUCCESS) { - TELEPHONY_LOGE("call failed! errCode:%{public}d", error); - return TELEPHONY_ERR_IPC_CONNECT_STUB_FAIL; - } - int32_t result = reply.ReadInt32(); - return result; -} - -int32_t CellularDataServiceProxy::GetApnState(int32_t slotId, const std::string &apnType) -{ - MessageParcel data; - MessageParcel reply; - MessageOption option; - data.WriteInterfaceToken(CellularDataServiceProxy::GetDescriptor()); - data.WriteInt32(slotId); - data.WriteString(apnType); - if (Remote() == nullptr) { - TELEPHONY_LOGE("remote is null"); - return TELEPHONY_ERR_IPC_CONNECT_STUB_FAIL; - } - int32_t error = Remote()->SendRequest((uint32_t)CellularDataInterfaceCode::GET_CELLULAR_DATA_APN_STATE, data, - reply, option); - if (error != TELEPHONY_SUCCESS) { - TELEPHONY_LOGE("function GetCellularDataState call failed! errCode:%{public}d", error); - return TELEPHONY_ERR_IPC_CONNECT_STUB_FAIL; - } - int32_t result = reply.ReadInt32(); - return result; -} - -int32_t CellularDataServiceProxy::GetDataRecoveryState() -{ - MessageParcel data; - MessageParcel reply; - MessageOption option; - data.WriteInterfaceToken(CellularDataServiceProxy::GetDescriptor()); - if (Remote() == nullptr) { - TELEPHONY_LOGE("remote is null"); - return TELEPHONY_ERR_IPC_CONNECT_STUB_FAIL; - } - int32_t error = Remote()->SendRequest((uint32_t)CellularDataInterfaceCode::GET_RECOVERY_STATE, data, - reply, option); - if (error != TELEPHONY_SUCCESS) { - TELEPHONY_LOGE("function GetDefaultCellularDataSlotId call failed! errCode:%{public}d", error); - return TELEPHONY_ERR_IPC_CONNECT_STUB_FAIL; - } - int32_t result = reply.ReadInt32(); - return result; -} - -int32_t CellularDataServiceProxy::IsCellularDataRoamingEnabled(int32_t slotId, bool &dataRoamingEnabled) -{ - MessageParcel data; - MessageParcel reply; - MessageOption option; - data.WriteInterfaceToken(CellularDataServiceProxy::GetDescriptor()); - data.WriteInt32(slotId); - if (Remote() == nullptr) { - TELEPHONY_LOGE("remote is null"); - return TELEPHONY_ERR_IPC_CONNECT_STUB_FAIL; - } - int32_t error = Remote()->SendRequest((uint32_t)CellularDataInterfaceCode::IS_DATA_ROAMING_ENABLED, data, - reply, option); - if (error != TELEPHONY_SUCCESS) { - TELEPHONY_LOGE("call failed! errCode:%{public}d", error); - return TELEPHONY_ERR_IPC_CONNECT_STUB_FAIL; - } - int32_t result = reply.ReadInt32(); - if (result == TELEPHONY_SUCCESS) { - dataRoamingEnabled = reply.ReadBool(); - } - - return result; -} - -int32_t CellularDataServiceProxy::EnableCellularDataRoaming(int32_t slotId, bool enable) -{ - MessageParcel data; - MessageParcel reply; - MessageOption option; - data.WriteInterfaceToken(CellularDataServiceProxy::GetDescriptor()); - data.WriteInt32(slotId); - data.WriteBool(enable); - if (Remote() == nullptr) { - TELEPHONY_LOGE("remote is null"); - return TELEPHONY_ERR_IPC_CONNECT_STUB_FAIL; - } - int32_t error = Remote()->SendRequest((uint32_t)CellularDataInterfaceCode::ENABLE_DATA_ROAMING, data, - reply, option); - if (error != TELEPHONY_SUCCESS) { - TELEPHONY_LOGE("call failed! errCode:%{public}d", error); - return TELEPHONY_ERR_IPC_CONNECT_STUB_FAIL; - } - int32_t result = reply.ReadInt32(); - return result; -} - -int32_t CellularDataServiceProxy::HandleApnChanged(int32_t slotId) -{ - MessageParcel data; - MessageParcel reply; - MessageOption option; - data.WriteInterfaceToken(CellularDataServiceProxy::GetDescriptor()); - data.WriteInt32(slotId); - if (Remote() == nullptr) { - TELEPHONY_LOGE("remote is null"); - return TELEPHONY_ERR_IPC_CONNECT_STUB_FAIL; - } - int32_t error = Remote()->SendRequest((uint32_t)CellularDataInterfaceCode::APN_DATA_CHANGED, data, reply, option); - if (error != TELEPHONY_SUCCESS) { - TELEPHONY_LOGE("call failed! errCode:%{public}d", error); - return TELEPHONY_ERR_IPC_CONNECT_STUB_FAIL; - } - int32_t result = reply.ReadInt32(); - return result; -} - -int32_t CellularDataServiceProxy::GetDefaultCellularDataSlotId() -{ - MessageParcel data; - MessageParcel reply; - MessageOption option; - data.WriteInterfaceToken(CellularDataServiceProxy::GetDescriptor()); - if (Remote() == nullptr) { - TELEPHONY_LOGE("remote is null"); - return TELEPHONY_ERR_IPC_CONNECT_STUB_FAIL; - } - int32_t error = Remote()->SendRequest((uint32_t)CellularDataInterfaceCode::GET_DEFAULT_SLOT_ID, data, - reply, option); - if (error != TELEPHONY_SUCCESS) { - TELEPHONY_LOGE("call failed! errCode:%{public}d", error); - return TELEPHONY_ERR_IPC_CONNECT_STUB_FAIL; - } - int32_t result = reply.ReadInt32(); - return result; -} - -int32_t CellularDataServiceProxy::GetDefaultCellularDataSimId(int32_t &simId) -{ - MessageParcel data; - data.WriteInterfaceToken(CellularDataServiceProxy::GetDescriptor()); - if (Remote() == nullptr) { - TELEPHONY_LOGE("failed: remote is null"); - return TELEPHONY_ERR_IPC_CONNECT_STUB_FAIL; - } - MessageParcel reply; - MessageOption option; - int32_t error = Remote()->SendRequest((uint32_t)CellularDataInterfaceCode::GET_DEFAULT_SIM_ID, data, reply, option); - if (error != TELEPHONY_SUCCESS) { - TELEPHONY_LOGE("SendRequest failed! errCode:%{public}d", error); - return TELEPHONY_ERR_IPC_CONNECT_STUB_FAIL; - } - int32_t result = reply.ReadInt32(); - TELEPHONY_LOGD("end: result=%{public}d", result); - if (result == TELEPHONY_ERR_SUCCESS) { - simId = reply.ReadInt32(); - } - return result; -} - -int32_t CellularDataServiceProxy::SetDefaultCellularDataSlotId(int32_t slotId) -{ - MessageParcel data; - MessageParcel reply; - MessageOption option; - data.WriteInterfaceToken(CellularDataServiceProxy::GetDescriptor()); - data.WriteInt32(slotId); - if (Remote() == nullptr) { - TELEPHONY_LOGE("remote is null"); - return TELEPHONY_ERR_IPC_CONNECT_STUB_FAIL; - } - int32_t error = Remote()->SendRequest((uint32_t)CellularDataInterfaceCode::SET_DEFAULT_SLOT_ID, data, - reply, option); - if (error != TELEPHONY_SUCCESS) { - TELEPHONY_LOGE("call failed! errCode:%{public}d", error); - return TELEPHONY_ERR_IPC_CONNECT_STUB_FAIL; - } - int32_t result = reply.ReadInt32(); - return result; -} - -int32_t CellularDataServiceProxy::GetCellularDataFlowType() -{ - MessageParcel data; - MessageParcel reply; - MessageOption option; - data.WriteInterfaceToken(CellularDataServiceProxy::GetDescriptor()); - if (Remote() == nullptr) { - TELEPHONY_LOGE("remote is null"); - return TELEPHONY_ERR_IPC_CONNECT_STUB_FAIL; - } - int32_t error = Remote()->SendRequest((uint32_t)CellularDataInterfaceCode::GET_FLOW_TYPE_ID, data, reply, option); - if (error != TELEPHONY_SUCCESS) { - TELEPHONY_LOGE("call failed! errCode:%{public}d", error); - return TELEPHONY_ERR_IPC_CONNECT_STUB_FAIL; - } - int32_t result = reply.ReadInt32(); - return result; -} - -int32_t CellularDataServiceProxy::HasInternetCapability(int32_t slotId, int32_t cid) -{ - MessageParcel data; - MessageParcel reply; - MessageOption option; - data.WriteInterfaceToken(CellularDataServiceProxy::GetDescriptor()); - data.WriteInt32(slotId); - data.WriteInt32(cid); - if (Remote() == nullptr) { - TELEPHONY_LOGE("remote is null"); - return TELEPHONY_ERR_IPC_CONNECT_STUB_FAIL; - } - int32_t error = Remote()->SendRequest((uint32_t)CellularDataInterfaceCode::HAS_CAPABILITY, data, reply, option); - if (error != TELEPHONY_SUCCESS) { - TELEPHONY_LOGE("Strategy switch fail! errCode:%{public}d", error); - return TELEPHONY_ERR_IPC_CONNECT_STUB_FAIL; - } - int32_t result = reply.ReadInt32(); - return result; -} - -int32_t CellularDataServiceProxy::ClearCellularDataConnections(int32_t slotId) -{ - MessageParcel data; - MessageParcel reply; - MessageOption option; - data.WriteInterfaceToken(CellularDataServiceProxy::GetDescriptor()); - data.WriteInt32(slotId); - if (Remote() == nullptr) { - TELEPHONY_LOGE("remote is null"); - return TELEPHONY_ERR_IPC_CONNECT_STUB_FAIL; - } - int32_t error = Remote()->SendRequest((uint32_t)CellularDataInterfaceCode::CLEAR_ALL_CONNECTIONS, data, - reply, option); - if (error != TELEPHONY_SUCCESS) { - TELEPHONY_LOGE("Strategy switch fail! errCode:%{public}d", error); - return TELEPHONY_ERR_IPC_CONNECT_STUB_FAIL; - } - int32_t result = reply.ReadInt32(); - return result; -} - -int32_t CellularDataServiceProxy::ClearAllConnections(int32_t slotId, DisConnectionReason reason) -{ - MessageParcel data; - MessageParcel reply; - MessageOption option; - data.WriteInterfaceToken(CellularDataServiceProxy::GetDescriptor()); - data.WriteInt32(slotId); - data.WriteInt32(static_cast(reason)); - if (Remote() == nullptr) { - TELEPHONY_LOGE("remote is null"); - return TELEPHONY_ERR_IPC_CONNECT_STUB_FAIL; - } - int32_t error = Remote()->SendRequest((uint32_t)CellularDataInterfaceCode::CLEAR_ALL_CONNECTIONS_USE_REASON, data, - reply, option); - if (error != TELEPHONY_SUCCESS) { - TELEPHONY_LOGE("Strategy switch fail! errCode:%{public}d", error); - return TELEPHONY_ERR_IPC_CONNECT_STUB_FAIL; - } - int32_t result = reply.ReadInt32(); - return result; -} - -int32_t CellularDataServiceProxy::RegisterSimAccountCallback(const sptr &callback) -{ - if (callback == nullptr) { - TELEPHONY_LOGE("callback is nullptr!"); - return TELEPHONY_ERR_ARGUMENT_NULL; - } - MessageParcel data; - MessageParcel reply; - MessageOption option; - if (!data.WriteInterfaceToken(CellularDataServiceProxy::GetDescriptor())) { - TELEPHONY_LOGE("write interface token failed!"); - return TELEPHONY_ERR_WRITE_DESCRIPTOR_TOKEN_FAIL; - } - if (!data.WriteRemoteObject(callback->AsObject())) { - TELEPHONY_LOGE("write remote object failed!"); - return TELEPHONY_ERR_WRITE_DATA_FAIL; - } - sptr remote = Remote(); - if (remote == nullptr) { - TELEPHONY_LOGE("remote is nullptr!"); - return TELEPHONY_ERR_IPC_CONNECT_STUB_FAIL; - } - int32_t error = remote->SendRequest(static_cast(CellularDataInterfaceCode::REG_SIM_ACCOUNT_CALLBACK), - data, reply, option); - if (error != TELEPHONY_SUCCESS) { - TELEPHONY_LOGD("error! errCode:%{public}d", error); - return error; - } - return reply.ReadInt32(); -} - -int32_t CellularDataServiceProxy::UnregisterSimAccountCallback(const sptr &callback) -{ - MessageParcel data; - MessageParcel reply; - MessageOption option; - if (!data.WriteInterfaceToken(CellularDataServiceProxy::GetDescriptor())) { - TELEPHONY_LOGE("write interface token failed!"); - return TELEPHONY_ERR_WRITE_DESCRIPTOR_TOKEN_FAIL; - } - if (!data.WriteRemoteObject(callback->AsObject())) { - TELEPHONY_LOGE("write remote object failed!"); - return TELEPHONY_ERR_WRITE_DATA_FAIL; - } - sptr remote = Remote(); - if (remote == nullptr) { - TELEPHONY_LOGE("remote is nullptr!"); - return TELEPHONY_ERR_IPC_CONNECT_STUB_FAIL; - } - int32_t error = remote->SendRequest(static_cast(CellularDataInterfaceCode::UN_REG_SIM_ACCOUNT_CALLBACK), - data, reply, option); - if (error != TELEPHONY_SUCCESS) { - TELEPHONY_LOGE("error! errCode:%{public}d", error); - return error; - } - return reply.ReadInt32(); -} - -int32_t CellularDataServiceProxy::GetDataConnApnAttr(int32_t slotId, ApnItem::Attribute &apnAttr) -{ - MessageParcel dataParcel; - MessageParcel replyParcel; - MessageOption option; - if (!dataParcel.WriteInterfaceToken(CellularDataServiceProxy::GetDescriptor())) { - TELEPHONY_LOGE("write interface token failed!"); - return TELEPHONY_ERR_WRITE_DESCRIPTOR_TOKEN_FAIL; - } - if (!dataParcel.WriteInt32(slotId)) { - TELEPHONY_LOGE("write userId failed!"); - return TELEPHONY_ERR_WRITE_DATA_FAIL; - } - sptr remote = Remote(); - if (remote == nullptr) { - TELEPHONY_LOGE("remote is nullptr!"); - return TELEPHONY_ERR_IPC_CONNECT_STUB_FAIL; - } - int32_t error = remote->SendRequest((uint32_t)CellularDataInterfaceCode::GET_DATA_CONN_APN_ATTR, - dataParcel, replyParcel, option); - if (error != TELEPHONY_SUCCESS) { - TELEPHONY_LOGE("Strategy switch fail! errCode:%{public}d", error); - return TELEPHONY_ERR_IPC_CONNECT_STUB_FAIL; - } - int32_t result = replyParcel.ReadInt32(); - if (result == TELEPHONY_ERR_SUCCESS) { - auto apnAttrPtr = replyParcel.ReadRawData(sizeof(ApnItem::Attribute)); - if (apnAttrPtr == nullptr) { - return TELEPHONY_ERR_READ_DATA_FAIL; - } - if (memcpy_s(&apnAttr, sizeof(ApnItem::Attribute), apnAttrPtr, sizeof(ApnItem::Attribute)) != EOK) { - return TELEPHONY_ERR_MEMCPY_FAIL; - } - } else { - TELEPHONY_LOGE("end failed: result=%{public}d", result); - } - - return TELEPHONY_ERR_SUCCESS; -} - -int32_t CellularDataServiceProxy::GetDataConnIpType(int32_t slotId, std::string &ipType) -{ - MessageParcel dataParcel; - MessageParcel replyParcel; - MessageOption option; - if (!dataParcel.WriteInterfaceToken(CellularDataServiceProxy::GetDescriptor())) { - TELEPHONY_LOGE("write interface token failed!"); - return TELEPHONY_ERR_WRITE_DESCRIPTOR_TOKEN_FAIL; - } - if (!dataParcel.WriteInt32(slotId)) { - TELEPHONY_LOGE("write userId failed!"); - return TELEPHONY_ERR_WRITE_DATA_FAIL; - } - sptr remote = Remote(); - if (remote == nullptr) { - TELEPHONY_LOGE("remote is nullptr!"); - return TELEPHONY_ERR_IPC_CONNECT_STUB_FAIL; - } - int32_t error = remote->SendRequest((uint32_t)CellularDataInterfaceCode::GET_DATA_CONN_IP_TYPE, dataParcel, - replyParcel, option); - if (error != TELEPHONY_SUCCESS) { - TELEPHONY_LOGE("Strategy switch fail! errCode:%{public}d", error); - return TELEPHONY_ERR_IPC_CONNECT_STUB_FAIL; - } - int32_t result = replyParcel.ReadInt32(); - TELEPHONY_LOGI("end: result=%{public}d", result); - if (result == TELEPHONY_ERR_SUCCESS) { - ipType = replyParcel.ReadString(); - } - - return TELEPHONY_ERR_SUCCESS; -} - -int32_t CellularDataServiceProxy::IsNeedDoRecovery(int32_t slotId, bool needDoRecovery) -{ - MessageParcel dataParcel; - MessageParcel replyParcel; - MessageOption option; - if (!dataParcel.WriteInterfaceToken(CellularDataServiceProxy::GetDescriptor())) { - TELEPHONY_LOGE("write interface token failed!"); - return TELEPHONY_ERR_WRITE_DESCRIPTOR_TOKEN_FAIL; - } - dataParcel.WriteInt32(slotId); - dataParcel.WriteBool(needDoRecovery); - sptr remote = Remote(); - if (remote == nullptr) { - TELEPHONY_LOGE("remote is nullptr!"); - return TELEPHONY_ERR_IPC_CONNECT_STUB_FAIL; - } - int32_t error = remote->SendRequest((uint32_t)CellularDataInterfaceCode::IS_NEED_DO_RECOVERY, dataParcel, - replyParcel, option); - if (error != TELEPHONY_SUCCESS) { - TELEPHONY_LOGE("function IsNeedDoRecovery call failed! errCode:%{public}d", error); - return TELEPHONY_ERR_IPC_CONNECT_STUB_FAIL; - } - int32_t result = replyParcel.ReadInt32(); - return result; -} - -int32_t CellularDataServiceProxy::InitCellularDataController(int32_t slotId) -{ - MessageParcel dataParcel; - MessageParcel replyParcel; - MessageOption option; - if (!dataParcel.WriteInterfaceToken(CellularDataServiceProxy::GetDescriptor())) { - TELEPHONY_LOGE("write interface token failed!"); - return TELEPHONY_ERR_WRITE_DESCRIPTOR_TOKEN_FAIL; - } - dataParcel.WriteInt32(slotId); - sptr remote = Remote(); - if (remote == nullptr) { - TELEPHONY_LOGE("remote is nullptr!"); - return TELEPHONY_ERR_IPC_CONNECT_STUB_FAIL; - } - int32_t error = remote->SendRequest((uint32_t)CellularDataInterfaceCode::INIT_CELLULAR_DATA_CONTROLLER, dataParcel, - replyParcel, option); - if (error != TELEPHONY_SUCCESS) { - TELEPHONY_LOGE("function InitCellularDataController call failed! errCode:%{public}d", error); - return TELEPHONY_ERR_IPC_CONNECT_STUB_FAIL; - } - int32_t result = replyParcel.ReadInt32(); - return result; -} - -int32_t CellularDataServiceProxy::EstablishAllApnsIfConnectable(int32_t slotId) -{ - MessageParcel data; - MessageParcel reply; - MessageOption option; - data.WriteInterfaceToken(CellularDataServiceProxy::GetDescriptor()); - data.WriteInt32(slotId); - if (Remote() == nullptr) { - TELEPHONY_LOGE("remote is null"); - return TELEPHONY_ERR_IPC_CONNECT_STUB_FAIL; - } - - int32_t error = Remote()->SendRequest((uint32_t)CellularDataInterfaceCode::ESTABLISH_ALL_APNS_IF_CONNECTABLE, - data, reply, option); - if (error != TELEPHONY_SUCCESS) { - TELEPHONY_LOGE("EstablishAllApnsIfConnectable fail! errCode: %{public}d", error); - return TELEPHONY_ERR_IPC_CONNECT_STUB_FAIL; - } - int32_t result = reply.ReadInt32(); - return result; -} - -int32_t CellularDataServiceProxy::ReleaseCellularDataConnection(int32_t slotId) -{ - MessageParcel dataParcel; - MessageParcel replyParcel; - MessageOption option; - if (!dataParcel.WriteInterfaceToken(CellularDataServiceProxy::GetDescriptor())) { - TELEPHONY_LOGE("write interface token failed!"); - return TELEPHONY_ERR_WRITE_DESCRIPTOR_TOKEN_FAIL; - } - if (!dataParcel.WriteInt32(slotId)) { - TELEPHONY_LOGE("write slotId failed"); - return TELEPHONY_ERR_WRITE_DATA_FAIL; - } - sptr remote = Remote(); - if (remote == nullptr) { - TELEPHONY_LOGE("remote is nullptr!"); - return TELEPHONY_ERR_IPC_CONNECT_STUB_FAIL; - } - int32_t error = remote->SendRequest((uint32_t)CellularDataInterfaceCode::RELEASE_CELLULAR_DATA_CONNECTION, - dataParcel, replyParcel, option); - if (error != TELEPHONY_SUCCESS) { - TELEPHONY_LOGE("function ReleaseCellularDataConnection call failed! errCode:%{public}d", error); - return TELEPHONY_ERR_IPC_CONNECT_STUB_FAIL; - } - int32_t result; - if (!replyParcel.ReadInt32(result)) { - TELEPHONY_LOGE("read reply result failed"); - } - return result; -} - -int32_t CellularDataServiceProxy::GetCellularDataSupplierId(int32_t slotId, uint64_t capability, uint32_t &supplierId) -{ - MessageParcel dataParcel; - MessageParcel replyParcel; - MessageOption option; - if (!dataParcel.WriteInterfaceToken(CellularDataServiceProxy::GetDescriptor())) { - TELEPHONY_LOGE("write interface token failed!"); - return TELEPHONY_ERR_WRITE_DESCRIPTOR_TOKEN_FAIL; - } - dataParcel.WriteInt32(slotId); - dataParcel.WriteUint64(capability); - sptr remote = Remote(); - if (remote == nullptr) { - TELEPHONY_LOGE("remote is nullptr!"); - return TELEPHONY_ERR_IPC_CONNECT_STUB_FAIL; - } - int32_t error = remote->SendRequest((uint32_t)CellularDataInterfaceCode::GET_CELLULAR_DATA_SUPPLIERID, - dataParcel, replyParcel, option); - if (error != TELEPHONY_SUCCESS) { - TELEPHONY_LOGE("function GetCellularDataSupplierId call failed! errCode:%{public}d", error); - return TELEPHONY_ERR_IPC_CONNECT_STUB_FAIL; - } - int32_t result = replyParcel.ReadInt32(); - TELEPHONY_LOGD("end: result=%{public}d", result); - if (result == TELEPHONY_ERR_SUCCESS) { - supplierId = replyParcel.ReadUint32(); - } - return result; -} - -int32_t CellularDataServiceProxy::CorrectNetSupplierNoAvailable(int32_t slotId) -{ - MessageParcel dataParcel; - MessageParcel replyParcel; - MessageOption option; - if (!dataParcel.WriteInterfaceToken(CellularDataServiceProxy::GetDescriptor())) { - TELEPHONY_LOGE("write interface token failed!"); - return TELEPHONY_ERR_WRITE_DESCRIPTOR_TOKEN_FAIL; - } - dataParcel.WriteInt32(slotId); - sptr remote = Remote(); - if (remote == nullptr) { - TELEPHONY_LOGE("remote is nullptr!"); - return TELEPHONY_ERR_IPC_CONNECT_STUB_FAIL; - } - int32_t error = remote->SendRequest((uint32_t)CellularDataInterfaceCode::CORRECT_NET_SUPPLIER_NO_AVAILABLE, - dataParcel, replyParcel, option); - if (error != TELEPHONY_SUCCESS) { - TELEPHONY_LOGE("function CorrectNetSupplierNoAvailable call failed! errCode:%{public}d", error); - return TELEPHONY_ERR_IPC_CONNECT_STUB_FAIL; - } - int32_t result = replyParcel.ReadInt32(); - return result; -} - -int32_t CellularDataServiceProxy::GetSupplierRegisterState(uint32_t supplierId, int32_t ®State) -{ - MessageParcel dataParcel; - MessageParcel replyParcel; - MessageOption option; - if (!dataParcel.WriteInterfaceToken(CellularDataServiceProxy::GetDescriptor())) { - TELEPHONY_LOGE("write interface token failed!"); - return TELEPHONY_ERR_WRITE_DESCRIPTOR_TOKEN_FAIL; - } - dataParcel.WriteUint32(supplierId); - sptr remote = Remote(); - if (remote == nullptr) { - TELEPHONY_LOGE("remote is nullptr!"); - return TELEPHONY_ERR_IPC_CONNECT_STUB_FAIL; - } - int32_t error = remote->SendRequest((uint32_t)CellularDataInterfaceCode::GET_SUPPLIER_REGISTER_STATE, - dataParcel, replyParcel, option); - if (error != TELEPHONY_SUCCESS) { - TELEPHONY_LOGE("function GetSupplierRegisterState call failed! errCode:%{public}d", error); - return TELEPHONY_ERR_IPC_CONNECT_STUB_FAIL; - } - int32_t result = replyParcel.ReadInt32(); - TELEPHONY_LOGD("end: result=%{public}d", result); - if (result == TELEPHONY_ERR_SUCCESS) { - regState = replyParcel.ReadInt32(); - } - return result; -} - -int32_t CellularDataServiceProxy::GetIfSupportDunApn(bool &isSupportDun) -{ - MessageParcel data; - MessageParcel reply; - MessageOption option; - if (!data.WriteInterfaceToken(CellularDataServiceProxy::GetDescriptor())) { - TELEPHONY_LOGE("write interface token failed!"); - return TELEPHONY_ERR_WRITE_DESCRIPTOR_TOKEN_FAIL; - } - sptr remote = Remote(); - if (remote == nullptr) { - TELEPHONY_LOGE("remote is nullptr!"); - return TELEPHONY_ERR_IPC_CONNECT_STUB_FAIL; - } - int32_t error = remote->SendRequest((uint32_t)CellularDataInterfaceCode::GET_IF_SUPPORT_DUN_APN, data, - reply, option); - if (error != TELEPHONY_SUCCESS) { - TELEPHONY_LOGE("call failed! errCode:%{public}d", error); - return TELEPHONY_ERR_IPC_CONNECT_STUB_FAIL; - } - int32_t result = reply.ReadInt32(); - if (result == TELEPHONY_ERR_SUCCESS) { - isSupportDun = reply.ReadBool(); - } - return result; -} - -int32_t CellularDataServiceProxy::GetDefaultActReportInfo(int32_t slotId, ApnActivateReportInfo &info) -{ - MessageParcel dataParcel; - MessageParcel replyParcel; - MessageOption option; - if (!dataParcel.WriteInterfaceToken(CellularDataServiceProxy::GetDescriptor())) { - TELEPHONY_LOGE("write interface token failed!"); - return TELEPHONY_ERR_WRITE_DESCRIPTOR_TOKEN_FAIL; - } - dataParcel.WriteInt32(slotId); - sptr remote = Remote(); - if (remote == nullptr) { - TELEPHONY_LOGE("remote is nullptr!"); - return TELEPHONY_ERR_IPC_CONNECT_STUB_FAIL; - } - int32_t error = remote->SendRequest((uint32_t)CellularDataInterfaceCode::GET_DEFAULT_ACT_REPORT_INFO, - dataParcel, replyParcel, option); - if (error != TELEPHONY_SUCCESS) { - TELEPHONY_LOGE("function GetDefaultActReportInfo call failed! errCode:%{public}d", error); - return TELEPHONY_ERR_IPC_CONNECT_STUB_FAIL; - } - int32_t result = replyParcel.ReadInt32(); - TELEPHONY_LOGD("end: result=%{public}d", result); - if (result == TELEPHONY_ERR_SUCCESS) { - info.actTimes = replyParcel.ReadUint32(); - info.averDuration = replyParcel.ReadUint32(); - info.topReason = replyParcel.ReadUint32(); - info.actSuccTimes = replyParcel.ReadUint32(); - } - return result; -} - -int32_t CellularDataServiceProxy::GetInternalActReportInfo(int32_t slotId, ApnActivateReportInfo &info) -{ - MessageParcel dataParcel; - MessageParcel replyParcel; - MessageOption option; - if (!dataParcel.WriteInterfaceToken(CellularDataServiceProxy::GetDescriptor())) { - TELEPHONY_LOGE("write interface token failed!"); - return TELEPHONY_ERR_WRITE_DESCRIPTOR_TOKEN_FAIL; - } - dataParcel.WriteInt32(slotId); - sptr remote = Remote(); - if (remote == nullptr) { - TELEPHONY_LOGE("remote is nullptr!"); - return TELEPHONY_ERR_IPC_CONNECT_STUB_FAIL; - } - int32_t error = remote->SendRequest((uint32_t)CellularDataInterfaceCode::GET_INTERNAL_ACT_REPORT_INFO, - dataParcel, replyParcel, option); - if (error != TELEPHONY_SUCCESS) { - TELEPHONY_LOGE("function GetInternalActReportInfo call failed! errCode:%{public}d", error); - return TELEPHONY_ERR_IPC_CONNECT_STUB_FAIL; - } - int32_t result = replyParcel.ReadInt32(); - TELEPHONY_LOGD("end: result=%{public}d", result); - if (result == TELEPHONY_ERR_SUCCESS) { - info.actTimes = replyParcel.ReadUint32(); - info.averDuration = replyParcel.ReadUint32(); - info.topReason = replyParcel.ReadUint32(); - info.actSuccTimes = replyParcel.ReadUint32(); - } - return result; -} - -int32_t CellularDataServiceProxy::QueryApnIds(ApnInfo apnInfo, std::vector &apnIdList) -{ - MessageParcel dataParcel; - MessageParcel replyParcel; - MessageOption option; - if (!dataParcel.WriteInterfaceToken(CellularDataServiceProxy::GetDescriptor())) { - TELEPHONY_LOGE("write interface token failed!"); - return TELEPHONY_ERR_WRITE_DESCRIPTOR_TOKEN_FAIL; - } - dataParcel.WriteString16(apnInfo.apnName); - dataParcel.WriteString16(apnInfo.apn); - dataParcel.WriteString16(apnInfo.mcc); - dataParcel.WriteString16(apnInfo.mnc); - dataParcel.WriteString16(apnInfo.user); - dataParcel.WriteString16(apnInfo.type); - dataParcel.WriteString16(apnInfo.proxy); - dataParcel.WriteString16(apnInfo.mmsproxy); - TELEPHONY_LOGI("QueryApnIds type: %{public}s", Str16ToStr8(apnInfo.type).c_str()); - sptr remote = Remote(); - if (remote == nullptr) { - TELEPHONY_LOGE("remote is nullptr!"); - return TELEPHONY_ERR_IPC_CONNECT_STUB_FAIL; - } - int32_t error = remote->SendRequest((uint32_t)CellularDataInterfaceCode::QUERY_APN_INFO, - dataParcel, replyParcel, option); - if (error != TELEPHONY_SUCCESS) { - TELEPHONY_LOGE("function QueryApnIds call failed! errCode:%{public}d", error); - return TELEPHONY_ERR_IPC_CONNECT_STUB_FAIL; - } - int32_t result = replyParcel.ReadInt32(); - TELEPHONY_LOGI("QueryApnIds end: result=%{public}d", result); - if (result == TELEPHONY_ERR_SUCCESS) { - int32_t size = replyParcel.ReadInt32(); - if (size > MAX_REPLY_COUNT) { - TELEPHONY_LOGE("QueryApnIds size error = %{public}d", size); - return result; - } - TELEPHONY_LOGI("QueryApnIds size = %{public}d", size); - apnIdList.clear(); - for (int i = 0; i < size; i++) { - int apnId = replyParcel.ReadInt32(); - TELEPHONY_LOGI("QueryApnIds success apnId = %{public}d", apnId); - apnIdList.emplace_back(apnId); - } - } - return result; -} - -int32_t CellularDataServiceProxy::SetPreferApn(int32_t apnId) -{ - MessageParcel dataParcel; - MessageParcel replyParcel; - MessageOption option; - if (!dataParcel.WriteInterfaceToken(CellularDataServiceProxy::GetDescriptor())) { - TELEPHONY_LOGE("write interface token failed!"); - return TELEPHONY_ERR_WRITE_DESCRIPTOR_TOKEN_FAIL; - } - dataParcel.WriteInt32(apnId); - sptr remote = Remote(); - if (remote == nullptr) { - TELEPHONY_LOGE("remote is nullptr!"); - return TELEPHONY_ERR_IPC_CONNECT_STUB_FAIL; - } - int32_t error = remote->SendRequest((uint32_t)CellularDataInterfaceCode::SET_PREFER_APN, - dataParcel, replyParcel, option); - if (error != TELEPHONY_SUCCESS) { - TELEPHONY_LOGE("function SetPreferApn call failed! errCode:%{public}d", error); - return TELEPHONY_ERR_IPC_CONNECT_STUB_FAIL; - } - return replyParcel.ReadInt32(); -} - -int32_t CellularDataServiceProxy::QueryAllApnInfo(std::vector &apnInfoList) -{ - MessageParcel dataParcel; - MessageParcel replyParcel; - MessageOption option; - if (!dataParcel.WriteInterfaceToken(CellularDataServiceProxy::GetDescriptor())) { - TELEPHONY_LOGE("write interface token failed!"); - return TELEPHONY_ERR_WRITE_DESCRIPTOR_TOKEN_FAIL; - } - sptr remote = Remote(); - if (remote == nullptr) { - TELEPHONY_LOGE("remote is nullptr!"); - return TELEPHONY_ERR_IPC_CONNECT_STUB_FAIL; - } - int32_t error = remote->SendRequest((uint32_t)CellularDataInterfaceCode::QUERY_ALL_APN_INFO, - dataParcel, replyParcel, option); - if (error != TELEPHONY_SUCCESS) { - TELEPHONY_LOGE("function QueryAllApnInfo call failed! errCode:%{public}d", error); - return TELEPHONY_ERR_IPC_CONNECT_STUB_FAIL; - } - int32_t result = replyParcel.ReadInt32(); - TELEPHONY_LOGI("QueryAllApnInfo end: result=%{public}d", result); - if (result == TELEPHONY_ERR_SUCCESS) { - int32_t size = replyParcel.ReadInt32(); - if (size > MAX_REPLY_COUNT) { - TELEPHONY_LOGE("QueryAllApnInfo size error = %{public}d", size); - return result; - } - TELEPHONY_LOGI("QueryAllApnInfo size = %{public}d", size); - apnInfoList.clear(); - for (int i = 0; i < size; i++) { - ApnInfo apnInfo; - apnInfo.ReadFromParcel(replyParcel); - apnInfoList.emplace_back(apnInfo); - } - } - return result; -} - -} // namespace Telephony -} // namespace OHOS diff --git a/frameworks/native/cellular_data_service_proxy.h b/frameworks/native/cellular_data_service_proxy.h deleted file mode 100644 index 33aaaa2254a42648bd0ecd7016055cf6d8dadfec..0000000000000000000000000000000000000000 --- a/frameworks/native/cellular_data_service_proxy.h +++ /dev/null @@ -1,197 +0,0 @@ -/* - * Copyright (C) 2021-2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#ifndef CELLULAR_DATA_SERVICE_PROXY_H -#define CELLULAR_DATA_SERVICE_PROXY_H - -#include - -#include "cellular_data_ipc_interface_code.h" -#include "functional" -#include "i_cellular_data_manager.h" -#include "iremote_broker.h" -#include "iremote_proxy.h" -#include "refbase.h" -#include "cellular_data_constant.h" - -namespace OHOS { -class IRemoteObject; -namespace Telephony { -class CellularDataServiceProxy : public IRemoteProxy { -public: - explicit CellularDataServiceProxy(const sptr &impl) : IRemoteProxy(impl) - {} - ~CellularDataServiceProxy() = default; - - /** - * Whether the cellular data user switch is enabled - * - * @return return errorCode of is cellulardata enabled - */ - virtual int32_t IsCellularDataEnabled(bool &dataEnabled); - - /** - * Whether to enable intelligence switch - * - * @param enable allow or not - * @return return 84082688 invalid parameter, 1 data enable success, 0 enable fail - */ - int32_t EnableIntelligenceSwitch(bool enable); - - /** - * Whether to enable cellular data user switch - * - * @param enable allow or not - * @return return 84082688 invalid parameter, 1 data enable success, 0 enable fail - */ - int32_t EnableCellularData(bool enable); - - /** - * Cellular data connection status - * - * @return 84082688 Indicates that a cellular data link is unknown - * 11 Indicates that a cellular data link is disconnected - * 12 Indicates that a cellular data link is being connected - * 13 Indicates that a cellular data link is connected - * 14 Indicates that a cellular data link is suspended - */ - int32_t GetCellularDataState(); - - /** - * Get the apn status based on slotId and apnType - * - * @param slotId card slot identification - * @param apnType apn type, eg."default" - * @return apnstate - */ - int32_t GetApnState(int32_t slotId, const std::string &apnType); - - int32_t GetDataRecoveryState(); - - /** - * Whether roaming is allowed - * - * @param slotId card slot identification - * @return return 84082688 invalid parameter, 0 roaming is not allowed, 1 roaming is allowed - */ - int32_t IsCellularDataRoamingEnabled(int32_t slotId, bool &dataRoamingEnabled); - - /** - * Whether roaming switches are allowed - * - * @param slotId card slot identification - * @param enable Whether roaming switches are allowed - * @return Returns 0 on failure, 1 on failure. 84082688 invalid parameter - */ - int32_t EnableCellularDataRoaming(int32_t slotId, bool enable); - - /** - * Processing of APN content changes - * - * @param slotId card slot identification - * @return the number of apns created else 84082688 invalid parameter - */ - int32_t HandleApnChanged(int32_t slotId); - - /** - * Get the slotId that uses the data traffic by default - * - * @return default settings data card, -1 error code - */ - int32_t GetDefaultCellularDataSlotId(); - - /** - * Get the sim id that uses the data traffic by default - * - * @param simId Returns default settings data sim id - * @return Returns 0 on success, others on failure. - */ - int32_t GetDefaultCellularDataSimId(int32_t &simId); - - /** - * set the slotId that uses the data traffic by default - * - * @param slotId card slot identification - * @return 1 set success, 0 set fail, 84082688 invalid parameter - */ - int32_t SetDefaultCellularDataSlotId(int32_t slotId); - - /** - * get data packet type - * - * @return 0 Indicates that there is no uplink or down link data, - * 1 Indicates that there is only down link data, - * 2 Indicates that there is only uplink data, - * 3 Indicates that there is uplink and down link data - * 4 Indicates that there is no uplink or down link data, - * and the bottom-layer link is in the dormant state - * 84082688 Indicates invalid parameter - */ - int32_t GetCellularDataFlowType(); - - /** - * Get the State Of Intelligence Switch - * - * @param switchState Returns switch state - * @return Returns 0 on success, others on failure. - */ - int32_t GetIntelligenceSwitchState(bool &switchState); - - int32_t HasInternetCapability(int32_t slotId, int32_t cid); - - int32_t ClearCellularDataConnections(int32_t slotId); - - int32_t ClearAllConnections(int32_t slotId, DisConnectionReason reason); - - int32_t RegisterSimAccountCallback(const sptr &callback); - - int32_t UnregisterSimAccountCallback(const sptr &callback); - - int32_t GetDataConnApnAttr(int32_t slotId, ApnItem::Attribute &apnAttr); - - int32_t GetDataConnIpType(int32_t slotId, std::string &ipType); - - int32_t IsNeedDoRecovery(int32_t slotId, bool needDoRecovery); - - int32_t InitCellularDataController(int32_t slotId); - - int32_t EstablishAllApnsIfConnectable(int32_t slotId); - - int32_t ReleaseCellularDataConnection(int32_t slotId); - - int32_t GetCellularDataSupplierId(int32_t slotId, uint64_t capability, uint32_t &supplierId); - - int32_t CorrectNetSupplierNoAvailable(int32_t slotId); - - int32_t GetSupplierRegisterState(uint32_t supplierId, int32_t ®State); - - int32_t GetIfSupportDunApn(bool &isSupportDun); - - int32_t GetDefaultActReportInfo(int32_t slotId, ApnActivateReportInfo &info); - - int32_t GetInternalActReportInfo(int32_t slotId, ApnActivateReportInfo &info); - - int32_t QueryApnIds(ApnInfo apnInfo, std::vector &apnIdList); - - int32_t SetPreferApn(int32_t apnId); - - int32_t QueryAllApnInfo(std::vector &apnInfoList); - -private: - static inline BrokerDelegator delegator_; -}; -} // namespace Telephony -} // namespace OHOS -#endif // CELLULAR_DATA_SERVICE_PROXY_H diff --git a/frameworks/native/data_sim_account_call_back.cpp b/frameworks/native/data_sim_account_callback.cpp similarity index 95% rename from frameworks/native/data_sim_account_call_back.cpp rename to frameworks/native/data_sim_account_callback.cpp index 6591994a7d3fe2b429b145dba2bf1143b0f36f1a..c0723eeadd89ea2e5937fd8f0d03e63d1d9b1376 100644 --- a/frameworks/native/data_sim_account_call_back.cpp +++ b/frameworks/native/data_sim_account_callback.cpp @@ -13,7 +13,7 @@ * limitations under the License. */ -#include "data_sim_account_call_back.h" +#include "data_sim_account_callback.h" #include "cellular_data_client.h" #include "telephony_log_wrapper.h" diff --git a/interfaces/innerkits/apn_activate_report_info.h b/interfaces/innerkits/apn_activate_report_info.h new file mode 100644 index 0000000000000000000000000000000000000000..16375b1cab0625d3900b3f29ca8537dd1823e25a --- /dev/null +++ b/interfaces/innerkits/apn_activate_report_info.h @@ -0,0 +1,51 @@ +/* + * Copyright (C) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +#ifndef APN_ACTIVATE_REPORT_INFO_H +#define APN_ACTIVATE_REPORT_INFO_H + +#include "parcel.h" +#include "apn_item.h" +namespace OHOS { +namespace Telephony { +struct ApnActivateReportInfoIpc : public Parcelable { + uint32_t actTimes; + uint32_t averDuration; + uint32_t topReason; + uint32_t actSuccTimes; + + ApnActivateReportInfoIpc() + { + actTimes = 0; + averDuration = 0; + topReason = 0; + actSuccTimes = 0; + } + + ApnActivateReportInfoIpc(const ApnActivateReportInfo& obj) + { + actTimes = obj.actTimes; + averDuration = obj.averDuration; + topReason = obj.topReason; + actSuccTimes = obj.actSuccTimes; + } + + static void transferToReportInfo(ApnActivateReportInfoIpc infoIpc, ApnActivateReportInfo &info); + + bool Marshalling(Parcel &parcel) const override; + static ApnActivateReportInfoIpc* Unmarshalling(Parcel &parcel); +}; +} +} +#endif //APN_ACTIVATE_REPORT_INFO_H \ No newline at end of file diff --git a/interfaces/innerkits/apn_attribute.h b/interfaces/innerkits/apn_attribute.h new file mode 100644 index 0000000000000000000000000000000000000000..d92e8353240ff3ff629f9370bdc7e9a21eba1da7 --- /dev/null +++ b/interfaces/innerkits/apn_attribute.h @@ -0,0 +1,48 @@ +/* + * Copyright (C) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +#ifndef APN_ATTRIBUTE_H +#define APN_ATTRIBUTE_H + +#include "apn_item.h" +#include "parcel.h" +namespace OHOS { +namespace Telephony { +constexpr static int ALL_APN_ITEM_CHAR_LENGTH = 256; +struct ApnAttribute final : public Parcelable { + std::string types_; + std::string numeric_; + int32_t profileId_ = 0; + std::string protocol_; + std::string roamingProtocol_; + int32_t authType_ = 0; + std::string apn_; + std::string apnName_; + std::string user_; + std::string password_; + bool isRoamingApn_ = false; + std::string homeUrl_; + std::string proxyIpAddress_; + std::string mmsIpAddress_; + bool isEdited_ = false; + + bool Marshalling(Parcel &parcel) const override; + static ApnAttribute* Unmarshalling(Parcel &parcel); + + static void TransferApnAttributeBeforeIpc(ApnItem::Attribute &apnAttr, ApnAttribute &apnAfterTrans); + static void TransferApnAttributeAfterIpc(ApnItem::Attribute &apnAttr, ApnAttribute &apnAfterTrans); +}; +} +} +#endif //APN_ATTRIBUTE_H \ No newline at end of file diff --git a/interfaces/innerkits/cellular_data_client.h b/interfaces/innerkits/cellular_data_client.h index 8c88be4a8b48d151b8f1ce72875cfa6948a3eedb..ee44f1de6847855e69a7f7ab201230450b18672c 100644 --- a/interfaces/innerkits/cellular_data_client.h +++ b/interfaces/innerkits/cellular_data_client.h @@ -20,11 +20,12 @@ #include #include -#include "data_sim_account_call_back.h" -#include "i_cellular_data_manager.h" +#include "data_sim_account_callback.h" +#include "icellular_data_manager.h" #include "sim_account_callback.h" #include "apn_item.h" #include "cellular_data_constant.h" +#include "apn_attribute.h" namespace OHOS { namespace Telephony { @@ -296,6 +297,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/cellular_data_types.h b/interfaces/innerkits/cellular_data_types.h index d499225a35ac6d7a3bdc1a0a503213fa56825835..060d3b5b0e0fb4897e87bd3dbaab22c50671bcde 100644 --- a/interfaces/innerkits/cellular_data_types.h +++ b/interfaces/innerkits/cellular_data_types.h @@ -41,6 +41,11 @@ enum class DataSwitchCode : int32_t { CELLULAR_DATA_ENABLED = 1 }; +enum class DataSimDetectedCode : int32_t { + SIM_DETECTED_DISABLED = 0, + SIM_DETECTED_ENABLED = 1 +}; + enum class IntelligenceSwitchCode : int32_t { INTELLIGENCE_SWITCH_DISABLED = 0, INTELLIGENCE_SWITCH_ENABLED = 1 @@ -127,9 +132,9 @@ struct ApnInfo : public Parcelable { return true; }; - std::shared_ptr UnMarshalling(Parcel &parcel) + static ApnInfo* Unmarshalling(Parcel &parcel) { - std::shared_ptr param = std::make_shared(); + ApnInfo* param = new ApnInfo(); if (param == nullptr || !param->ReadFromParcel(parcel)) { param = nullptr; } diff --git a/interfaces/innerkits/data_sim_account_call_back.h b/interfaces/innerkits/data_sim_account_callback.h similarity index 100% rename from interfaces/innerkits/data_sim_account_call_back.h rename to interfaces/innerkits/data_sim_account_callback.h diff --git a/interfaces/innerkits/i_cellular_data_manager.h b/interfaces/innerkits/i_cellular_data_manager.h deleted file mode 100644 index ed30e041f3ae8af79f056d51993cb0cdb3f6d2d7..0000000000000000000000000000000000000000 --- a/interfaces/innerkits/i_cellular_data_manager.h +++ /dev/null @@ -1,181 +0,0 @@ -/* - * Copyright (C) 2021-2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#ifndef I_CELLULAR_DATA_MANAGER_H -#define I_CELLULAR_DATA_MANAGER_H - -#include "iremote_broker.h" -#include "sim_account_callback.h" -#include "apn_item.h" -#include "cellular_data_constant.h" - -namespace OHOS { -namespace Telephony { -class ICellularDataManager : public IRemoteBroker { -public: - /** - * Whether the cellular data user switch is enabled - * - * @return return errorCode of is cellulardata enabled - */ - virtual int32_t IsCellularDataEnabled(bool &dataEnabled) = 0; - - /** - * Whether to enable cellular data user switch - * - * @param enable allow or not - * @return return 84082688 invalid parameter, 1 data enable success, 0 enable fail - */ - virtual int32_t EnableCellularData(bool enable) = 0; - - /** - * Whether to enable intelligence switch - * - * @param enable allow or not - * @return return 84082688 invalid parameter, 1 data enable success, 0 enable fail - */ - virtual int32_t EnableIntelligenceSwitch(bool enable) = 0; - - /** - * Cellular data connection status - * - * @return 84082688 Indicates that a cellular data link is unknown - * 11 Indicates that a cellular data link is disconnected - * 12 Indicates that a cellular data link is being connected - * 13 Indicates that a cellular data link is connected - * 14 Indicates that a cellular data link is suspended - */ - virtual int32_t GetCellularDataState() = 0; - - /** - * Whether roaming is allowed - * - * @param slotId card slot identification - * @param dataRoamingEnabled result of data is enabled - * @return return errorCode of is cellulardata enabled - */ - virtual int32_t IsCellularDataRoamingEnabled(int32_t slotId, bool &dataRoamingEnabled) = 0; - - /** - * Whether roaming switches are allowed - * - * @param slotId card slot identification - * @param enable Whether roaming switches are allowed - * @return Returns 0 on failure, 1 on failure. 84082688 invalid parameter - */ - virtual int32_t EnableCellularDataRoaming(int32_t slotId, bool enable) = 0; - - /** - * Processing of APN content changes - * - * @param slotId card slot identification - * @param apns changed apns - * @return the number of apns created else 84082688 invalid parameter - */ - virtual int32_t HandleApnChanged(int32_t slotId) = 0; - - /** - * Get the slotId that uses the data traffic by default - * - * @return default settings data card, -1 error code - */ - virtual int32_t GetDefaultCellularDataSlotId() = 0; - - /** - * Get the simId that uses the data traffic by default - * - * @param simId Returns default settings data sim id - * @return Returns 0 on success, others on failure. - */ - virtual int32_t GetDefaultCellularDataSimId(int32_t &simId) = 0; - - /** - * set the slotId that uses the data traffic by default - * - * @return 1 set success, 0 set fail, 84082688 invalid parameter - */ - virtual int32_t SetDefaultCellularDataSlotId(int32_t slotId) = 0; - - /** - * get data packet type - * - * @return 0 Indicates that there is no uplink or down link data, - * 1 Indicates that there is only down link data, - * 2 Indicates that there is only uplink data, - * 3 Indicates that there is uplink and down link data - * 4 Indicates that there is no uplink or down link data, - * and the bottom-layer link is in the dormant state - * 84082688 Indicates invalid parameter - */ - virtual int32_t GetCellularDataFlowType() = 0; - - /** - * get intelligence switch state - * - * @param state the state of intelligence switch - * @return return 84082688 invalid parameter, 1 data enable success, 0 enable fail - */ - virtual int32_t GetIntelligenceSwitchState(bool &state) = 0; - - virtual int32_t HasInternetCapability(int32_t slotId, int32_t cid) = 0; - - virtual int32_t ClearCellularDataConnections(int32_t slotId) = 0; - - virtual int32_t ClearAllConnections(int32_t slotId, DisConnectionReason reason) = 0; - - virtual int32_t RegisterSimAccountCallback(const sptr &callback) = 0; - - virtual int32_t UnregisterSimAccountCallback(const sptr &callback) = 0; - - virtual int32_t GetDataConnApnAttr(int32_t slotId, ApnItem::Attribute &apnAttr) = 0; - - virtual int32_t GetDataConnIpType(int32_t slotId, std::string &ipType) = 0; - - virtual int32_t GetApnState(int32_t slotId, const std::string &apnType) = 0; - - virtual int32_t GetDataRecoveryState() = 0; - - virtual int32_t IsNeedDoRecovery(int32_t slotId, bool needDoRecovery) = 0; - - virtual int32_t InitCellularDataController(int32_t slotId) = 0; - - virtual int32_t EstablishAllApnsIfConnectable(int32_t slotId) = 0; - - virtual int32_t ReleaseCellularDataConnection(int32_t slotId) = 0; - - virtual int32_t GetCellularDataSupplierId(int32_t slotId, uint64_t capability, uint32_t &supplierId) = 0; - - virtual int32_t CorrectNetSupplierNoAvailable(int32_t slotId) = 0; - - virtual int32_t GetSupplierRegisterState(uint32_t supplierId, int32_t ®State) = 0; - - virtual int32_t GetIfSupportDunApn(bool &isSupportDun) = 0; - - virtual int32_t GetDefaultActReportInfo(int32_t slotId, ApnActivateReportInfo &info) = 0; - - virtual int32_t GetInternalActReportInfo(int32_t slotId, ApnActivateReportInfo &info) = 0; - - virtual int32_t QueryApnIds(ApnInfo apnInfo, std::vector &apnIdList) = 0; - - virtual int32_t SetPreferApn(int32_t apnId) = 0; - - virtual int32_t QueryAllApnInfo(std::vector &apnInfoList) = 0; - -public: - DECLARE_INTERFACE_DESCRIPTOR(u"ohos.telephony.ICellularDataManager"); -}; -} // namespace Telephony -} // namespace OHOS -#endif // I_CELLULAR_DATA_MANAGER_H diff --git a/interfaces/innerkits/libtel_cellular_data_api.versionscript b/interfaces/innerkits/libtel_cellular_data_api.versionscript index 4fe0de0e41448d43b6e4a33b67a80af61ab3c5e8..7a2a256eae7e00506d15b3375f96e74b54b46c1a 100644 --- a/interfaces/innerkits/libtel_cellular_data_api.versionscript +++ b/interfaces/innerkits/libtel_cellular_data_api.versionscript @@ -15,6 +15,7 @@ global: extern "C++" { *OHOS::Telephony::CellularDataClient*; + *OHOS::Telephony::DataSimAccountCallback*; *ApnInfo*; }; local: diff --git a/services/include/apn_manager/apn_holder.h b/services/include/apn_manager/apn_holder.h index 68ea52e760de6db9b5fe36f7db8ff82115af11ae..d729545d74be13157d90266e2ff077cd4b33f56d 100644 --- a/services/include/apn_manager/apn_holder.h +++ b/services/include/apn_manager/apn_holder.h @@ -68,6 +68,7 @@ public: void RemoveUid(uint32_t uid); HasSystemUse GetUidStatus() const; void SetApnBadState(bool isBad); + bool IsReqUidsEmpty(); private: ApnHolder(ApnHolder &apnHolder) = default; diff --git a/services/include/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/apn_manager/apn_manager.h b/services/include/apn_manager/apn_manager.h index 09df02549b3ff5a956a492c91afaaa9d41dfa768..c3b138f3fc605bbb3b44e1daa4da0abbe1f61e5e 100644 --- a/services/include/apn_manager/apn_manager.h +++ b/services/include/apn_manager/apn_manager.h @@ -65,6 +65,7 @@ private: void GetCTOperator(int32_t slotId, std::string &numeric); void TryMergeSimilarPdpProfile(std::vector &apnVec); void MergePdpProfile(PdpProfile &newProfile, PdpProfile &oldProfile); + bool GetPreferId(int32_t slotId); private: static const std::map apnIdApnNameMap_; diff --git a/services/include/cellular_data_handler.h b/services/include/cellular_data_handler.h index ed1e9a80c1d778f23530219601f7cda62b69604a..6ada15bd0658892a23c127e8af3fffa1e2f7ebe3 100644 --- a/services/include/cellular_data_handler.h +++ b/services/include/cellular_data_handler.h @@ -84,6 +84,9 @@ public: void ReleaseCellularDataConnection(); bool UpdateNetworkInfo(); bool IsSupportDunApn(); + void ConnectIfNeed( + const AppExecFwk::InnerEvent::Pointer &event, sptr apnHolder, const NetRequest &request); + ApnActivateReportInfo GetDefaultActReportInfo(); ApnActivateReportInfo GetInternalActReportInfo(); @@ -103,6 +106,7 @@ private: void PsRadioEmergencyStateClose(const AppExecFwk::InnerEvent::Pointer &event); void EstablishDataConnectionComplete(const AppExecFwk::InnerEvent::Pointer &event); void DisconnectDataComplete(const AppExecFwk::InnerEvent::Pointer &event); + void HandleDisconnectDataCompleteForMmsType(sptr &apnHolder); void MsgEstablishDataConnection(const AppExecFwk::InnerEvent::Pointer &event); void MsgRequestNetwork(const AppExecFwk::InnerEvent::Pointer &event); void HandleSettingSwitchChanged(const AppExecFwk::InnerEvent::Pointer &event); @@ -159,6 +163,7 @@ private: void HandleEstablishAllApnsIfConnectable(const AppExecFwk::InnerEvent::Pointer &event); #ifdef OHOS_BUILD_ENABLE_TELEPHONY_EXT bool IsSimRequestNetOnVSimEnabled(int32_t reqType, bool isMmsType) const; + bool NotifyReqCellularData(bool isCellularDataRequested); #endif void SetNetRequest(NetRequest &request, const std::unique_ptr &netRequest); void SendEstablishDataConnectionEvent(int32_t id); diff --git a/services/include/cellular_data_service.h b/services/include/cellular_data_service.h index 30430dbb713cef27c7964fec023be97bb65d3060..8ab58df6d7787113a80b45d46a1d1b8f8c3a3f4a 100644 --- a/services/include/cellular_data_service.h +++ b/services/include/cellular_data_service.h @@ -21,10 +21,12 @@ #include "singleton.h" #include "system_ability.h" -#include "cellular_data_service_stub.h" +#include "cellular_data_manager_stub.h" #include "cellular_data_constant.h" #include "cellular_data_controller.h" #include "traffic_management.h" +#include "apn_activate_report_info.h" +#include "apn_attribute.h" #include "apn_item.h" namespace OHOS { @@ -34,7 +36,7 @@ enum class ServiceRunningState { STATE_RUNNING, }; -class CellularDataService : public SystemAbility, public CellularDataServiceStub { +class CellularDataService : public SystemAbility, public CellularDataManagerStub { DECLARE_DELAYED_REF_SINGLETON(CellularDataService) DECLARE_SYSTEM_ABILITY(CellularDataService) @@ -55,18 +57,18 @@ public: std::string GetFlowDataInfoDump(); int32_t IsCellularDataEnabled(bool &dataEnabled) override; int32_t EnableCellularData(bool enable) override; - int32_t GetCellularDataState() override; + int32_t GetCellularDataState(int32_t &state) override; int32_t IsCellularDataRoamingEnabled(const int32_t slotId, bool &dataRoamingEnabled) override; int32_t EnableCellularDataRoaming(const int32_t slotId, bool enable) override; int32_t HandleApnChanged(const int32_t slotId) override; - int32_t GetDefaultCellularDataSlotId() override; + int32_t GetDefaultCellularDataSlotId(int32_t &slotId) override; int32_t GetDefaultCellularDataSimId(int32_t &simId) override; int32_t SetDefaultCellularDataSlotId(const int32_t slotId) override; - int32_t GetCellularDataFlowType() override; + int32_t GetCellularDataFlowType(int32_t &type) override; void DispatchEvent(int32_t slotId, const AppExecFwk::InnerEvent::Pointer &event); - int32_t HasInternetCapability(const int32_t slotId, const int32_t cid) override; + int32_t HasInternetCapability(const int32_t slotId, const int32_t cid, int32_t &capability) override; int32_t ClearCellularDataConnections(const int32_t slotId) override; - int32_t ClearAllConnections(const int32_t slotId, DisConnectionReason reason) override; + int32_t ClearAllConnections(const int32_t slotId, const int32_t reason) override; int32_t ChangeConnectionForDsds(const int32_t slotId, bool enable); int32_t StrategySwitch(int32_t slotId, bool enable); int32_t RequestNet(const NetRequest &request); @@ -75,11 +77,11 @@ public: int32_t RemoveUid(const NetRequest &request); int32_t GetServiceRunningState(); int64_t GetSpendTime(); - int32_t GetApnState(int32_t slotId, const std::string &apnType) override; - int32_t GetDataRecoveryState() override; + int32_t GetApnState(int32_t slotId, const std::string &apnType, int &state) override; + int32_t GetDataRecoveryState(int32_t &state) override; int32_t RegisterSimAccountCallback(const sptr &callback) override; int32_t UnregisterSimAccountCallback(const sptr &callback) override; - int32_t GetDataConnApnAttr(int32_t slotId, ApnItem::Attribute &apnAttr) override; + int32_t GetDataConnApnAttr(int32_t slotId, ApnAttribute &apnAttr) override; int32_t GetDataConnIpType(int32_t slotId, std::string &ipType) override; int32_t IsNeedDoRecovery(int32_t slotId, bool needDoRecovery) override; int32_t EnableIntelligenceSwitch(bool enable) override; @@ -91,11 +93,16 @@ public: int32_t CorrectNetSupplierNoAvailable(int32_t slotId) override; int32_t GetSupplierRegisterState(uint32_t supplierId, int32_t ®State) override; int32_t GetIfSupportDunApn(bool &isSupportDun) override; - int32_t GetDefaultActReportInfo(int32_t slotId, ApnActivateReportInfo &info) override; - int32_t GetInternalActReportInfo(int32_t slotId, ApnActivateReportInfo &info) override; - int32_t QueryApnIds(ApnInfo apnInfo, std::vector &apnIdList) override; + int32_t GetDefaultActReportInfo(int32_t slotId, ApnActivateReportInfoIpc &info) override; + int32_t GetInternalActReportInfo(int32_t slotId, ApnActivateReportInfoIpc &info) override; + int32_t QueryApnIds(const ApnInfo& apnInfo, std::vector &apnIdList) override; int32_t SetPreferApn(int32_t apnId) override; int32_t QueryAllApnInfo(std::vector &apnInfoList) override; + int32_t SendUrspDecodeResult(int32_t slotId, const std::vector& buffer) override; + int32_t SendUePolicySectionIdentifier(int32_t slotId, const std::vector& buffer) override; + int32_t SendImsRsdList(int32_t slotId, const std::vector& buffer) override; + int32_t GetNetworkSliceAllowedNssai(int32_t slotId, const std::vector& buffer) override; + int32_t GetNetworkSliceEhplmn(int32_t slotId) override; private: bool Init(); diff --git a/services/include/cellular_data_service_stub.h b/services/include/cellular_data_service_stub.h deleted file mode 100644 index 3eb5c2c0380a81893b6bc6360388878a5def24eb..0000000000000000000000000000000000000000 --- a/services/include/cellular_data_service_stub.h +++ /dev/null @@ -1,157 +0,0 @@ -/* - * Copyright (C) 2021-2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#ifndef CELLULAR_DATA_SERVICE_STUB_H -#define CELLULAR_DATA_SERVICE_STUB_H - -#include - -#include "iremote_object.h" -#include "iremote_stub.h" - -#include "cellular_data_ipc_interface_code.h" -#include "i_cellular_data_manager.h" - -namespace OHOS { -namespace Telephony { -class CellularDataServiceStub : public IRemoteStub { -public: - CellularDataServiceStub(); - ~CellularDataServiceStub(); - int32_t OnRemoteRequest( - uint32_t code, MessageParcel &data, MessageParcel &reply, MessageOption &option) override; - int32_t OnRegisterSimAccountCallback(MessageParcel &data, MessageParcel &reply); - int32_t OnUnregisterSimAccountCallback(MessageParcel &data, MessageParcel &reply); - -private: - int32_t OnIsCellularDataEnabled(MessageParcel &data, MessageParcel &reply); - int32_t OnEnableCellularData(MessageParcel &data, MessageParcel &reply); - int32_t OnGetCellularDataState(MessageParcel &data, MessageParcel &reply); - int32_t OnIsCellularDataRoamingEnabled(MessageParcel &data, MessageParcel &reply); - int32_t OnEnableCellularDataRoaming(MessageParcel &data, MessageParcel &reply); - int32_t OnHandleApnChanged(MessageParcel &data, MessageParcel &reply); - int32_t OnGetDefaultCellularDataSlotId(MessageParcel &data, MessageParcel &reply); - int32_t OnGetDefaultCellularDataSimId(MessageParcel &data, MessageParcel &reply); - int32_t OnSetDefaultCellularDataSlotId(MessageParcel &data, MessageParcel &reply); - int32_t OnGetCellularDataFlowType(MessageParcel &data, MessageParcel &reply); - int32_t OnHasInternetCapability(MessageParcel &data, MessageParcel &reply); - int32_t OnClearCellularDataConnections(MessageParcel &data, MessageParcel &reply); - int32_t OnGetDataConnApnAttr(MessageParcel &data, MessageParcel &reply); - int32_t OnGetDataConnIpType(MessageParcel &data, MessageParcel &reply); - int32_t OnClearAllConnections(MessageParcel &data, MessageParcel &reply); - int32_t OnGetApnState(MessageParcel &data, MessageParcel &reply); - int32_t OnGetRecoveryState(MessageParcel &data, MessageParcel &reply); - int32_t OnIsNeedDoRecovery(MessageParcel &data, MessageParcel &reply); - int32_t OnEnableIntelligenceSwitch(MessageParcel &data, MessageParcel &reply); - int32_t OnInitCellularDataController(MessageParcel &data, MessageParcel &reply); - int32_t OnGetIntelligenceSwitchState(MessageParcel &data, MessageParcel &reply); - int32_t OnEstablishAllApnsIfConnectable(MessageParcel &data, MessageParcel &reply); - int32_t OnReleaseCellularDataConnection(MessageParcel &data, MessageParcel &reply); - int32_t OnGetCellularDataSupplierId(MessageParcel &data, MessageParcel &reply); - int32_t OnCorrectNetSupplierNoAvailable(MessageParcel &data, MessageParcel &reply); - int32_t OnGetSupplierRegisterState(MessageParcel &data, MessageParcel &reply); - int32_t SetTimer(uint32_t code); - void CancelTimer(int32_t id); - int32_t OnIsSupportDunApn(MessageParcel &data, MessageParcel &reply); - int32_t OnGetDefaultActReportInfo(MessageParcel &data, MessageParcel &reply); - int32_t OnGetInternalActReportInfo(MessageParcel &data, MessageParcel &reply); - int32_t OnQueryApnInfo(MessageParcel &data, MessageParcel &reply); - int32_t OnSetPreferApn(MessageParcel &data, MessageParcel &reply); - int32_t OnQueryAllApnInfo(MessageParcel &data, MessageParcel &reply); - -private: - using Fun = std::function; - std::map eventIdFunMap_ { - { (uint32_t)CellularDataInterfaceCode::IS_CELLULAR_DATA_ENABLED, - [this](MessageParcel &data, MessageParcel &reply) { return OnIsCellularDataEnabled(data, reply); } }, - { (uint32_t)CellularDataInterfaceCode::ENABLE_CELLULAR_DATA, - [this](MessageParcel &data, MessageParcel &reply) { return OnEnableCellularData(data, reply); } }, - { (uint32_t)CellularDataInterfaceCode::GET_CELLULAR_DATA_STATE, - [this](MessageParcel &data, MessageParcel &reply) { return OnGetCellularDataState(data, reply); } }, - { (uint32_t)CellularDataInterfaceCode::IS_DATA_ROAMING_ENABLED, - [this](MessageParcel &data, MessageParcel &reply) { return OnIsCellularDataRoamingEnabled(data, reply); } }, - { (uint32_t)CellularDataInterfaceCode::ENABLE_DATA_ROAMING, - [this](MessageParcel &data, MessageParcel &reply) { return OnEnableCellularDataRoaming(data, reply); } }, - { (uint32_t)CellularDataInterfaceCode::APN_DATA_CHANGED, - [this](MessageParcel &data, MessageParcel &reply) { return OnHandleApnChanged(data, reply); } }, - { (uint32_t)CellularDataInterfaceCode::GET_DEFAULT_SLOT_ID, - [this](MessageParcel &data, MessageParcel &reply) { return OnGetDefaultCellularDataSlotId(data, reply); } }, - { (uint32_t)CellularDataInterfaceCode::GET_DEFAULT_SIM_ID, - [this](MessageParcel &data, MessageParcel &reply) { return OnGetDefaultCellularDataSimId(data, reply); } }, - { (uint32_t)CellularDataInterfaceCode::SET_DEFAULT_SLOT_ID, - [this](MessageParcel &data, MessageParcel &reply) { return OnSetDefaultCellularDataSlotId(data, reply); } }, - { (uint32_t)CellularDataInterfaceCode::GET_FLOW_TYPE_ID, - [this](MessageParcel &data, MessageParcel &reply) { return OnGetCellularDataFlowType(data, reply); } }, - { (uint32_t)CellularDataInterfaceCode::HAS_CAPABILITY, - [this](MessageParcel &data, MessageParcel &reply) { return OnHasInternetCapability(data, reply); } }, - { (uint32_t)CellularDataInterfaceCode::CLEAR_ALL_CONNECTIONS, - [this](MessageParcel &data, MessageParcel &reply) { return OnClearCellularDataConnections(data, reply); } }, - { (uint32_t)CellularDataInterfaceCode::CLEAR_ALL_CONNECTIONS_USE_REASON, - [this](MessageParcel &data, MessageParcel &reply) { return OnClearAllConnections(data, reply); } }, - { (uint32_t)CellularDataInterfaceCode::REG_SIM_ACCOUNT_CALLBACK, - [this](MessageParcel &data, MessageParcel &reply) { return OnRegisterSimAccountCallback(data, reply); } }, - { (uint32_t)CellularDataInterfaceCode::UN_REG_SIM_ACCOUNT_CALLBACK, - [this](MessageParcel &data, MessageParcel &reply) { return OnUnregisterSimAccountCallback(data, reply); } }, - { (uint32_t)CellularDataInterfaceCode::GET_DATA_CONN_APN_ATTR, - [this](MessageParcel &data, MessageParcel &reply) { return OnGetDataConnApnAttr(data, reply); } }, - { (uint32_t)CellularDataInterfaceCode::GET_DATA_CONN_IP_TYPE, - [this](MessageParcel &data, MessageParcel &reply) { return OnGetDataConnIpType(data, reply); } }, - { (uint32_t)CellularDataInterfaceCode::GET_CELLULAR_DATA_APN_STATE, - [this](MessageParcel &data, MessageParcel &reply) { return OnGetApnState(data, reply); } }, - { (uint32_t)CellularDataInterfaceCode::GET_RECOVERY_STATE, - [this](MessageParcel &data, MessageParcel &reply) { return OnGetRecoveryState(data, reply); } }, - { (uint32_t)CellularDataInterfaceCode::IS_NEED_DO_RECOVERY, - [this](MessageParcel &data, MessageParcel &reply) { return OnIsNeedDoRecovery(data, reply); } }, - { (uint32_t)CellularDataInterfaceCode::ENABLE_INTELLIGENCE_SWITCH, - [this](MessageParcel &data, MessageParcel &reply) { return OnEnableIntelligenceSwitch(data, reply); } }, - { (uint32_t)CellularDataInterfaceCode::INIT_CELLULAR_DATA_CONTROLLER, - [this](MessageParcel &data, MessageParcel &reply) { return OnInitCellularDataController(data, reply); } }, - { (uint32_t)CellularDataInterfaceCode::GET_INTELLIGENCE_SWITCH_STATE, - [this](MessageParcel &data, MessageParcel &reply) { return OnGetIntelligenceSwitchState(data, reply); } }, - { (uint32_t)CellularDataInterfaceCode::ESTABLISH_ALL_APNS_IF_CONNECTABLE, - [this](MessageParcel &data, MessageParcel &reply) { - return OnEstablishAllApnsIfConnectable(data, reply); } }, - { (uint32_t)CellularDataInterfaceCode::RELEASE_CELLULAR_DATA_CONNECTION, - [this](MessageParcel &data, MessageParcel &reply) { return OnReleaseCellularDataConnection(data, reply); }}, - { (uint32_t)CellularDataInterfaceCode::GET_CELLULAR_DATA_SUPPLIERID, - [this](MessageParcel &data, MessageParcel &reply) { return OnGetCellularDataSupplierId(data, reply); } }, - { (uint32_t)CellularDataInterfaceCode::CORRECT_NET_SUPPLIER_NO_AVAILABLE, - [this](MessageParcel &data, MessageParcel &reply) { - return OnCorrectNetSupplierNoAvailable(data, reply); } }, - { (uint32_t)CellularDataInterfaceCode::GET_SUPPLIER_REGISTER_STATE, - [this](MessageParcel &data, MessageParcel &reply) { return OnGetSupplierRegisterState(data, reply); } }, - { (uint32_t)CellularDataInterfaceCode::GET_IF_SUPPORT_DUN_APN, - [this](MessageParcel &data, MessageParcel &reply) { return OnIsSupportDunApn(data, reply); } }, - { (uint32_t)CellularDataInterfaceCode::GET_DEFAULT_ACT_REPORT_INFO, - [this](MessageParcel &data, MessageParcel &reply) { return OnGetDefaultActReportInfo(data, reply); } }, - { (uint32_t)CellularDataInterfaceCode::GET_INTERNAL_ACT_REPORT_INFO, - [this](MessageParcel &data, MessageParcel &reply) { return OnGetInternalActReportInfo(data, reply); } }, - { (uint32_t)CellularDataInterfaceCode::QUERY_APN_INFO, - [this](MessageParcel &data, MessageParcel &reply) { return OnQueryApnInfo(data, reply); } }, - { (uint32_t)CellularDataInterfaceCode::SET_PREFER_APN, - [this](MessageParcel &data, MessageParcel &reply) { return OnSetPreferApn(data, reply); } }, - { (uint32_t)CellularDataInterfaceCode::QUERY_ALL_APN_INFO, - [this](MessageParcel &data, MessageParcel &reply) { return OnQueryAllApnInfo(data, reply); } } - }; - std::map collieCodeStringMap_ = { - { uint32_t(CellularDataInterfaceCode::GET_CELLULAR_DATA_STATE), "GET_CELLULAR_DATA_STATE" }, - { uint32_t(CellularDataInterfaceCode::IS_CELLULAR_DATA_ENABLED), "IS_CELLULAR_DATA_ENABLED" }, - { uint32_t(CellularDataInterfaceCode::ENABLE_CELLULAR_DATA), "ENABLE_CELLULAR_DATA" }, - { uint32_t(CellularDataInterfaceCode::GET_DEFAULT_SLOT_ID), "GET_DEFAULT_SLOT_ID" }, - }; -}; -} // namespace Telephony -} // namespace OHOS -#endif // CELLULAR_DATA_SERVICE_STUB_H diff --git a/services/include/common/cellular_data_constant.h b/services/include/common/cellular_data_constant.h index 7502320018e9dd15b4157572f62a76af5bd41c90..2a4339a5561c8dab395317d98f127e55dae4f93e 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; @@ -237,6 +261,8 @@ static constexpr const char *CELLULAR_DATA_SETTING_URI = static constexpr const char *CELLULAR_DATA_SETTING_EXT_URI = "datashare:///com.ohos.settingsdata.DataAbility"; static constexpr const char *CELLULAR_DATA_SETTING_DATA_ENABLE_URI = "datashare:///com.ohos.settingsdata/entry/settingsdata/SETTINGSDATA?Proxy=true&key=cellular_data_enable"; +static constexpr const char *CELLULAR_DATA_SETTING_ANY_SIM_DETECTED_URI = + "datashare:///com.ohos.settingsdata/entry/settingsdata/SETTINGSDATA?Proxy=true&key=any_sim_detected"; static constexpr const char *CELLULAR_DATA_SETTING_DATA_ROAMING_URI = "datashare:///com.ohos.settingsdata/entry/settingsdata/SETTINGSDATA?Proxy=true&key=cellular_data_roaming_enable"; static constexpr const char *CELLULAR_DATA_SETTING_DATA_INCALL_URI = @@ -308,6 +334,7 @@ static const int32_t DELAY_SET_RIL_BANDWIDTH_MS = 3000; static const int32_t DELAY_SET_RIL_UP_DOWN_BANDWIDTH_MS = 50; static const int32_t MAX_REPLY_COUNT = 200; static constexpr const char *CELLULAR_DATA_COLUMN_ENABLE = "cellular_data_enable"; +static constexpr const char *SIM_DETECTED_COLUMN_ENABLE = "any_sim_detected"; static constexpr const char *CELLULAR_DATA_COLUMN_ROAMING = "cellular_data_roaming_enable"; static constexpr const char *CELLULAR_DATA_COLUMN_INCALL = "cellular_data_incall_enable"; static constexpr const char *INTELLIGENCE_SWITCH_COLUMN_ENABLE = "intelligence_card_switch_enable"; diff --git a/services/include/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/data_connection_monitor.h b/services/include/data_connection_monitor.h index f846a795df1d162a01ab0fd086dbf695a430a30b..0526d60b8a043774c8be2bdbde2bd06cf07115ee 100644 --- a/services/include/data_connection_monitor.h +++ b/services/include/data_connection_monitor.h @@ -114,6 +114,7 @@ private: bool IsAggressiveRecovery(); int32_t GetStallDetectionPeriod(); bool IsScreenOn(); + bool IsVsimEnabled(); std::unique_ptr trafficManager_; std::unique_ptr stallDetectionTrafficManager_; diff --git a/services/include/data_switch_settings.h b/services/include/data_switch_settings.h index b82b70e85d1034a2c6d22d4d42cb89b67feaceb1..654cbf652bd3bdcb01736a485826c887273dbaeb 100644 --- a/services/include/data_switch_settings.h +++ b/services/include/data_switch_settings.h @@ -36,10 +36,12 @@ public: bool IsUserDataRoamingOn(); void UpdateUserDataRoamingOn(bool dataRoaming); int32_t SetUserDataOn(bool userDataOn); + int32_t SetAnySimDetected(int32_t simDetected); int32_t SetIntelliSwitchOn(bool userSwitchOn); int32_t SetUserDataRoamingOn(bool dataRoamingEnabled); int32_t QueryIntelligenceSwitchStatus(bool &switchEnabled); int32_t QueryUserDataStatus(bool &dataEnabled); + int32_t QueryAnySimDetectedStatus(int32_t simDetected); int32_t QueryUserDataRoamingStatus(bool &dataRoamingEnabled); private: 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/include/state_machine/incall_data_state_machine.h b/services/include/state_machine/incall_data_state_machine.h index 4ac9de8b84728d851a4eef2e1fd119e389009ca7..23f634c511b90519a45793c7b2e87ea199525afd 100644 --- a/services/include/state_machine/incall_data_state_machine.h +++ b/services/include/state_machine/incall_data_state_machine.h @@ -43,6 +43,7 @@ public: void UpdateCallState(int32_t state); void Init(int32_t callState); bool IsSecondaryActiveState() const; + void DeInit(); protected: sptr idleState_; diff --git a/services/include/utils/cellular_data_rdb_helper.h b/services/include/utils/cellular_data_rdb_helper.h index 00464d60d4777ff37b722dc4c13abda4e948e17c..d38c159e22d23904ba0eda7782739f268781c854 100644 --- a/services/include/utils/cellular_data_rdb_helper.h +++ b/services/include/utils/cellular_data_rdb_helper.h @@ -35,6 +35,8 @@ namespace OHOS { namespace Telephony { +static constexpr int SETUP_DATA_AUTH_NONE = 0; +static constexpr int SETUP_DATA_AUTH_PAP_CHAP = 3; class CellularDataRdbHelper : public DelayedSingleton { DECLARE_DELAYED_SINGLETON(CellularDataRdbHelper); diff --git a/services/src/apn_manager/apn_holder.cpp b/services/src/apn_manager/apn_holder.cpp index 6ac6e89bd75bee140f3a2aec7f260a129f115f28..af50a9cbd8c77bf9c43c8bc0ec528ec066d17839 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) {} @@ -65,10 +71,17 @@ sptr ApnHolder::GetCurrentApn() const return apnItem_; } +bool ApnHolder::IsReqUidsEmpty() +{ + std::shared_lock lock(reqUidsMutex_); + return reqUids_.empty(); +} + void ApnHolder::AddUid(uint32_t uid) { std::unique_lock lock(reqUidsMutex_); if (reqUids_.find(uid) != reqUids_.end()) { + TELEPHONY_LOGI("apnholder add uid %{public}u", uid); return; } reqUids_.insert(uid); @@ -80,6 +93,7 @@ void ApnHolder::RemoveUid(uint32_t uid) auto it = reqUids_.find(uid); if (it != reqUids_.end()) { reqUids_.erase(it); + TELEPHONY_LOGI("apnholder erase uid %{public}u", uid); return; } } diff --git a/services/src/apn_manager/apn_item.cpp b/services/src/apn_manager/apn_item.cpp index 1d1e9e95d21d3bd76cf6bccf78e9e21d099031c4..144594ab8dad9d0fabce075d13ee70c4bfb3ebb9 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) { @@ -158,12 +158,12 @@ sptr ApnItem::BuildOtherApnAttributes(sptr &apnItem, const Pdp bool ApnItem::IsSimilarPdpProfile(const PdpProfile &newPdpProfile, const PdpProfile &oldPdpProfile) { - return (newPdpProfile.apn == oldPdpProfile.apn) && (newPdpProfile.authType == oldPdpProfile.authType) && - (newPdpProfile.authUser == oldPdpProfile.authUser) && (newPdpProfile.authPwd == oldPdpProfile.authPwd) && - (newPdpProfile.proxyIpAddress == oldPdpProfile.proxyIpAddress) && - (newPdpProfile.mmsIpAddress == oldPdpProfile.mmsIpAddress) && + return (newPdpProfile.apn == oldPdpProfile.apn) && + IsSimilarProperty(newPdpProfile.proxyIpAddress, oldPdpProfile.proxyIpAddress) && IsSimilarProtocol(newPdpProfile.pdpProtocol, oldPdpProfile.pdpProtocol) && IsSimilarProtocol(newPdpProfile.roamPdpProtocol, oldPdpProfile.roamPdpProtocol) && + (newPdpProfile.mvnoType == oldPdpProfile.mvnoType) && + (newPdpProfile.mvnoMatchData == oldPdpProfile.mvnoMatchData) && IsSimilarProperty(newPdpProfile.homeUrl, oldPdpProfile.homeUrl) && IsSimilarProperty(newPdpProfile.mmsIpAddress, oldPdpProfile.mmsIpAddress); } diff --git a/services/src/apn_manager/apn_manager.cpp b/services/src/apn_manager/apn_manager.cpp index 60ef103eabfd9ca557dd3d52ee30788e5d580bbc..0f550b79c5dc59e9a96ff541b7651b70901f94ac 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; } @@ -247,8 +295,8 @@ std::vector> ApnManager::GetSortApnHolder() const int32_t ApnManager::CreateAllApnItemByDatabase(int32_t slotId) { int32_t count = 0; + sptr extraApnItem = ApnItem::MakeDefaultApn("default"); if (TELEPHONY_EXT_WRAPPER.createAllApnItemExt_) { - sptr extraApnItem = ApnItem::MakeDefaultApn("default"); if (TELEPHONY_EXT_WRAPPER.createAllApnItemExt_(slotId, extraApnItem)) { std::lock_guard lock(mutex_); allApnItem_.clear(); @@ -256,6 +304,13 @@ int32_t ApnManager::CreateAllApnItemByDatabase(int32_t slotId) return ++count; } } + if (TELEPHONY_EXT_WRAPPER.createDcApnItemExt_ && + TELEPHONY_EXT_WRAPPER.createDcApnItemExt_(slotId_, extraApnItem)) { + std::lock_guard lock(mutex_); + allApnItem_.clear(); + allApnItem_.push_back(extraApnItem); + return ++count; + } std::u16string operatorNumeric; CoreManagerInner::GetInstance().GetSimOperatorNumeric(slotId, operatorNumeric); std::string numeric = Str16ToStr8(operatorNumeric); @@ -265,17 +320,16 @@ int32_t ApnManager::CreateAllApnItemByDatabase(int32_t slotId) return count; } TELEPHONY_LOGI("current slotId = %{public}d, numeric = %{public}s", slotId, numeric.c_str()); + preferId_ = INVALID_PROFILE_ID; + if (!GetPreferId(slotId)) { + TELEPHONY_LOGE("query prefer apn fail"); + return count; + } auto helper = CellularDataRdbHelper::GetInstance(); if (helper == nullptr) { TELEPHONY_LOGE("get cellularDataRdbHelper failed"); return count; } - preferId_ = INVALID_PROFILE_ID; - std::vector preferApnVec; - if (helper->QueryPreferApn(slotId, preferApnVec)) { - preferId_ = preferApnVec[0].profileId; - TELEPHONY_LOGI("query preferId_ = %{public}d", preferId_); - } std::string mcc = numeric.substr(0, DEFAULT_MCC_SIZE); std::string mnc = numeric.substr(mcc.size(), numeric.size() - mcc.size()); int32_t mvnoCount = CreateMvnoApnItems(slotId, mcc, mnc); @@ -406,7 +460,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); @@ -652,6 +705,12 @@ void ApnManager::TryMergeSimilarPdpProfile(std::vector &apnVec) void ApnManager::MergePdpProfile(PdpProfile &newProfile, PdpProfile &oldProfile) { + if (oldProfile.apnTypes.find(DATA_CONTEXT_ROLE_DEFAULT) != std::string::npos) { + newProfile.authType = oldProfile.authType; + newProfile.authUser = oldProfile.authUser; + newProfile.authPwd = oldProfile.authPwd; + newProfile.server = oldProfile.server; + } newProfile.apnTypes = newProfile.apnTypes + ',' + oldProfile.apnTypes; newProfile.pdpProtocol = (newProfile.pdpProtocol == PROTOCOL_IPV4V6) ? newProfile.pdpProtocol : oldProfile.pdpProtocol; @@ -659,6 +718,8 @@ void ApnManager::MergePdpProfile(PdpProfile &newProfile, PdpProfile &oldProfile) newProfile.roamPdpProtocol : oldProfile.roamPdpProtocol; newProfile.homeUrl = newProfile.homeUrl.empty() ? oldProfile.homeUrl : newProfile.homeUrl; newProfile.mmsIpAddress = newProfile.mmsIpAddress.empty() ? oldProfile.mmsIpAddress : newProfile.mmsIpAddress; + newProfile.proxyIpAddress = newProfile.proxyIpAddress.empty() ? + oldProfile.proxyIpAddress : newProfile.proxyIpAddress; if (preferId_ == oldProfile.profileId) { TELEPHONY_LOGI("preferId change from %{public}d to %{public}d", oldProfile.profileId, newProfile.profileId); preferId_ = newProfile.profileId; @@ -686,6 +747,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; } @@ -702,5 +775,31 @@ void ApnManager::GetBipApnItem(sptr &bipApn) } } } + +bool ApnManager::GetPreferId(int32_t slotId) +{ + int32_t simId = CoreManagerInner::GetInstance().GetSimId(slotId); + if (simId <= INVALID_SIM_ID) { + TELEPHONY_LOGE("Slot%{public}d: failed due to invalid sim id %{public}d", slotId, simId); + return false; + } + auto helper = CellularDataRdbHelper::GetInstance(); + if (helper == nullptr) { + TELEPHONY_LOGE("get cellularDataRdbHelper failed"); + return false; + } + std::vector preferApnVec; + if (helper->QueryPreferApn(slotId, preferApnVec)) { + if (preferApnVec.size() > 0) { + preferId_ = preferApnVec[0].profileId; + TELEPHONY_LOGI("query preferId_ = %{public}d", preferId_); + } else { + TELEPHONY_LOGI("query prefer apn is null"); + } + return true; + } + TELEPHONY_LOGE("query prefer apn fail"); + return false; +} } // namespace Telephony } // namespace OHOS diff --git a/services/src/apn_manager/connection_retry_policy.cpp b/services/src/apn_manager/connection_retry_policy.cpp index ee7bab92091a33af8e1871916d141c577b791955..6bcbceb72275e7df9311c6ebe370bcfbe8f2de25 100644 --- a/services/src/apn_manager/connection_retry_policy.cpp +++ b/services/src/apn_manager/connection_retry_policy.cpp @@ -81,6 +81,18 @@ sptr ConnectionRetryPolicy::GetNextRetryApnItem() const void ConnectionRetryPolicy::SetMatchedApns(std::vector> &apns) { + if (matchedApns_.size() != apns.size()) { + TELEPHONY_LOGI("reset currentApnIndex"); + currentApnIndex_ = 0; + } else { + for (int32_t i = 0; i < static_cast(apns.size()); i++) { + if (apns[i]->attr_.profileId_ != matchedApns_[i]->attr_.profileId_) { + TELEPHONY_LOGI("reset currentApnIndex"); + currentApnIndex_ = 0; + break; + } + } + } matchedApns_ = apns; } diff --git a/services/src/cellular_data_dump_helper.cpp b/services/src/cellular_data_dump_helper.cpp index 61210cc97e9176a030cfc566f82229740316043c..d8b9d39e500f623bba45f1f4dabd47b62c53ca98 100644 --- a/services/src/cellular_data_dump_helper.cpp +++ b/services/src/cellular_data_dump_helper.cpp @@ -108,7 +108,9 @@ void CellularDataDumpHelper::ShowCellularDataInfo(std::string &result) const result.append(GetBoolValue(dataEnabled)); result.append("\n"); result.append("CellularDataState : "); - result.append(GetCellularDataConnectionState(dataService.GetCellularDataState())); + int32_t cellularDataState; + dataService.GetCellularDataState(cellularDataState); + result.append(GetCellularDataConnectionState(cellularDataState)); result.append("\n"); } } // namespace Telephony diff --git a/services/src/cellular_data_handler.cpp b/services/src/cellular_data_handler.cpp index 58f576023c8b7a68a7714f90825c5cf25f397642..001baeaf22a01ae01093d0fd41679e714559b132 100644 --- a/services/src/cellular_data_handler.cpp +++ b/services/src/cellular_data_handler.cpp @@ -44,6 +44,8 @@ using namespace OHOS::EventFwk; using namespace NetManagerStandard; static const int32_t ESM_FLAG_INVALID = -1; const std::string DEFAULT_DATA_ROAMING = "persist.telephony.defaultdataroaming"; +constexpr const char *PERSIST_EDM_MOBILE_DATA_POLICY = "persist.edm.mobile_data_policy"; +constexpr const char *MOBILE_DATA_POLICY_FORCE_OPEN = "force_open"; CellularDataHandler::CellularDataHandler(const EventFwk::CommonEventSubscribeInfo &sp, int32_t slotId) : TelEventHandler("CellularDataHandler"), CommonEventSubscriber(sp), slotId_(slotId) {} @@ -158,6 +160,7 @@ int32_t CellularDataHandler::SetCellularDataEnable(bool userDataOn) int32_t result = dataSwitchSettings_->QueryUserDataStatus(dataEnabled); if (result != TELEPHONY_ERR_SUCCESS) { TELEPHONY_LOGE("Slot%{public}d: Query result: %{public}d", slotId_, result); + return result; } if (dataEnabled == userDataOn) { TELEPHONY_LOGI("Slot%{public}d: The status of the cellular data switch has not changed", slotId_); @@ -811,6 +814,7 @@ bool CellularDataHandler::HandleCompatibleDataConnection( TELEPHONY_LOGI("Enter HandleCompatibleDataConnection"); int32_t oldApnId = ApnManager::FindApnIdByCapability(stateMachine->GetCapability()); int32_t newApnId = ApnManager::FindApnIdByCapability(apnHolder->GetCapability()); + apnHolder->ReleaseAllCellularData(); if (stateMachine->IsActiveState()) { TELEPHONY_LOGI("set reuse apnId[%{public}d] for apnId[%{public}d]", newApnId, oldApnId); stateMachine->SetReuseApnCap(apnHolder->GetCapability()); @@ -906,7 +910,7 @@ std::shared_ptr CellularDataHandler::CreatorDataShar bool CellularDataHandler::GetCurrentDataShareApnInfo(std::shared_ptr dataShareHelper, const int32_t simId, int32_t &profileIdValue) { - Uri preferApnUri(std::string(CELLULAR_DATA_RDB_PREFER) + "?Proxy=true&simId=" + std::to_string(simId)); + Uri preferApnUri(std::string(CELLULAR_DATA_RDB_PREFER) + "?simId=" + std::to_string(simId)); DataShare::DataSharePredicates predicates; std::vector columns; std::shared_ptr resultSet = @@ -945,6 +949,8 @@ void CellularDataHandler::UpdateApnInfo(const int32_t profileId) int32_t profileIdValue = 0; if (!GetCurrentDataShareApnInfo(dataShareHelper, simId, profileIdValue)) { TELEPHONY_LOGE("GetCurrentDataShareApnInfo fail."); + dataShareHelper->Release(); + return; } if (profileIdValue != profileId) { DataShare::DataSharePredicates predicates; @@ -1021,6 +1027,10 @@ void CellularDataHandler::DisconnectDataComplete(const InnerEvent::Pointer &even UpdatePhysicalConnectionState(connectionManager_->isNoActiveConnection()); if (apnHolder->IsDataCallEnabled()) { RetryOrClearConnection(apnHolder, reason, netInfo); + } else { +#ifdef OHOS_BUILD_ENABLE_TELEPHONY_EXT + NotifyReqCellularData(false); +#endif } if (!apnManager_->HasAnyConnectedState()) { connectionManager_->StopStallDetectionTimer(); @@ -1033,6 +1043,11 @@ void CellularDataHandler::DisconnectDataComplete(const InnerEvent::Pointer &even if (reason == DisConnectionReason::REASON_CHANGE_CONNECTION) { HandleSortConnection(); } + HandleDisconnectDataCompleteForMmsType(apnHolder); +} + +void CellularDataHandler::HandleDisconnectDataCompleteForMmsType(sptr &apnHolder) +{ if (apnHolder->IsMmsType()) { SetDataPermittedForMms(false); RemoveEvent(CellularDataEventCode::MSG_RESUME_DATA_PERMITTED_TIMEOUT); @@ -1049,6 +1064,9 @@ void CellularDataHandler::RetryOrClearConnection(const sptr &apnHolde if (reason == DisConnectionReason::REASON_CLEAR_CONNECTION) { TELEPHONY_LOGI("clear connection"); ClearConnection(apnHolder, reason); +#ifdef OHOS_BUILD_ENABLE_TELEPHONY_EXT + NotifyReqCellularData(false); +#endif } else if (reason == DisConnectionReason::REASON_PERMANENT_REJECT) { TELEPHONY_LOGI("permannent reject, mark bad and clear connection"); apnHolder->SetApnBadState(true); @@ -1160,6 +1178,16 @@ bool CellularDataHandler::IsSimRequestNetOnVSimEnabled(int32_t reqType, bool isM } return false; } + +bool CellularDataHandler::NotifyReqCellularData(bool isCellularDataRequested) +{ + if (TELEPHONY_EXT_WRAPPER.dynamicLoadNotifyReqCellularDataStatus_) { + TELEPHONY_EXT_WRAPPER.dynamicLoadNotifyReqCellularDataStatus_(isCellularDataRequested); + TELEPHONY_LOGE("NotifyReqCellularData isCellularDataRequested %{public}d", isCellularDataRequested); + return true; + } + return false; +} #endif void CellularDataHandler::SetNetRequest(NetRequest &request, const std::unique_ptr &netRequest) @@ -1179,6 +1207,20 @@ void CellularDataHandler::SendEstablishDataConnectionEvent(int32_t id) } } +void CellularDataHandler::ConnectIfNeed( + const InnerEvent::Pointer &event, sptr apnHolder, const NetRequest &request) +{ + if (event == nullptr || apnHolder == nullptr) { + return; + } + if (event->GetParam() == TYPE_REQUEST_NET) { + TELEPHONY_LOGI("try to activate Cellular"); + apnHolder->RequestCellularData(request); + int32_t id = ApnManager::FindApnIdByCapability(request.capability); + SendEstablishDataConnectionEvent(id); + } +} + void CellularDataHandler::MsgRequestNetwork(const InnerEvent::Pointer &event) { if (apnManager_ == nullptr || event == nullptr) { @@ -1198,8 +1240,13 @@ void CellularDataHandler::MsgRequestNetwork(const InnerEvent::Pointer &event) TELEPHONY_LOGE("Slot%{public}d: apnHolder is null.", slotId_); return; } - + WriteEventCellularRequest(request, event->GetParam()); #ifdef OHOS_BUILD_ENABLE_TELEPHONY_EXT + if (TELEPHONY_EXT_WRAPPER.judgeOtherRequestHolding_ && + TELEPHONY_EXT_WRAPPER.judgeOtherRequestHolding_(request, apnHolder->GetUidStatus())) { + ConnectIfNeed(event, apnHolder, request); + return; + } if (IsSimRequestNetOnVSimEnabled(event->GetParam(), apnHolder->IsMmsType())) { return; } @@ -1212,15 +1259,20 @@ void CellularDataHandler::MsgRequestNetwork(const InnerEvent::Pointer &event) TELEPHONY_EXT_WRAPPER.isAllCellularDataAllowed_(request, apnHolder->GetUidStatus()); } #endif - WriteEventCellularRequest(request, event->GetParam()); if (isAllCellularDataAllowed) { TELEPHONY_LOGD("allow cellular data"); if (event->GetParam() == TYPE_REQUEST_NET) { apnHolder->RequestCellularData(request); +#ifdef OHOS_BUILD_ENABLE_TELEPHONY_EXT + NotifyReqCellularData(true); +#endif } else { - if (!apnHolder->ReleaseCellularData(request)) { - return; + if (apnHolder->IsReqUidsEmpty()) { + apnHolder->ReleaseAllCellularData(); } +#ifdef OHOS_BUILD_ENABLE_TELEPHONY_EXT + NotifyReqCellularData(false); +#endif } } else { if (event->GetParam() == TYPE_REQUEST_NET) { @@ -1262,7 +1314,6 @@ void CellularDataHandler::OnReceiveEvent(const EventFwk::CommonEventData &data) { const AAFwk::Want &want = data.GetWant(); std::string action = want.GetAction(); - const int32_t defSlotId = CoreManagerInner::GetInstance().GetDefaultCellularDataSlotId(); int32_t slotId = want.GetIntParam("slotId", 0); TELEPHONY_LOGI("[slot%{public}d] action=%{public}s code=%{public}d", slotId_, action.c_str(), data.GetCode()); if (EventFwk::CommonEventSupport::COMMON_EVENT_CALL_STATE_CHANGED == action) { @@ -1283,14 +1334,8 @@ void CellularDataHandler::OnReceiveEvent(const EventFwk::CommonEventData &data) } GetConfigurationFor5G(); } else if (action == CommonEventSupport::COMMON_EVENT_SCREEN_ON) { - if (slotId_ != defSlotId) { - return; - } HandleScreenStateChanged(true); } else if (action == CommonEventSupport::COMMON_EVENT_SCREEN_OFF) { - if (slotId_ != defSlotId) { - return; - } HandleScreenStateChanged(false); } else if (action == CommonEventSupport::COMMON_EVENT_DATA_SHARE_READY) { RegisterDataSettingObserver(); @@ -1372,7 +1417,7 @@ void CellularDataHandler::IncallDataComplete(const InnerEvent::Pointer &event) { TELEPHONY_LOGI("Slot%{public}d: MSG_INCALL_DATA_COMPLETE", slotId_); if (incallDataStateMachine_ != nullptr) { - incallDataStateMachine_ = nullptr; + incallDataStateMachine_->DeInit(); } } @@ -1406,6 +1451,10 @@ void CellularDataHandler::HandleImsCallChanged(int32_t state) if (state == TelCallStatus::CALL_STATUS_DIALING || state == TelCallStatus::CALL_STATUS_INCOMING) { if (incallDataStateMachine_ == nullptr) { incallDataStateMachine_ = CreateIncallDataStateMachine(state); + } else { + if (incallDataStateMachine_->GetCurrentState() == nullptr) { + incallDataStateMachine_->Init(state); + } } } if (incallDataStateMachine_ == nullptr) { @@ -2068,17 +2117,21 @@ void CellularDataHandler::GetDefaultDataEnableConfig() return; } bool dataEnbaled = true; - int32_t ret = dataSwitchSettings_->QueryUserDataStatus(dataEnbaled); + int32_t ret = dataSwitchSettings_->QueryAnySimDetectedStatus( + static_cast(DataSimDetectedCode::SIM_DETECTED_DISABLED)); const int32_t defSlotId = CoreManagerInner::GetInstance().GetDefaultCellularDataSlotId(); - if (ret == TELEPHONY_ERR_SUCCESS && defSlotId != slotId_) { + if (ret == TELEPHONY_ERR_SUCCESS || defSlotId != slotId_) { return; } OperatorConfig config; - CoreManagerInner::GetInstance().GetOperatorConfigs(slotId_, config); - if (config.boolValue.find(KEY_DEFAULT_DATA_ENABLE_BOOL) != config.boolValue.end()) { - dataEnbaled = config.boolValue[KEY_DEFAULT_DATA_ENABLE_BOOL]; - TELEPHONY_LOGI("Slot%{public}d: OperatorConfig dataEnable_ = %{public}d", slotId_, dataEnbaled); - dataSwitchSettings_->SetUserDataOn(dataEnbaled); + if (ret == TELEPHONY_ERR_DATABASE_READ_EMPTY) { + CoreManagerInner::GetInstance().GetOperatorConfigs(slotId_, config); + if (config.boolValue.find(KEY_DEFAULT_DATA_ENABLE_BOOL) != config.boolValue.end()) { + dataEnbaled = config.boolValue[KEY_DEFAULT_DATA_ENABLE_BOOL]; + TELEPHONY_LOGI("Slot%{public}d: OperatorConfig dataEnable_ = %{public}d", slotId_, dataEnbaled); + dataSwitchSettings_->SetUserDataOn(dataEnbaled); + } + dataSwitchSettings_->SetAnySimDetected(static_cast(DataSimDetectedCode::SIM_DETECTED_ENABLED)); } } @@ -2221,6 +2274,7 @@ void CellularDataHandler::SetRilLinkBandwidths() void CellularDataHandler::HandleDBSettingEnableChanged(const AppExecFwk::InnerEvent::Pointer &event) { + TELEPHONY_LOGI("Slot%{public}d: HandleDBSettingEnableChanged enter.", slotId_); if (dataSwitchSettings_ == nullptr) { TELEPHONY_LOGE("Slot%{public}d: dataSwitchSettings_ is null.", slotId_); return; @@ -2229,9 +2283,14 @@ void CellularDataHandler::HandleDBSettingEnableChanged(const AppExecFwk::InnerEv dataSwitchSettings_->QueryUserDataStatus(dataEnabled); CoreManagerInner &coreInner = CoreManagerInner::GetInstance(); const int32_t defSlotId = coreInner.GetDefaultCellularDataSlotId(); + std::string dataPolicy = system::GetParameter(PERSIST_EDM_MOBILE_DATA_POLICY, ""); if (dataEnabled && defSlotId == slotId_) { EstablishAllApnsIfConnectable(); } else { + if (dataPolicy == MOBILE_DATA_POLICY_FORCE_OPEN) { + TELEPHONY_LOGE("Slot%{public}d: policy is force_open, not allow clear connections", slotId_); + return; + } ClearAllConnections(DisConnectionReason::REASON_CLEAR_CONNECTION); } } @@ -2247,6 +2306,8 @@ void CellularDataHandler::HandleDBSettingRoamingChanged(const AppExecFwk::InnerE if (CoreManagerInner::GetInstance().GetPsRoamingState(slotId_) > 0) { roamingState = true; } + TELEPHONY_LOGI("Slot%{public}d: roamingState%{public}d, dataRoamingEnabled%{public}d.", + slotId_, roamingState, dataRoamingEnabled); if (roamingState) { if (dataRoamingEnabled) { EstablishAllApnsIfConnectable(); @@ -2545,6 +2606,9 @@ void CellularDataHandler::ReleaseCellularDataConnection() return; } ClearConnection(apnHolder, DisConnectionReason::REASON_CLEAR_CONNECTION); +#ifdef OHOS_BUILD_ENABLE_TELEPHONY_EXT + NotifyReqCellularData(false); +#endif } bool CellularDataHandler::UpdateNetworkInfo() diff --git a/services/src/cellular_data_service.cpp b/services/src/cellular_data_service.cpp index 70ea8b1b55d2410172fa1e81977735c11b8a3051..d7b162c9d18e7cb37d871e91b3315de772ebefe8 100644 --- a/services/src/cellular_data_service.cpp +++ b/services/src/cellular_data_service.cpp @@ -38,6 +38,8 @@ namespace OHOS { namespace Telephony { using namespace NetManagerStandard; +constexpr const char *PERSIST_EDM_MOBILE_DATA_POLICY = "persist.edm.mobile_data_policy"; +constexpr const char *MOBILE_DATA_POLICY_FORCE_OPEN = "force_open"; bool g_registerResult = SystemAbility::MakeAndRegisterAbility(&DelayedRefSingleton::GetInstance()); CellularDataService::CellularDataService() : SystemAbility(TELEPHONY_CELLULAR_DATA_SYS_ABILITY_ID, true), registerToService_(false), @@ -106,7 +108,8 @@ int32_t CellularDataService::GetIntelligenceSwitchState(bool &switchState) return TELEPHONY_ERR_ILLEGAL_USE_OF_SYSTEM_API; } if (!TelephonyPermission::CheckPermission(Permission::GET_TELEPHONY_STATE)) { - int32_t slotId = CellularDataService::GetDefaultCellularDataSlotId(); + int32_t slotId; + CellularDataService::GetDefaultCellularDataSlotId(slotId); CellularDataHiSysEvent::WriteDataActivateFaultEvent( slotId, switchState, CellularDataErrorCode::DATA_ERROR_PERMISSION_ERROR, Permission::SET_TELEPHONY_STATE); return TELEPHONY_ERR_PERMISSION_ERR; @@ -168,7 +171,8 @@ int32_t CellularDataService::EnableCellularData(bool enable) return TELEPHONY_ERR_ILLEGAL_USE_OF_SYSTEM_API; } if (!TelephonyPermission::CheckPermission(Permission::SET_TELEPHONY_STATE)) { - int32_t slotId = CellularDataService::GetDefaultCellularDataSlotId(); + int32_t slotId; + CellularDataService::GetDefaultCellularDataSlotId(slotId); CellularDataHiSysEvent::WriteDataActivateFaultEvent( slotId, enable, CellularDataErrorCode::DATA_ERROR_PERMISSION_ERROR, Permission::SET_TELEPHONY_STATE); return TELEPHONY_ERR_PERMISSION_ERR; @@ -178,6 +182,11 @@ int32_t CellularDataService::EnableCellularData(bool enable) TELEPHONY_LOGE("cellularDataControllers is null, slotId=%{public}d", DEFAULT_SIM_SLOT_ID); return TELEPHONY_ERR_LOCAL_PTR_NULL; } + std::string dataPolicy = system::GetParameter(PERSIST_EDM_MOBILE_DATA_POLICY, ""); + if (dataPolicy == MOBILE_DATA_POLICY_FORCE_OPEN && !enable) { + TELEPHONY_LOGE("cellular data policy is force_open"); + return TELEPHONY_ERR_POLICY_DISABLED; + } return cellularDataController->SetCellularDataEnable(enable); } @@ -188,7 +197,8 @@ int32_t CellularDataService::EnableIntelligenceSwitch(bool enable) return TELEPHONY_ERR_ILLEGAL_USE_OF_SYSTEM_API; } if (!TelephonyPermission::CheckPermission(Permission::SET_TELEPHONY_STATE)) { - int32_t slotId = CellularDataService::GetDefaultCellularDataSlotId(); + int32_t slotId; + CellularDataService::GetDefaultCellularDataSlotId(slotId); CellularDataHiSysEvent::WriteDataActivateFaultEvent( slotId, enable, CellularDataErrorCode::DATA_ERROR_PERMISSION_ERROR, Permission::SET_TELEPHONY_STATE); return TELEPHONY_ERR_PERMISSION_ERR; @@ -201,9 +211,10 @@ int32_t CellularDataService::EnableIntelligenceSwitch(bool enable) return cellularDataController->SetIntelligenceSwitchEnable(enable); } -int32_t CellularDataService::GetCellularDataState() +int32_t CellularDataService::GetCellularDataState(int32_t &state) { - int32_t slotId = CellularDataService::GetDefaultCellularDataSlotId(); + int32_t slotId; + CellularDataService::GetDefaultCellularDataSlotId(slotId); #ifdef OHOS_BUILD_ENABLE_TELEPHONY_EXT if (TELEPHONY_EXT_WRAPPER.isVSimEnabled_ && TELEPHONY_EXT_WRAPPER.isVSimEnabled_()) { TELEPHONY_LOGI("VSimEnabled slotId: %{public}d => %{public}d", slotId, CELLULAR_DATA_VSIM_SLOT_ID); @@ -221,23 +232,23 @@ int32_t CellularDataService::GetCellularDataState() if (reason == DisConnectionReason::REASON_GSM_AND_CALLING_ONLY && cellularDataController->IsRestrictedMode()) { dataState = static_cast(DataConnectionStatus::DATA_STATE_SUSPENDED); } - return dataState; + state = dataState; + return TELEPHONY_ERR_SUCCESS; } -int32_t CellularDataService::GetApnState(int32_t slotId, const std::string &apnType) +int32_t CellularDataService::GetApnState(int32_t slotId, const std::string &apnType, int &state) { std::shared_ptr cellularDataController = GetCellularDataController(slotId); if (cellularDataController == nullptr) { TELEPHONY_LOGE("cellularDataControllers is null, slotId=%{public}d", slotId); return CELLULAR_DATA_INVALID_PARAM; } - int32_t apnState = static_cast(cellularDataController->GetCellularDataState(apnType)); - return apnState; + state = static_cast(cellularDataController->GetCellularDataState(apnType)); + return TELEPHONY_ERR_SUCCESS; } -int32_t CellularDataService::GetDataRecoveryState() +int32_t CellularDataService::GetDataRecoveryState(int32_t &state) { - int32_t state = 0; std::lock_guard guard(mapLock_); for (const auto &controller : cellularDataControllers_) { auto cellularDataController = controller.second; @@ -247,7 +258,7 @@ int32_t CellularDataService::GetDataRecoveryState() int32_t curState = cellularDataController->GetDataRecoveryState(); state = (curState > state) ? curState : state; } - return state; + return TELEPHONY_ERR_SUCCESS; } int32_t CellularDataService::IsCellularDataRoamingEnabled(const int32_t slotId, bool &dataRoamingEnabled) @@ -304,6 +315,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); @@ -477,9 +494,10 @@ int32_t CellularDataService::HandleApnChanged(const int32_t slotId) : static_cast(DataRespondCode::SET_FAILED); } -int32_t CellularDataService::GetDefaultCellularDataSlotId() +int32_t CellularDataService::GetDefaultCellularDataSlotId(int32_t &slotId) { - return CoreManagerInner::GetInstance().GetDefaultCellularDataSlotId(); + slotId = CoreManagerInner::GetInstance().GetDefaultCellularDataSlotId(); + return TELEPHONY_ERR_SUCCESS; } int32_t CellularDataService::GetDefaultCellularDataSimId(int32_t &simId) @@ -506,7 +524,8 @@ int32_t CellularDataService::SetDefaultCellularDataSlotId(const int32_t slotId) TELEPHONY_LOGE("sim is not active!"); return TELEPHONY_ERR_SLOTID_INVALID; } - int32_t formerSlotId = GetDefaultCellularDataSlotId(); + int32_t formerSlotId; + GetDefaultCellularDataSlotId(formerSlotId); if (formerSlotId < 0) { TELEPHONY_LOGI("No old card slot id."); } @@ -518,9 +537,10 @@ int32_t CellularDataService::SetDefaultCellularDataSlotId(const int32_t slotId) return TELEPHONY_ERR_SUCCESS; } -int32_t CellularDataService::GetCellularDataFlowType() +int32_t CellularDataService::GetCellularDataFlowType(int32_t &type) { - int32_t slotId = CellularDataService::GetDefaultCellularDataSlotId(); + int32_t slotId; + CellularDataService::GetDefaultCellularDataSlotId(slotId); std::shared_ptr cellularDataController = GetCellularDataController(slotId); if (cellularDataController == nullptr) { TELEPHONY_LOGE("cellularDataControllers is null, slotId=%{public}d", slotId); @@ -553,14 +573,17 @@ std::string CellularDataService::GetEndTime() std::string CellularDataService::GetCellularDataSlotIdDump() { std::ostringstream oss; - oss << "slotId:" << GetDefaultCellularDataSlotId(); + int32_t slotId; + GetDefaultCellularDataSlotId(slotId); + oss << "slotId:" << slotId; return oss.str(); } std::string CellularDataService::GetStateMachineCurrentStatusDump() { std::ostringstream oss; - int32_t slotId = GetDefaultCellularDataSlotId(); + int32_t slotId; + GetDefaultCellularDataSlotId(slotId); std::shared_ptr cellularDataController = GetCellularDataController(slotId); if (cellularDataController == nullptr) { oss << "default slotId: " << slotId; @@ -576,7 +599,8 @@ std::string CellularDataService::GetStateMachineCurrentStatusDump() std::string CellularDataService::GetFlowDataInfoDump() { std::ostringstream oss; - int32_t slotId = GetDefaultCellularDataSlotId(); + int32_t slotId; + GetDefaultCellularDataSlotId(slotId); std::shared_ptr cellularDataController = GetCellularDataController(slotId); if (cellularDataController == nullptr) { oss << "default slotId: " << slotId; @@ -601,7 +625,7 @@ int32_t CellularDataService::StrategySwitch(int32_t slotId, bool enable) return result; } -int32_t CellularDataService::HasInternetCapability(const int32_t slotId, const int32_t cid) +int32_t CellularDataService::HasInternetCapability(const int32_t slotId, const int32_t cid, int32_t &capability) { std::shared_ptr cellularDataController = GetCellularDataController(slotId); if (cellularDataController == nullptr) { @@ -609,8 +633,9 @@ int32_t CellularDataService::HasInternetCapability(const int32_t slotId, const i return CELLULAR_DATA_INVALID_PARAM; } bool result = cellularDataController->HasInternetCapability(cid); - return result ? static_cast(RequestNetCode::REQUEST_SUCCESS) - : static_cast(RequestNetCode::REQUEST_FAILED); + capability = result ? static_cast(RequestNetCode::REQUEST_SUCCESS) + : static_cast(RequestNetCode::REQUEST_FAILED); + return TELEPHONY_ERR_SUCCESS; } int32_t CellularDataService::ClearCellularDataConnections(const int32_t slotId) @@ -619,10 +644,10 @@ int32_t CellularDataService::ClearCellularDataConnections(const int32_t slotId) TELEPHONY_LOGE("Permission denied!"); return TELEPHONY_ERR_PERMISSION_ERR; } - return ClearAllConnections(slotId, DisConnectionReason::REASON_CLEAR_CONNECTION); + return ClearAllConnections(slotId, (int32_t) DisConnectionReason::REASON_CLEAR_CONNECTION); } -int32_t CellularDataService::ClearAllConnections(const int32_t slotId, DisConnectionReason reason) +int32_t CellularDataService::ClearAllConnections(const int32_t slotId, const int32_t reason) { if (!TelephonyPermission::CheckPermission(Permission::SET_TELEPHONY_STATE)) { TELEPHONY_LOGE("Permission denied!"); @@ -633,7 +658,7 @@ int32_t CellularDataService::ClearAllConnections(const int32_t slotId, DisConnec TELEPHONY_LOGE("cellularDataControllers is null, slotId=%{public}d", slotId); return CELLULAR_DATA_INVALID_PARAM; } - bool result = cellularDataController->ClearAllConnections(reason); + bool result = cellularDataController->ClearAllConnections((DisConnectionReason) reason); return result ? static_cast(RequestNetCode::REQUEST_SUCCESS) : static_cast(RequestNetCode::REQUEST_FAILED); } @@ -670,7 +695,7 @@ int32_t CellularDataService::UnregisterSimAccountCallback(const sptrGetDataConnApnAttr(apnAttr); + ApnItem::Attribute apn; + cellularDataController->GetDataConnApnAttr(apn); + ApnAttribute::TransferApnAttributeBeforeIpc(apn, apnAttr); return TELEPHONY_ERR_SUCCESS; } @@ -785,7 +812,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; } @@ -830,7 +857,8 @@ int32_t CellularDataService::GetIfSupportDunApn(bool &isSupportDun) TELEPHONY_LOGE("Permission denied!"); return TELEPHONY_ERR_PERMISSION_ERR; } - int32_t slotId = CellularDataService::GetDefaultCellularDataSlotId(); + int32_t slotId; + CellularDataService::GetDefaultCellularDataSlotId(slotId); auto cellularDataController = GetCellularDataController(slotId); if (cellularDataController == nullptr) { TELEPHONY_LOGE("cellularDataControllers is null, slotId=%{public}d", slotId); @@ -840,9 +868,9 @@ int32_t CellularDataService::GetIfSupportDunApn(bool &isSupportDun) return TELEPHONY_ERR_SUCCESS; } - -int32_t CellularDataService::GetDefaultActReportInfo(int32_t slotId, ApnActivateReportInfo &info) +int32_t CellularDataService::GetDefaultActReportInfo(int32_t slotId, ApnActivateReportInfoIpc &infoIpc) { + ApnActivateReportInfo info; if (!TelephonyPermission::CheckPermission(Permission::GET_TELEPHONY_STATE)) { TELEPHONY_LOGE("Permission denied!"); return TELEPHONY_ERR_PERMISSION_ERR; @@ -853,11 +881,13 @@ int32_t CellularDataService::GetDefaultActReportInfo(int32_t slotId, ApnActivate return CELLULAR_DATA_INVALID_PARAM; } bool result = cellularDataController->GetDefaultActReportInfo(info); + infoIpc = info; return result ? TELEPHONY_ERR_SUCCESS : TELEPHONY_ERR_FAIL; } -int32_t CellularDataService::GetInternalActReportInfo(int32_t slotId, ApnActivateReportInfo &info) +int32_t CellularDataService::GetInternalActReportInfo(int32_t slotId, ApnActivateReportInfoIpc &infoIpc) { + ApnActivateReportInfo info; if (!TelephonyPermission::CheckPermission(Permission::GET_TELEPHONY_STATE)) { TELEPHONY_LOGE("Permission denied!"); return TELEPHONY_ERR_PERMISSION_ERR; @@ -871,7 +901,7 @@ int32_t CellularDataService::GetInternalActReportInfo(int32_t slotId, ApnActivat return result ? TELEPHONY_ERR_SUCCESS : TELEPHONY_ERR_FAIL; } -int32_t CellularDataService::QueryApnIds(ApnInfo apnInfo, std::vector &apnIdList) +int32_t CellularDataService::QueryApnIds(const ApnInfo& apnInfo, std::vector &apnIdList) { if (!TelephonyPermission::CheckPermission(Permission::MANAGE_APN_SETTING)) { TELEPHONY_LOGE("Permission denied!"); @@ -917,5 +947,35 @@ int32_t CellularDataService::QueryAllApnInfo(std::vector &allApnInfoLis helper->QueryAllApnInfo(allApnInfoList); return 0; } + +int32_t CellularDataService::SendUrspDecodeResult(int32_t slotId, const std::vector& buffer) +{ + int32_t eventid = static_cast(CellularDataEventCode::MSG_SEND_UEPOLICY_COMMAND_REJECT); + return CoreManagerInner::GetInstance().SendUrspDecodeResult(slotId, buffer, eventid); +} + +int32_t CellularDataService::SendUePolicySectionIdentifier(int32_t slotId, const std::vector& buffer) +{ + int32_t eventid = static_cast(CellularDataEventCode::MSG_SEND_UE_STATE_INDICATION); + return CoreManagerInner::GetInstance().SendUePolicySectionIdentifier(slotId, buffer, eventid); +} + +int32_t CellularDataService::SendImsRsdList(int32_t slotId, const std::vector& buffer) +{ + int32_t eventid = static_cast(CellularDataEventCode::MSG_SEND_IMS_RSDLIST); + return CoreManagerInner::GetInstance().SendImsRsdList(slotId, buffer, eventid); +} + +int32_t CellularDataService::GetNetworkSliceAllowedNssai(int32_t slotId, const 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 deleted file mode 100644 index 4a616802b47819a4bdf33f0e2c709b2f0aa7b853..0000000000000000000000000000000000000000 --- a/services/src/cellular_data_service_stub.cpp +++ /dev/null @@ -1,582 +0,0 @@ -/* - * Copyright (C) 2021 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "cellular_data_service_stub.h" - -#include - -#include "cellular_data_controller.h" -#include "cellular_data_service.h" -#include "ipc_skeleton.h" -#include "sim_account_callback_proxy.h" -#include "telephony_errors.h" -#include "telephony_log_wrapper.h" - -#ifdef HICOLLIE_ENABLE -#include "xcollie/xcollie.h" -#include "xcollie/xcollie_define.h" -#define XCOLLIE_TIMEOUT_SECONDS 30 -#endif - -namespace OHOS { -namespace Telephony { -CellularDataServiceStub::CellularDataServiceStub() = default; - -CellularDataServiceStub::~CellularDataServiceStub() = default; - -int32_t CellularDataServiceStub::OnRemoteRequest( - uint32_t code, MessageParcel &data, MessageParcel &reply, MessageOption &option) -{ - std::u16string myDescriptor = CellularDataServiceStub::GetDescriptor(); - std::u16string remoteDescriptor = data.ReadInterfaceToken(); - // NetManager has no transport description - if (myDescriptor != remoteDescriptor) { - TELEPHONY_LOGE("descriptor check fail!"); - return TELEPHONY_ERR_DESCRIPTOR_MISMATCH; - } - std::map::iterator it = eventIdFunMap_.find(code); - if (it != eventIdFunMap_.end()) { - if (it->second != nullptr) { - int32_t idTimer = SetTimer(code); - int32_t result = it->second(data, reply); - CancelTimer(idTimer); - return result; - } - } else { - TELEPHONY_LOGE("event code is not exist"); - } - return IPCObjectStub::OnRemoteRequest(code, data, reply, option); -} - -int32_t CellularDataServiceStub::SetTimer(uint32_t code) -{ -#ifdef HICOLLIE_ENABLE - int32_t idTimer = HiviewDFX::INVALID_ID; - std::map::iterator itCollieId = collieCodeStringMap_.find(code); - if (itCollieId != collieCodeStringMap_.end()) { - std::string collieStr = itCollieId->second; - std::string collieName = "CellularDataServiceStub: " + collieStr; - unsigned int flag = HiviewDFX::XCOLLIE_FLAG_NOOP; - auto TimerCallback = [collieStr](void *) { - TELEPHONY_LOGE("OnRemoteRequest timeout func: %{public}s", collieStr.c_str()); - }; - idTimer = HiviewDFX::XCollie::GetInstance().SetTimer( - collieName, XCOLLIE_TIMEOUT_SECONDS, TimerCallback, nullptr, flag); - TELEPHONY_LOGD("SetTimer id: %{public}d, name: %{public}s.", idTimer, collieStr.c_str()); - } - return idTimer; -#else - TELEPHONY_LOGD("No HICOLLIE_ENABLE"); - return -1; -#endif -} - -void CellularDataServiceStub::CancelTimer(int32_t id) -{ -#ifdef HICOLLIE_ENABLE - if (id == HiviewDFX::INVALID_ID) { - return; - } - TELEPHONY_LOGD("CancelTimer id: %{public}d.", id); - HiviewDFX::XCollie::GetInstance().CancelTimer(id); -#else - return; -#endif -} - -int32_t CellularDataServiceStub::OnIsCellularDataEnabled(MessageParcel &data, MessageParcel &reply) -{ - bool dataEnabled = false; - int32_t result = IsCellularDataEnabled(dataEnabled); - if (!reply.WriteInt32(result)) { - TELEPHONY_LOGE("write int32 reply failed."); - return TELEPHONY_ERR_WRITE_REPLY_FAIL; - } - if (result != TELEPHONY_ERR_SUCCESS) { - return result; - } - if (!reply.WriteBool(dataEnabled)) { - TELEPHONY_LOGE("write bool reply failed."); - return TELEPHONY_ERR_WRITE_REPLY_FAIL; - } - return TELEPHONY_SUCCESS; -} - -int32_t CellularDataServiceStub::OnEnableCellularData(MessageParcel &data, MessageParcel &reply) -{ - bool enable = data.ReadBool(); - int32_t result = EnableCellularData(enable); - if (!reply.WriteInt32(result)) { - TELEPHONY_LOGE("fail to write parcel"); - return TELEPHONY_ERR_WRITE_REPLY_FAIL; - } - return result; -} - -int32_t CellularDataServiceStub::OnEnableIntelligenceSwitch(MessageParcel &data, MessageParcel &reply) -{ - bool enable = data.ReadBool(); - int32_t result = EnableIntelligenceSwitch(enable); - if (!reply.WriteInt32(result)) { - TELEPHONY_LOGE("fail to write parcel"); - return TELEPHONY_ERR_WRITE_REPLY_FAIL; - } - return result; -} - -int32_t CellularDataServiceStub::OnGetCellularDataState(MessageParcel &data, MessageParcel &reply) -{ - int32_t result = GetCellularDataState(); - if (!reply.WriteInt32(result)) { - TELEPHONY_LOGE("fail to write parcel"); - return TELEPHONY_ERR_WRITE_REPLY_FAIL; - } - return result; -} - -int32_t CellularDataServiceStub::OnIsCellularDataRoamingEnabled(MessageParcel &data, MessageParcel &reply) -{ - int32_t slotId = data.ReadInt32(); - bool dataRoamingEnabled = false; - int32_t result = IsCellularDataRoamingEnabled(slotId, dataRoamingEnabled); - if (!reply.WriteInt32(result)) { - TELEPHONY_LOGE("write int32 reply failed."); - return TELEPHONY_ERR_WRITE_REPLY_FAIL; - } - if (result != TELEPHONY_ERR_SUCCESS) { - return result; - } - if (!reply.WriteBool(dataRoamingEnabled)) { - TELEPHONY_LOGE("write bool reply failed."); - return TELEPHONY_ERR_WRITE_REPLY_FAIL; - } - - return TELEPHONY_SUCCESS; -} - -int32_t CellularDataServiceStub::OnEnableCellularDataRoaming(MessageParcel &data, MessageParcel &reply) -{ - int32_t slotId = data.ReadInt32(); - bool enable = data.ReadBool(); - int32_t result = EnableCellularDataRoaming(slotId, enable); - if (!reply.WriteInt32(result)) { - TELEPHONY_LOGE("fail to write parcel"); - return TELEPHONY_ERR_WRITE_REPLY_FAIL; - } - return result; -} - -int32_t CellularDataServiceStub::OnGetIntelligenceSwitchState(MessageParcel &data, MessageParcel &reply) -{ - bool switchState = false; - int32_t result = GetIntelligenceSwitchState(switchState); - if (!reply.WriteInt32(result)) { - TELEPHONY_LOGE("write int32 reply failed."); - return TELEPHONY_ERR_WRITE_REPLY_FAIL; - } - if (result != TELEPHONY_ERR_SUCCESS) { - return result; - } - if (!reply.WriteBool(switchState)) { - TELEPHONY_LOGE("write bool reply failed."); - return TELEPHONY_ERR_WRITE_REPLY_FAIL; - } - return TELEPHONY_SUCCESS; -} - -int32_t CellularDataServiceStub::OnHandleApnChanged(MessageParcel &data, MessageParcel &reply) -{ - int32_t slotId = data.ReadInt32(); - int32_t result = HandleApnChanged(slotId); - if (!reply.WriteInt32(result)) { - TELEPHONY_LOGE("fail to write parcel"); - return TELEPHONY_ERR_WRITE_REPLY_FAIL; - } - return result; -} - -int32_t CellularDataServiceStub::OnGetDefaultCellularDataSlotId(MessageParcel &data, MessageParcel &reply) -{ - int32_t result = GetDefaultCellularDataSlotId(); - if (!reply.WriteInt32(result)) { - TELEPHONY_LOGE("fail to write parcel"); - return TELEPHONY_ERR_WRITE_REPLY_FAIL; - } - return result; -} - -int32_t CellularDataServiceStub::OnGetDefaultCellularDataSimId(MessageParcel &data, MessageParcel &reply) -{ - int32_t simId = 0; - int32_t result = GetDefaultCellularDataSimId(simId); - if (!reply.WriteInt32(result)) { - TELEPHONY_LOGE("write int32 reply failed."); - return TELEPHONY_ERR_WRITE_REPLY_FAIL; - } - if (result != TELEPHONY_ERR_SUCCESS) { - return result; - } - if (!reply.WriteInt32(simId)) { - TELEPHONY_LOGE("write int32 reply failed."); - return TELEPHONY_ERR_WRITE_REPLY_FAIL; - } - return TELEPHONY_SUCCESS; -} - -int32_t CellularDataServiceStub::OnSetDefaultCellularDataSlotId(MessageParcel &data, MessageParcel &reply) -{ - int32_t slotId = data.ReadInt32(); - int32_t result = SetDefaultCellularDataSlotId(slotId); - if (!reply.WriteInt32(result)) { - TELEPHONY_LOGE("fail to write parcel"); - return TELEPHONY_ERR_WRITE_REPLY_FAIL; - } - return result; -} - -int32_t CellularDataServiceStub::OnGetCellularDataFlowType(MessageParcel &data, MessageParcel &reply) -{ - int32_t result = GetCellularDataFlowType(); - if (!reply.WriteInt32(result)) { - TELEPHONY_LOGE("fail to write parcel"); - return TELEPHONY_ERR_WRITE_REPLY_FAIL; - } - return result; -} - -int32_t CellularDataServiceStub::OnHasInternetCapability(MessageParcel &data, MessageParcel &reply) -{ - int32_t slotId = data.ReadInt32(); - int32_t cid = data.ReadInt32(); - int32_t result = HasInternetCapability(slotId, cid); - if (!reply.WriteInt32(result)) { - TELEPHONY_LOGE("fail to write parcel"); - return TELEPHONY_ERR_WRITE_REPLY_FAIL; - } - return result; -} - -int32_t CellularDataServiceStub::OnClearCellularDataConnections(MessageParcel &data, MessageParcel &reply) -{ - int32_t slotId = data.ReadInt32(); - int32_t result = ClearCellularDataConnections(slotId); - if (!reply.WriteInt32(result)) { - TELEPHONY_LOGE("fail to write parcel"); - return TELEPHONY_ERR_WRITE_REPLY_FAIL; - } - return result; -} - -int32_t CellularDataServiceStub::OnClearAllConnections(MessageParcel &data, MessageParcel &reply) -{ - int32_t slotId = data.ReadInt32(); - DisConnectionReason reason = static_cast(data.ReadInt32()); - int32_t result = ClearAllConnections(slotId, reason); - if (!reply.WriteInt32(result)) { - TELEPHONY_LOGE("fail to write parcel"); - return TELEPHONY_ERR_WRITE_REPLY_FAIL; - } - return result; -} - -int32_t CellularDataServiceStub::OnRegisterSimAccountCallback(MessageParcel &data, MessageParcel &reply) -{ - sptr callback = iface_cast(data.ReadRemoteObject()); - int32_t result; - if (callback == nullptr) { - TELEPHONY_LOGE("callback is nullptr!"); - result = TELEPHONY_ERR_ARGUMENT_NULL; - } else { - result = RegisterSimAccountCallback(callback); - } - reply.WriteInt32(result); - return result; -} - -int32_t CellularDataServiceStub::OnUnregisterSimAccountCallback(MessageParcel &data, MessageParcel &reply) -{ - sptr callback = iface_cast(data.ReadRemoteObject()); - int32_t result; - if (callback == nullptr) { - TELEPHONY_LOGE("callback is nullptr!"); - result = TELEPHONY_ERR_ARGUMENT_NULL; - } else { - result = UnregisterSimAccountCallback(callback); - } - reply.WriteInt32(result); - return result; -} - -int32_t CellularDataServiceStub::OnGetDataConnApnAttr(MessageParcel &data, MessageParcel &reply) -{ - int32_t slotId = data.ReadInt32(); - ApnItem::Attribute apnAttr; - int32_t result = GetDataConnApnAttr(slotId, apnAttr); - if (!reply.WriteInt32(result)) { - TELEPHONY_LOGE("write int32 reply failed."); - return TELEPHONY_ERR_WRITE_REPLY_FAIL; - } - if (!reply.WriteRawData(&apnAttr, sizeof(ApnItem::Attribute))) { - TELEPHONY_LOGE("write apnAttr reply failed."); - return TELEPHONY_ERR_WRITE_REPLY_FAIL; - } - return TELEPHONY_SUCCESS; -} - -int32_t CellularDataServiceStub::OnGetDataConnIpType(MessageParcel &data, MessageParcel &reply) -{ - int32_t slotId = data.ReadInt32(); - std::string ipType; - int32_t result = GetDataConnIpType(slotId, ipType); - if (!reply.WriteInt32(result)) { - TELEPHONY_LOGE("write int32 reply failed."); - return TELEPHONY_ERR_WRITE_REPLY_FAIL; - } - if (!reply.WriteString(ipType)) { - TELEPHONY_LOGE("write int32 reply failed."); - return TELEPHONY_ERR_WRITE_REPLY_FAIL; - } - return TELEPHONY_SUCCESS; -} - -int32_t CellularDataServiceStub::OnGetApnState(MessageParcel &data, MessageParcel &reply) -{ - int32_t slotId = data.ReadInt32(); - std::string apnType = data.ReadString(); - int32_t result = GetApnState(slotId, apnType); - if (!reply.WriteInt32(result)) { - TELEPHONY_LOGE("fail to write parcel"); - return TELEPHONY_ERR_WRITE_REPLY_FAIL; - } - return result; -} - -int32_t CellularDataServiceStub::OnGetRecoveryState(MessageParcel &data, MessageParcel &reply) -{ - int32_t result = GetDataRecoveryState(); - if (!reply.WriteInt32(result)) { - TELEPHONY_LOGE("fail to write parcel"); - return TELEPHONY_ERR_WRITE_REPLY_FAIL; - } - return result; -} - -int32_t CellularDataServiceStub::OnIsNeedDoRecovery(MessageParcel &data, MessageParcel &reply) -{ - int32_t slotId = data.ReadInt32(); - int32_t needDoRecovery = data.ReadBool(); - int32_t result = IsNeedDoRecovery(slotId, needDoRecovery); - if (!reply.WriteInt32(result)) { - TELEPHONY_LOGE("write int32 reply failed."); - return TELEPHONY_ERR_WRITE_REPLY_FAIL; - } - return result; -} - -int32_t CellularDataServiceStub::OnInitCellularDataController(MessageParcel &data, MessageParcel &reply) -{ - int32_t slotId = data.ReadInt32(); - int32_t result = InitCellularDataController(slotId); - if (!reply.WriteInt32(result)) { - TELEPHONY_LOGE("write int32 reply failed."); - return TELEPHONY_ERR_WRITE_REPLY_FAIL; - } - return result; -} - -int32_t CellularDataServiceStub::OnEstablishAllApnsIfConnectable(MessageParcel &data, MessageParcel &reply) -{ - int32_t slotId = data.ReadInt32(); - int32_t result = EstablishAllApnsIfConnectable(slotId); - if (!reply.WriteInt32(result)) { - TELEPHONY_LOGE("fail to write parcel"); - return TELEPHONY_ERR_WRITE_REPLY_FAIL; - } - return result; -} - -int32_t CellularDataServiceStub::OnReleaseCellularDataConnection(MessageParcel &data, MessageParcel &reply) -{ - int32_t slotId; - if (!data.ReadInt32(slotId)) { - TELEPHONY_LOGE("write int32 slotId failed."); - return TELEPHONY_ERR_READ_DATA_FAIL; - } - int32_t result = ReleaseCellularDataConnection(slotId); - if (!reply.WriteInt32(result)) { - TELEPHONY_LOGE("write int32 reply failed."); - return TELEPHONY_ERR_WRITE_REPLY_FAIL; - } - return result; -} - -int32_t CellularDataServiceStub::OnGetCellularDataSupplierId(MessageParcel &data, MessageParcel &reply) -{ - int32_t slotId = data.ReadInt32(); - uint64_t capability = data.ReadUint64(); - uint32_t supplierId = 0; - int32_t result = GetCellularDataSupplierId(slotId, capability, supplierId); - if (!reply.WriteInt32(result)) { - TELEPHONY_LOGE("write int32 reply failed."); - return TELEPHONY_ERR_WRITE_REPLY_FAIL; - } - if (!reply.WriteUint32(supplierId)) { - TELEPHONY_LOGE("write uint32 reply failed."); - return TELEPHONY_ERR_WRITE_REPLY_FAIL; - } - return result; -} - -int32_t CellularDataServiceStub::OnCorrectNetSupplierNoAvailable(MessageParcel &data, MessageParcel &reply) -{ - int32_t slotId = data.ReadInt32(); - int32_t result = CorrectNetSupplierNoAvailable(slotId); - if (!reply.WriteInt32(result)) { - TELEPHONY_LOGE("write int32 reply failed."); - return TELEPHONY_ERR_WRITE_REPLY_FAIL; - } - return result; -} - -int32_t CellularDataServiceStub::OnGetSupplierRegisterState(MessageParcel &data, MessageParcel &reply) -{ - uint32_t supplierId = data.ReadUint32(); - int32_t regState = -1; - int32_t result = GetSupplierRegisterState(supplierId, regState); - if (!reply.WriteInt32(result)) { - TELEPHONY_LOGE("write int32 reply failed."); - return TELEPHONY_ERR_WRITE_REPLY_FAIL; - } - if (!reply.WriteInt32(regState)) { - TELEPHONY_LOGE("write int32 reply failed."); - return TELEPHONY_ERR_WRITE_REPLY_FAIL; - } - return result; -} - -int32_t CellularDataServiceStub::OnIsSupportDunApn(MessageParcel &data, MessageParcel &reply) -{ - bool isSupportDun = false; - int32_t result = GetIfSupportDunApn(isSupportDun); - if (!reply.WriteInt32(result)) { - TELEPHONY_LOGE("fail to write parcel"); - return TELEPHONY_ERR_WRITE_REPLY_FAIL; - } - if (!reply.WriteBool(isSupportDun)) { - TELEPHONY_LOGE("fail to write parcel"); - return TELEPHONY_ERR_WRITE_REPLY_FAIL; - } - return result; -} - -int32_t CellularDataServiceStub::OnGetDefaultActReportInfo(MessageParcel &data, MessageParcel &reply) -{ - int32_t slotId = data.ReadInt32(); - ApnActivateReportInfo info; - int32_t result = GetDefaultActReportInfo(slotId, info); - if (!reply.WriteInt32(result)) { - TELEPHONY_LOGE("OnGetDefaultActReportInfo write int32 reply failed."); - return TELEPHONY_ERR_WRITE_REPLY_FAIL; - } - reply.WriteInt32(info.actTimes); - reply.WriteInt32(info.averDuration); - reply.WriteInt32(info.topReason); - reply.WriteInt32(info.actSuccTimes); - return result; -} - -int32_t CellularDataServiceStub::OnGetInternalActReportInfo(MessageParcel &data, MessageParcel &reply) -{ - int32_t slotId = data.ReadInt32(); - ApnActivateReportInfo info; - int32_t result = GetInternalActReportInfo(slotId, info); - if (!reply.WriteInt32(result)) { - TELEPHONY_LOGE("OnGetInternalActReportInfo write int32 reply failed."); - return TELEPHONY_ERR_WRITE_REPLY_FAIL; - } - reply.WriteInt32(info.actTimes); - reply.WriteInt32(info.averDuration); - reply.WriteInt32(info.topReason); - reply.WriteInt32(info.actSuccTimes); - return result; -} - -int32_t CellularDataServiceStub::OnQueryApnInfo(MessageParcel &data, MessageParcel &reply) -{ - ApnInfo info; - info.apnName = data.ReadString16(); - info.apn = data.ReadString16(); - info.mcc = data.ReadString16(); - info.mnc = data.ReadString16(); - info.user = data.ReadString16(); - info.type = data.ReadString16(); - info.proxy = data.ReadString16(); - info.mmsproxy = data.ReadString16(); - std::vector apnIdList; - int32_t result = QueryApnIds(info, apnIdList); - int32_t size = static_cast(apnIdList.size()); - bool ret = reply.WriteInt32(result); - ret = (ret && reply.WriteInt32(size)); - if (!ret) { - TELEPHONY_LOGE("OnQueryApnInfo write reply failed."); - return TELEPHONY_ERR_WRITE_REPLY_FAIL; - } - std::vector::iterator it = apnIdList.begin(); - while (it != apnIdList.end()) { - TELEPHONY_LOGI("OnQueryApnInfo slotIndex = %{public}d", (*it)); - if (!reply.WriteInt32(*it)) { - TELEPHONY_LOGE("OnQueryApnInfo IccAccountInfo reply Marshalling is false"); - return TELEPHONY_ERR_WRITE_REPLY_FAIL; - } - ++it; - } - return 0; -} - -int32_t CellularDataServiceStub::OnSetPreferApn(MessageParcel &data, MessageParcel &reply) -{ - int32_t apnId = data.ReadInt32(); - int32_t result = SetPreferApn(apnId); - if (!reply.WriteInt32(result)) { - TELEPHONY_LOGE("fail to write parcel"); - return TELEPHONY_ERR_WRITE_REPLY_FAIL; - } - return result; -} - -int32_t CellularDataServiceStub::OnQueryAllApnInfo(MessageParcel &data, MessageParcel &reply) -{ - std::vector allApnInfoList; - int32_t result = QueryAllApnInfo(allApnInfoList); - int32_t size = static_cast(allApnInfoList.size()); - bool ret = reply.WriteInt32(result); - ret = (ret && reply.WriteInt32(size)); - if (!ret) { - TELEPHONY_LOGE("OnQueryAllApnInfo write reply failed."); - return TELEPHONY_ERR_WRITE_REPLY_FAIL; - } - std::vector::iterator it = allApnInfoList.begin(); - while (it != allApnInfoList.end()) { - TELEPHONY_LOGI("OnQueryAllApnInfo apn = %{public}s", Str16ToStr8((*it).apn).c_str()); - if (!(*it).Marshalling(reply)) { - TELEPHONY_LOGE("OnQueryAllApnInfo ApnInfo reply Marshalling is false"); - return TELEPHONY_ERR_WRITE_REPLY_FAIL; - } - ++it; - } - return 0; -} -} // 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/data_connection_monitor.cpp b/services/src/data_connection_monitor.cpp index 7bfd56494ea1656d530c2e9d9ce357a5c6cd23cd..837978e610fd5d9f5f1130885c744c874b808d3a 100644 --- a/services/src/data_connection_monitor.cpp +++ b/services/src/data_connection_monitor.cpp @@ -25,7 +25,8 @@ #include "cellular_data_types.h" #include "cellular_data_constant.h" #include "data_service_ext_wrapper.h" - +#include "telephony_ext_wrapper.h" + #ifdef ABILITY_POWER_SUPPORT #include "power_mgr_client.h" #endif @@ -47,10 +48,28 @@ void DataConnectionMonitor::HandleScreenStateChanged(bool isScreenOn) return; } isScreenOn_ = isScreenOn; + const int32_t defSlotId = CoreManagerInner::GetInstance().GetDefaultCellularDataSlotId(); + if (slotId_ != defSlotId && !IsVsimEnabled()) { + return; + } StopStallDetectionTimer(); StartStallDetectionTimer(); } +bool DataConnectionMonitor::IsVsimEnabled() +{ +#ifdef OHOS_BUILD_ENABLE_TELEPHONY_EXT + if (TELEPHONY_EXT_WRAPPER.getVSimSlotId_ && TELEPHONY_EXT_WRAPPER.isVSimEnabled_) { + int vSimSlotId = INVALID_SLOT_ID; + TELEPHONY_EXT_WRAPPER.getVSimSlotId_(vSimSlotId); + if (vSimSlotId == slotId_ && TELEPHONY_EXT_WRAPPER.isVSimEnabled_()) { + return true; + } + } +#endif + return false; +} + bool DataConnectionMonitor::IsAggressiveRecovery() { return (dataRecoveryState_ == RecoveryState::STATE_CLEANUP_CONNECTIONS) || @@ -154,7 +173,7 @@ void DataConnectionMonitor::HandleRecovery() TELEPHONY_LOGI("Slot%{public}d: Handle Recovery: cleanup connections", slotId_); dataRecoveryState_ = RecoveryState::STATE_REREGISTER_NETWORK; int32_t ret = DelayedRefSingleton::GetInstance().ClearAllConnections( - slotId_, DisConnectionReason::REASON_RETRY_CONNECTION); + slotId_, (int32_t) DisConnectionReason::REASON_RETRY_CONNECTION); if (ret != static_cast(RequestNetCode::REQUEST_SUCCESS)) { TELEPHONY_LOGE("Slot%{public}d: Handle Recovery: cleanup connections failed", slotId_); } @@ -170,7 +189,7 @@ void DataConnectionMonitor::HandleRecovery() TELEPHONY_LOGI("Slot%{public}d: Handle Recovery: radio restart", slotId_); dataRecoveryState_ = RecoveryState::STATE_REQUEST_CONTEXT_LIST; int32_t ret = DelayedRefSingleton::GetInstance().ClearAllConnections( - slotId_, DisConnectionReason::REASON_RETRY_CONNECTION); + slotId_, (int32_t)DisConnectionReason::REASON_RETRY_CONNECTION); if (ret != static_cast(RequestNetCode::REQUEST_SUCCESS)) { TELEPHONY_LOGE("Slot%{public}d: Handle Recovery: radio restart cleanup connections failed", slotId_); } diff --git a/services/src/data_switch_settings.cpp b/services/src/data_switch_settings.cpp index 787e9687601cf51711afdf941fbd5c7014b931d8..6fd1a186859973b855beef34de22e74eef29707e 100644 --- a/services/src/data_switch_settings.cpp +++ b/services/src/data_switch_settings.cpp @@ -69,6 +69,19 @@ int32_t DataSwitchSettings::SetUserDataOn(bool userDataOn) return result; } +int32_t DataSwitchSettings::SetAnySimDetected(int32_t simDetected) +{ + std::shared_ptr settingsRdbHelper = CellularDataSettingsRdbHelper::GetInstance(); + if (settingsRdbHelper == nullptr) { + TELEPHONY_LOGE("settingsRdbHelper == nullptr!"); + return TELEPHONY_ERR_LOCAL_PTR_NULL; + } + Uri anySimDetectedUri(CELLULAR_DATA_SETTING_ANY_SIM_DETECTED_URI); + int32_t result = settingsRdbHelper->PutValue(anySimDetectedUri, SIM_DETECTED_COLUMN_ENABLE, simDetected); + TELEPHONY_LOGI("DataSwitchSettings::SetAnySimDetected result:%{public}d", result); + return result; +} + int32_t DataSwitchSettings::SetIntelliSwitchOn(bool userSwitchOn) { std::shared_ptr settingsRdbHelper = CellularDataSettingsRdbHelper::GetInstance(); @@ -112,6 +125,19 @@ int32_t DataSwitchSettings::QueryUserDataStatus(bool &dataEnabled) return TELEPHONY_ERR_SUCCESS; } +int32_t DataSwitchSettings::QueryAnySimDetectedStatus(int32_t simDetected) +{ + std::shared_ptr settingsRdbHelper = CellularDataSettingsRdbHelper::GetInstance(); + if (settingsRdbHelper == nullptr) { + TELEPHONY_LOGE("settingsRdbHelper is nullptr!"); + return TELEPHONY_ERR_LOCAL_PTR_NULL; + } + Uri anySimDetectedUri(CELLULAR_DATA_SETTING_ANY_SIM_DETECTED_URI); + int32_t ret = settingsRdbHelper->GetValue(anySimDetectedUri, SIM_DETECTED_COLUMN_ENABLE, simDetected); + TELEPHONY_LOGI("DataSwitchSettings::QueryAnySimDetectedStatus ret:%{public}d", ret); + return ret; +} + int32_t DataSwitchSettings::QueryIntelligenceSwitchStatus(bool &switchEnabled) { std::shared_ptr settingsRdbHelper = CellularDataSettingsRdbHelper::GetInstance(); diff --git a/services/src/state_machine/active.cpp b/services/src/state_machine/active.cpp index a1929fec49e12446f065024749ff617f1ff9862d..d73323fc15db406f7b33a62e6fdc1ba909d43df9 100644 --- a/services/src/state_machine/active.cpp +++ b/services/src/state_machine/active.cpp @@ -118,6 +118,10 @@ bool Active::ProcessDisconnectAllDone(const AppExecFwk::InnerEvent::Pointer &eve TELEPHONY_LOGE("object is null"); return false; } + if (stateMachine->GetReuseApnCap() != NetManagerStandard::NetCap::NET_CAPABILITY_END) { + stateMachine->SetIfReuseSupplierId(false); + stateMachine->SetReuseApnCap(NetManagerStandard::NetCap::NET_CAPABILITY_END); + } DisConnectionReason reason = object->GetReason(); Inactive *inActive = static_cast(stateMachine->inActiveState_.GetRefPtr()); if (inActive == nullptr) { @@ -147,6 +151,10 @@ bool Active::ProcessLostConnection(const AppExecFwk::InnerEvent::Pointer &event) TELEPHONY_LOGE("stateMachine is null"); return false; } + if (stateMachine->GetReuseApnCap() != NetManagerStandard::NetCap::NET_CAPABILITY_END) { + stateMachine->SetIfReuseSupplierId(false); + stateMachine->SetReuseApnCap(NetManagerStandard::NetCap::NET_CAPABILITY_END); + } CellularDataHiSysEvent::WriteDataDeactiveBehaviorEvent(stateMachine->GetSlotId(), DataDisconnectCause::LOST_CONNECTION, ApnManager::FindApnNameByApnId(stateMachine->apnId_)); Inactive *inActive = static_cast(stateMachine->inActiveState_.GetRefPtr()); diff --git a/services/src/state_machine/cellular_data_state_machine.cpp b/services/src/state_machine/cellular_data_state_machine.cpp index 6c736099c6781ce99e17c4ca2c45e066a788edd0..ff58bb15c663880c0d93e61a122540f0973af2f6 100644 --- a/services/src/state_machine/cellular_data_state_machine.cpp +++ b/services/src/state_machine/cellular_data_state_machine.cpp @@ -17,6 +17,7 @@ #include #include +#include #include "activating.h" #include "active.h" @@ -30,11 +31,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 +97,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 +129,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 +500,77 @@ 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 = static_cast(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") { + int sscMode = 0; + std::from_chars(networkSliceParas["sscmode"].data(), networkSliceParas["sscmode"].data() + + networkSliceParas["sscmode"].size(), sscMode); + apn->attr_.sscMode_ = sscMode; + } + if (networkSliceParas["snssai"] != "") { + std::string snssai = networkSliceParas["snssai"]; + 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/state_machine/inactive.cpp b/services/src/state_machine/inactive.cpp index 3e212a0e89bbc57789fc860a111bffc0ceaddffd..4dfba4c3b5b45df42534e6e832dc3712701663db 100644 --- a/services/src/state_machine/inactive.cpp +++ b/services/src/state_machine/inactive.cpp @@ -88,7 +88,12 @@ bool Inactive::StateProcess(const AppExecFwk::InnerEvent::Pointer &event) switch (eventCode) { case CellularDataEventCode::MSG_SM_CONNECT: { TELEPHONY_LOGD("Inactive::MSG_SM_CONNECT"); - stateMachine->DoConnect(*(event->GetUniqueObject())); + std::unique_ptr params = event->GetUniqueObject(); + if (params == nullptr) { + TELEPHONY_LOGE("Failed to get DataConnectionParams"); + return false; + } + stateMachine->DoConnect(*params); stateMachine->TransitionTo(stateMachine->activatingState_); retVal = PROCESSED; break; diff --git a/services/src/state_machine/incall_data_state_machine.cpp b/services/src/state_machine/incall_data_state_machine.cpp index 5e27fd7227b26405dd705a8ec3a91feeb33f21e7..a623094fe817e019016dd4fb76d7e2f2adae512d 100644 --- a/services/src/state_machine/incall_data_state_machine.cpp +++ b/services/src/state_machine/incall_data_state_machine.cpp @@ -172,6 +172,21 @@ bool IncallDataStateMachine::IsSecondaryActiveState() const return currentState_ == activatingSecondaryState_ || currentState_ == activatedSecondaryState_; } +void IncallDataStateMachine::DeInit() +{ + idleState_ = nullptr; + secondaryActiveState_ = nullptr; + activatingSecondaryState_ = nullptr; + activatedSecondaryState_ = nullptr; + deactivatingSecondaryState_ = nullptr; + currentState_ = nullptr; + cellularDataHandler_.reset(); + apnManager_ = nullptr; + + slotId_ = INVALID_SLOT_ID; + callState_ = static_cast(TelCallStatus::CALL_STATUS_IDLE); +} + void IdleState::StateBegin() { TELEPHONY_LOGI("Enter Idle State"); 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/services/src/utils/cellular_data_rdb_helper.cpp b/services/src/utils/cellular_data_rdb_helper.cpp index 35fb258492c55197b974d93ac06557e11e55b386..d2958e1d000de546cabbb013a75511eef47598a2 100644 --- a/services/src/utils/cellular_data_rdb_helper.cpp +++ b/services/src/utils/cellular_data_rdb_helper.cpp @@ -100,7 +100,7 @@ bool CellularDataRdbHelper::QueryApns( DataShare::DataSharePredicates predicates; predicates.EqualTo(PdpProfileData::MCCMNC, mcc + mnc); int32_t simId = CoreManagerInner::GetInstance().GetSimId(slotId); - Uri cellularDataUri(std::string(CELLULAR_DATA_RDB_SELECTION) + "?Proxy=true&simId=" + std::to_string(simId)); + Uri cellularDataUri(std::string(CELLULAR_DATA_RDB_SELECTION) + "?simId=" + std::to_string(simId)); std::shared_ptr result = dataShareHelper->Query(cellularDataUri, predicates, columns); if (result == nullptr) { @@ -132,7 +132,7 @@ bool CellularDataRdbHelper::QueryMvnoApnsByType(const std::string &mcc, const st predicates.EqualTo(PdpProfileData::MVNO_TYPE, mvnoType) ->EqualTo(PdpProfileData::MCCMNC, mcc + mnc); int32_t simId = CoreManagerInner::GetInstance().GetSimId(slotId); - Uri cellularDataUri(std::string(CELLULAR_DATA_RDB_SELECTION) + "?Proxy=true&simId=" + std::to_string(simId)); + Uri cellularDataUri(std::string(CELLULAR_DATA_RDB_SELECTION) + "?simId=" + std::to_string(simId)); std::shared_ptr result = dataShareHelper->Query(cellularDataUri, predicates, columns); if (result == nullptr) { @@ -158,7 +158,7 @@ bool CellularDataRdbHelper::QueryPreferApn(int32_t slotId, std::vector columns; DataShare::DataSharePredicates predicates; int32_t simId = CoreManagerInner::GetInstance().GetSimId(slotId); - Uri preferApnUri(std::string(CELLULAR_DATA_RDB_PREFER) + "?Proxy=true&simId=" + std::to_string(simId)); + Uri preferApnUri(std::string(CELLULAR_DATA_RDB_PREFER) + "?simId=" + std::to_string(simId)); std::shared_ptr result = dataShareHelper->Query(preferApnUri, predicates, columns); if (result == nullptr) { TELEPHONY_LOGE("query prefer apns error"); @@ -170,12 +170,12 @@ bool CellularDataRdbHelper::QueryPreferApn(int32_t slotId, std::vectorClose(); dataShareHelper->Release(); - if (apnVec.size() > 0) { - return true; + if (apnVec.size() <= 0) { + TELEPHONY_LOGI("simid no set prefer apn"); + CellularDataHiSysEvent::WriteDataActivateFaultEvent(slotId, SWITCH_ON, + CellularDataErrorCode::DATA_ERROR_APN_FOUND_EMPTY, "Apn list is empty"); } - CellularDataHiSysEvent::WriteDataActivateFaultEvent(slotId, SWITCH_ON, - CellularDataErrorCode::DATA_ERROR_APN_FOUND_EMPTY, "Apn list is empty"); - return false; + return true; } void CellularDataRdbHelper::ReadApnResult( @@ -231,10 +231,13 @@ void CellularDataRdbHelper::MakePdpProfile( result->GetString(index, apnBean.mnc); result->GetColumnIndex(PdpProfileData::APN, index); result->GetString(index, apnBean.apn); - result->GetColumnIndex(PdpProfileData::AUTH_TYPE, index); - result->GetInt(index, apnBean.authType); result->GetColumnIndex(PdpProfileData::AUTH_USER, index); result->GetString(index, apnBean.authUser); + result->GetColumnIndex(PdpProfileData::AUTH_TYPE, index); + result->GetInt(index, apnBean.authType); + if (apnBean.authType == -1) { + apnBean.authType = (apnBean.authUser.empty()) ? SETUP_DATA_AUTH_NONE : SETUP_DATA_AUTH_PAP_CHAP; + } result->GetColumnIndex(PdpProfileData::AUTH_PWD, index); result->GetString(index, apnBean.authPwd); result->GetColumnIndex(PdpProfileData::APN_TYPES, index); @@ -257,6 +260,12 @@ void CellularDataRdbHelper::MakePdpProfile( if (apnBean.roamPdpProtocol.empty()) { apnBean.roamPdpProtocol = "IP"; } + result->GetColumnIndex(PdpProfileData::HOME_URL, index); + result->GetString(index, apnBean.homeUrl); + result->GetColumnIndex(PdpProfileData::MMS_IP_ADDRESS, index); + result->GetString(index, apnBean.mmsIpAddress); + result->GetColumnIndex(PdpProfileData::SERVER, index); + result->GetString(index, apnBean.server); } bool CellularDataRdbHelper::IsMvnoDataMatched(const std::string &mvnoDataFromSim, const PdpProfile &apnBean) @@ -371,7 +380,7 @@ void CellularDataRdbHelper::QueryApnIds(const ApnInfo &apnInfo, std::vector &apnInfoList) DataShare::DataSharePredicates predicates; std::string opkey = GetOpKey(CoreManagerInner::GetInstance().GetDefaultCellularDataSlotId()); predicates.EqualTo(Telephony::PdpProfileData::OPKEY, opkey); - Uri cellularDataUri(std::string(CELLULAR_DATA_RDB_SELECTION) + "?Proxy=true&simId=" + std::to_string(GetSimId())); + Uri cellularDataUri(std::string(CELLULAR_DATA_RDB_SELECTION) + "?simId=" + std::to_string(GetSimId())); std::shared_ptr result = dataShareHelper->Query(cellularDataUri, predicates, columns); if (result == nullptr) { diff --git a/services/src/utils/cellular_data_settings_rdb_helper.cpp b/services/src/utils/cellular_data_settings_rdb_helper.cpp index ce8e6c745126ade98a0b8b531f089af9e93cac37..ffaa7445c5bb96f1b07ba49847254a313330d033 100644 --- a/services/src/utils/cellular_data_settings_rdb_helper.cpp +++ b/services/src/utils/cellular_data_settings_rdb_helper.cpp @@ -121,7 +121,7 @@ int32_t CellularDataSettingsRdbHelper::GetValue(Uri &uri, const std::string &col TELEPHONY_LOGD("Query end resultValue is %{public}s", resultValue.c_str()); if (resultValue.empty()) { TELEPHONY_LOGE("resultValue is empty"); - return TELEPHONY_ERR_DATABASE_READ_FAIL; + return TELEPHONY_ERR_DATABASE_READ_EMPTY; } value = atoi(resultValue.c_str()); return TELEPHONY_ERR_SUCCESS; diff --git a/services/src/utils/network_search_callback.cpp b/services/src/utils/network_search_callback.cpp index ef09e25c35a24dc55237cc1e4a5caf49b7451137..6ecd73113edee2b3f993962da3ad21094860d6e6 100644 --- a/services/src/utils/network_search_callback.cpp +++ b/services/src/utils/network_search_callback.cpp @@ -22,7 +22,8 @@ namespace OHOS { namespace Telephony { bool NetworkSearchCallback::HasInternetCapability(int32_t slotId, int32_t cId) { - int32_t result = DelayedRefSingleton::GetInstance().HasInternetCapability(slotId, cId); + int32_t result; + DelayedRefSingleton::GetInstance().HasInternetCapability(slotId, cId, result); if (result == static_cast(RequestNetCode::REQUEST_SUCCESS)) { return true; } diff --git a/services/telephony_ext_wrapper/include/telephony_ext_wrapper.h b/services/telephony_ext_wrapper/include/telephony_ext_wrapper.h index 7b972a5d7ebc5f02c0ba74518eb21d97750e5f2b..86f41fe79037853a55bcc87f8143451db028adef 100644 --- a/services/telephony_ext_wrapper/include/telephony_ext_wrapper.h +++ b/services/telephony_ext_wrapper/include/telephony_ext_wrapper.h @@ -51,6 +51,11 @@ public: typedef void (*RESTART_RADIO_IF_RQUIRED)(int32_t, int32_t); typedef bool (*GET_USER_DATA_ROAMING_EXPEND)(int32_t, bool); typedef void (*SEND_APN_NEED_RETRY_INFO)(int32_t); + typedef bool (*JUDGE_OTHER_REQUEST_HOLDING)(const NetRequest &, const HasSystemUse hasSystemUse); + typedef void (*DynamicLoadInit)(void); + typedef void (*NotifyReqCellularData)(bool isReqCellularData); + typedef bool (*CREATE_DC_APN_ITEM_EXT)(int32_t slotId, sptr &apnItem); + DATA_EDN_SELF_CURE dataEndSelfCure_ = nullptr; IS_APN_ALLOWED_ACTIVE isApnAllowedActive_ = nullptr; GET_VSIM_SLOT_ID getVSimSlotId_ = nullptr; @@ -66,9 +71,15 @@ public: HANDLE_DEND_FAILCAUSE handleDendFailcause_ = nullptr; CONVERT_PDP_ERROR convertPdpError_ = nullptr; RESTART_RADIO_IF_RQUIRED restartRadioIfRequired_ = nullptr; + JUDGE_OTHER_REQUEST_HOLDING judgeOtherRequestHolding_ = nullptr; + DynamicLoadInit dynamicLoadInit_ = nullptr; + NotifyReqCellularData dynamicLoadNotifyReqCellularDataStatus_ = nullptr; + CREATE_DC_APN_ITEM_EXT createDcApnItemExt_ = nullptr; + private: void* telephonyExtWrapperHandle_ = nullptr; void* telephonyVSimWrapperHandle_ = nullptr; + void* telephonyDynamicLoadWrapperHandle_ = nullptr; void InitTelephonyExtWrapperForCellularData(); void InitDataEndSelfCure(); @@ -81,6 +92,9 @@ private: void InitConvertPdpError(); void InitRestartRadioIfRequired(); void InitSendApnNeedRetryInfo(); + void InitJudgeOtherRequestHolding(); + void InitTelephonyExtWrapperForDynamicLoad(); + void InitCreateDcApnItemExt(); }; #define TELEPHONY_EXT_WRAPPER ::OHOS::DelayedRefSingleton::GetInstance() diff --git a/services/telephony_ext_wrapper/src/telephony_ext_wrapper.cpp b/services/telephony_ext_wrapper/src/telephony_ext_wrapper.cpp index fdee092ca298919fdc94462bfcf0a76aaa952c1a..88013cc178812dd64f2d66ce706ee6e202c6f261 100644 --- a/services/telephony_ext_wrapper/src/telephony_ext_wrapper.cpp +++ b/services/telephony_ext_wrapper/src/telephony_ext_wrapper.cpp @@ -22,6 +22,7 @@ namespace Telephony { namespace { const std::string TELEPHONY_EXT_WRAPPER_PATH = "libtelephony_ext_service.z.so"; const std::string TELEPHONY_VSIM_WRAPPER_PATH = "libtel_vsim_symbol.z.so"; +const std::string TELEPHONY_DYNAMIC_LOAD_WRAPPER_PATH = "libtel_dynamic_load_service.z.so"; } // namespace TelephonyExtWrapper::TelephonyExtWrapper() {} @@ -36,10 +37,15 @@ TelephonyExtWrapper::~TelephonyExtWrapper() dlclose(telephonyVSimWrapperHandle_); telephonyVSimWrapperHandle_ = nullptr; } + if (telephonyDynamicLoadWrapperHandle_ != nullptr) { + dlclose(telephonyDynamicLoadWrapperHandle_); + telephonyDynamicLoadWrapperHandle_ = nullptr; + } } void TelephonyExtWrapper::InitTelephonyExtWrapper() { + InitTelephonyExtWrapperForDynamicLoad(); TELEPHONY_LOGD("TelephonyExtWrapper::InitTelephonyExtWrapper() start"); InitTelephonyExtWrapperForCellularData(); InitTelephonyExtWrapperForVSim(); @@ -62,6 +68,19 @@ void TelephonyExtWrapper::InitTelephonyExtWrapperForCellularData() InitConvertPdpError(); InitRestartRadioIfRequired(); InitSendApnNeedRetryInfo(); + InitJudgeOtherRequestHolding(); + InitCreateDcApnItemExt(); +} + +void TelephonyExtWrapper::InitJudgeOtherRequestHolding() +{ + judgeOtherRequestHolding_ = + (JUDGE_OTHER_REQUEST_HOLDING)dlsym(telephonyExtWrapperHandle_, "JudgeOtherRequestHolding"); + if (judgeOtherRequestHolding_ == nullptr) { + TELEPHONY_LOGE("telephony ext wrapper symbol JudgeOtherRequestHolding failed, error: %{public}s", dlerror()); + return; + } + TELEPHONY_LOGD("telephony ext wrapper init JudgeOtherRequestHolding success"); } void TelephonyExtWrapper::InitDataEndSelfCure() @@ -178,5 +197,38 @@ void TelephonyExtWrapper::InitSendApnNeedRetryInfo() TELEPHONY_LOGD("telephony ext wrapper init SendApnNeedRetryInfo success"); } +void TelephonyExtWrapper::InitTelephonyExtWrapperForDynamicLoad() +{ + TELEPHONY_LOGI("[DynamicLoad]telephony ext wrapper dynamic load init begin"); + telephonyDynamicLoadWrapperHandle_ = dlopen(TELEPHONY_DYNAMIC_LOAD_WRAPPER_PATH.c_str(), RTLD_NOW); + if (telephonyDynamicLoadWrapperHandle_ == nullptr) { + TELEPHONY_LOGE("[DynamicLoad] libtel_dynamic_load_service.z.so was not loaded, error: %{public}s", dlerror()); + return; + } + dynamicLoadInit_ = (DynamicLoadInit)dlsym(telephonyDynamicLoadWrapperHandle_, "InitDynamicLoadHandle"); + if (dynamicLoadInit_ == nullptr) { + TELEPHONY_LOGE("[DynamicLoad] telephony ext wrapper symbol failed, error: %{public}s", dlerror()); + return; + } + dynamicLoadNotifyReqCellularDataStatus_ = + (NotifyReqCellularData)dlsym(telephonyDynamicLoadWrapperHandle_, "InformReqCellularDataStatus"); + if (dynamicLoadNotifyReqCellularDataStatus_ == nullptr) { + TELEPHONY_LOGE("[DynamicLoad] telephony ext wrapper dynamicLoadNotifyReqCellularDataStatus_ symbol failed,\ + error: %{public}s", dlerror()); + return; + } + TELEPHONY_LOGI("[DynamicLoad]telephony ext wrapper dynamic load init success"); +} + +void TelephonyExtWrapper::InitCreateDcApnItemExt() +{ + createDcApnItemExt_ = + (CREATE_DC_APN_ITEM_EXT)dlsym(telephonyExtWrapperHandle_, "CreateDcApnItemExt"); + if (createDcApnItemExt_ == nullptr) { + TELEPHONY_LOGE("telephony ext wrapper symbol CreateDcApnItemExt failed, error: %{public}s", dlerror()); + return; + } + TELEPHONY_LOGI("telephony ext wrapper init CreateDcApnItemExt success"); +} } // namespace Telephony } // namespace OHOS \ No newline at end of file diff --git a/test/BUILD.gn b/test/BUILD.gn index 34f4dddbd31ffc63ef0b32182d41556cd5539425..ac0f1c52ac74872719054851beecb4480384d5bb 100644 --- a/test/BUILD.gn +++ b/test/BUILD.gn @@ -16,8 +16,9 @@ SOURCE_DIR = ".." ohos_unittest("tel_cellular_data_test") { subsystem_name = "telephony" part_name = "cellular_data" - test_module = "tel_cellular_data_test" - module_out_path = part_name + "/" + test_module + test_module = "cellular_data" + test_suite = "tel_cellular_data_test" + module_out_path = part_name + "/" + test_module + "/" + test_suite sources = [ "$SOURCE_DIR/test/apn_manager_test.cpp", @@ -38,6 +39,7 @@ ohos_unittest("tel_cellular_data_test") { deps = [ "$SOURCE_DIR:tel_cellular_data_static", + "$SOURCE_DIR/frameworks/native:cellulardata_interface_stub", "$SOURCE_DIR/frameworks/native:tel_cellular_data_api", ] @@ -57,6 +59,7 @@ ohos_unittest("tel_cellular_data_test") { "data_share:datashare_common", "data_share:datashare_consumer", "eventhandler:libeventhandler", + "googletest:gmock_main", "hilog:libhilog", "hisysevent:libhisysevent", "init:libbegetutil", @@ -64,6 +67,7 @@ ohos_unittest("tel_cellular_data_test") { "netmanager_base:net_conn_manager_if", "netmanager_base:net_policy_manager_if", "netmanager_base:net_stats_manager_if", + "preferences:native_preferences", "relational_store:native_dataability", "relational_store:native_rdb", "safwk:system_ability_fwk", @@ -82,8 +86,9 @@ ohos_unittest("tel_cellular_data_test") { ohos_unittest("tel_cellular_state_machine_test") { subsystem_name = "telephony" part_name = "cellular_data" - test_module = "tel_cellular_data_test" - module_out_path = part_name + "/" + test_module + test_module = "cellular_data" + test_suite = "tel_cellular_state_machine_test" + module_out_path = part_name + "/" + test_module + "/" + test_suite sources = [ "$SOURCE_DIR/test/cellular_state_machine_test.cpp", @@ -101,6 +106,7 @@ ohos_unittest("tel_cellular_state_machine_test") { deps = [ "$SOURCE_DIR:tel_cellular_data_static", + "$SOURCE_DIR/frameworks/native:cellulardata_interface_stub", "$SOURCE_DIR/frameworks/native:tel_cellular_data_api", "//third_party/googletest:gmock_main", ] @@ -145,8 +151,9 @@ ohos_unittest("tel_cellular_state_machine_test") { ohos_unittest("tel_cellular_state_branch_test") { subsystem_name = "telephony" part_name = "cellular_data" - test_module = "tel_cellular_data_test" - module_out_path = part_name + "/" + test_module + test_module = "cellular_data" + test_suite = "tel_cellular_state_branch_test" + module_out_path = part_name + "/" + test_module + "/" + test_suite sources = [ "$SOURCE_DIR/test/cellualr_data_branch_test.cpp", @@ -164,6 +171,7 @@ ohos_unittest("tel_cellular_state_branch_test") { deps = [ "$SOURCE_DIR:tel_cellular_data_static", + "$SOURCE_DIR/frameworks/native:cellulardata_interface_stub", "$SOURCE_DIR/frameworks/native:tel_cellular_data_api", ] @@ -207,8 +215,9 @@ ohos_unittest("tel_cellular_state_branch_test") { ohos_unittest("tel_cellular_data_client_test") { subsystem_name = "telephony" part_name = "cellular_data" - test_module = "tel_cellular_data_test" - module_out_path = part_name + "/" + test_module + test_module = "cellular_data" + test_suite = "tel_cellular_data_client_test" + module_out_path = part_name + "/" + test_module + "/" + test_suite sources = [ "$SOURCE_DIR/test/cellular_data_client_test.cpp", @@ -252,6 +261,7 @@ ohos_unittest("tel_cellular_data_client_test") { "netmanager_base:net_conn_manager_if", "netmanager_base:net_policy_manager_if", "netmanager_base:net_stats_manager_if", + "preferences:native_preferences", "relational_store:native_dataability", "relational_store:native_rdb", "safwk:system_ability_fwk", @@ -270,8 +280,9 @@ ohos_unittest("tel_cellular_data_client_test") { ohos_unittest("tel_cellular_data_traffic_test") { subsystem_name = "telephony" part_name = "cellular_data" - test_module = "tel_cellular_data_test" - module_out_path = part_name + "/" + test_module + test_module = "cellular_data" + test_suite = "tel_cellular_data_traffic_test" + module_out_path = part_name + "/" + test_module + "/" + test_suite sources = [ "$SOURCE_DIR/test/cellular_data_dump_helper_test.cpp", @@ -319,6 +330,7 @@ ohos_unittest("tel_cellular_data_traffic_test") { "netmanager_base:net_conn_manager_if", "netmanager_base:net_policy_manager_if", "netmanager_base:net_stats_manager_if", + "preferences:native_preferences", "relational_store:native_dataability", "relational_store:native_rdb", "safwk:system_ability_fwk", diff --git a/test/apn_manager_test.cpp b/test/apn_manager_test.cpp index 05be700138ebfcfc74a78e868ae6d59afe02078b..983060e454a301bedc0032607e573037bca8b724 100644 --- a/test/apn_manager_test.cpp +++ b/test/apn_manager_test.cpp @@ -24,6 +24,7 @@ #include "gtest/gtest.h" #include "tel_event_handler.h" #include "pdp_profile_data.h" +#include "telephony_ext_wrapper.h" namespace OHOS { namespace Telephony { @@ -228,6 +229,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 @@ -1227,18 +1306,54 @@ HWTEST_F(ApnManagerTest, ApnItem_IsSimilarPdpProfile_001, TestSize.Level0) EXPECT_FALSE(ApnItem::IsSimilarPdpProfile(p1, p2)); p1.apn = ""; p2.apn = ""; - p1.authType = 1; - p2.authType = 2; + p1.proxyIpAddress = "1"; + p2.proxyIpAddress = ""; + EXPECT_TRUE(ApnItem::IsSimilarPdpProfile(p1, p2)); + p1.proxyIpAddress = ""; + p2.proxyIpAddress = "1"; + EXPECT_TRUE(ApnItem::IsSimilarPdpProfile(p1, p2)); + p1.proxyIpAddress = "1"; + p2.proxyIpAddress = "2"; + EXPECT_FALSE(ApnItem::IsSimilarPdpProfile(p1, p2)); + p1.proxyIpAddress = ""; + p2.proxyIpAddress = ""; + p1.mvnoType = "1"; + p2.mvnoType = ""; + EXPECT_FALSE(ApnItem::IsSimilarPdpProfile(p1, p2)); +} + +/** + * @tc.name : ApnItem_IsSimilarPdpProfile_002 + * @tc.number: ApnItemTest_007 + */ +HWTEST_F(ApnManagerTest, ApnItem_IsSimilarPdpProfile_002, TestSize.Level0) +{ + PdpProfile p1; + PdpProfile p2; + p1.mvnoMatchData = "1"; + p2.mvnoMatchData = ""; EXPECT_FALSE(ApnItem::IsSimilarPdpProfile(p1, p2)); - p1.authType = 1; - p2.authType = 1; - p1.authUser = "1"; - p2.authUser = "2"; + p1.mvnoMatchData = ""; + p2.mvnoMatchData = ""; + p1.homeUrl = "1"; + p2.homeUrl = ""; + EXPECT_TRUE(ApnItem::IsSimilarPdpProfile(p1, p2)); + p1.homeUrl = ""; + p2.homeUrl = "1"; + EXPECT_TRUE(ApnItem::IsSimilarPdpProfile(p1, p2)); + p1.homeUrl = "1"; + p2.homeUrl = "2"; EXPECT_FALSE(ApnItem::IsSimilarPdpProfile(p1, p2)); - p1.authUser = "1"; - p2.authUser = "1"; - p1.authPwd = "1"; - p2.authPwd = "2"; + p1.homeUrl = ""; + p2.homeUrl = ""; + p1.mmsIpAddress = "1"; + p2.mmsIpAddress = ""; + EXPECT_TRUE(ApnItem::IsSimilarPdpProfile(p1, p2)); + p1.mmsIpAddress = ""; + p2.mmsIpAddress = "1"; + EXPECT_TRUE(ApnItem::IsSimilarPdpProfile(p1, p2)); + p1.mmsIpAddress = "1"; + p2.mmsIpAddress = "2"; EXPECT_FALSE(ApnItem::IsSimilarPdpProfile(p1, p2)); } @@ -1287,13 +1402,18 @@ HWTEST_F(ApnManagerTest, ApnManager_TryMergeSimilarPdpProfile_001, TestSize.Leve apnVec.push_back(pdpProfile2); apnManager->TryMergeSimilarPdpProfile(apnVec); EXPECT_EQ(apnVec.size(), 1); + PdpProfile pdpProfile3 = pdpProfile; + pdpProfile3.apnTypes = "default"; + apnVec.push_back(pdpProfile3); + apnManager->TryMergeSimilarPdpProfile(apnVec); + EXPECT_EQ(apnVec.size(), 1); } /** * @tc.name : ApnManager_TryMergeSimilarPdpProfile_002 * @tc.number: ApnManagerTest_005 */ -HWTEST_F(ApnManagerTest, ApnManager_TryMergeSimilarPdpProfile_002, TestSize.Level0) +HWTEST_F(ApnManagerTest, ApnManager_TryMergeSimilarPdpProfile_002, TestSize.Level1) { uint64_t expected = NetManagerStandard::NetCap::NET_CAPABILITY_INTERNET; int32_t apnId = DATA_CONTEXT_ROLE_DEFAULT_ID; @@ -1392,5 +1512,33 @@ HWTEST_F(ApnManagerTest, FetchBipApns_001, TestSize.Level0) EXPECT_NE(bipApn, nullptr); } +bool CreateDcApnItemExtMock() { + return true; +} + +/** + * @tc.name : ApnItem_CreateDcApnItemExt_001 + * @tc.number: ApnItem_CreateDcApnItemExt_001 + * @tc.desc : Test create Dc apn item 001 + */ +HWTEST_F(ApnManagerTest, ApnItem_CreateDcApnItemExt_001, TestSize.Level0) +{ + TELEPHONY_EXT_WRAPPER.createAllApnItemExt_ = nullptr; + TELEPHONY_EXT_WRAPPER.createDcApnItemExt_ = CreateDcApnItemExtMock; + int32_t ret = apnManager->CreateAllApnItemByDatabase(0); + EXPECT_EQ(ret, 1); +} + +/** + * @tc.name : ApnItem_CreateDcApnItemExt_002 + * @tc.number: ApnItem_CreateDcApnItemExt_002 + * @tc.desc : Test create Dc apn item 002 + */ +HWTEST_F(ApnManagerTest, ApnItem_CreateDcApnItemExt_002, TestSize.Level0) +{ + int32_t ret = apnManager->CreateAllApnItemByDatabase(0); + EXPECT_EQ(ret, 1); +} + } // namespace Telephony } // namespace OHOS \ No newline at end of file diff --git a/test/cellular_data_client_test.cpp b/test/cellular_data_client_test.cpp index ab7e240b026aeac12494c46ddc97ef0ea908eb9d..d5109966907c77e9c5375047cd1620a1a653a683 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.Level1) +{ + 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.Level1) +{ + 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.Level1) +{ + 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.Level1) +{ + 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_handler_branch_test.cpp b/test/cellular_data_handler_branch_test.cpp index f6d1e99f9eacdab11730bf621e812c5614b58423..63c4ce775801da6a2beb33a20f8c74361f22af9e 100644 --- a/test/cellular_data_handler_branch_test.cpp +++ b/test/cellular_data_handler_branch_test.cpp @@ -216,6 +216,30 @@ HWTEST_F(CellularDataHandlerBranchTest, DisconnectDataComplete_001, Function | M ASSERT_EQ(event->GetSharedObject(), nullptr); } +HWTEST_F(CellularDataHandlerBranchTest, DisconnectDataComplete_002, Function | MediumTest | Level3) +{ + EventFwk::MatchingSkills matchingSkills; + matchingSkills.AddEvent(EventFwk::CommonEventSupport::COMMON_EVENT_CALL_STATE_CHANGED); + EventFwk::CommonEventSubscribeInfo subscriberInfo(matchingSkills); + auto cellularDataHandler = std::make_shared(subscriberInfo, 2); + cellularDataHandler->Init(); + + std::shared_ptr resultInfo = std::make_shared(); + resultInfo->flag = 2; + auto event = AppExecFwk::InnerEvent::Get(0, resultInfo); + sptr apnHolder = cellularDataHandler->apnManager_->FindApnHolderById(2); + sptr connectionManager = std::make_unique(0).release(); + if (connectionManager == nullptr) { + return; + } + connectionManager->Init(); + std::shared_ptr cellularDataStateMachine = + std::make_shared(connectionManager, cellularDataHandler); + apnHolder->SetCellularDataStateMachine(cellularDataStateMachine); + cellularDataHandler->DisconnectDataComplete(event); + ASSERT_EQ(event->GetSharedObject(), resultInfo); +} + HWTEST_F(CellularDataHandlerBranchTest, UpdatePhysicalConnectionState_001, Function | MediumTest | Level3) { EventFwk::MatchingSkills matchingSkills; diff --git a/test/cellular_data_handler_test.cpp b/test/cellular_data_handler_test.cpp index f1dac62b5fde2ddbf8d09285d74ba93ba77dcc67..b523efac0bc87ff4896bc4bd0e9f21fb688f0d77 100644 --- a/test/cellular_data_handler_test.cpp +++ b/test/cellular_data_handler_test.cpp @@ -1014,5 +1014,107 @@ HWTEST_F(CellularDataHandlerTest, Telephony_CellularDataHandler_002, Function | controller.cellularDataHandler_ = nullptr; EXPECT_FALSE(controller.RemoveUid(request)); } + +/** + * @tc.number Telephony_MsgRequest + * @tc.name test error branch + * @tc.desc Function test + */ +HWTEST_F(CellularDataHandlerTest, Telephony_MsgRequest, Function | MediumTest | Level1) +{ + EventFwk::MatchingSkills matchingSkills; + matchingSkills.AddEvent(EventFwk::CommonEventSupport::COMMON_EVENT_CALL_STATE_CHANGED); + EventFwk::CommonEventSubscribeInfo subscriberInfo(matchingSkills); + auto cellularDataHandler = std::make_shared(subscriberInfo, 0); + cellularDataHandler->Init(); + NetRequest request1; + request1.capability = NetManagerStandard::NET_CAPABILITY_INTERNET; + request1.registerType = REGISTER; + + EXPECT_TRUE(cellularDataHandler->RequestNet(request1)); + NetRequest request2; + request2.capability = NetManagerStandard::NET_CAPABILITY_INTERNET; + request2.registerType = REQUEST; + EXPECT_TRUE(cellularDataHandler->RequestNet(request2)); + sleep(2); +} + +/** + * @tc.number Telephony_ConnectIfNeed + * @tc.name test error branch + * @tc.desc Function test + */ +HWTEST_F(CellularDataHandlerTest, Telephony_ConnectIfNeed, Function | MediumTest | Level1) +{ + EventFwk::MatchingSkills matchingSkills; + matchingSkills.AddEvent(EventFwk::CommonEventSupport::COMMON_EVENT_CALL_STATE_CHANGED); + EventFwk::CommonEventSubscribeInfo subscriberInfo(matchingSkills); + auto cellularDataHandler = std::make_shared(subscriberInfo, 0); + cellularDataHandler->Init(); + + NetRequest request1; + request1.capability = NetManagerStandard::NET_CAPABILITY_INTERNET; + request1.registerType = REQUEST; + EXPECT_TRUE(cellularDataHandler->RequestNet(request1)); + auto event1 = AppExecFwk::InnerEvent::Get(CellularDataEventCode::MSG_REQUEST_NETWORK, TYPE_REQUEST_NET); + auto apnHolder = + cellularDataHandler->apnManager_->FindApnHolderById(ApnManager::FindApnIdByCapability(request1.capability)); + cellularDataHandler->ConnectIfNeed(event1, apnHolder, request1); + auto event2 = AppExecFwk::InnerEvent::Get(CellularDataEventCode::MSG_REQUEST_NETWORK, TYPE_RELEASE_NET); + cellularDataHandler->ConnectIfNeed(event2, apnHolder, request1); + cellularDataHandler->ConnectIfNeed(event2, nullptr, request1); +} + +HWTEST_F(CellularDataHandlerTest, Telephony_CellularDataHandler_003, Function | MediumTest | Level1) +{ + CellularDataController controller {0}; + controller.Init(); + ApnActivateReportInfo info1; + ApnActivateReportInfo info2; + EXPECT_TRUE(controller.GetDefaultActReportInfo(info1)); + EXPECT_TRUE(controller.GetInternalActReportInfo(info2)); + controller.cellularDataHandler_ = nullptr; + EXPECT_FALSE(controller.GetDefaultActReportInfo(info1)); + EXPECT_FALSE(controller.GetInternalActReportInfo(info2)); +} + +HWTEST_F(CellularDataHandlerTest, DataConnCompleteUpdateStateTest001, Function | MediumTest | Level1) +{ + int32_t slotId = 0; + EventFwk::MatchingSkills matchingSkills; + matchingSkills.AddEvent(EventFwk::CommonEventSupport::COMMON_EVENT_CALL_STATE_CHANGED); + EventFwk::CommonEventSubscribeInfo subscriberInfo(matchingSkills); + auto cellularDataHandler = std::make_shared(subscriberInfo, slotId); + std::string apnType = DATA_CONTEXT_ROLE_MMS; + sptr apnHolder = new ApnHolder(apnType, slotId); + apnHolder->cellularDataStateMachine_ = nullptr; + auto resultInfo = std::make_shared(); + cellularDataHandler->connectionManager_ = nullptr; + cellularDataHandler->physicalConnectionActiveState_ = true; + cellularDataHandler->incallDataStateMachine_ = nullptr; + cellularDataHandler->DataConnCompleteUpdateState(apnHolder, resultInfo); + EXPECT_FALSE(cellularDataHandler->isRilApnAttached_); + + sptr cdConnectionManager = nullptr; + std::shared_ptr telEventHandler = nullptr; + apnHolder->cellularDataStateMachine_ = std::make_shared + (cdConnectionManager, std::move(telEventHandler)); + apnHolder->cellularDataStateMachine_->netLinkInfo_ = new NetLinkInfo(); + apnHolder->cellularDataStateMachine_->netSupplierInfo_ = nullptr; + cellularDataHandler->apnManager_ = std::make_unique().release(); + cellularDataHandler->apnManager_->allApnItem_.clear(); + cellularDataHandler->connectionManager_ = std::make_unique(slotId).release(); + cellularDataHandler->physicalConnectionActiveState_ = false; + cellularDataHandler->incallDataStateMachine_ = + cellularDataHandler->CreateIncallDataStateMachine(TelCallStatus::CALL_STATUS_DIALING); + apnHolder->apnType_ = DATA_CONTEXT_ROLE_DEFAULT; + apnHolder->apnItem_ = new ApnItem(); + cellularDataHandler->DataConnCompleteUpdateState(apnHolder, resultInfo); + + cellularDataHandler->apnManager_->preferId_ = 1; + cellularDataHandler->apnManager_->allApnItem_.push_back(new ApnItem()); + cellularDataHandler->DataConnCompleteUpdateState(apnHolder, resultInfo); + EXPECT_FALSE(cellularDataHandler->isRilApnAttached_); +} } // namespace Telephony } // namespace OHOS \ No newline at end of file diff --git a/test/cellular_data_observer_test.cpp b/test/cellular_data_observer_test.cpp index a3a925281045cc6dbf659e53460920084e0c23ec..0f9359bd6d3dc9bc76c003cc0c68fc8351b038bf 100644 --- a/test/cellular_data_observer_test.cpp +++ b/test/cellular_data_observer_test.cpp @@ -167,6 +167,8 @@ HWTEST_F(CellularDataObserverTest, CellularDataAirplaneObserver_05, Function | M EXPECT_TRUE(settingHelper->PutValue(uri, CELLULAR_DATA_COLUMN_AIRPLANE, 0) == TELEPHONY_ERR_SUCCESS); cellularDataAirplaneObserver->OnChange(); EXPECT_FALSE(cellularDataAirplaneObserver->IsAirplaneModeOn()); + + settingHelper->NotifyChange(uri); } } // namespace Telephony diff --git a/test/cellular_data_service_test.cpp b/test/cellular_data_service_test.cpp index 14370537b012fb207f85ad47af55358d3c71c221..de6a08988d44fc3c3cab1f9c1c3daed6e192960d 100644 --- a/test/cellular_data_service_test.cpp +++ b/test/cellular_data_service_test.cpp @@ -22,6 +22,7 @@ #include "gtest/gtest.h" #include "tel_ril_network_parcel.h" #include "traffic_management.h" +#include "apn_attribute.h" namespace OHOS { namespace Telephony { @@ -53,21 +54,21 @@ void CellularDataServiceTest::TearDown() {} * @tc.name test function branch * @tc.desc Function test */ -HWTEST_F(CellularDataServiceTest, CellularDataService_001, TestSize.Level0) +HWTEST_F(CellularDataServiceTest, CellularDataService_001, TestSize.Level1) { DataAccessToken token; service->OnStart(); service->isInitSuccess_ = true; bool dataEnabled = false; bool dataRoamingEnabled = false; + int32_t state; ASSERT_NE(TELEPHONY_ERR_SUCCESS, service->IsCellularDataEnabled(dataEnabled)); ASSERT_NE(TELEPHONY_ERR_SUCCESS, service->EnableCellularData(false)); ASSERT_NE(TELEPHONY_ERR_SUCCESS, service->EnableCellularData(true)); ASSERT_NE(TELEPHONY_ERR_SUCCESS, service->EnableIntelligenceSwitch(false)); ASSERT_NE(TELEPHONY_ERR_SUCCESS, service->EnableIntelligenceSwitch(true)); - ASSERT_NE(TELEPHONY_ERR_SUCCESS, service->GetCellularDataState()); - ASSERT_EQ(static_cast(DisConnectionReason::REASON_CHANGE_CONNECTION), - service->GetApnState(DEFAULT_SIM_SLOT_ID, std::string())); + ASSERT_NE(TELEPHONY_ERR_SUCCESS, service->GetCellularDataState(state)); + ASSERT_EQ(TELEPHONY_ERR_SUCCESS, service->GetApnState(DEFAULT_SIM_SLOT_ID, std::string(), state)); ASSERT_NE(TELEPHONY_ERR_SUCCESS, service->IsCellularDataRoamingEnabled(DEFAULT_SIM_SLOT_ID, dataRoamingEnabled)); ASSERT_NE(TELEPHONY_ERR_SUCCESS, service->EnableCellularDataRoaming(DEFAULT_SIM_SLOT_ID, true)); NetRequest request; @@ -85,18 +86,20 @@ HWTEST_F(CellularDataServiceTest, CellularDataService_001, TestSize.Level0) * @tc.name test function branch * @tc.desc Function test */ -HWTEST_F(CellularDataServiceTest, CellularDataService_002, TestSize.Level0) +HWTEST_F(CellularDataServiceTest, CellularDataService_002, TestSize.Level1) { - ASSERT_NE(TELEPHONY_ERR_SUCCESS, service->GetCellularDataFlowType()); + int32_t type; + ASSERT_NE(TELEPHONY_ERR_SUCCESS, service->GetCellularDataFlowType(type)); ASSERT_EQ("default slotId: -1", service->GetStateMachineCurrentStatusDump()); service->GetFlowDataInfoDump(); ASSERT_NE(TELEPHONY_ERR_SUCCESS, service->StrategySwitch(DEFAULT_SIM_SLOT_ID, false)); - ASSERT_EQ(TELEPHONY_ERR_SUCCESS, service->HasInternetCapability(DEFAULT_SIM_SLOT_ID, 0)); - DisConnectionReason reason = DisConnectionReason::REASON_NORMAL; + int32_t capability; + ASSERT_EQ(TELEPHONY_ERR_SUCCESS, service->HasInternetCapability(DEFAULT_SIM_SLOT_ID, 0, capability)); + int32_t reason = static_cast(DisConnectionReason::REASON_NORMAL); ASSERT_NE(TELEPHONY_ERR_SUCCESS, service->ClearAllConnections(DEFAULT_SIM_SLOT_ID, reason)); ASSERT_EQ(TELEPHONY_ERR_SUCCESS, service->ChangeConnectionForDsds(DEFAULT_SIM_SLOT_ID, false)); ASSERT_EQ(TELEPHONY_ERR_SUCCESS, service->ChangeConnectionForDsds(DEFAULT_SIM_SLOT_ID, true)); - ApnItem::Attribute apnAttr; + ApnAttribute apnAttr; ASSERT_NE(TELEPHONY_ERR_SUCCESS, service->GetDataConnApnAttr(DEFAULT_SIM_SLOT_ID, apnAttr)); std::string ipType; ASSERT_EQ(TELEPHONY_ERR_SUCCESS, service->GetDataConnIpType(DEFAULT_SIM_SLOT_ID, ipType)); @@ -108,6 +111,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; @@ -136,7 +146,7 @@ HWTEST_F(CellularDataServiceTest, DataConnectionMonitor_HandleScreenStateChanged * @tc.name test function branch * @tc.desc Function test */ -HWTEST_F(CellularDataServiceTest, DataConnectionMonitor_OnStallDetectionTimer_001, TestSize.Level0) +HWTEST_F(CellularDataServiceTest, DataConnectionMonitor_OnStallDetectionTimer_001, TestSize.Level1) { std::shared_ptr dataConnectionMonitor = std::make_shared(0); dataConnectionMonitor->noRecvPackets_ = 20; @@ -391,5 +401,33 @@ HWTEST_F(CellularDataServiceTest, EstablishAllApnsIfConnectableTest001, TestSize EXPECT_EQ(service->ReleaseCellularDataConnection(slotId), TELEPHONY_ERR_PERMISSION_ERR); } +/** + * @tc.number GetActReportInfoTest001 + * @tc.name test GetDefaultActReportInfo and GetInternalActReportInfo + * @tc.desc Function test + */ +HWTEST_F(CellularDataServiceTest, GetActReportInfoTest001, TestSize.Level0) +{ + ApnActivateReportInfoIpc infoIpc; + int32_t slotId = -1; + EXPECT_EQ(service->GetDefaultActReportInfo(slotId, infoIpc), TELEPHONY_ERR_PERMISSION_ERR); + EXPECT_EQ(service->GetInternalActReportInfo(slotId, infoIpc), TELEPHONY_ERR_PERMISSION_ERR); +} + +/** + * @tc.number ApnInfoTest001 + * @tc.name test QueryApnIds, SetPreferApn and QueryAllApnInfo + * @tc.desc Function test + */ +HWTEST_F(CellularDataServiceTest, ApnInfoTest001, TestSize.Level0) +{ + ApnInfo apnInfo; + std::vector apnIdList; + std::vector allApnInfoList; + int32_t apnId = 1; + EXPECT_EQ(service->QueryApnIds(apnInfo, apnIdList), TELEPHONY_ERR_PERMISSION_ERR); + EXPECT_EQ(service->SetPreferApn(apnId), TELEPHONY_ERR_PERMISSION_ERR); + EXPECT_EQ(service->QueryAllApnInfo(allApnInfoList), TELEPHONY_ERR_PERMISSION_ERR); +} } // namespace Telephony } // namespace OHOS \ No newline at end of file diff --git a/test/cellular_data_test.cpp b/test/cellular_data_test.cpp index b017735b5f07078a8601a577a4267e0e22829662..3857b50f6e1d7eb51f2ded0146463e9a03a05833 100644 --- a/test/cellular_data_test.cpp +++ b/test/cellular_data_test.cpp @@ -18,6 +18,8 @@ #define private public #include +#include +#include #include "cellular_data_client.h" #include "cellular_data_controller.h" @@ -32,7 +34,7 @@ #include "gtest/gtest_pred_impl.h" #include "gtest/hwext/gtest-tag.h" #include "hap_token_info.h" -#include "i_cellular_data_manager.h" +#include "icellular_data_manager.h" #include "iosfwd" #include "iostream" #include "net_conn_callback_stub.h" @@ -55,8 +57,10 @@ namespace OHOS { namespace Telephony { +using namespace testing; using namespace testing::ext; using namespace OHOS::NetManagerStandard; +using ::testing::NiceMock; static const int32_t SLEEP_TIME = 1; static const int32_t SIM_SLOT_ID_1 = DEFAULT_SIM_SLOT_ID + 1; @@ -117,6 +121,34 @@ public: bool isCallback_ = false; }; +class MockDlsym { +public: + MOCK_METHOD(void *, dlopen, (const char *fileName, int flag)); + MOCK_METHOD(void *, dlsym, (void *handle, const char *symbol)); +}; + +NiceMock *mockDlsym; + +extern "C" { +// mock dlopen +void *dlopen(const char *fileName, int flag) +{ + if (mockDlsym == nullptr) { + mockDlsym = new NiceMock(); + } + return mockDlsym->dlopen(fileName, flag); +} + +// mock dlsym +void *dlsym(void *handle, const char *symbol) +{ + if (mockDlsym == nullptr) { + mockDlsym = new NiceMock(); + } + return mockDlsym->dlsym(handle, symbol); +} +} + class CellularDataTest : public testing::Test { public: static void SetUpTestCase(); @@ -1074,6 +1106,97 @@ HWTEST_F(CellularDataTest, Telephony_Cellulardata_InitTelephonyExtService_0100, } } +/** + * @tc.number Telephony_Cellulardata_InitTelephonyExtService_0101 + * @tc.name Init Telephony Ext Service. + * @tc.desc Function test + */ +HWTEST_F(CellularDataTest, Telephony_Cellulardata_InitTelephonyExtService_0101, Function | MediumTest | Level1) +{ + mockDlsym = new NiceMock(); + EXPECT_CALL(*mockDlsym, dlopen(_, _)) + .WillRepeatedly(Return(nullptr)); + TELEPHONY_EXT_WRAPPER.InitTelephonyExtWrapperForDynamicLoad(); + EXPECT_EQ(TELEPHONY_EXT_WRAPPER.telephonyDynamicLoadWrapperHandle_, nullptr); + delete mockDlsym; + mockDlsym = nullptr; +} + +/** + * @tc.number Telephony_Cellulardata_InitTelephonyExtService_0102 + * @tc.name Init Telephony Ext Service. + * @tc.desc Function test + */ +HWTEST_F(CellularDataTest, Telephony_Cellulardata_InitTelephonyExtService_0102, Function | MediumTest | Level1) +{ + mockDlsym = new NiceMock(); + EXPECT_CALL(*mockDlsym, dlopen(_, _)) + .WillRepeatedly(Return(reinterpret_cast(0x1234))); + EXPECT_CALL(*mockDlsym, dlsym(_, _)) + .WillRepeatedly(Return(nullptr)); + TELEPHONY_EXT_WRAPPER.InitTelephonyExtWrapperForDynamicLoad(); + EXPECT_EQ(TELEPHONY_EXT_WRAPPER.telephonyDynamicLoadWrapperHandle_ != nullptr, true); + EXPECT_EQ(TELEPHONY_EXT_WRAPPER.dynamicLoadInit_, nullptr); + delete mockDlsym; + mockDlsym = nullptr; +} + +/** + * @tc.number Telephony_Cellulardata_InitTelephonyExtService_0103 + * @tc.name Init Telephony Ext Service. + * @tc.desc Function test + */ +HWTEST_F(CellularDataTest, Telephony_Cellulardata_InitTelephonyExtService_0103, Function | MediumTest | Level1) +{ + mockDlsym = new NiceMock(); + EXPECT_CALL(*mockDlsym, dlopen(_, _)) + .WillRepeatedly(Return(reinterpret_cast(0x1234))); + EXPECT_CALL(*mockDlsym, dlsym(_, _)) + .WillOnce(Return(reinterpret_cast(0x12345))) + .WillOnce(Return(nullptr)); + auto controller = std::make_shared(DEFAULT_SIM_SLOT_ID); + controller->Init(); + ASSERT_TRUE(controller->cellularDataHandler_ != nullptr); + TELEPHONY_EXT_WRAPPER.InitTelephonyExtWrapperForDynamicLoad(); + EXPECT_EQ(TELEPHONY_EXT_WRAPPER.telephonyDynamicLoadWrapperHandle_ != nullptr, true); + EXPECT_EQ(TELEPHONY_EXT_WRAPPER.dynamicLoadInit_ != nullptr, true); +#ifdef OHOS_BUILD_ENABLE_TELEPHONY_EXT + controller->cellularDataHandler_->NotifyReqCellularData(false); +#endif + EXPECT_EQ(TELEPHONY_EXT_WRAPPER.dynamicLoadNotifyReqCellularDataStatus_, nullptr); + delete mockDlsym; + mockDlsym = nullptr; +} + +/** + * @tc.number Telephony_Cellulardata_InitTelephonyExtService_0104 + * @tc.name Init Telephony Ext Service. + * @tc.desc Function test + */ +HWTEST_F(CellularDataTest, Telephony_Cellulardata_InitTelephonyExtService_0104, Function | MediumTest | Level1) +{ + mockDlsym = new NiceMock(); + EXPECT_CALL(*mockDlsym, dlopen(_, _)) + .WillRepeatedly(Return(reinterpret_cast(0x1234))); + EXPECT_CALL(*mockDlsym, dlsym(_, _)) + .WillRepeatedly(Return(reinterpret_cast(0x12345))); + auto controller = std::make_shared(DEFAULT_SIM_SLOT_ID); + controller->Init(); + ASSERT_TRUE(controller->cellularDataHandler_ != nullptr); + TELEPHONY_EXT_WRAPPER.InitTelephonyExtWrapperForDynamicLoad(); + EXPECT_EQ(TELEPHONY_EXT_WRAPPER.telephonyDynamicLoadWrapperHandle_ != nullptr, true); + EXPECT_EQ(TELEPHONY_EXT_WRAPPER.dynamicLoadInit_ != nullptr, true); +#ifdef OHOS_BUILD_ENABLE_TELEPHONY_EXT + controller->cellularDataHandler_->NotifyReqCellularData(true); +#endif + EXPECT_EQ(TELEPHONY_EXT_WRAPPER.dynamicLoadNotifyReqCellularDataStatus_ != nullptr, true); + delete mockDlsym; + mockDlsym = nullptr; + TELEPHONY_EXT_WRAPPER.telephonyDynamicLoadWrapperHandle_ = nullptr; + TELEPHONY_EXT_WRAPPER.dynamicLoadInit_ = nullptr; + TELEPHONY_EXT_WRAPPER.dynamicLoadNotifyReqCellularDataStatus_ = nullptr; +} + /** * @tc.number GetDataConnApnAttr_Test_01 * @tc.name Test the GetDataConnApnAttr function @@ -1977,19 +2100,6 @@ HWTEST_F(CellularDataTest, ControllerReleaseCellularDataConnection_Test_1, TestS controller->cellularDataHandler_ = nullptr; ASSERT_FALSE(controller->ReleaseCellularDataConnection()); } -/** - * @tc.number ControllerReleaseCellularDataConnection_Test_02 - * @tc.name Test the Controller ReleaseCellularDataConnection function - * @tc.desc Function test - */ -HWTEST_F(CellularDataTest, ControllerReleaseCellularDataConnection_Test_2, TestSize.Level3) -{ - auto controller = std::make_shared(DEFAULT_SIM_SLOT_ID); - controller->Init(); - ASSERT_TRUE(controller->cellularDataHandler_ != nullptr); - NetRequest request; - ASSERT_TRUE(controller->ReleaseCellularDataConnection()); -} /** * @tc.number ControllerUpdateNetworkInfo_Test_01 @@ -2021,5 +2131,27 @@ HWTEST_F(CellularDataTest, ControllerUpdateNetworkInfo_Test_02, TestSize.Level3) ASSERT_TRUE(controller->UpdateNetworkInfo()); } +/** + * @tc.number GetSimIdTest001 + * @tc.name Test the function + * @tc.desc Function test + */ +HWTEST_F(CellularDataTest, GetSimIdTest001, TestSize.Level3) +{ + CellularDataRdbHelper cellularDataRdbHelper; + int32_t result = cellularDataRdbHelper.GetSimId(); + ASSERT_EQ(result, -1); + + ApnInfo apnInfo; + std::vector apnIdList; + cellularDataRdbHelper.QueryApnIds(apnInfo, apnIdList); + + int32_t apnId = -1; + result = cellularDataRdbHelper.SetPreferApn(apnId); + ASSERT_EQ(result, -1); + + std::vector apnInfoList; + cellularDataRdbHelper.QueryAllApnInfo(apnInfoList); +} } // namespace Telephony } // namespace OHOS diff --git a/test/data_switch_settings_test.cpp b/test/data_switch_settings_test.cpp index 9a96750483ed824d62d738562a952930d234e312..be909debed508cff85f37b7499ff22134cfc3583 100644 --- a/test/data_switch_settings_test.cpp +++ b/test/data_switch_settings_test.cpp @@ -115,5 +115,27 @@ HWTEST_F(DataSwitchSettingTest, DataSwitchSetting_05, Function | MediumTest | Le ASSERT_TRUE(sets.IsAllowActiveData()); } +HWTEST_F(DataSwitchSettingTest, DataSwitchSetting_06, Function | MediumTest | Level1) +{ + DataSwitchSettings sets(2); + std::cout << "DataSwitchSetting_06 slotId: " << sets.slotId_ << std::endl; + int32_t simDetected = 1; + ASSERT_TRUE(sets.SetAnySimDetected(simDetected) == TELEPHONY_ERR_SUCCESS); + + DataSwitchSettings sets1(0); + ASSERT_TRUE(sets1.SetAnySimDetected(simDetected) == TELEPHONY_ERR_SUCCESS); +} + +HWTEST_F(DataSwitchSettingTest, DataSwitchSetting_07, Function | MediumTest | Level1) +{ + DataSwitchSettings sets(2); + std::cout << "DataSwitchSetting_07 slotId: " << sets.slotId_ << std::endl; + int32_t simDetected = 0; + ASSERT_TRUE(sets.QueryAnySimDetectedStatus(simDetected) == TELEPHONY_ERR_SUCCESS); + + DataSwitchSettings sets1(0); + ASSERT_TRUE(sets1.QueryAnySimDetectedStatus(simDetected) == TELEPHONY_ERR_SUCCESS); +} + } // namespace Telephony } // namespace OHOS \ No newline at end of file diff --git a/test/fuzztest/getcellulardatastate_fuzzer/BUILD.gn b/test/fuzztest/getcellulardatastate_fuzzer/BUILD.gn index 6da942c1be3eec8af6a2054156126f2dd6efd5f7..cdf9c90517b99965b36b9c8b5d551e221c023dd3 100644 --- a/test/fuzztest/getcellulardatastate_fuzzer/BUILD.gn +++ b/test/fuzztest/getcellulardatastate_fuzzer/BUILD.gn @@ -33,6 +33,7 @@ ohos_fuzztest("GetCellularDataStateFuzzTest") { deps = [ "$SOURCE_DIR:tel_cellular_data", + "$SOURCE_DIR/frameworks/native:cellulardata_interface_stub", "$SOURCE_DIR/frameworks/native:tel_cellular_data_api", ] @@ -56,7 +57,9 @@ ohos_fuzztest("GetCellularDataStateFuzzTest") { "netmanager_base:net_conn_manager_if", "netmanager_base:net_policy_manager_if", "netmanager_base:net_stats_manager_if", + "preferences:native_preferences", "relational_store:native_rdb", + "safwk:system_ability_fwk", "telephony_data:tel_telephony_data", ] diff --git a/test/fuzztest/getcellulardatastate_fuzzer/getcellulardatastate_fuzzer.cpp b/test/fuzztest/getcellulardatastate_fuzzer/getcellulardatastate_fuzzer.cpp index 5dfd3274faa8a45dd9a3e43d9b8c2a024a2ae249..fb50edbd9230e195b0e545e16d7155763ed4657b 100644 --- a/test/fuzztest/getcellulardatastate_fuzzer/getcellulardatastate_fuzzer.cpp +++ b/test/fuzztest/getcellulardatastate_fuzzer/getcellulardatastate_fuzzer.cpp @@ -21,15 +21,25 @@ #include "adddatatoken_fuzzer.h" #include "cellular_data_ipc_interface_code.h" #include "cellular_data_service.h" -#include "cellular_data_service_stub.h" +#include "cellular_data_types.h" +#include "cellular_data_manager_stub.h" +#include "data_sim_account_callback.h" #include "system_ability_definition.h" #include +#include "icellular_data_manager.h" using namespace OHOS::Telephony; namespace OHOS { static bool g_isInited = false; constexpr int32_t SLOT_NUM_MAX = 3; - +constexpr int32_t APN_ID_MAX = 5; +constexpr int32_t APN_STRING_LENGTH = 10; +constexpr int32_t NET_CAPABILITY_MAX = 32; +static constexpr const char16_t *DESCRIPTOR = u"OHOS.Telephony.ICellularDataManager"; +static inline const std::u16string GetDescriptor() +{ + return DESCRIPTOR; +} bool IsServiceInited() { if (!g_isInited) { @@ -42,37 +52,40 @@ bool IsServiceInited() return g_isInited; } -void OnRemoteRequest(const uint8_t *data, size_t size) +void EnableCellularData(const uint8_t *data, size_t size) { if (!IsServiceInited()) { return; } MessageParcel dataMessageParcel; - if (!dataMessageParcel.WriteInterfaceToken(CellularDataServiceStub::GetDescriptor())) { + if (!dataMessageParcel.WriteInterfaceToken(GetDescriptor())) { return; } dataMessageParcel.WriteBuffer(data, size); dataMessageParcel.RewindRead(0); - FuzzedDataProvider fdp(data, size); - uint32_t code = fdp.ConsumeIntegralInRange(0, - static_cast(CellularDataInterfaceCode::GET_SUPPLIER_REGISTER_STATE) + 1); + uint32_t code = static_cast(ICellularDataManagerIpcCode::COMMAND_ENABLE_CELLULAR_DATA); MessageParcel reply; - MessageOption option; + MessageOption option(MessageOption::TF_SYNC); DelayedSingleton::GetInstance()->OnRemoteRequest(code, dataMessageParcel, reply, option); } -void EnableCellularData(const uint8_t *data, size_t size) +void EnableIntelligenceSwitch(const uint8_t *data, size_t size) { if (!IsServiceInited()) { return; } MessageParcel dataMessageParcel; + if (!dataMessageParcel.WriteInterfaceToken(GetDescriptor())) { + return; + } dataMessageParcel.WriteBuffer(data, size); dataMessageParcel.RewindRead(0); + uint32_t code = static_cast(ICellularDataManagerIpcCode::COMMAND_ENABLE_INTELLIGENCE_SWITCH); MessageParcel reply; - DelayedSingleton::GetInstance()->OnEnableCellularData(dataMessageParcel, reply); + MessageOption option(MessageOption::TF_SYNC); + DelayedSingleton::GetInstance()->OnRemoteRequest(code, dataMessageParcel, reply, option); } void GetCellularDataState(const uint8_t *data, size_t size) @@ -82,10 +95,15 @@ void GetCellularDataState(const uint8_t *data, size_t size) } MessageParcel dataMessageParcel; + if (!dataMessageParcel.WriteInterfaceToken(GetDescriptor())) { + return; + } dataMessageParcel.WriteBuffer(data, size); dataMessageParcel.RewindRead(0); + uint32_t code = static_cast(ICellularDataManagerIpcCode::COMMAND_GET_CELLULAR_DATA_STATE); MessageParcel reply; - DelayedSingleton::GetInstance()->OnGetCellularDataState(dataMessageParcel, reply); + MessageOption option(MessageOption::TF_SYNC); + DelayedSingleton::GetInstance()->OnRemoteRequest(code, dataMessageParcel, reply, option); } void IsCellularDataEnabled(const uint8_t *data, size_t size) @@ -95,10 +113,15 @@ void IsCellularDataEnabled(const uint8_t *data, size_t size) } MessageParcel dataMessageParcel; + if (!dataMessageParcel.WriteInterfaceToken(GetDescriptor())) { + return; + } dataMessageParcel.WriteBuffer(data, size); dataMessageParcel.RewindRead(0); + uint32_t code = static_cast(ICellularDataManagerIpcCode::COMMAND_IS_CELLULAR_DATA_ENABLED); MessageParcel reply; - DelayedSingleton::GetInstance()->OnIsCellularDataEnabled(dataMessageParcel, reply); + MessageOption option(MessageOption::TF_SYNC); + DelayedSingleton::GetInstance()->OnRemoteRequest(code, dataMessageParcel, reply, option); } void IsCellularDataRoamingEnabled(const uint8_t *data, size_t size) @@ -109,11 +132,16 @@ void IsCellularDataRoamingEnabled(const uint8_t *data, size_t size) FuzzedDataProvider fdp(data, size); int32_t slotId = fdp.ConsumeIntegralInRange(0, SLOT_NUM_MAX); MessageParcel dataMessageParcel; + if (!dataMessageParcel.WriteInterfaceToken(GetDescriptor())) { + return; + } dataMessageParcel.WriteInt32(slotId); dataMessageParcel.WriteBuffer(data, size); dataMessageParcel.RewindRead(0); + uint32_t code = static_cast(ICellularDataManagerIpcCode::COMMAND_IS_CELLULAR_DATA_ROAMING_ENABLED); MessageParcel reply; - DelayedSingleton::GetInstance()->OnIsCellularDataRoamingEnabled(dataMessageParcel, reply); + MessageOption option(MessageOption::TF_SYNC); + DelayedSingleton::GetInstance()->OnRemoteRequest(code, dataMessageParcel, reply, option); } void GetDefaultCellularDataSlotId(const uint8_t *data, size_t size) @@ -123,10 +151,15 @@ void GetDefaultCellularDataSlotId(const uint8_t *data, size_t size) } MessageParcel dataMessageParcel; + if (!dataMessageParcel.WriteInterfaceToken(GetDescriptor())) { + return; + } dataMessageParcel.WriteBuffer(data, size); dataMessageParcel.RewindRead(0); + uint32_t code = static_cast(ICellularDataManagerIpcCode::COMMAND_GET_DEFAULT_CELLULAR_DATA_SLOT_ID); MessageParcel reply; - DelayedSingleton::GetInstance()->OnGetDefaultCellularDataSlotId(dataMessageParcel, reply); + MessageOption option(MessageOption::TF_SYNC); + DelayedSingleton::GetInstance()->OnRemoteRequest(code, dataMessageParcel, reply, option); } void EnableCellularDataRoaming(const uint8_t *data, size_t size) @@ -138,11 +171,16 @@ void EnableCellularDataRoaming(const uint8_t *data, size_t size) FuzzedDataProvider fdp(data, size); int32_t slotId = fdp.ConsumeIntegralInRange(0, SLOT_NUM_MAX); MessageParcel dataMessageParcel; + if (!dataMessageParcel.WriteInterfaceToken(GetDescriptor())) { + return; + } dataMessageParcel.WriteInt32(slotId); dataMessageParcel.WriteBuffer(data, size); dataMessageParcel.RewindRead(0); + uint32_t code = static_cast(ICellularDataManagerIpcCode::COMMAND_ENABLE_CELLULAR_DATA_ROAMING); MessageParcel reply; - DelayedSingleton::GetInstance()->OnEnableCellularDataRoaming(dataMessageParcel, reply); + MessageOption option(MessageOption::TF_SYNC); + DelayedSingleton::GetInstance()->OnRemoteRequest(code, dataMessageParcel, reply, option); } void SetDefaultCellularDataSlotId(const uint8_t *data, size_t size) @@ -154,11 +192,16 @@ void SetDefaultCellularDataSlotId(const uint8_t *data, size_t size) FuzzedDataProvider fdp(data, size); int32_t slotId = fdp.ConsumeIntegralInRange(0, SLOT_NUM_MAX); MessageParcel dataMessageParcel; + if (!dataMessageParcel.WriteInterfaceToken(GetDescriptor())) { + return; + } dataMessageParcel.WriteInt32(slotId); dataMessageParcel.WriteBuffer(data, size); dataMessageParcel.RewindRead(0); + uint32_t code = static_cast(ICellularDataManagerIpcCode::COMMAND_SET_DEFAULT_CELLULAR_DATA_SLOT_ID); MessageParcel reply; - DelayedSingleton::GetInstance()->OnSetDefaultCellularDataSlotId(dataMessageParcel, reply); + MessageOption option(MessageOption::TF_SYNC); + DelayedSingleton::GetInstance()->OnRemoteRequest(code, dataMessageParcel, reply, option); } void HasInternetCapability(const uint8_t *data, size_t size) @@ -170,11 +213,16 @@ void HasInternetCapability(const uint8_t *data, size_t size) FuzzedDataProvider fdp(data, size); int32_t slotId = fdp.ConsumeIntegralInRange(0, SLOT_NUM_MAX); MessageParcel dataMessageParcel; + if (!dataMessageParcel.WriteInterfaceToken(GetDescriptor())) { + return; + } dataMessageParcel.WriteInt32(slotId); dataMessageParcel.WriteBuffer(data, size); dataMessageParcel.RewindRead(0); + uint32_t code = static_cast(ICellularDataManagerIpcCode::COMMAND_HAS_INTERNET_CAPABILITY); MessageParcel reply; - DelayedSingleton::GetInstance()->OnHasInternetCapability(dataMessageParcel, reply); + MessageOption option(MessageOption::TF_SYNC); + DelayedSingleton::GetInstance()->OnRemoteRequest(code, dataMessageParcel, reply, option); } void ClearCellularDataConnections(const uint8_t *data, size_t size) @@ -186,11 +234,16 @@ void ClearCellularDataConnections(const uint8_t *data, size_t size) FuzzedDataProvider fdp(data, size); int32_t slotId = fdp.ConsumeIntegralInRange(0, SLOT_NUM_MAX); MessageParcel dataMessageParcel; + if (!dataMessageParcel.WriteInterfaceToken(GetDescriptor())) { + return; + } dataMessageParcel.WriteInt32(slotId); dataMessageParcel.WriteBuffer(data, size); dataMessageParcel.RewindRead(0); + uint32_t code = static_cast(ICellularDataManagerIpcCode::COMMAND_CLEAR_CELLULAR_DATA_CONNECTIONS); MessageParcel reply; - DelayedSingleton::GetInstance()->OnClearCellularDataConnections(dataMessageParcel, reply); + MessageOption option(MessageOption::TF_SYNC); + DelayedSingleton::GetInstance()->OnRemoteRequest(code, dataMessageParcel, reply, option); } void GetCellularDataFlowType(const uint8_t *data, size_t size) @@ -200,10 +253,15 @@ void GetCellularDataFlowType(const uint8_t *data, size_t size) } MessageParcel dataMessageParcel; + if (!dataMessageParcel.WriteInterfaceToken(GetDescriptor())) { + return; + } dataMessageParcel.WriteBuffer(data, size); dataMessageParcel.RewindRead(0); + uint32_t code = static_cast(ICellularDataManagerIpcCode::COMMAND_GET_CELLULAR_DATA_FLOW_TYPE); MessageParcel reply; - DelayedSingleton::GetInstance()->OnGetCellularDataFlowType(dataMessageParcel, reply); + MessageOption option(MessageOption::TF_SYNC); + DelayedSingleton::GetInstance()->OnRemoteRequest(code, dataMessageParcel, reply, option); } void RegisterSimAccountCallback(const uint8_t *data, size_t size) @@ -212,46 +270,425 @@ void RegisterSimAccountCallback(const uint8_t *data, size_t size) return; } MessageParcel dataMessageParcel; + if (!dataMessageParcel.WriteInterfaceToken(GetDescriptor())) { + return; + } + sptr callback = new (std::nothrow) DataSimAccountCallback(); + if (callback == nullptr) { + return; + } + dataMessageParcel.WriteRemoteObject(callback->AsObject()); + uint32_t code = static_cast(ICellularDataManagerIpcCode::COMMAND_REGISTER_SIM_ACCOUNT_CALLBACK); + MessageParcel reply; + MessageOption option(MessageOption::TF_SYNC); + DelayedSingleton::GetInstance()->OnRemoteRequest(code, dataMessageParcel, reply, option); +} + +void UnregisterSimAccountCallback(const uint8_t *data, size_t size) +{ + if (!IsServiceInited()) { + return; + } + MessageParcel dataMessageParcel; + if (!dataMessageParcel.WriteInterfaceToken(GetDescriptor())) { + return; + } + sptr callback = new (std::nothrow) DataSimAccountCallback(); + if (callback == nullptr) { + return; + } + dataMessageParcel.WriteRemoteObject(callback->AsObject()); + uint32_t code = static_cast(ICellularDataManagerIpcCode::COMMAND_UNREGISTER_SIM_ACCOUNT_CALLBACK); + MessageParcel reply; + MessageOption option(MessageOption::TF_SYNC); + DelayedSingleton::GetInstance()->OnRemoteRequest(code, dataMessageParcel, reply, option); +} + +void GetDefaultActReportInfo(const uint8_t *data, size_t size) +{ + if (!IsServiceInited()) { + return; + } + MessageParcel dataMessageParcel; + if (!dataMessageParcel.WriteInterfaceToken(GetDescriptor())) { + return; + } dataMessageParcel.WriteBuffer(data, size); dataMessageParcel.RewindRead(0); + uint32_t code = static_cast(ICellularDataManagerIpcCode::COMMAND_GET_DEFAULT_ACT_REPORT_INFO); MessageParcel reply; - DelayedSingleton::GetInstance()->OnRegisterSimAccountCallback(dataMessageParcel, reply); + MessageOption option(MessageOption::TF_SYNC); + DelayedSingleton::GetInstance()->OnRemoteRequest(code, dataMessageParcel, reply, option); } -void UnregisterSimAccountCallback(const uint8_t *data, size_t size) +void GetInternalActReportInfo(const uint8_t *data, size_t size) { if (!IsServiceInited()) { return; } MessageParcel dataMessageParcel; + if (!dataMessageParcel.WriteInterfaceToken(GetDescriptor())) { + return; + } dataMessageParcel.WriteBuffer(data, size); dataMessageParcel.RewindRead(0); + uint32_t code = static_cast(ICellularDataManagerIpcCode::COMMAND_GET_INTERNAL_ACT_REPORT_INFO); MessageParcel reply; - DelayedSingleton::GetInstance()->OnUnregisterSimAccountCallback(dataMessageParcel, reply); + MessageOption option(MessageOption::TF_SYNC); + DelayedSingleton::GetInstance()->OnRemoteRequest(code, dataMessageParcel, reply, option); } -void GetDefaultActReportInfo(const uint8_t *data, size_t size) +void HandleApnChanged(const uint8_t *data, size_t size) { if (!IsServiceInited()) { return; } + + FuzzedDataProvider fdp(data, size); + int32_t slotId = fdp.ConsumeIntegralInRange(0, SLOT_NUM_MAX); MessageParcel dataMessageParcel; + if (!dataMessageParcel.WriteInterfaceToken(GetDescriptor())) { + return; + } + dataMessageParcel.WriteInt32(slotId); dataMessageParcel.WriteBuffer(data, size); dataMessageParcel.RewindRead(0); + uint32_t code = static_cast(ICellularDataManagerIpcCode::COMMAND_HANDLE_APN_CHANGED); MessageParcel reply; - DelayedSingleton::GetInstance()->OnGetDefaultActReportInfo(dataMessageParcel, reply); + MessageOption option(MessageOption::TF_SYNC); + DelayedSingleton::GetInstance()->OnRemoteRequest(code, dataMessageParcel, reply, option); } -void GetInternalActReportInfo(const uint8_t *data, size_t size) +void GetDefaultCellularDataSimId(const uint8_t *data, size_t size) +{ + if (!IsServiceInited()) { + return; + } + + MessageParcel dataMessageParcel; + if (!dataMessageParcel.WriteInterfaceToken(GetDescriptor())) { + return; + } + dataMessageParcel.WriteBuffer(data, size); + dataMessageParcel.RewindRead(0); + uint32_t code = static_cast(ICellularDataManagerIpcCode::COMMAND_GET_DEFAULT_CELLULAR_DATA_SIM_ID); + MessageParcel reply; + MessageOption option(MessageOption::TF_SYNC); + DelayedSingleton::GetInstance()->OnRemoteRequest(code, dataMessageParcel, reply, option); +} + +void ClearAllConnections(const uint8_t *data, size_t size) +{ + if (!IsServiceInited()) { + return; + } + + FuzzedDataProvider fdp(data, size); + int32_t slotId = fdp.ConsumeIntegralInRange(0, SLOT_NUM_MAX); + int32_t reason = fdp.ConsumeIntegralInRange( + 0, static_cast(DisConnectionReason::REASON_PERMANENT_REJECT)); + MessageParcel dataMessageParcel; + if (!dataMessageParcel.WriteInterfaceToken(GetDescriptor())) { + return; + } + dataMessageParcel.WriteInt32(slotId); + dataMessageParcel.WriteInt32(reason); + dataMessageParcel.WriteBuffer(data, size); + dataMessageParcel.RewindRead(0); + uint32_t code = static_cast(ICellularDataManagerIpcCode::COMMAND_CLEAR_ALL_CONNECTIONS); + MessageParcel reply; + MessageOption option(MessageOption::TF_SYNC); + DelayedSingleton::GetInstance()->OnRemoteRequest(code, dataMessageParcel, reply, option); +} + +void GetDataConnApnAttr(const uint8_t *data, size_t size) +{ + if (!IsServiceInited()) { + return; + } + + FuzzedDataProvider fdp(data, size); + int32_t slotId = fdp.ConsumeIntegralInRange(0, SLOT_NUM_MAX); + MessageParcel dataMessageParcel; + if (!dataMessageParcel.WriteInterfaceToken(GetDescriptor())) { + return; + } + dataMessageParcel.WriteInt32(slotId); + dataMessageParcel.WriteBuffer(data, size); + dataMessageParcel.RewindRead(0); + uint32_t code = static_cast(ICellularDataManagerIpcCode::COMMAND_GET_DATA_CONN_APN_ATTR); + MessageParcel reply; + MessageOption option(MessageOption::TF_SYNC); + DelayedSingleton::GetInstance()->OnRemoteRequest(code, dataMessageParcel, reply, option); +} + +void GetDataConnIpType(const uint8_t *data, size_t size) +{ + if (!IsServiceInited()) { + return; + } + + FuzzedDataProvider fdp(data, size); + int32_t slotId = fdp.ConsumeIntegralInRange(0, SLOT_NUM_MAX); + MessageParcel dataMessageParcel; + if (!dataMessageParcel.WriteInterfaceToken(GetDescriptor())) { + return; + } + dataMessageParcel.WriteInt32(slotId); + dataMessageParcel.WriteBuffer(data, size); + dataMessageParcel.RewindRead(0); + uint32_t code = static_cast(ICellularDataManagerIpcCode::COMMAND_GET_DATA_CONN_IP_TYPE); + MessageParcel reply; + MessageOption option(MessageOption::TF_SYNC); + DelayedSingleton::GetInstance()->OnRemoteRequest(code, dataMessageParcel, reply, option); +} + +void GetApnState(const uint8_t *data, size_t size) +{ + if (!IsServiceInited()) { + return; + } + + FuzzedDataProvider fdp(data, size); + int32_t slotId = fdp.ConsumeIntegralInRange(0, SLOT_NUM_MAX); + MessageParcel dataMessageParcel; + if (!dataMessageParcel.WriteInterfaceToken(GetDescriptor())) { + return; + } + dataMessageParcel.WriteInt32(slotId); + std::string apnType = fdp.ConsumeRandomLengthString(APN_STRING_LENGTH); + if (!dataMessageParcel.WriteString16(Str8ToStr16(apnType))) { + return; + } + dataMessageParcel.RewindRead(0); + uint32_t code = static_cast(ICellularDataManagerIpcCode::COMMAND_GET_APN_STATE); + MessageParcel reply; + MessageOption option(MessageOption::TF_SYNC); + DelayedSingleton::GetInstance()->OnRemoteRequest(code, dataMessageParcel, reply, option); +} + +void GetDataRecoveryState(const uint8_t *data, size_t size) { if (!IsServiceInited()) { return; } + + MessageParcel dataMessageParcel; + if (!dataMessageParcel.WriteInterfaceToken(GetDescriptor())) { + return; + } + dataMessageParcel.WriteBuffer(data, size); + dataMessageParcel.RewindRead(0); + uint32_t code = static_cast(ICellularDataManagerIpcCode::COMMAND_GET_DATA_RECOVERY_STATE); + MessageParcel reply; + MessageOption option(MessageOption::TF_SYNC); + DelayedSingleton::GetInstance()->OnRemoteRequest(code, dataMessageParcel, reply, option); +} + +void GetCellularDataSupplierId(const uint8_t *data, size_t size) +{ + if (!IsServiceInited()) { + return; + } + + MessageParcel dataMessageParcel; + if (!dataMessageParcel.WriteInterfaceToken(GetDescriptor())) { + return; + } + FuzzedDataProvider fdp(data, size); + int32_t slotId = fdp.ConsumeIntegralInRange(0, SLOT_NUM_MAX); + dataMessageParcel.WriteInt32(slotId); + uint64_t capability = fdp.ConsumeIntegralInRange(0, NET_CAPABILITY_MAX); + dataMessageParcel.WriteUint64(capability); + dataMessageParcel.RewindRead(0); + uint32_t code = static_cast(ICellularDataManagerIpcCode::COMMAND_GET_CELLULAR_DATA_SUPPLIER_ID); + MessageParcel reply; + MessageOption option(MessageOption::TF_SYNC); + DelayedSingleton::GetInstance()->OnRemoteRequest(code, dataMessageParcel, reply, option); +} + +void IsNeedDoRecovery(const uint8_t *data, size_t size) +{ + if (!IsServiceInited()) { + return; + } + + FuzzedDataProvider fdp(data, size); + int32_t slotId = fdp.ConsumeIntegralInRange(0, SLOT_NUM_MAX); + MessageParcel dataMessageParcel; + if (!dataMessageParcel.WriteInterfaceToken(GetDescriptor())) { + return; + } + dataMessageParcel.WriteInt32(slotId); + dataMessageParcel.WriteBuffer(data, size); + dataMessageParcel.RewindRead(0); + uint32_t code = static_cast(ICellularDataManagerIpcCode::COMMAND_IS_NEED_DO_RECOVERY); + MessageParcel reply; + MessageOption option(MessageOption::TF_SYNC); + DelayedSingleton::GetInstance()->OnRemoteRequest(code, dataMessageParcel, reply, option); +} + +void CorrectNetSupplierNoAvailable(const uint8_t *data, size_t size) +{ + if (!IsServiceInited()) { + return; + } + + FuzzedDataProvider fdp(data, size); + int32_t slotId = fdp.ConsumeIntegralInRange(0, SLOT_NUM_MAX); + MessageParcel dataMessageParcel; + if (!dataMessageParcel.WriteInterfaceToken(GetDescriptor())) { + return; + } + dataMessageParcel.WriteInt32(slotId); + dataMessageParcel.WriteBuffer(data, size); + dataMessageParcel.RewindRead(0); + uint32_t code = static_cast(ICellularDataManagerIpcCode::COMMAND_CORRECT_NET_SUPPLIER_NO_AVAILABLE); + MessageParcel reply; + MessageOption option(MessageOption::TF_SYNC); + DelayedSingleton::GetInstance()->OnRemoteRequest(code, dataMessageParcel, reply, option); +} + +void GetIfSupportDunApn(const uint8_t *data, size_t size) +{ + if (!IsServiceInited()) { + return; + } + + MessageParcel dataMessageParcel; + if (!dataMessageParcel.WriteInterfaceToken(GetDescriptor())) { + return; + } + dataMessageParcel.WriteBuffer(data, size); + dataMessageParcel.RewindRead(0); + uint32_t code = static_cast(ICellularDataManagerIpcCode::COMMAND_GET_IF_SUPPORT_DUN_APN); + MessageParcel reply; + MessageOption option(MessageOption::TF_SYNC); + DelayedSingleton::GetInstance()->OnRemoteRequest(code, dataMessageParcel, reply, option); +} + +void QueryApnIds(const uint8_t *data, size_t size) +{ + if (!IsServiceInited()) { + return; + } + + MessageParcel dataMessageParcel; + if (!dataMessageParcel.WriteInterfaceToken(GetDescriptor())) { + return; + } + ApnInfo apnInfo; + dataMessageParcel.WriteParcelable(&apnInfo); + dataMessageParcel.WriteBuffer(data, size); + dataMessageParcel.RewindRead(0); + uint32_t code = static_cast(ICellularDataManagerIpcCode::COMMAND_QUERY_APN_IDS); + MessageParcel reply; + MessageOption option(MessageOption::TF_SYNC); + DelayedSingleton::GetInstance()->OnRemoteRequest(code, dataMessageParcel, reply, option); +} + +void SetPreferApn(const uint8_t *data, size_t size) +{ + if (!IsServiceInited()) { + return; + } + + MessageParcel dataMessageParcel; + if (!dataMessageParcel.WriteInterfaceToken(GetDescriptor())) { + return; + } + FuzzedDataProvider fdp(data, size); + int32_t apnId = fdp.ConsumeIntegralInRange(0, APN_ID_MAX); + dataMessageParcel.WriteInt32(apnId); + dataMessageParcel.RewindRead(0); + uint32_t code = static_cast(ICellularDataManagerIpcCode::COMMAND_SET_PREFER_APN); + MessageParcel reply; + MessageOption option(MessageOption::TF_SYNC); + DelayedSingleton::GetInstance()->OnRemoteRequest(code, dataMessageParcel, reply, option); +} + +void InitCellularDataController(const uint8_t *data, size_t size) +{ + if (!IsServiceInited()) { + return; + } + + FuzzedDataProvider fdp(data, size); + int32_t slotId = fdp.ConsumeIntegralInRange(0, SLOT_NUM_MAX); + MessageParcel dataMessageParcel; + if (!dataMessageParcel.WriteInterfaceToken(GetDescriptor())) { + return; + } + dataMessageParcel.WriteInt32(slotId); + dataMessageParcel.WriteBuffer(data, size); + dataMessageParcel.RewindRead(0); + uint32_t code = static_cast(ICellularDataManagerIpcCode::COMMAND_INIT_CELLULAR_DATA_CONTROLLER); + MessageParcel reply; + MessageOption option(MessageOption::TF_SYNC); + DelayedSingleton::GetInstance()->OnRemoteRequest(code, dataMessageParcel, reply, option); +} + +void EstablishAllApnsIfConnectable(const uint8_t *data, size_t size) +{ + if (!IsServiceInited()) { + return; + } + + FuzzedDataProvider fdp(data, size); + int32_t slotId = fdp.ConsumeIntegralInRange(0, SLOT_NUM_MAX); MessageParcel dataMessageParcel; + if (!dataMessageParcel.WriteInterfaceToken(GetDescriptor())) { + return; + } + dataMessageParcel.WriteInt32(slotId); dataMessageParcel.WriteBuffer(data, size); dataMessageParcel.RewindRead(0); + uint32_t code = static_cast(ICellularDataManagerIpcCode::COMMAND_ESTABLISH_ALL_APNS_IF_CONNECTABLE); MessageParcel reply; - DelayedSingleton::GetInstance()->OnGetInternalActReportInfo(dataMessageParcel, reply); + MessageOption option(MessageOption::TF_SYNC); + DelayedSingleton::GetInstance()->OnRemoteRequest(code, dataMessageParcel, reply, option); +} + +void ReleaseCellularDataConnection(const uint8_t *data, size_t size) +{ + if (!IsServiceInited()) { + return; + } + + FuzzedDataProvider fdp(data, size); + int32_t slotId = fdp.ConsumeIntegralInRange(0, SLOT_NUM_MAX); + MessageParcel dataMessageParcel; + if (!dataMessageParcel.WriteInterfaceToken(GetDescriptor())) { + return; + } + dataMessageParcel.WriteInt32(slotId); + dataMessageParcel.WriteBuffer(data, size); + dataMessageParcel.RewindRead(0); + uint32_t code = static_cast(ICellularDataManagerIpcCode::COMMAND_RELEASE_CELLULAR_DATA_CONNECTION); + MessageParcel reply; + MessageOption option(MessageOption::TF_SYNC); + DelayedSingleton::GetInstance()->OnRemoteRequest(code, dataMessageParcel, reply, option); +} + +void GetSupplierRegisterState(const uint8_t *data, size_t size) +{ + if (!IsServiceInited()) { + return; + } + + FuzzedDataProvider fdp(data, size); + int32_t slotId = fdp.ConsumeIntegralInRange(0, SLOT_NUM_MAX); + MessageParcel dataMessageParcel; + if (!dataMessageParcel.WriteInterfaceToken(GetDescriptor())) { + return; + } + dataMessageParcel.WriteInt32(slotId); + dataMessageParcel.WriteBuffer(data, size); + dataMessageParcel.RewindRead(0); + uint32_t code = static_cast(ICellularDataManagerIpcCode::COMMAND_GET_SUPPLIER_REGISTER_STATE); + MessageParcel reply; + MessageOption option(MessageOption::TF_SYNC); + DelayedSingleton::GetInstance()->OnRemoteRequest(code, dataMessageParcel, reply, option); } void DoSomethingInterestingWithMyAPI(const uint8_t *data, size_t size) @@ -260,8 +697,8 @@ void DoSomethingInterestingWithMyAPI(const uint8_t *data, size_t size) return; } - OnRemoteRequest(data, size); EnableCellularData(data, size); + EnableIntelligenceSwitch(data, size); GetCellularDataState(data, size); IsCellularDataEnabled(data, size); IsCellularDataRoamingEnabled(data, size); @@ -275,6 +712,23 @@ void DoSomethingInterestingWithMyAPI(const uint8_t *data, size_t size) UnregisterSimAccountCallback(data, size); GetDefaultActReportInfo(data, size); GetInternalActReportInfo(data, size); + HandleApnChanged(data, size); + GetDefaultCellularDataSimId(data, size); + ClearAllConnections(data, size); + GetDataConnApnAttr(data, size); + GetDataConnIpType(data, size); + GetApnState(data, size); + GetDataRecoveryState(data, size); + IsNeedDoRecovery(data, size); + InitCellularDataController(data, size); + EstablishAllApnsIfConnectable(data, size); + ReleaseCellularDataConnection(data, size); + GetSupplierRegisterState(data, size); + GetCellularDataSupplierId(data, size); + CorrectNetSupplierNoAvailable(data, size); + GetIfSupportDunApn(data, size); + QueryApnIds(data, size); + SetPreferApn(data, size); } } // namespace OHOS diff --git a/test/fuzztest/updatecellulardata_fuzzer/BUILD.gn b/test/fuzztest/updatecellulardata_fuzzer/BUILD.gn index 98404ea8fee440c061937e13105e9259f2e92e49..0d1208dc0ef0e7d619f119e124b8cc1c0995477a 100644 --- a/test/fuzztest/updatecellulardata_fuzzer/BUILD.gn +++ b/test/fuzztest/updatecellulardata_fuzzer/BUILD.gn @@ -60,6 +60,7 @@ ohos_fuzztest("UpdateCellularDataFuzzTest") { "netmanager_base:net_conn_manager_if", "netmanager_base:net_policy_manager_if", "netmanager_base:net_stats_manager_if", + "preferences:native_preferences", "relational_store:native_dataability", "relational_store:native_rdb", "safwk:system_ability_fwk", diff --git a/test/mock/mock_core_service.h b/test/mock/mock_core_service.h index 9cd7528f5d4b6d7afcb97d1a1bfc037bd2fc6d11..2aff93bee6a4344bdcbea93215f59a7b7e036fc1 100644 --- a/test/mock/mock_core_service.h +++ b/test/mock/mock_core_service.h @@ -41,8 +41,8 @@ public: MOCK_METHOD( int32_t, SetRadioState, (int32_t slotId, bool isOn, const sptr &callback), (override)); MOCK_METHOD(int32_t, GetRadioState, (int32_t slotId, const sptr &callback), (override)); - MOCK_METHOD(int32_t, GetImei, (int32_t slotId, std::u16string &imei), (override)); - MOCK_METHOD(int32_t, GetImeiSv, (int32_t slotId, std::u16string &imeiSv), (override)); + MOCK_METHOD(int32_t, GetImei, (int32_t slotId, const sptr &callback), (override)); + MOCK_METHOD(int32_t, GetImeiSv, (int32_t slotId, const sptr &callback), (override)); MOCK_METHOD(int32_t, GetMeid, (int32_t slotId, std::u16string &meid), (override)); MOCK_METHOD(int32_t, GetUniqueDeviceId, (int32_t slotId, std::u16string &deviceId), (override)); MOCK_METHOD(bool, IsNrSupported, (int32_t slotId), (override)); @@ -102,9 +102,9 @@ public: MOCK_METHOD(int32_t, SetPrimarySlotId, (int32_t slotId), (override)); MOCK_METHOD(int32_t, GetPrimarySlotId, (int32_t & slotId), (override)); MOCK_METHOD(int32_t, SetShowNumber, (int32_t slotId, const std::u16string &number), (override)); - MOCK_METHOD(int32_t, GetShowNumber, (int32_t slotId, std::u16string &showNumber), (override)); + MOCK_METHOD(int32_t, GetShowNumber, (int32_t slotId, const sptr &callback), (override)); MOCK_METHOD(int32_t, SetShowName, (int32_t slotId, const std::u16string &name), (override)); - MOCK_METHOD(int32_t, GetShowName, (int32_t slotId, std::u16string &showName), (override)); + MOCK_METHOD(int32_t, GetShowName, (int32_t slotId, const sptr &callback), (override)); MOCK_METHOD(int32_t, GetActiveSimAccountInfoList, (std::vector & iccAccountInfoList), (override)); MOCK_METHOD(int32_t, GetOperatorConfigs, (int32_t slotId, OperatorConfig &poc), (override)); MOCK_METHOD(int32_t, RefreshSimState, (int32_t slotId), (override)); diff --git a/test/mock/mock_net_conn_service.h b/test/mock/mock_net_conn_service.h index dafb5cdb8680a14d16dbc22fa1bb8c5f27280cee..b8fdf91e92e336c6727b0ba7a76d6f419cec4a31 100644 --- a/test/mock/mock_net_conn_service.h +++ b/test/mock/mock_net_conn_service.h @@ -97,8 +97,8 @@ public: MOCK_METHOD(int32_t, RegisterPreAirplaneCallback, (const sptr callback)); MOCK_METHOD(int32_t, UnregisterPreAirplaneCallback, (const sptr callback)); MOCK_METHOD( - int32_t, DecreaseSupplierScore, (NetBearType bearerType, const std::string &ident, uint32_t &supplierId)); - MOCK_METHOD(int32_t, IncreaseSupplierScore, (uint32_t supplierId)); + int32_t, GetDefaultSupplierId, (NetBearType bearerType, const std::string &ident, uint32_t &supplierId)); + MOCK_METHOD(int32_t, UpdateSupplierScore, (uint32_t supplierId, uint32_t detectionStatus)); MOCK_METHOD(int32_t, EnableVnicNetwork, (const sptr &netLinkInfo, const std::set &uids)); MOCK_METHOD(int32_t, DisableVnicNetwork, ()); MOCK_METHOD(int32_t, EnableDistributedClientNet, (const std::string &virnicAddr, const std::string &iif)); diff --git a/test/mock/mock_network_search.h b/test/mock/mock_network_search.h index 08357ce793032eaaf4e657edf1ccd5f40142e436..fafb7ea0288121331c1efbb72b3d71d83254020b 100644 --- a/test/mock/mock_network_search.h +++ b/test/mock/mock_network_search.h @@ -55,6 +55,7 @@ public: MOCK_METHOD2(GetPreferredNetwork, int32_t(int32_t slotId, NSCALLBACK &callback)); MOCK_METHOD3(SetPreferredNetwork, int32_t(int32_t slotId, int32_t networkMode, NSCALLBACK &callback)); MOCK_METHOD2(SetPreferredNetwork, bool(int32_t, int32_t)); + MOCK_METHOD2(SetForcePreferredNetwork, bool(int32_t, int32_t)); MOCK_METHOD1(GetPsRegState, int32_t(int32_t slotId)); MOCK_METHOD1(GetCsRegState, int32_t(int32_t slotId)); MOCK_METHOD1(GetPsRoamingState, int32_t(int32_t slotId)); @@ -68,6 +69,7 @@ public: MOCK_METHOD2(GetMeid, int32_t(int32_t slotId, std::u16string &meid)); MOCK_METHOD2(GetUniqueDeviceId, int32_t(int32_t slotId, std::u16string &deviceId)); MOCK_METHOD1(GetPhoneType, PhoneType(int32_t slotId)); + MOCK_METHOD2(SetNrOptionMode, int32_t(int32_t slotId, int32_t mode)); MOCK_METHOD3(SetNrOptionMode, int32_t(int32_t slotId, int32_t mode, NSCALLBACK &callback)); MOCK_METHOD2(GetNrOptionMode, int32_t(int32_t slotId, NrMode &mode)); MOCK_METHOD2(GetNrOptionMode, int32_t(int32_t slotId, NSCALLBACK &callback)); diff --git a/test/mock/mock_sim_manager.h b/test/mock/mock_sim_manager.h index 6a538d7f46ccacced18a51d9c8f343d49f3cf6ed..64223e4016383b5210af42465a9dd7bb9c908fa1 100644 --- a/test/mock/mock_sim_manager.h +++ b/test/mock/mock_sim_manager.h @@ -100,6 +100,8 @@ public: MOCK_METHOD2(SendTerminalResponseCmd, int32_t(int32_t, const std::string &)); MOCK_METHOD2(RegisterSimAccountCallback, int32_t(const int32_t, const sptr &)); MOCK_METHOD2(UpdateImsCapFromChip, void(int32_t, const ImsCapFromChip &)); + MOCK_METHOD2(GetSpdiPlmns, int32_t(int32_t, std::set &)); + MOCK_METHOD2(GetEhPlmns, int32_t(int32_t, std::set &)); MOCK_METHOD3(GetLockState, int32_t(int32_t, LockType, LockState &)); MOCK_METHOD3(GetSimAccountInfo, int32_t(int32_t, bool, IccAccountInfo &)); MOCK_METHOD3(ObtainSpnCondition, int(int32_t, bool, std::string)); diff --git a/test/unit_test/cellular_data_code_test.cpp b/test/unit_test/cellular_data_code_test.cpp index d54576ea149d094d6ebf9226b33b6d9afb9b6b15..5ebdfccd8214f1d67c1d3427b301fc8f850dc4c0 100644 --- a/test/unit_test/cellular_data_code_test.cpp +++ b/test/unit_test/cellular_data_code_test.cpp @@ -288,9 +288,10 @@ public: static void GetDefaultSlotId() { sptr proxy = CellularDataClient::GetInstance().GetProxy(); + int32_t slotId; if (proxy != nullptr) { - int32_t result = proxy->GetDefaultCellularDataSlotId(); - std::cout << "get default slot id is := " << result << std::endl; + int32_t result = proxy->GetDefaultCellularDataSlotId(slotId); + std::cout << "get default slot id is := " << slotId << std::endl; } else { std::cout << "get default slot id fail" << std::endl; } @@ -313,10 +314,11 @@ public: static void GetDataFlowType() { + int32_t type; sptr proxy = CellularDataClient::GetInstance().GetProxy(); if (proxy != nullptr) { - int32_t result = proxy->GetCellularDataFlowType(); - std::cout << "get CellDataFlowType is := " << result << std::endl; + int32_t result = proxy->GetCellularDataFlowType(type); + std::cout << "get CellDataFlowType is := " << type << std::endl; } else { std::cout << "get CellDataFlowType is fail" << std::endl; } diff --git a/test/zero_branch_test.cpp b/test/zero_branch_test.cpp index 57cc6fbbc5ba06918041f2fa1df041843a55330d..d2f5b2caaa84fb91545a9600f89cfb9da37628b2 100644 --- a/test/zero_branch_test.cpp +++ b/test/zero_branch_test.cpp @@ -29,13 +29,14 @@ #include "cellular_data_rdb_observer.h" #include "cellular_data_roaming_observer.h" #include "cellular_data_service.h" -#include "cellular_data_service_stub.h" +#include "cellular_data_manager_stub.h" #include "cellular_data_setting_observer.h" #include "cellular_data_settings_rdb_helper.h" #include "cellular_data_state_machine.h" #include "cellular_data_utils.h" #include "common_event_manager.h" #include "common_event_support.h" +#include "core_service_client.h" #include "data_access_token.h" #include "data_connection_manager.h" #include "data_connection_monitor.h" @@ -54,6 +55,8 @@ #include "telephony_hisysevent.h" #include "telephony_log_wrapper.h" #include "uri.h" +#include "apn_attribute.h" +#include "icellular_data_manager.h" namespace OHOS { namespace Telephony { @@ -653,6 +656,25 @@ HWTEST_F(BranchTest, Telephony_CellularDataHandler_013, Function | MediumTest | ASSERT_FALSE(cellularDataHandler.HasInnerEvent(CellularDataEventCode::MSG_ESTABLISH_DATA_CONNECTION)); } +/** + * @tc.number Telephony_CellularDataHandler_014 + * @tc.name test error branch + * @tc.desc Function test + */ +HWTEST_F(BranchTest, Telephony_CellularDataHandler_014, Function | MediumTest | Level1) +{ + CellularDataController controller { 0 }; + controller.Init(); + ASSERT_FALSE(controller.cellularDataHandler_ == nullptr); + auto event = AppExecFwk::InnerEvent::Get(0); + system::SetParameter("persist.edm.mobile_data_policy", "force_open"); + controller.cellularDataHandler_->HandleDBSettingEnableChanged(event); + controller.cellularDataHandler_->UnRegisterDataSettingObserver(); + controller.cellularDataHandler_->RemoveAllEvents(); + system::SetParameter("persist.edm.mobile_data_policy", "none"); + sleep(SLEEP_TIME_SECONDS); +} + /** * @tc.number Telephony_CellularDataService_001 * @tc.name test error branch @@ -669,25 +691,29 @@ HWTEST_F(BranchTest, Telephony_CellularDataService_001, Function | MediumTest | service.InitModule(); bool dataEnabled = false; bool dataRoamingEnabled = false; + int32_t cellularDataState; + int32_t slotId; + int32_t capability; + int32_t type; ASSERT_NE(TELEPHONY_ERR_SUCCESS, service.IsCellularDataEnabled(dataEnabled)); ASSERT_NE(TELEPHONY_ERR_SUCCESS, service.EnableCellularData(false)); ASSERT_NE(TELEPHONY_ERR_SUCCESS, service.EnableCellularData(true)); - ASSERT_NE(TELEPHONY_ERR_SUCCESS, service.GetCellularDataState()); + ASSERT_NE(TELEPHONY_ERR_SUCCESS, service.GetCellularDataState(cellularDataState)); ASSERT_NE(TELEPHONY_ERR_SUCCESS, service.IsCellularDataRoamingEnabled(INVALID_SLOTID, dataRoamingEnabled)); ASSERT_NE(TELEPHONY_ERR_SUCCESS, service.EnableCellularDataRoaming(INVALID_SLOTID, false)); ASSERT_NE(TELEPHONY_ERR_SUCCESS, service.IsCellularDataRoamingEnabled(DEFAULT_SIM_SLOT_ID, dataRoamingEnabled)); ASSERT_NE(TELEPHONY_ERR_SUCCESS, service.EnableCellularDataRoaming(DEFAULT_SIM_SLOT_ID, true)); ASSERT_NE(TELEPHONY_ERR_SUCCESS, service.HandleApnChanged(INVALID_SLOTID)); ASSERT_NE(TELEPHONY_ERR_SUCCESS, service.HandleApnChanged(DEFAULT_SIM_SLOT_ID)); - ASSERT_NE(TELEPHONY_ERR_SUCCESS, service.GetDefaultCellularDataSlotId()); + ASSERT_NE(TELEPHONY_ERR_SUCCESS, service.GetDefaultCellularDataSlotId(slotId)); ASSERT_NE(TELEPHONY_ERR_SUCCESS, service.SetDefaultCellularDataSlotId(INVALID_SLOTID)); ASSERT_NE(TELEPHONY_ERR_SUCCESS, service.SetDefaultCellularDataSlotId(DEFAULT_SIM_SLOT_ID)); - ASSERT_NE(TELEPHONY_ERR_SUCCESS, service.GetCellularDataFlowType()); - ASSERT_NE(TELEPHONY_ERR_SUCCESS, service.HasInternetCapability(INVALID_SLOTID, 0)); - ASSERT_NE(TELEPHONY_ERR_SUCCESS, service.HasInternetCapability(DEFAULT_SIM_SLOT_ID, 0)); + ASSERT_NE(TELEPHONY_ERR_SUCCESS, service.GetCellularDataFlowType(type)); + ASSERT_NE(TELEPHONY_ERR_SUCCESS, service.HasInternetCapability(INVALID_SLOTID, 0, capability)); + ASSERT_NE(TELEPHONY_ERR_SUCCESS, service.HasInternetCapability(DEFAULT_SIM_SLOT_ID, 0, capability)); ASSERT_NE(TELEPHONY_ERR_SUCCESS, service.ClearCellularDataConnections(INVALID_SLOTID)); ASSERT_NE(TELEPHONY_ERR_SUCCESS, service.ClearCellularDataConnections(DEFAULT_SIM_SLOT_ID)); - DisConnectionReason reason = DisConnectionReason::REASON_NORMAL; + int32_t reason = static_cast(DisConnectionReason::REASON_NORMAL); ASSERT_NE(TELEPHONY_ERR_SUCCESS, service.ClearAllConnections(INVALID_SLOTID, reason)); ASSERT_NE(TELEPHONY_ERR_SUCCESS, service.ClearAllConnections(DEFAULT_SIM_SLOT_ID, reason)); ASSERT_NE(TELEPHONY_ERR_SUCCESS, service.ChangeConnectionForDsds(INVALID_SLOTID, false)); @@ -720,28 +746,33 @@ HWTEST_F(BranchTest, Telephony_CellularDataService_002, Function | MediumTest | service.InitModule(); bool dataEnabled = false; bool dataRoamingEnabled = false; + int32_t cellularDataState; + int32_t state; + int32_t slotId; + int32_t capability; + int32_t type; ASSERT_NE(TELEPHONY_ERR_SUCCESS, service.IsCellularDataEnabled(dataEnabled)); ASSERT_NE(TELEPHONY_ERR_SUCCESS, service.EnableIntelligenceSwitch(false)); ASSERT_NE(TELEPHONY_ERR_SUCCESS, service.EnableIntelligenceSwitch(true)); ASSERT_NE(TELEPHONY_ERR_SUCCESS, service.EnableCellularData(false)); - ASSERT_NE(TELEPHONY_ERR_SUCCESS, service.GetCellularDataState()); + ASSERT_NE(TELEPHONY_ERR_SUCCESS, service.GetCellularDataState(cellularDataState)); ASSERT_NE(TELEPHONY_ERR_SUCCESS, service.IsCellularDataRoamingEnabled(INVALID_SLOTID, dataRoamingEnabled)); ASSERT_NE(TELEPHONY_ERR_SUCCESS, service.EnableCellularDataRoaming(INVALID_SLOTID, false)); ASSERT_NE(TELEPHONY_ERR_SUCCESS, service.HandleApnChanged(INVALID_SLOTID)); - ASSERT_NE(TELEPHONY_ERR_SUCCESS, service.GetDefaultCellularDataSlotId()); + ASSERT_NE(TELEPHONY_ERR_SUCCESS, service.GetDefaultCellularDataSlotId(slotId)); ASSERT_NE(TELEPHONY_ERR_SUCCESS, service.SetDefaultCellularDataSlotId(INVALID_SLOTID)); - ASSERT_NE(TELEPHONY_ERR_SUCCESS, service.GetCellularDataFlowType()); - ASSERT_NE(TELEPHONY_ERR_SUCCESS, service.HasInternetCapability(INVALID_SLOTID, 0)); + ASSERT_NE(TELEPHONY_ERR_SUCCESS, service.GetCellularDataFlowType(type)); + ASSERT_NE(TELEPHONY_ERR_SUCCESS, service.HasInternetCapability(INVALID_SLOTID, 0, capability)); ASSERT_NE(TELEPHONY_ERR_SUCCESS, service.ClearCellularDataConnections(INVALID_SLOTID)); - DisConnectionReason reason = DisConnectionReason::REASON_NORMAL; + int32_t reason = static_cast(DisConnectionReason::REASON_NORMAL); ASSERT_NE(TELEPHONY_ERR_SUCCESS, service.ClearAllConnections(INVALID_SLOTID, reason)); ASSERT_NE(TELEPHONY_ERR_SUCCESS, service.ChangeConnectionForDsds(INVALID_SLOTID, false)); ASSERT_NE(TELEPHONY_ERR_SUCCESS, service.StrategySwitch(INVALID_SLOTID, false)); ASSERT_FALSE(service.GetCellularDataController(INVALID_SLOTID) != nullptr); ASSERT_FALSE(service.GetCellularDataController(INVALID_SLOTID_TWO) != nullptr); - ASSERT_EQ(CELLULAR_DATA_INVALID_PARAM, service.GetApnState(DEFAULT_SIM_SLOT_ID, std::string())); - ASSERT_EQ(CELLULAR_DATA_INVALID_PARAM, service.GetApnState(INVALID_SLOTID, std::string())); - ASSERT_EQ(service.GetDataRecoveryState(), 0); + ASSERT_EQ(CELLULAR_DATA_INVALID_PARAM, service.GetApnState(DEFAULT_SIM_SLOT_ID, std::string(), state)); + ASSERT_EQ(CELLULAR_DATA_INVALID_PARAM, service.GetApnState(INVALID_SLOTID, std::string(), state)); + ASSERT_EQ(service.GetDataRecoveryState(state), 0); ASSERT_NE(TELEPHONY_ERR_SUCCESS, service.InitCellularDataController(2)); ASSERT_NE(TELEPHONY_ERR_SUCCESS, service.InitCellularDataController(INVALID_SLOTID)); service.GetFlowDataInfoDump(); @@ -765,27 +796,31 @@ HWTEST_F(BranchTest, Telephony_CellularDataService_003, Function | MediumTest | service.cellularDataControllers_.clear(); bool dataEnabled = false; bool dataRoamingEnabled = false; + int32_t cellularDataState; + int32_t slotId; + int32_t capability; + int32_t type; ASSERT_NE(TELEPHONY_ERR_SUCCESS, service.IsCellularDataEnabled(dataEnabled)); ASSERT_NE(TELEPHONY_ERR_SUCCESS, service.EnableCellularData(false)); ASSERT_NE(TELEPHONY_ERR_SUCCESS, service.EnableCellularData(true)); ASSERT_NE(TELEPHONY_ERR_SUCCESS, service.EnableCellularDataRoaming(INVALID_SLOTID, false)); ASSERT_NE(TELEPHONY_ERR_SUCCESS, service.IsCellularDataRoamingEnabled(DEFAULT_SIM_SLOT_ID, dataRoamingEnabled)); ASSERT_NE(TELEPHONY_ERR_SUCCESS, service.EnableCellularDataRoaming(DEFAULT_SIM_SLOT_ID, true)); - ASSERT_NE(TELEPHONY_ERR_SUCCESS, service.GetCellularDataState()); + ASSERT_NE(TELEPHONY_ERR_SUCCESS, service.GetCellularDataState(cellularDataState)); ASSERT_NE(TELEPHONY_ERR_SUCCESS, service.IsCellularDataRoamingEnabled(INVALID_SLOTID, dataRoamingEnabled)); ASSERT_NE(TELEPHONY_ERR_SUCCESS, service.HandleApnChanged(INVALID_SLOTID)); ASSERT_NE(TELEPHONY_ERR_SUCCESS, service.HandleApnChanged(DEFAULT_SIM_SLOT_ID)); ASSERT_NE(TELEPHONY_ERR_SUCCESS, service.SetDefaultCellularDataSlotId(INVALID_SLOTID)); ASSERT_NE(TELEPHONY_ERR_SUCCESS, service.SetDefaultCellularDataSlotId(DEFAULT_SIM_SLOT_ID)); - ASSERT_NE(TELEPHONY_ERR_SUCCESS, service.GetCellularDataFlowType()); - ASSERT_NE(TELEPHONY_ERR_SUCCESS, service.HasInternetCapability(INVALID_SLOTID, 0)); - ASSERT_NE(TELEPHONY_ERR_SUCCESS, service.HasInternetCapability(DEFAULT_SIM_SLOT_ID, 0)); - ASSERT_NE(TELEPHONY_ERR_SUCCESS, service.GetDefaultCellularDataSlotId()); + ASSERT_NE(TELEPHONY_ERR_SUCCESS, service.GetCellularDataFlowType(type)); + ASSERT_NE(TELEPHONY_ERR_SUCCESS, service.HasInternetCapability(INVALID_SLOTID, 0, capability)); + ASSERT_NE(TELEPHONY_ERR_SUCCESS, service.HasInternetCapability(DEFAULT_SIM_SLOT_ID, 0, capability)); + ASSERT_NE(TELEPHONY_ERR_SUCCESS, service.GetDefaultCellularDataSlotId(slotId)); ASSERT_NE(TELEPHONY_ERR_SUCCESS, service.StrategySwitch(INVALID_SLOTID, false)); ASSERT_NE(TELEPHONY_ERR_SUCCESS, service.StrategySwitch(DEFAULT_SIM_SLOT_ID, false)); ASSERT_NE(TELEPHONY_ERR_SUCCESS, service.ClearCellularDataConnections(INVALID_SLOTID)); ASSERT_NE(TELEPHONY_ERR_SUCCESS, service.ClearCellularDataConnections(DEFAULT_SIM_SLOT_ID)); - DisConnectionReason reason = DisConnectionReason::REASON_NORMAL; + int32_t reason = static_cast(DisConnectionReason::REASON_NORMAL); ASSERT_NE(TELEPHONY_ERR_SUCCESS, service.ClearAllConnections(INVALID_SLOTID, reason)); ASSERT_NE(TELEPHONY_ERR_SUCCESS, service.ClearAllConnections(DEFAULT_SIM_SLOT_ID, reason)); ASSERT_NE(TELEPHONY_ERR_SUCCESS, service.ChangeConnectionForDsds(INVALID_SLOTID, false)); @@ -811,6 +846,7 @@ HWTEST_F(BranchTest, Telephony_CellularDataService_004, Function | MediumTest | DataAccessToken token; CellularDataService service; std::vector strV; + int32_t state; ASSERT_EQ(TELEPHONY_ERR_FAIL, service.Dump(INVALID_FD, strV)); service.state_ = ServiceRunningState::STATE_RUNNING; service.OnStart(); @@ -818,12 +854,12 @@ HWTEST_F(BranchTest, Telephony_CellularDataService_004, Function | MediumTest | service.GetFlowDataInfoDump(); ASSERT_NE(TELEPHONY_ERR_SUCCESS, service.EnableIntelligenceSwitch(false)); ASSERT_NE(TELEPHONY_ERR_SUCCESS, service.EnableIntelligenceSwitch(true)); - ASSERT_EQ(CELLULAR_DATA_INVALID_PARAM, service.GetApnState(DEFAULT_SIM_SLOT_ID, std::string())); - ASSERT_EQ(CELLULAR_DATA_INVALID_PARAM, service.GetApnState(INVALID_SLOTID, std::string())); - ASSERT_EQ(service.GetDataRecoveryState(), 0); + ASSERT_EQ(CELLULAR_DATA_INVALID_PARAM, service.GetApnState(DEFAULT_SIM_SLOT_ID, std::string(), state)); + ASSERT_EQ(CELLULAR_DATA_INVALID_PARAM, service.GetApnState(INVALID_SLOTID, std::string(), state)); + ASSERT_EQ(service.GetDataRecoveryState(state), 0); ASSERT_EQ(TELEPHONY_ERR_SUCCESS, service.InitCellularDataController(2)); ASSERT_NE(TELEPHONY_ERR_SUCCESS, service.InitCellularDataController(INVALID_SLOTID)); - ApnItem::Attribute apnAttr; + ApnAttribute apnAttr; ASSERT_NE(TELEPHONY_ERR_SUCCESS, service.GetDataConnApnAttr(INVALID_SLOTID, apnAttr)); ASSERT_NE(TELEPHONY_ERR_SUCCESS, service.GetDataConnApnAttr(DEFAULT_SIM_SLOT_ID, apnAttr)); std::string ipType; @@ -843,6 +879,7 @@ HWTEST_F(BranchTest, Telephony_CellularDataService_005, Function | MediumTest | DataAccessToken token; CellularDataService service; std::vector strV; + int32_t state; ASSERT_EQ(TELEPHONY_ERR_FAIL, service.Dump(INVALID_FD, strV)); service.state_ = ServiceRunningState::STATE_RUNNING; service.OnStart(); @@ -850,13 +887,13 @@ HWTEST_F(BranchTest, Telephony_CellularDataService_005, Function | MediumTest | service.cellularDataControllers_.clear(); ASSERT_NE(TELEPHONY_ERR_SUCCESS, service.EnableIntelligenceSwitch(false)); ASSERT_NE(TELEPHONY_ERR_SUCCESS, service.EnableIntelligenceSwitch(true)); - ASSERT_EQ(CELLULAR_DATA_INVALID_PARAM, service.GetApnState(DEFAULT_SIM_SLOT_ID, std::string())); - ASSERT_EQ(CELLULAR_DATA_INVALID_PARAM, service.GetApnState(INVALID_SLOTID, std::string())); - ASSERT_EQ(service.GetDataRecoveryState(), 0); + ASSERT_EQ(CELLULAR_DATA_INVALID_PARAM, service.GetApnState(DEFAULT_SIM_SLOT_ID, std::string(), state)); + ASSERT_EQ(CELLULAR_DATA_INVALID_PARAM, service.GetApnState(INVALID_SLOTID, std::string(), state)); + ASSERT_EQ(service.GetDataRecoveryState(state), 0); ASSERT_EQ(TELEPHONY_ERR_SUCCESS, service.InitCellularDataController(2)); ASSERT_NE(TELEPHONY_ERR_SUCCESS, service.InitCellularDataController(INVALID_SLOTID)); service.GetFlowDataInfoDump(); - ApnItem::Attribute apnAttr; + ApnAttribute apnAttr; ASSERT_NE(TELEPHONY_ERR_SUCCESS, service.GetDataConnApnAttr(INVALID_SLOTID, apnAttr)); ASSERT_NE(TELEPHONY_ERR_SUCCESS, service.GetDataConnApnAttr(DEFAULT_SIM_SLOT_ID, apnAttr)); std::string ipType; @@ -897,6 +934,30 @@ HWTEST_F(BranchTest, Telephony_CellularDataService_006, Function | MediumTest | ASSERT_NE(TELEPHONY_ERR_FAIL, service.GetSupplierRegisterState(0, regState)); } +/** + * @tc.number Telephony_CellularDataService_007 + * @tc.name test error branch + * @tc.desc Function test + */ +HWTEST_F(BranchTest, Telephony_CellularDataService_007, Function | MediumTest | Level3) +{ + CellularDataService service; + std::vector strV; + ASSERT_EQ(TELEPHONY_ERR_FAIL, service.Dump(INVALID_FD, strV)); + service.state_ = ServiceRunningState::STATE_RUNNING; + service.OnStart(); + service.InitModule(); + system::SetParameter("persist.edm.mobile_data_policy", "none"); + ASSERT_NE(TELEPHONY_ERR_SUCCESS, service.EnableCellularData(false)); + ASSERT_NE(TELEPHONY_ERR_SUCCESS, service.EnableCellularData(true)); + system::SetParameter("persist.edm.mobile_data_policy", "force_open"); + ASSERT_NE(TELEPHONY_ERR_SUCCESS, service.EnableCellularData(false)); + ASSERT_NE(TELEPHONY_ERR_SUCCESS, service.EnableCellularData(true)); + service.GetFlowDataInfoDump(); + service.OnStop(); + system::SetParameter("persist.edm.mobile_data_policy", "none"); +} + /** * @tc.number CellularDataController_001 * @tc.name test error branch @@ -1204,6 +1265,32 @@ HWTEST_F(BranchTest, Telephony_DataConnectionMonitor_002, Function | MediumTest ASSERT_EQ(CellDataFlowType::DATA_FLOW_TYPE_NONE, con.connectionMonitor_->GetDataFlowType()); } +/** + +@tc.number DataConnectionMonitor_003 +@tc.name test error branch +@tc.desc Function test +*/ +HWTEST_F(BranchTest, Telephony_DataConnectionMonitor_003, Function | MediumTest | Level3) +{ + std::shared_ptr dataConnectionMonitor = std::make_shared(0); + ASSERT_FALSE(dataConnectionMonitor == nullptr); + dataConnectionMonitor->HandleScreenStateChanged(false); + dataConnectionMonitor->HandleScreenStateChanged(true); + ASSERT_FALSE(dataConnectionMonitor->IsVsimEnabled()); +#ifdef OHOS_BUILD_ENABLE_TELEPHONY_EXT + auto getVSimSlotId = TELEPHONY_EXT_WRAPPER.getVSimSlotId_; + auto isVSimEnabled = TELEPHONY_EXT_WRAPPER.isVSimEnabled_; + TELEPHONY_EXT_WRAPPER.getVSimSlotId_ = nullptr; + ASSERT_FALSE(dataConnectionMonitor->IsVsimEnabled()); + TELEPHONY_EXT_WRAPPER.isVSimEnabled_ = nullptr; + ASSERT_FALSE(dataConnectionMonitor->IsVsimEnabled()); + TELEPHONY_EXT_WRAPPER.getVSimSlotId_ = getVSimSlotId; + ASSERT_FALSE(dataConnectionMonitor->IsVsimEnabled()); + TELEPHONY_EXT_WRAPPER.isVSimEnabled_ = isVSimEnabled; +#endif +} + /** * @tc.number CellularDataUtils_001 * @tc.name test error branch @@ -1817,36 +1904,81 @@ HWTEST_F(BranchTest, CellularDataUtils_Test_01, Function | MediumTest | Level3) dataConnectionMonitor->GetDataFlowType(); dataConnectionMonitor->IsNeedDoRecovery(true); dataConnectionMonitor->IsNeedDoRecovery(false); +} + +/** + * @tc.number CellularDataUtils_Test_02 + * @tc.name test error branch + * @tc.desc Function test + */ +HWTEST_F(BranchTest, CellularDataUtils_Test_02, Function | MediumTest | Level3) +{ + auto cellularDataService = DelayedSingleton::GetInstance(); + MessageParcel data; + MessageParcel reply; + MessageOption option(MessageOption::TF_SYNC); + EXPECT_GE(cellularDataService->OnRemoteRequest(static_cast( + ICellularDataManagerIpcCode::COMMAND_IS_CELLULAR_DATA_ENABLED), data, reply, option), 0); + EXPECT_GE(cellularDataService->OnRemoteRequest(static_cast( + ICellularDataManagerIpcCode::COMMAND_ENABLE_CELLULAR_DATA), data, reply, option), 0); + EXPECT_GE(cellularDataService->OnRemoteRequest(static_cast( + ICellularDataManagerIpcCode::COMMAND_ENABLE_INTELLIGENCE_SWITCH), data, reply, option), 0); + EXPECT_GE(cellularDataService->OnRemoteRequest(static_cast( + ICellularDataManagerIpcCode::COMMAND_GET_CELLULAR_DATA_STATE), data, reply, option), 0); + EXPECT_GE(cellularDataService->OnRemoteRequest(static_cast( + ICellularDataManagerIpcCode::COMMAND_IS_CELLULAR_DATA_ROAMING_ENABLED), data, reply, option), 0); + EXPECT_GE(cellularDataService->OnRemoteRequest(static_cast( + ICellularDataManagerIpcCode::COMMAND_ENABLE_CELLULAR_DATA_ROAMING), data, reply, option), 0); + EXPECT_GE(cellularDataService->OnRemoteRequest(static_cast( + ICellularDataManagerIpcCode::COMMAND_HANDLE_APN_CHANGED), data, reply, option), 0); + EXPECT_GE(cellularDataService->OnRemoteRequest(static_cast( + ICellularDataManagerIpcCode::COMMAND_GET_DEFAULT_CELLULAR_DATA_SLOT_ID), data, reply, option), 0); + EXPECT_GE(cellularDataService->OnRemoteRequest(static_cast( + ICellularDataManagerIpcCode::COMMAND_GET_DEFAULT_CELLULAR_DATA_SIM_ID), data, reply, option), 0); + EXPECT_GE(cellularDataService->OnRemoteRequest(static_cast( + ICellularDataManagerIpcCode::COMMAND_SET_DEFAULT_CELLULAR_DATA_SLOT_ID), data, reply, option), 0); +} + +/** + * @tc.number CellularDataUtils_Test_03 + * @tc.name test error branch + * @tc.desc Function test + */ +HWTEST_F(BranchTest, CellularDataUtils_Test_03, Function | MediumTest | Level3) +{ auto cellularDataService = DelayedSingleton::GetInstance(); MessageParcel data; MessageParcel reply; - EXPECT_GE(cellularDataService->OnIsCellularDataEnabled(data, reply), 0); - EXPECT_GE(cellularDataService->OnEnableCellularData(data, reply), 0); - EXPECT_GE(cellularDataService->OnGetCellularDataState(data, reply), 0); - EXPECT_GE(cellularDataService->OnIsCellularDataRoamingEnabled(data, reply), 0); - EXPECT_GE(cellularDataService->OnEnableCellularDataRoaming(data, reply), 0); - EXPECT_GE(cellularDataService->OnHandleApnChanged(data, reply), 0); - cellularDataService->OnGetDefaultCellularDataSlotId(data, reply); - EXPECT_GE(cellularDataService->OnGetDefaultCellularDataSimId(data, reply), 0); - EXPECT_GE(cellularDataService->OnSetDefaultCellularDataSlotId(data, reply), 0); - EXPECT_GE(cellularDataService->OnGetCellularDataFlowType(data, reply), 0); - EXPECT_GE(cellularDataService->OnHasInternetCapability(data, reply), 0); - EXPECT_GE(cellularDataService->OnClearCellularDataConnections(data, reply), 0); - EXPECT_GE(cellularDataService->OnRegisterSimAccountCallback(data, reply), 0); - EXPECT_GE(cellularDataService->OnUnregisterSimAccountCallback(data, reply), 0); - EXPECT_GE(cellularDataService->OnEnableIntelligenceSwitch(data, reply), 0); - EXPECT_GE(cellularDataService->OnGetDataConnApnAttr(data, reply), 0); - EXPECT_GE(cellularDataService->OnGetDataConnIpType(data, reply), 0); - EXPECT_GE(cellularDataService->OnGetApnState(data, reply), 0); - EXPECT_GE(cellularDataService->OnGetRecoveryState(data, reply), 0); - EXPECT_GE(cellularDataService->OnIsNeedDoRecovery(data, reply), 0); - EXPECT_GE(cellularDataService->OnIsNeedDoRecovery(data, reply), 0); - EXPECT_GE(cellularDataService->OnClearAllConnections(data, reply), 0); - EXPECT_GE(cellularDataService->OnGetCellularDataSupplierId(data, reply), 0); - EXPECT_GE(cellularDataService->OnCorrectNetSupplierNoAvailable(data, reply), 0); - EXPECT_GE(cellularDataService->OnGetSupplierRegisterState(data, reply), 0); + MessageOption option(MessageOption::TF_SYNC); + EXPECT_GE(cellularDataService->OnRemoteRequest(static_cast( + ICellularDataManagerIpcCode::COMMAND_GET_CELLULAR_DATA_FLOW_TYPE), data, reply, option), 0); + EXPECT_GE(cellularDataService->OnRemoteRequest(static_cast( + ICellularDataManagerIpcCode::COMMAND_HAS_INTERNET_CAPABILITY), data, reply, option), 0); + EXPECT_GE(cellularDataService->OnRemoteRequest(static_cast( + ICellularDataManagerIpcCode::COMMAND_CLEAR_CELLULAR_DATA_CONNECTIONS), data, reply, option), 0); + EXPECT_GE(cellularDataService->OnRemoteRequest(static_cast( + ICellularDataManagerIpcCode::COMMAND_CLEAR_ALL_CONNECTIONS), data, reply, option), 0); + EXPECT_GE(cellularDataService->OnRemoteRequest(static_cast( + ICellularDataManagerIpcCode::COMMAND_GET_DATA_CONN_APN_ATTR), data, reply, option), 0); + EXPECT_GE(cellularDataService->OnRemoteRequest(static_cast( + ICellularDataManagerIpcCode::COMMAND_GET_DATA_CONN_IP_TYPE), data, reply, option), 0); + EXPECT_GE(cellularDataService->OnRemoteRequest(static_cast( + ICellularDataManagerIpcCode::COMMAND_GET_APN_STATE), data, reply, option), 0); + EXPECT_GE(cellularDataService->OnRemoteRequest(static_cast( + ICellularDataManagerIpcCode::COMMAND_GET_DATA_RECOVERY_STATE), data, reply, option), 0); + EXPECT_GE(cellularDataService->OnRemoteRequest(static_cast( + ICellularDataManagerIpcCode::COMMAND_IS_NEED_DO_RECOVERY), data, reply, option), 0); + EXPECT_GE(cellularDataService->OnRemoteRequest(static_cast( + ICellularDataManagerIpcCode::COMMAND_INIT_CELLULAR_DATA_CONTROLLER), data, reply, option), 0); + EXPECT_GE(cellularDataService->OnRemoteRequest(static_cast( + ICellularDataManagerIpcCode::COMMAND_ESTABLISH_ALL_APNS_IF_CONNECTABLE), data, reply, option), 0); + EXPECT_GE(cellularDataService->OnRemoteRequest(static_cast( + ICellularDataManagerIpcCode::COMMAND_RELEASE_CELLULAR_DATA_CONNECTION), data, reply, option), 0); + EXPECT_GE(cellularDataService->OnRemoteRequest(static_cast( + ICellularDataManagerIpcCode::COMMAND_GET_CELLULAR_DATA_SUPPLIER_ID), data, reply, option), 0); + EXPECT_GE(cellularDataService->OnRemoteRequest(static_cast( + ICellularDataManagerIpcCode::COMMAND_CORRECT_NET_SUPPLIER_NO_AVAILABLE), data, reply, option), 0); } - /** * @tc.number CellularDataSettingsRdbHelper_Test_01 * @tc.name test error branch @@ -2241,5 +2373,126 @@ HWTEST_F(BranchTest, IsSupportDunApn_001, Function | MediumTest | Level1) EXPECT_FALSE(controller.IsSupportDunApn()); } +/** + * @tc.number CellularDataConnectionManager_003 + * @tc.name test error branch + * @tc.desc Function test + */ +HWTEST_F(BranchTest, Telephony_CellularDataConnectionManager_003, Function | MediumTest | Level3) +{ + DataConnectionManager con { 0 }; + con.Init(); + std::shared_ptr machine = std::make_shared(); + std::shared_ptr stateMachine = machine->CreateCellularDataConnect(0); + con.AddConnectionStateMachine(stateMachine); + con.RemoveConnectionStateMachine(stateMachine); + con.AddActiveConnectionByCid(stateMachine); + con.GetActiveConnectionByCid(1); + con.GetAllConnectionMachine(); + con.StartStallDetectionTimer(); + con.StopStallDetectionTimer(); + con.RegisterRadioObserver(); + con.UnRegisterRadioObserver(); + con.uplinkUseLte_ = true; + con.UpdateBandWidthsUseLte(); + con.GetActiveConnection(); + con.IsBandwidthSourceModem(); + ASSERT_NE(-1, con.GetDataRecoveryState()); + con.IsNeedDoRecovery(true); + con.GetActiveConnectionByCid(0); + con.isNoActiveConnection(); + auto event = AppExecFwk::InnerEvent::Get(0); + CcmDefaultState ccmDefaultState { con, "CcmDefaultState" }; + ASSERT_FALSE(ccmDefaultState.StateProcess(event)); + event = AppExecFwk::InnerEvent::Get(RadioEvent::RADIO_NETWORKSLICE_URSP_RPT); + ASSERT_TRUE(ccmDefaultState.StateProcess(event)); + event = AppExecFwk::InnerEvent::Get(RadioEvent::RADIO_NETWORKSLICE_ALLOWEDNSSAI_RPT); + ASSERT_TRUE(ccmDefaultState.StateProcess(event)); + event = AppExecFwk::InnerEvent::Get(RadioEvent::RADIO_NETWORKSLICE_EHPLMN_RPT); + ASSERT_TRUE(ccmDefaultState.StateProcess(event)); + event = AppExecFwk::InnerEvent::Get(0); + ASSERT_FALSE(ccmDefaultState.StateProcess(event)); + ccmDefaultState.RadioDataCallListChanged(event); + ccmDefaultState.UpdateNetworkInfo(event); + ccmDefaultState.RadioLinkCapabilityChanged(event); + ccmDefaultState.RadioNetworkSliceUrspRpt(event); + ccmDefaultState.RadioNetworkSliceAllowedNssaiRpt(event); + ccmDefaultState.RadioNetworkSliceEhplmnRpt(event); + con.GetDataFlowType(); + con.GetDefaultBandWidthsConfig(); + con.GetDefaultTcpBufferConfig(); + con.SetDataFlowType(CellDataFlowType::DATA_FLOW_TYPE_NONE); + con.UpdateCallState(0); + ASSERT_EQ("", con.GetTcpBufferByRadioTech(0)); + ASSERT_TRUE(con.GetBandwidthsByRadioTech(0).upBandwidth == DEFAULT_BANDWIDTH); +} + +/** + * @tc.number DataConnectionMonitor_003 + * @tc.name test error branch + * @tc.desc Function test + */ +HWTEST_F(BranchTest, Telephony_DataConnectionMonitor_004, Function | MediumTest | Level3) +{ + DataConnectionManager con { 0 }; + ASSERT_FALSE(con.connectionMonitor_ == nullptr); + con.connectionMonitor_->UpdateFlowInfo(); + con.connectionMonitor_->UpdateCallState(0); + con.connectionMonitor_->OnStallDetectionTimer(); + con.connectionMonitor_->StopStallDetectionTimer(); + con.connectionMonitor_->dataRecoveryState_ = RecoveryState::STATE_REQUEST_CONTEXT_LIST; + con.connectionMonitor_->HandleRecovery(); + con.connectionMonitor_->dataRecoveryState_ = RecoveryState::STATE_CLEANUP_CONNECTIONS; + con.connectionMonitor_->HandleRecovery(); + con.connectionMonitor_->dataRecoveryState_ = RecoveryState::STATE_REREGISTER_NETWORK; + con.connectionMonitor_->HandleRecovery(); + con.connectionMonitor_->dataRecoveryState_ = RecoveryState::STATE_RADIO_STATUS_RESTART; + con.connectionMonitor_->HandleRecovery(); + con.connectionMonitor_->BeginNetStatistics(); + con.connectionMonitor_->EndNetStatistics(); + con.connectionMonitor_->HandleScreenStateChanged(true); + con.connectionMonitor_->UpdateNetTrafficState(); + auto event = AppExecFwk::InnerEvent::Get(0); + con.connectionMonitor_->SetPreferredNetworkPara(event); + con.connectionMonitor_->UpdateDataFlowType(); + con.connectionMonitor_->ProcessEvent(event); + event = nullptr; + con.connectionMonitor_->ProcessEvent(event); + ASSERT_EQ(CellDataFlowType::DATA_FLOW_TYPE_NONE, con.connectionMonitor_->GetDataFlowType()); +} + +/** + * @tc.number DataConnectionMonitor_004 + * @tc.name test error branch + * @tc.desc Function test + */ +HWTEST_F(BranchTest, Telephony_DataConnectionMonitor_005, Function | MediumTest | Level3) +{ + DataConnectionManager con { 0 }; + ASSERT_FALSE(con.connectionMonitor_ == nullptr); + con.connectionMonitor_->UpdateFlowInfo(); + con.connectionMonitor_->UpdateCallState(0); + con.connectionMonitor_->OnStallDetectionTimer(); + con.connectionMonitor_->StopStallDetectionTimer(); + con.connectionMonitor_->dataRecoveryState_ = RecoveryState::STATE_REQUEST_CONTEXT_LIST; + con.connectionMonitor_->HandleRecovery(); + con.connectionMonitor_->dataRecoveryState_ = RecoveryState::STATE_CLEANUP_CONNECTIONS; + con.connectionMonitor_->HandleRecovery(); + con.connectionMonitor_->dataRecoveryState_ = RecoveryState::STATE_REREGISTER_NETWORK; + con.connectionMonitor_->HandleRecovery(); + con.connectionMonitor_->dataRecoveryState_ = RecoveryState::STATE_RADIO_STATUS_RESTART; + con.connectionMonitor_->HandleRecovery(); + con.connectionMonitor_->BeginNetStatistics(); + con.connectionMonitor_->BeginNetStatistics(); + con.connectionMonitor_->HandleScreenStateChanged(true); + con.connectionMonitor_->UpdateNetTrafficState(); + auto event = AppExecFwk::InnerEvent::Get(0); + con.connectionMonitor_->SetPreferredNetworkPara(event); + con.connectionMonitor_->UpdateDataFlowType(); + con.connectionMonitor_->ProcessEvent(event); + event = nullptr; + con.connectionMonitor_->ProcessEvent(event); + ASSERT_EQ(CellDataFlowType::DATA_FLOW_TYPE_NONE, con.connectionMonitor_->GetDataFlowType()); +} } // namespace Telephony } // namespace OHOS