Merge branch 'master' of gitee.com:openharmony/telephony_core_service into master

Signed-off-by: Aurora <liuxiyao223@huawei.com>
This commit is contained in:
Aurora 2023-05-06 11:06:40 +00:00 committed by SubmarinePhantom
commit 7a8a5e0b6d
102 changed files with 1144 additions and 702 deletions

View File

@ -11,27 +11,17 @@
# See the License for the specific language governing permissions and # See the License for the specific language governing permissions and
# limitations under the License. # limitations under the License.
import("//base/telephony/core_service/core_service_aafwk.gni")
import("//base/telephony/core_service/telephony.gni")
import("//build/ohos.gni") import("//build/ohos.gni")
import("//drivers/hdf_core/adapter/uhdf2/uhdf.gni")
TELEPHONY_CORE_SERVICE_ROOT = "//base/telephony/core_service" TELEPHONY_NETWORK_SEARCH_ROOT = "services/network_search"
TELEPHONY_NETWORK_SEARCH_ROOT = TELEPHONY_SIM_ROOT = "services/sim"
"//base/telephony/core_service/services/network_search" TELEPHONY_TEL_RIL_ROOT = "services/tel_ril"
TELEPHONY_SIM_ROOT = "//base/telephony/core_service/services/sim" TELEPHONY_IMS_CORE_SERVICE_SRC_PATH = "services/ims_service_interaction/src"
TELEPHONY_TEL_RIL_ROOT = "//base/telephony/core_service/services/tel_ril"
TELEPHONY_IMS_CORE_SERVICE_SRC_PATH =
"$TELEPHONY_CORE_SERVICE_ROOT/services/ims_service_interaction/src"
ohos_shared_library("tel_core_service") { ohos_shared_library("tel_core_service") {
install_enable = true install_enable = true
sources = [ sources = [
"$TELEPHONY_CORE_SERVICE_ROOT/services/core/src/core_service.cpp",
"$TELEPHONY_CORE_SERVICE_ROOT/services/core/src/core_service_dump_helper.cpp",
"$TELEPHONY_CORE_SERVICE_ROOT/services/core/src/core_service_hisysevent.cpp",
"$TELEPHONY_CORE_SERVICE_ROOT/services/core/src/core_service_stub.cpp",
"$TELEPHONY_IMS_CORE_SERVICE_SRC_PATH/ims_core_service_callback_stub.cpp", "$TELEPHONY_IMS_CORE_SERVICE_SRC_PATH/ims_core_service_callback_stub.cpp",
"$TELEPHONY_IMS_CORE_SERVICE_SRC_PATH/ims_core_service_client.cpp", "$TELEPHONY_IMS_CORE_SERVICE_SRC_PATH/ims_core_service_client.cpp",
"$TELEPHONY_IMS_CORE_SERVICE_SRC_PATH/ims_core_service_proxy.cpp", "$TELEPHONY_IMS_CORE_SERVICE_SRC_PATH/ims_core_service_proxy.cpp",
@ -105,40 +95,38 @@ ohos_shared_library("tel_core_service") {
"$TELEPHONY_TEL_RIL_ROOT/src/tel_ril_network.cpp", "$TELEPHONY_TEL_RIL_ROOT/src/tel_ril_network.cpp",
"$TELEPHONY_TEL_RIL_ROOT/src/tel_ril_sim.cpp", "$TELEPHONY_TEL_RIL_ROOT/src/tel_ril_sim.cpp",
"$TELEPHONY_TEL_RIL_ROOT/src/tel_ril_sms.cpp", "$TELEPHONY_TEL_RIL_ROOT/src/tel_ril_sms.cpp",
"services/core/src/core_service.cpp",
"services/core/src/core_service_dump_helper.cpp",
"services/core/src/core_service_hisysevent.cpp",
"services/core/src/core_service_stub.cpp",
"services/core/src/runner_pool.cpp",
] ]
include_dirs = [ include_dirs = [
"//base/telephony/telephony_data/sim/include", "$TELEPHONY_SIM_ROOT/include",
"//base/telephony/telephony_data/common/include",
"$TELEPHONY_CORE_SERVICE_ROOT/services/core/include",
"$TELEPHONY_TEL_RIL_ROOT/include", "$TELEPHONY_TEL_RIL_ROOT/include",
"$TELEPHONY_NETWORK_SEARCH_ROOT/include", "$TELEPHONY_NETWORK_SEARCH_ROOT/include",
"$TELEPHONY_CORE_SERVICE_ROOT/utils/log/include", "services/core/include",
"$TELEPHONY_SIM_ROOT/include", "utils/log/include",
"//third_party/icu/icu4c/source/common/unicode",
"//third_party/icu/icu4c/source/common",
"//third_party/libphonenumber/cpp/src",
"//third_party/protobuf/src",
"//third_party/protobuf/src/google",
"//third_party/protobuf/src/google/protobuf",
] ]
configs = [ "//base/telephony/core_service/utils:telephony_log_config" ] configs = [ "utils:telephony_log_config" ]
defines += [ defines = [
"TELEPHONY_LOG_TAG = \"CoreService\"", "TELEPHONY_LOG_TAG = \"CoreService\"",
"LOG_DOMAIN = 0xD001F04", "LOG_DOMAIN = 0xD001F04",
"OPENSSL_SUPPRESS_DEPRECATED", "OPENSSL_SUPPRESS_DEPRECATED",
] ]
deps = [ deps = [
"${ability_runtime_inner_api_path}/dataobs_manager:dataobs_manager", "interfaces/innerkits:tel_core_service_api",
"//base/telephony/core_service/interfaces/innerkits:tel_core_service_api", "utils:libtel_common",
"//base/telephony/core_service/utils:libtel_common", "//third_party/icu/icu4c:static_icustubdata",
"//third_party/jsoncpp:jsoncpp", "//third_party/jsoncpp:jsoncpp",
"//third_party/libphonenumber/cpp:phonenumber_standard", "//third_party/libphonenumber/cpp:phonenumber_standard",
"//third_party/libxml2:libxml2", "//third_party/libxml2:libxml2",
"//third_party/openssl:libcrypto_shared", "//third_party/openssl:libcrypto_shared",
"//third_party/protobuf:protobuf_lite",
] ]
external_deps = [ external_deps = [
@ -146,6 +134,7 @@ ohos_shared_library("tel_core_service") {
"ability_base:zuri", "ability_base:zuri",
"ability_runtime:ability_manager", "ability_runtime:ability_manager",
"ability_runtime:data_ability_helper", "ability_runtime:data_ability_helper",
"ability_runtime:dataobs_manager",
"ability_runtime:wantagent_innerkits", "ability_runtime:wantagent_innerkits",
"battery_manager:batterysrv_client", "battery_manager:batterysrv_client",
"c_utils:utils", "c_utils:utils",
@ -169,6 +158,7 @@ ohos_shared_library("tel_core_service") {
"relational_store:native_rdb", "relational_store:native_rdb",
"safwk:system_ability_fwk", "safwk:system_ability_fwk",
"samgr:samgr_proxy", "samgr:samgr_proxy",
"telephony_data:tel_telephony_data",
"time_service:time_client", "time_service:time_client",
] ]

View File

@ -1,6 +1,6 @@
{ {
"name": "@ohos/core_service", "name": "@ohos/core_service",
"version": "3.1.0", "version": "4.0",
"description": "telephony core service", "description": "telephony core service",
"publishAs": "code-segment", "publishAs": "code-segment",
"homePage": "https://gitee.com/openharmony", "homePage": "https://gitee.com/openharmony",
@ -41,12 +41,13 @@
"c_utils", "c_utils",
"common_event_service", "common_event_service",
"config_policy", "config_policy",
"data_share",
"drivers_interface_ril", "drivers_interface_ril",
"eventhandler", "eventhandler",
"hdf_core", "hdf_core",
"hilog",
"hisysevent_native", "hisysevent_native",
"hiviewdfx_hilog_native", "hiviewdfx_hilog_native",
"huks",
"i18n", "i18n",
"init", "init",
"ipc", "ipc",
@ -59,10 +60,18 @@
"resource_management", "resource_management",
"safwk", "safwk",
"samgr", "samgr",
"telephony_data",
"time_service" "time_service"
], ],
"third_party": [ "third_party": [
"libphonenumber" "googletest",
"icu4c",
"jsoncpp",
"libphonenumber",
"libxml2",
"node",
"openssl",
"protobuf"
] ]
}, },
"build": { "build": {

View File

@ -1,17 +0,0 @@
# Copyright (c) 2022 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.
ability_runtime_path = "//foundation/ability/ability_runtime"
ability_runtime_inner_api_path = "${ability_runtime_path}/interfaces/inner_api"
ability_runtime_kits_path = "${ability_runtime_path}/frameworks/kits"
ability_runtime_services_path = "${ability_runtime_path}/services"

View File

@ -69,6 +69,11 @@ enum JsErrorCode {
*/ */
JS_ERROR_TELEPHONY_NO_SIM_CARD, JS_ERROR_TELEPHONY_NO_SIM_CARD,
/**
* Airplane mode is on.
*/
JS_ERROR_TELEPHONY_AIRPLANE_MODE_ON,
/** /**
* Unknown error code. * Unknown error code.
*/ */

View File

@ -53,6 +53,7 @@ static constexpr const char *JS_ERROR_CELLULAR_CALL_IMS_BASE_ERROR_STRING = "Cel
static constexpr const char *JS_ERROR_CELLULAR_DATA_BASE_ERROR_STRING = "Cellular data module base error."; static constexpr const char *JS_ERROR_CELLULAR_DATA_BASE_ERROR_STRING = "Cellular data module base error.";
static constexpr const char *JS_ERROR_SMS_MMS_BASE_ERROR_STRING = "Sms mms module base error."; static constexpr const char *JS_ERROR_SMS_MMS_BASE_ERROR_STRING = "Sms mms module base error.";
static constexpr const char *JS_ERROR_STATE_REGISTRY_BASE_ERROR_STRING = "State registry module base error."; static constexpr const char *JS_ERROR_STATE_REGISTRY_BASE_ERROR_STRING = "State registry module base error.";
static constexpr const char *JS_ERROR_AIRPLANE_MODE_ON_STRING = "Airplane mode is on, can not call.";
static std::unordered_map<int32_t, const char *> errorMap_ = { static std::unordered_map<int32_t, const char *> errorMap_ = {
{ JsErrorCode::JS_ERROR_TELEPHONY_PERMISSION_DENIED, JS_ERROR_TELEPHONY_PERMISSION_DENIED_STRING }, { JsErrorCode::JS_ERROR_TELEPHONY_PERMISSION_DENIED, JS_ERROR_TELEPHONY_PERMISSION_DENIED_STRING },
@ -76,6 +77,7 @@ static std::unordered_map<int32_t, const char *> errorMap_ = {
{ JsErrorCode::JS_ERROR_CELLULAR_DATA_BASE_ERROR, JS_ERROR_CELLULAR_DATA_BASE_ERROR_STRING }, { JsErrorCode::JS_ERROR_CELLULAR_DATA_BASE_ERROR, JS_ERROR_CELLULAR_DATA_BASE_ERROR_STRING },
{ JsErrorCode::JS_ERROR_SMS_MMS_BASE_ERROR, JS_ERROR_SMS_MMS_BASE_ERROR_STRING }, { JsErrorCode::JS_ERROR_SMS_MMS_BASE_ERROR, JS_ERROR_SMS_MMS_BASE_ERROR_STRING },
{ JsErrorCode::JS_ERROR_STATE_REGISTRY_BASE_ERROR, JS_ERROR_STATE_REGISTRY_BASE_ERROR_STRING }, { JsErrorCode::JS_ERROR_STATE_REGISTRY_BASE_ERROR, JS_ERROR_STATE_REGISTRY_BASE_ERROR_STRING },
{ JsErrorCode::JS_ERROR_TELEPHONY_AIRPLANE_MODE_ON, JS_ERROR_AIRPLANE_MODE_ON_STRING },
}; };
std::string NapiUtil::GetErrorMessage(int32_t errorCode) std::string NapiUtil::GetErrorMessage(int32_t errorCode)
@ -564,6 +566,9 @@ bool NapiUtil::CreateCommonErrorMessageForJs(int32_t errorCode, JsErrorCode &jsE
case TELEPHONY_ERR_ILLEGAL_USE_OF_SYSTEM_API: case TELEPHONY_ERR_ILLEGAL_USE_OF_SYSTEM_API:
jsErrorCode = JS_ERROR_ILLEGAL_USE_OF_SYSTEM_API; jsErrorCode = JS_ERROR_ILLEGAL_USE_OF_SYSTEM_API;
break; break;
case TELEPHONY_ERR_AIRPLANE_MODE_ON:
jsErrorCode = JS_ERROR_TELEPHONY_AIRPLANE_MODE_ON;
break;
default: default:
flag = false; flag = false;
break; break;

View File

@ -10,23 +10,16 @@
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and # See the License for the specific language governing permissions and
# limitations under the License. # limitations under the License.
import("//base/telephony/core_service/core_service_aafwk.gni") SUBSYSTEM_DIR = "../../../.."
import("//base/telephony/core_service/telephony.gni")
import("//build/ohos.gni") import("//build/ohos.gni")
SUBSYSTEM_DIR = "//base/telephony"
ohos_shared_library("radio") { ohos_shared_library("radio") {
include_dirs = [ include_dirs = [
"//third_party/node/src",
"include", "include",
"$SUBSYSTEM_DIR/core_service/interfaces/kits/native", "$SUBSYSTEM_DIR/core_service/interfaces/kits/native",
"$SUBSYSTEM_DIR/core_service/interfaces/innerkits/include", "$SUBSYSTEM_DIR/core_service/interfaces/innerkits/include",
"//commonlibrary/c_utils/base/include",
"$SUBSYSTEM_DIR/core_service/frameworks/js/napi", "$SUBSYSTEM_DIR/core_service/frameworks/js/napi",
"$SUBSYSTEM_DIR/core_service/common/sim", "$SUBSYSTEM_DIR/core_service/common/sim",
"//foundation/communication/ipc/interfaces/innerkits/ipc_core/include",
"${ability_runtime_path}/interfaces/kits/native/ability/native",
] ]
sources = [ sources = [
@ -43,21 +36,21 @@ ohos_shared_library("radio") {
"src/set_radio_state_callback.cpp", "src/set_radio_state_callback.cpp",
] ]
configs = [ "//base/telephony/core_service/utils:telephony_log_config" ] configs = [ "$SUBSYSTEM_DIR/core_service/utils:telephony_log_config" ]
deps = [ deps = [ "//third_party/node:node_header" ]
"$SUBSYSTEM_DIR/core_service/interfaces/innerkits:tel_core_service_api",
"//foundation/arkui/napi:ace_napi",
]
external_deps = [ external_deps = [
"ability_runtime:abilitykit_native",
"c_utils:utils", "c_utils:utils",
"core_service:libtel_common", "core_service:libtel_common",
"core_service:tel_core_service_api",
"hiviewdfx_hilog_native:libhilog", "hiviewdfx_hilog_native:libhilog",
"init:libbegetutil", "init:libbegetutil",
"ipc:ipc_core", "ipc:ipc_core",
"napi:ace_napi",
] ]
defines += [ defines = [
"TELEPHONY_LOG_TAG = \"CoreServiceRadioJsApi\"", "TELEPHONY_LOG_TAG = \"CoreServiceRadioJsApi\"",
"LOG_DOMAIN = 0xD001F04", "LOG_DOMAIN = 0xD001F04",
] ]

View File

@ -10,19 +10,14 @@
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and # See the License for the specific language governing permissions and
# limitations under the License. # limitations under the License.
import("//base/telephony/core_service/core_service_aafwk.gni")
import("//build/ohos.gni") import("//build/ohos.gni")
SUBSYSTEM_DIR = "//base/telephony" SUBSYSTEM_DIR = "../../../../"
ohos_shared_library("sim") { ohos_shared_library("sim") {
include_dirs = [ include_dirs = [
"$SUBSYSTEM_DIR/core_service/frameworks/js/napi", "$SUBSYSTEM_DIR/core_service/frameworks/js/napi",
"//third_party/node/src",
"include", "include",
"$SUBSYSTEM_DIR/core_service/interfaces/kits/native", "$SUBSYSTEM_DIR/core_service/interfaces/kits/native",
"$SUBSYSTEM_DIR/core_service/interfaces/innerkits/include", "$SUBSYSTEM_DIR/core_service/interfaces/innerkits/include",
"//commonlibrary/c_utils/base/include",
"//foundation/communication/ipc/interfaces/innerkits/ipc_core/include",
"${ability_runtime_path}/interfaces/kits/native/ability/native",
] ]
sources = [ sources = [
@ -30,18 +25,19 @@ ohos_shared_library("sim") {
"src/napi_sim.cpp", "src/napi_sim.cpp",
] ]
configs = [ "//base/telephony/core_service/utils:telephony_log_config" ] configs = [ "$SUBSYSTEM_DIR/core_service/utils:telephony_log_config" ]
deps = [ deps = [ "//third_party/node:node_header" ]
"$SUBSYSTEM_DIR/core_service/interfaces/innerkits:tel_core_service_api",
"//foundation/arkui/napi:ace_napi",
]
external_deps = [ external_deps = [
"ability_runtime:abilitykit_native",
"c_utils:utils", "c_utils:utils",
"core_service:libtel_common", "core_service:libtel_common",
"core_service:tel_core_service_api",
"hiviewdfx_hilog_native:libhilog", "hiviewdfx_hilog_native:libhilog",
"init:libbegetutil", "init:libbegetutil",
"ipc:ipc_core",
"napi:ace_napi",
] ]
defines = [ defines = [
"TELEPHONY_LOG_TAG = \"CoreServiceSimJsApi\"", "TELEPHONY_LOG_TAG = \"CoreServiceSimJsApi\"",

View File

@ -1530,6 +1530,26 @@ int32_t CoreManagerInner::GetImsRegStatus(int32_t slotId, ImsServiceType imsSrvT
} }
return networkSearchManager_->GetImsRegStatus(slotId, imsSrvType, info); return networkSearchManager_->GetImsRegStatus(slotId, imsSrvType, info);
} }
int32_t CoreManagerInner::GetAirplaneMode(bool &airplaneMode)
{
if (networkSearchManager_ == nullptr) {
TELEPHONY_LOGE("networkSearchManager is null!");
return TELEPHONY_ERR_LOCAL_PTR_NULL;
}
return networkSearchManager_->GetAirplaneMode(airplaneMode);
}
int32_t CoreManagerInner::UpdateRadioOn(int32_t slotId)
{
if (networkSearchManager_ == nullptr) {
TELEPHONY_LOGE("networkSearchManager is null!");
return TELEPHONY_ERR_LOCAL_PTR_NULL;
}
networkSearchManager_->UpdateRadioOn(slotId);
return TELEPHONY_SUCCESS;
}
/******************** networkSearchManager end ************************/ /******************** networkSearchManager end ************************/
/******************** simManager_ start *******************/ /******************** simManager_ start *******************/

View File

@ -851,14 +851,14 @@ int32_t CoreServiceClient::HasOperatorPrivileges(const int32_t slotId, bool &has
} }
int32_t CoreServiceClient::SimAuthentication( int32_t CoreServiceClient::SimAuthentication(
int32_t slotId, const std::string &aid, const std::string &authData, SimAuthenticationResponse &response) int32_t slotId, AuthType authType, const std::string &authData, SimAuthenticationResponse &response)
{ {
auto proxy = GetProxy(); auto proxy = GetProxy();
if (proxy == nullptr) { if (proxy == nullptr) {
TELEPHONY_LOGE("proxy is null!"); TELEPHONY_LOGE("proxy is null!");
return false; return false;
} }
return proxy->SimAuthentication(slotId, aid, authData, response); return proxy->SimAuthentication(slotId, authType, authData, response);
} }
int32_t CoreServiceClient::GetPrimarySlotId(int32_t &slotId) int32_t CoreServiceClient::GetPrimarySlotId(int32_t &slotId)

View File

@ -2547,7 +2547,7 @@ int32_t CoreServiceProxy::HasOperatorPrivileges(const int32_t slotId, bool &hasO
} }
int32_t CoreServiceProxy::SimAuthentication( int32_t CoreServiceProxy::SimAuthentication(
int32_t slotId, const std::string &aid, const std::string &authData, SimAuthenticationResponse &response) int32_t slotId, AuthType authType, const std::string &authData, SimAuthenticationResponse &response)
{ {
MessageParcel data; MessageParcel data;
MessageParcel reply; MessageParcel reply;
@ -2557,7 +2557,7 @@ int32_t CoreServiceProxy::SimAuthentication(
return ERROR; return ERROR;
} }
data.WriteInt32(slotId); data.WriteInt32(slotId);
data.WriteString(aid); data.WriteInt32(static_cast<int32_t>(authType));
data.WriteString(authData); data.WriteString(authData);
auto remote = Remote(); auto remote = Remote();
if (remote == nullptr) { if (remote == nullptr) {

View File

@ -10,10 +10,9 @@
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and # See the License for the specific language governing permissions and
# limitations under the License. # limitations under the License.
import("//base/telephony/core_service/telephony.gni")
import("//build/ohos.gni") import("//build/ohos.gni")
SUBSYSTEM_DIR = "//base/telephony" SUBSYSTEM_DIR = "../../../"
TELEPHONY_CORE_SERVICE_ROOT = "$SUBSYSTEM_DIR/core_service" TELEPHONY_CORE_SERVICE_ROOT = "$SUBSYSTEM_DIR/core_service"
TELEPHONY_INTERFACES_INNERKITS = TELEPHONY_INTERFACES_INNERKITS =
"$TELEPHONY_CORE_SERVICE_ROOT/interfaces/innerkits" "$TELEPHONY_CORE_SERVICE_ROOT/interfaces/innerkits"
@ -64,7 +63,7 @@ ohos_shared_library("tel_core_service_api") {
"$TELEPHONY_IMS_CORE_SERVICE_ROOT/src/ims_core_service_callback_proxy.cpp", "$TELEPHONY_IMS_CORE_SERVICE_ROOT/src/ims_core_service_callback_proxy.cpp",
] ]
defines += [ defines = [
"TELEPHONY_LOG_TAG = \"CoreServiceApi\"", "TELEPHONY_LOG_TAG = \"CoreServiceApi\"",
"LOG_DOMAIN = 0xD001F04", "LOG_DOMAIN = 0xD001F04",
] ]

View File

@ -211,6 +211,8 @@ public:
int32_t GetPreferredNetwork(int32_t slotId, const sptr<INetworkSearchCallback> &callback); int32_t GetPreferredNetwork(int32_t slotId, const sptr<INetworkSearchCallback> &callback);
int32_t SetPreferredNetwork(int32_t slotId, int32_t networkMode, const sptr<INetworkSearchCallback> &callback); int32_t SetPreferredNetwork(int32_t slotId, int32_t networkMode, const sptr<INetworkSearchCallback> &callback);
int32_t GetAirplaneMode(bool &airplaneMode);
int32_t UpdateRadioOn(int32_t slotId);
bool IsNrSupported(int32_t slotId); bool IsNrSupported(int32_t slotId);
int32_t GetNrOptionMode(int32_t slotId, NrMode &mode); int32_t GetNrOptionMode(int32_t slotId, NrMode &mode);

View File

@ -114,7 +114,7 @@ public:
int32_t UnlockSimLock(int32_t slotId, const PersoLockInfo &lockInfo, LockStatusResponse &response); int32_t UnlockSimLock(int32_t slotId, const PersoLockInfo &lockInfo, LockStatusResponse &response);
int32_t HasOperatorPrivileges(const int32_t slotId, bool &hasOperatorPrivileges); int32_t HasOperatorPrivileges(const int32_t slotId, bool &hasOperatorPrivileges);
int32_t SimAuthentication( int32_t SimAuthentication(
int32_t slotId, const std::string &aid, const std::string &authData, SimAuthenticationResponse &response); int32_t slotId, AuthType authType, const std::string &authData, SimAuthenticationResponse &response);
int32_t GetPrimarySlotId(int32_t &slotId); int32_t GetPrimarySlotId(int32_t &slotId);
int32_t SetPrimarySlotId(int32_t slotId); int32_t SetPrimarySlotId(int32_t slotId);
int32_t GetCellInfoList(int32_t slotId, std::vector<sptr<CellInformation>> &cellInfo); int32_t GetCellInfoList(int32_t slotId, std::vector<sptr<CellInformation>> &cellInfo);

View File

@ -120,8 +120,8 @@ public:
int32_t GetCellInfoList(int32_t slotId, std::vector<sptr<CellInformation>> &cellInfo) override; int32_t GetCellInfoList(int32_t slotId, std::vector<sptr<CellInformation>> &cellInfo) override;
int32_t SendUpdateCellLocationRequest(int32_t slotId) override; int32_t SendUpdateCellLocationRequest(int32_t slotId) override;
int32_t HasOperatorPrivileges(const int32_t slotId, bool &hasOperatorPrivileges) override; int32_t HasOperatorPrivileges(const int32_t slotId, bool &hasOperatorPrivileges) override;
int32_t SimAuthentication(int32_t slotId, const std::string &aid, const std::string &authData, int32_t SimAuthentication(
SimAuthenticationResponse &response) override; int32_t slotId, AuthType authType, const std::string &authData, SimAuthenticationResponse &response) override;
int32_t RegisterImsRegInfoCallback( int32_t RegisterImsRegInfoCallback(
int32_t slotId, ImsServiceType imsSrvType, const sptr<ImsRegInfoCallback> &callback) override; int32_t slotId, ImsServiceType imsSrvType, const sptr<ImsRegInfoCallback> &callback) override;
int32_t UnregisterImsRegInfoCallback(int32_t slotId, ImsServiceType imsSrvType) override; int32_t UnregisterImsRegInfoCallback(int32_t slotId, ImsServiceType imsSrvType) override;

View File

@ -126,7 +126,7 @@ public:
virtual int32_t SendUpdateCellLocationRequest(int32_t slotId) = 0; virtual int32_t SendUpdateCellLocationRequest(int32_t slotId) = 0;
virtual int32_t HasOperatorPrivileges(const int32_t slotId, bool &hasOperatorPrivileges) = 0; virtual int32_t HasOperatorPrivileges(const int32_t slotId, bool &hasOperatorPrivileges) = 0;
virtual int32_t SimAuthentication( virtual int32_t SimAuthentication(
int32_t slotId, const std::string &aid, const std::string &authData, SimAuthenticationResponse &response) = 0; int32_t slotId, AuthType authType, const std::string &authData, SimAuthenticationResponse &response) = 0;
virtual int32_t RegisterImsRegInfoCallback( virtual int32_t RegisterImsRegInfoCallback(
int32_t slotId, ImsServiceType imsSrvType, const sptr<ImsRegInfoCallback> &callback) = 0; int32_t slotId, ImsServiceType imsSrvType, const sptr<ImsRegInfoCallback> &callback) = 0;
virtual int32_t UnregisterImsRegInfoCallback(int32_t slotId, ImsServiceType imsSrvType) = 0; virtual int32_t UnregisterImsRegInfoCallback(int32_t slotId, ImsServiceType imsSrvType) = 0;

View File

@ -81,6 +81,8 @@ public:
const sptr<ImsRegInfoCallback> &callback) = 0; const sptr<ImsRegInfoCallback> &callback) = 0;
virtual int32_t UnregisterImsRegInfoCallback( virtual int32_t UnregisterImsRegInfoCallback(
int32_t slotId, ImsServiceType imsSrvType, const std::string &bundleName) = 0; int32_t slotId, ImsServiceType imsSrvType, const std::string &bundleName) = 0;
virtual int32_t GetAirplaneMode(bool &airplaneMode) = 0;
virtual int32_t UpdateRadioOn(int32_t slotId) = 0;
/** /**
* @brief support Nr network or not * @brief support Nr network or not
* *

View File

@ -71,7 +71,7 @@ public:
virtual int32_t GetOperatorConfigs(int slotId, OperatorConfig &poc) = 0; virtual int32_t GetOperatorConfigs(int slotId, OperatorConfig &poc) = 0;
virtual int32_t HasOperatorPrivileges(const int32_t slotId, bool &hasOperatorPrivileges) = 0; virtual int32_t HasOperatorPrivileges(const int32_t slotId, bool &hasOperatorPrivileges) = 0;
virtual int32_t SimAuthentication( virtual int32_t SimAuthentication(
int32_t slotId, const std::string &aid, const std::string &authData, SimAuthenticationResponse &response) = 0; int32_t slotId, AuthType authType, const std::string &authData, SimAuthenticationResponse &response) = 0;
virtual int32_t GetRadioProtocolTech(int32_t slotId) = 0; virtual int32_t GetRadioProtocolTech(int32_t slotId) = 0;
virtual void GetRadioProtocol(int32_t slotId) = 0; virtual void GetRadioProtocol(int32_t slotId) = 0;
// STK // STK

View File

@ -32,6 +32,7 @@ public:
} }
virtual void ClearCellularDataConnections(int32_t slotId) {} virtual void ClearCellularDataConnections(int32_t slotId) {}
virtual void ClearCellularCallList(int32_t slotId) {} virtual void ClearCellularCallList(int32_t slotId) {}
virtual void SetReadyToCall(int32_t slotId, bool isReadyToCall) {}
}; };
} // namespace Telephony } // namespace Telephony
} // namespace OHOS } // namespace OHOS

View File

@ -126,6 +126,11 @@ enum class LockType {
FDN_LOCK = 2, FDN_LOCK = 2,
}; };
enum AuthType {
SIM_AUTH_EAP_SIM_TYPE = 128,
SIM_AUTH_EAP_AKA_TYPE = 129,
};
enum class LockState { enum class LockState {
/**Indicates that the lock state card is in the <b>off</b> state. */ /**Indicates that the lock state card is in the <b>off</b> state. */
LOCK_OFF = 0, LOCK_OFF = 0,

View File

@ -73,6 +73,7 @@ enum {
TELEPHONY_ERR_RIL_CMD_FAIL, TELEPHONY_ERR_RIL_CMD_FAIL,
TELEPHONY_ERR_UNKNOWN_NETWORK_TYPE, TELEPHONY_ERR_UNKNOWN_NETWORK_TYPE,
TELEPHONY_ERR_ILLEGAL_USE_OF_SYSTEM_API, TELEPHONY_ERR_ILLEGAL_USE_OF_SYSTEM_API,
TELEPHONY_ERR_AIRPLANE_MODE_ON,
}; };
// Error code for telephony call manager // Error code for telephony call manager

View File

@ -208,8 +208,8 @@ public:
int32_t HasOperatorPrivileges(const int32_t slotId, bool &hasOperatorPrivileges) override; int32_t HasOperatorPrivileges(const int32_t slotId, bool &hasOperatorPrivileges) override;
int32_t SimAuthentication(int32_t slotId, const std::string &aid, const std::string &authData, int32_t SimAuthentication(
SimAuthenticationResponse &response) override; int32_t slotId, AuthType authType, const std::string &authData, SimAuthenticationResponse &response) override;
int32_t RegisterImsRegInfoCallback( int32_t RegisterImsRegInfoCallback(
int32_t slotId, ImsServiceType imsSrvType, const sptr<ImsRegInfoCallback> &callback) override; int32_t slotId, ImsServiceType imsSrvType, const sptr<ImsRegInfoCallback> &callback) override;

View File

@ -0,0 +1,44 @@
/*
* Copyright (C) 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 RUNNER_POOL_H
#define RUNNER_POOL_H
#include <mutex>
#include "event_runner.h"
namespace OHOS {
namespace Telephony {
class RunnerPool {
public:
static RunnerPool &GetInstance();
void Init();
std::shared_ptr<AppExecFwk::EventRunner> GetCommonRunner();
std::shared_ptr<AppExecFwk::EventRunner> GetSimDbAndFileRunner();
private:
std::shared_ptr<AppExecFwk::EventRunner> CreateRunner(const std::string &name);
RunnerPool() = default;
~RunnerPool() = default;
private:
std::shared_ptr<AppExecFwk::EventRunner> commonRunner_ = nullptr;
std::shared_ptr<AppExecFwk::EventRunner> simDbAndFileRunner_ = nullptr;
static RunnerPool runnerPool_;
bool isInit_ = false;
};
} // namespace Telephony
} // namespace OHOS
#endif // RUNNER_POOL_H

View File

@ -21,6 +21,7 @@
#include "network_search_manager.h" #include "network_search_manager.h"
#include "network_search_types.h" #include "network_search_types.h"
#include "parameter.h" #include "parameter.h"
#include "runner_pool.h"
#include "sim_manager.h" #include "sim_manager.h"
#include "string_ex.h" #include "string_ex.h"
#include "system_ability_definition.h" #include "system_ability_definition.h"
@ -56,7 +57,7 @@ void CoreService::OnStart()
} }
registerToService_ = true; registerToService_ = true;
} }
RunnerPool::GetInstance().Init();
if (!Init()) { if (!Init()) {
TELEPHONY_LOGE("failed to init CoreService"); TELEPHONY_LOGE("failed to init CoreService");
return; return;
@ -1134,7 +1135,7 @@ int32_t CoreService::HasOperatorPrivileges(const int32_t slotId, bool &hasOperat
} }
int32_t CoreService::SimAuthentication( int32_t CoreService::SimAuthentication(
int32_t slotId, const std::string &aid, const std::string &authData, SimAuthenticationResponse &response) int32_t slotId, AuthType authType, const std::string &authData, SimAuthenticationResponse &response)
{ {
if (!TelephonyPermission::CheckPermission(Permission::GET_TELEPHONY_STATE)) { if (!TelephonyPermission::CheckPermission(Permission::GET_TELEPHONY_STATE)) {
TELEPHONY_LOGE("Failed because no permission:GET_TELEPHONY_STATE"); TELEPHONY_LOGE("Failed because no permission:GET_TELEPHONY_STATE");
@ -1145,7 +1146,7 @@ int32_t CoreService::SimAuthentication(
TELEPHONY_LOGE("simManager_ is null"); TELEPHONY_LOGE("simManager_ is null");
return TELEPHONY_ERR_LOCAL_PTR_NULL; return TELEPHONY_ERR_LOCAL_PTR_NULL;
} }
return simManager_->SimAuthentication(slotId, aid, authData, response); return simManager_->SimAuthentication(slotId, authType, authData, response);
} }
int32_t CoreService::RegisterImsRegInfoCallback( int32_t CoreService::RegisterImsRegInfoCallback(

View File

@ -1459,10 +1459,10 @@ int32_t CoreServiceStub::OnHasOperatorPrivileges(MessageParcel &data, MessagePar
int32_t CoreServiceStub::OnSimAuthentication(MessageParcel &data, MessageParcel &reply) int32_t CoreServiceStub::OnSimAuthentication(MessageParcel &data, MessageParcel &reply)
{ {
int32_t slotId = data.ReadInt32(); int32_t slotId = data.ReadInt32();
std::string aid = data.ReadString(); AuthType authType = static_cast<AuthType>(data.ReadInt32());
std::string authData = data.ReadString(); std::string authData = data.ReadString();
SimAuthenticationResponse response = { 0 }; SimAuthenticationResponse response = { 0 };
int32_t result = SimAuthentication(slotId, aid, authData, response); int32_t result = SimAuthentication(slotId, authType, authData, response);
reply.WriteInt32(result); reply.WriteInt32(result);
reply.WriteInt32(response.sw1); reply.WriteInt32(response.sw1);
reply.WriteInt32(response.sw2); reply.WriteInt32(response.sw2);

View File

@ -0,0 +1,66 @@
/*
* Copyright (C) 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 "runner_pool.h"
#include "telephony_log_wrapper.h"
namespace OHOS {
namespace Telephony {
RunnerPool RunnerPool::runnerPool_;
RunnerPool &RunnerPool::GetInstance()
{
return runnerPool_;
}
void RunnerPool::Init()
{
if (isInit_) {
TELEPHONY_LOGI("RunnerPool has init");
return;
}
commonRunner_ = CreateRunner("CoreServiceCommonRunner");
simDbAndFileRunner_ = CreateRunner("SimDbAndFileRunner");
if (commonRunner_ == nullptr || simDbAndFileRunner_ == nullptr) {
return;
}
isInit_ = true;
TELEPHONY_LOGI("RunnerPool init success");
}
std::shared_ptr<AppExecFwk::EventRunner> RunnerPool::CreateRunner(const std::string &name)
{
auto runner = AppExecFwk::EventRunner::Create(name);
if (runner == nullptr) {
TELEPHONY_LOGE("%{public}s runner create thread fail!", name.c_str());
return nullptr;
}
runner->Run();
return runner;
}
std::shared_ptr<AppExecFwk::EventRunner> RunnerPool::GetCommonRunner()
{
return commonRunner_;
}
std::shared_ptr<AppExecFwk::EventRunner> RunnerPool::GetSimDbAndFileRunner()
{
return simDbAndFileRunner_;
}
} // namespace Telephony
} // namespace OHOS

View File

@ -23,14 +23,14 @@ group("param_files") {
} }
ohos_prebuilt_etc("telephony.para") { ohos_prebuilt_etc("telephony.para") {
source = "//base/telephony/core_service/services/etc/param/telephony.para" source = "telephony.para"
part_name = "core_service" part_name = "core_service"
subsystem_name = "telephony" subsystem_name = "telephony"
module_install_dir = "etc/param" module_install_dir = "etc/param"
} }
ohos_prebuilt_etc("telephony.para.dac") { ohos_prebuilt_etc("telephony.para.dac") {
source = "//base/telephony/core_service/services/etc/param/telephony.para.dac" source = "telephony.para.dac"
part_name = "core_service" part_name = "core_service"
subsystem_name = "telephony" subsystem_name = "telephony"
module_install_dir = "etc/param" module_install_dir = "etc/param"

View File

@ -70,6 +70,7 @@ struct NetworkSearchManagerInner {
FrequencyType freqType_ = FrequencyType::FREQ_TYPE_UNKNOWN; FrequencyType freqType_ = FrequencyType::FREQ_TYPE_UNKNOWN;
std::mutex mutex_; std::mutex mutex_;
bool isRadioFirstPowerOn_ = true; bool isRadioFirstPowerOn_ = true;
bool airplaneMode_ = false;
bool RegisterSetting(); bool RegisterSetting();
bool UnRegisterSetting(); bool UnRegisterSetting();
@ -202,11 +203,14 @@ public:
void GetVoiceTech(int32_t slotId); void GetVoiceTech(int32_t slotId);
std::shared_ptr<NetworkSearchManagerInner> FindManagerInner(int32_t slotId); std::shared_ptr<NetworkSearchManagerInner> FindManagerInner(int32_t slotId);
void SetLocateUpdate(int32_t slotId); void SetLocateUpdate(int32_t slotId);
bool GetAirplaneMode(); int32_t GetAirplaneMode(bool &airplaneMode) override;
bool IsRadioFirstPowerOn(int32_t slotId); bool IsRadioFirstPowerOn(int32_t slotId);
void SetRadioFirstPowerOn(int32_t slotId, bool isFirstPowerOn); void SetRadioFirstPowerOn(int32_t slotId, bool isFirstPowerOn);
void NotifyImsRegInfoChanged(int32_t slotId, ImsServiceType imsSrvType, const ImsRegInfo &info); void NotifyImsRegInfoChanged(int32_t slotId, ImsServiceType imsSrvType, const ImsRegInfo &info);
void InitSimRadioProtocol(int32_t slotId); void InitSimRadioProtocol(int32_t slotId);
int32_t SetLocalAirplaneMode(int32_t slotId, bool state);
int32_t GetLocalAirplaneMode(int32_t slotId, bool &state);
int32_t UpdateRadioOn(int32_t slotId) override;
inline void InitMsgNum(int32_t slotId) inline void InitMsgNum(int32_t slotId)
{ {
@ -257,7 +261,6 @@ private:
sptr<ImsRegInfoCallback> imsCallback; sptr<ImsRegInfoCallback> imsCallback;
}; };
bool AirplaneMode_ = false;
sptr<NetworkSearchCallBackBase> cellularDataCallBack_ = nullptr; sptr<NetworkSearchCallBackBase> cellularDataCallBack_ = nullptr;
sptr<NetworkSearchCallBackBase> cellularCallCallBack_ = nullptr; sptr<NetworkSearchCallBackBase> cellularCallCallBack_ = nullptr;
std::shared_ptr<ITelRilManager> telRilManager_ = nullptr; std::shared_ptr<ITelRilManager> telRilManager_ = nullptr;

View File

@ -49,9 +49,9 @@ public:
bool RegisterSettingsObserver(const Uri &uri, const sptr<AAFwk::IDataAbilityObserver> &dataObserver); bool RegisterSettingsObserver(const Uri &uri, const sptr<AAFwk::IDataAbilityObserver> &dataObserver);
bool UnRegisterSettingsObserver(const Uri &uri, const sptr<AAFwk::IDataAbilityObserver> &dataObserver); bool UnRegisterSettingsObserver(const Uri &uri, const sptr<AAFwk::IDataAbilityObserver> &dataObserver);
bool Query(Uri uri, const std::string &key, std::string &value); int32_t Query(Uri uri, const std::string &key, std::string &value);
bool Insert(Uri uri, const std::string &key, const std::string &value); int32_t Insert(Uri uri, const std::string &key, const std::string &value);
bool Update(Uri uri, const std::string &key, const std::string &value); int32_t Update(Uri uri, const std::string &key, const std::string &value);
private: private:
std::shared_ptr<DataShare::DataShareHelper> CreateDataShareHelper(); std::shared_ptr<DataShare::DataShareHelper> CreateDataShareHelper();

View File

@ -41,6 +41,7 @@ void DeviceStateObserver::StartEventSubscriber(const std::shared_ptr<DeviceState
matchingSkills.AddEvent(CommonEventSupport::COMMON_EVENT_CHARGING); matchingSkills.AddEvent(CommonEventSupport::COMMON_EVENT_CHARGING);
matchingSkills.AddEvent(CommonEventSupport::COMMON_EVENT_DISCHARGING); matchingSkills.AddEvent(CommonEventSupport::COMMON_EVENT_DISCHARGING);
CommonEventSubscribeInfo subscriberInfo(matchingSkills); CommonEventSubscribeInfo subscriberInfo(matchingSkills);
subscriberInfo.SetThreadMode(EventFwk::CommonEventSubscribeInfo::COMMON);
subscriber_ = std::make_shared<DeviceStateEventSubscriber>(subscriberInfo); subscriber_ = std::make_shared<DeviceStateEventSubscriber>(subscriberInfo);
subscriber_->SetEventHandler(deviceStateHandler); subscriber_->SetEventHandler(deviceStateHandler);
subscriber_->InitEventMap(); subscriber_->InitEventMap();

View File

@ -131,6 +131,7 @@ bool NetworkSearchHandler::InitOperatorName()
EventFwk::MatchingSkills matchingSkills; EventFwk::MatchingSkills matchingSkills;
matchingSkills.AddEvent(CommonEventSupport::COMMON_EVENT_OPERATOR_CONFIG_CHANGED); matchingSkills.AddEvent(CommonEventSupport::COMMON_EVENT_OPERATOR_CONFIG_CHANGED);
EventFwk::CommonEventSubscribeInfo subscriberInfo(matchingSkills); EventFwk::CommonEventSubscribeInfo subscriberInfo(matchingSkills);
subscriberInfo.SetThreadMode(EventFwk::CommonEventSubscribeInfo::COMMON);
operatorName_ = std::make_shared<OperatorName>( operatorName_ = std::make_shared<OperatorName>(
subscriberInfo, nsm->GetNetworkSearchState(slotId_), nsm->GetSimManager(), networkSearchManager_, slotId_); subscriberInfo, nsm->GetNetworkSearchState(slotId_), nsm->GetSimManager(), networkSearchManager_, slotId_);
if (operatorName_ == nullptr) { if (operatorName_ == nullptr) {
@ -356,6 +357,11 @@ void NetworkSearchHandler::RadioRilVoiceRegState(const AppExecFwk::InnerEvent::P
if (networkRegister_ != nullptr) { if (networkRegister_ != nullptr) {
networkRegister_->ProcessCsRegister(event); networkRegister_->ProcessCsRegister(event);
} }
sptr<NetworkSearchCallBackBase> cellularCall = networkSearchManager->GetCellularCallCallBack();
if (cellularCall) {
cellularCall->SetReadyToCall(slotId_, true);
}
TELEPHONY_LOGD("NetworkSearchHandler::RadioRilVoiceRegState slotId:%{public}d", slotId_); TELEPHONY_LOGD("NetworkSearchHandler::RadioRilVoiceRegState slotId:%{public}d", slotId_);
} }
@ -457,16 +463,23 @@ void NetworkSearchHandler::RadioOffOrUnavailableState(int32_t radioState) const
} }
networkSearchState->NotifyStateChange(); networkSearchState->NotifyStateChange();
networkSearchManager->SetNrOptionMode(slotId_, NrMode::NR_MODE_UNKNOWN); networkSearchManager->SetNrOptionMode(slotId_, NrMode::NR_MODE_UNKNOWN);
if (!networkSearchManager->GetAirplaneMode() && radioState == CORE_SERVICE_POWER_OFF) { bool isAirplaneModeOn = false;
if (networkSearchManager->GetAirplaneMode(isAirplaneModeOn) != TELEPHONY_SUCCESS) {
TELEPHONY_LOGE("RadioOffOrUnavailableState GetAirplaneMode fail slotId:%{public}d", slotId_);
return;
}
if (!isAirplaneModeOn && radioState == CORE_SERVICE_POWER_OFF) {
networkSearchManager->SetRadioState(slotId_, static_cast<bool>(ModemPowerState::CORE_SERVICE_POWER_ON), 0); networkSearchManager->SetRadioState(slotId_, static_cast<bool>(ModemPowerState::CORE_SERVICE_POWER_ON), 0);
} }
sptr<NetworkSearchCallBackBase> cellularData = networkSearchManager->GetCellularDataCallBack(); sptr<NetworkSearchCallBackBase> cellularData = networkSearchManager->GetCellularDataCallBack();
if (cellularData) { if (cellularData) {
cellularData->ClearCellularDataConnections(slotId_); cellularData->ClearCellularDataConnections(slotId_);
TELEPHONY_LOGD("RadioOffOrUnavailableState ClearCellularDataConnections");
} }
sptr<NetworkSearchCallBackBase> cellularCall = networkSearchManager->GetCellularCallCallBack(); sptr<NetworkSearchCallBackBase> cellularCall = networkSearchManager->GetCellularCallCallBack();
if (cellularCall) { if (cellularCall) {
cellularCall->ClearCellularCallList(slotId_); cellularCall->ClearCellularCallList(slotId_);
TELEPHONY_LOGD("RadioOffOrUnavailableState ClearCellularCallList");
} }
} }

View File

@ -29,11 +29,6 @@
namespace OHOS { namespace OHOS {
namespace Telephony { namespace Telephony {
namespace { namespace {
const std::string KEY_DEFAULT_PREFERRED_NETWORK_MODE = "preferred_network_mode";
const int32_t AIRPLANE_MODE_UNSUPPORT = 0;
const int32_t AIRPLANE_MODE_SUPPORT = 1;
const std::string SUPPORT_AIRPLANE_MODE_PARAM = "persist.sys.support_air_plane_mode";
const int32_t IS_SUPPORT_AIRPLANE_MODE = system::GetIntParameter(SUPPORT_AIRPLANE_MODE_PARAM, AIRPLANE_MODE_UNSUPPORT);
const size_t MCC_LEN = 3; const size_t MCC_LEN = 3;
} // namespace } // namespace
@ -112,7 +107,7 @@ bool NetworkSearchManagerInner::RegisterSetting()
Uri autoTimeUri(SettingUtils::NETWORK_SEARCH_SETTING_AUTO_TIME_URI); Uri autoTimeUri(SettingUtils::NETWORK_SEARCH_SETTING_AUTO_TIME_URI);
Uri autoTimezoneUri(SettingUtils::NETWORK_SEARCH_SETTING_AUTO_TIMEZONE_URI); Uri autoTimezoneUri(SettingUtils::NETWORK_SEARCH_SETTING_AUTO_TIMEZONE_URI);
Uri airplaneModeUri(SettingUtils::NETWORK_SEARCH_SETTING_AIRPLANE_MODE_URI); Uri airplaneModeUri(SettingUtils::NETWORK_SEARCH_SETTING_URI);
settingHelper->RegisterSettingsObserver(autoTimeUri, settingAutoTimeObserver_); settingHelper->RegisterSettingsObserver(autoTimeUri, settingAutoTimeObserver_);
settingHelper->RegisterSettingsObserver(autoTimezoneUri, settingAutoTimezoneObserver_); settingHelper->RegisterSettingsObserver(autoTimezoneUri, settingAutoTimezoneObserver_);
settingHelper->RegisterSettingsObserver(airplaneModeUri, airplaneModeObserver_); settingHelper->RegisterSettingsObserver(airplaneModeUri, airplaneModeObserver_);
@ -129,7 +124,7 @@ bool NetworkSearchManagerInner::UnRegisterSetting()
Uri autoTimeUri(SettingUtils::NETWORK_SEARCH_SETTING_AUTO_TIME_URI); Uri autoTimeUri(SettingUtils::NETWORK_SEARCH_SETTING_AUTO_TIME_URI);
Uri autoTimezoneUri(SettingUtils::NETWORK_SEARCH_SETTING_AUTO_TIMEZONE_URI); Uri autoTimezoneUri(SettingUtils::NETWORK_SEARCH_SETTING_AUTO_TIMEZONE_URI);
Uri airplaneModeUri(SettingUtils::NETWORK_SEARCH_SETTING_AIRPLANE_MODE_URI); Uri airplaneModeUri(SettingUtils::NETWORK_SEARCH_SETTING_URI);
settingHelper->UnRegisterSettingsObserver(autoTimeUri, settingAutoTimeObserver_); settingHelper->UnRegisterSettingsObserver(autoTimeUri, settingAutoTimeObserver_);
settingHelper->UnRegisterSettingsObserver(autoTimezoneUri, settingAutoTimezoneObserver_); settingHelper->UnRegisterSettingsObserver(autoTimezoneUri, settingAutoTimezoneObserver_);
settingHelper->UnRegisterSettingsObserver(airplaneModeUri, airplaneModeObserver_); settingHelper->UnRegisterSettingsObserver(airplaneModeUri, airplaneModeObserver_);
@ -170,6 +165,10 @@ bool NetworkSearchManager::OnInit()
return false; return false;
} }
ClearManagerInner(); ClearManagerInner();
bool mode = false;
if (GetAirplaneMode(mode) != TELEPHONY_SUCCESS) {
TELEPHONY_LOGE("NetworkSearchManager::Init GetAirplaneMode fail");
}
for (int32_t slotId = 0; slotId < SIM_SLOT_COUNT; slotId++) { for (int32_t slotId = 0; slotId < SIM_SLOT_COUNT; slotId++) {
std::shared_ptr<NetworkSearchManagerInner> inner = FindManagerInner(slotId); std::shared_ptr<NetworkSearchManagerInner> inner = FindManagerInner(slotId);
if (inner == nullptr) { if (inner == nullptr) {
@ -189,7 +188,8 @@ bool NetworkSearchManager::OnInit()
ClearManagerInner(); ClearManagerInner();
return false; return false;
} }
TELEPHONY_LOGI("NetworkSearchManager::Init inner init slotId:%{public}d", slotId); SetLocalAirplaneMode(slotId, mode);
TELEPHONY_LOGI("NetworkSearchManager::Init airplaneMode:%{public}d slotId:%{public}d", mode, slotId);
// Prevent running crash and query the radio status at startup // Prevent running crash and query the radio status at startup
eventSender_->SendBase(slotId, RadioEvent::RADIO_GET_STATUS); eventSender_->SendBase(slotId, RadioEvent::RADIO_GET_STATUS);
} }
@ -228,7 +228,6 @@ int32_t NetworkSearchManager::SetRadioState(int32_t slotId, bool isOn, int32_t r
TELEPHONY_LOGE("slotId:%{public}d inner is null", slotId); TELEPHONY_LOGE("slotId:%{public}d inner is null", slotId);
return TELEPHONY_ERR_LOCAL_PTR_NULL; return TELEPHONY_ERR_LOCAL_PTR_NULL;
} }
AirplaneMode_ = isOn ? false : true;
int32_t fun = static_cast<int32_t>(isOn); int32_t fun = static_cast<int32_t>(isOn);
if (!eventSender_->SendCallback(slotId, RadioEvent::RADIO_SET_STATUS, &callback, fun, rst)) { if (!eventSender_->SendCallback(slotId, RadioEvent::RADIO_SET_STATUS, &callback, fun, rst)) {
TELEPHONY_LOGE("slotId:%{public}d SetRadioState SendCallback failed.", slotId); TELEPHONY_LOGE("slotId:%{public}d SetRadioState SendCallback failed.", slotId);
@ -799,11 +798,42 @@ void NetworkSearchManager::SavePreferredNetworkValue(int32_t slotId, int32_t net
Uri uri(SettingUtils::NETWORK_SEARCH_SETTING_PREFERRED_NETWORK_MODE_URI); Uri uri(SettingUtils::NETWORK_SEARCH_SETTING_PREFERRED_NETWORK_MODE_URI);
std::string key = SettingUtils::SETTINGS_NETWORK_SEARCH_PREFERRED_NETWORK_MODE + "_" + std::to_string(slotId); std::string key = SettingUtils::SETTINGS_NETWORK_SEARCH_PREFERRED_NETWORK_MODE + "_" + std::to_string(slotId);
std::string value = std::to_string(networkMode); std::string value = std::to_string(networkMode);
if (!settingHelper->Update(uri, key, value)) { if (settingHelper->Update(uri, key, value) != TELEPHONY_SUCCESS) {
TELEPHONY_LOGE("Update %{public}s fail", key.c_str()); TELEPHONY_LOGE("Update %{public}s fail", key.c_str());
} }
} }
int32_t NetworkSearchManager::UpdateRadioOn(int32_t slotId)
{
std::shared_ptr<SettingUtils> settingHelper = SettingUtils::GetInstance();
if (settingHelper == nullptr) {
TELEPHONY_LOGE("settingHelper is null");
return TELEPHONY_ERR_LOCAL_PTR_NULL;
}
Uri uri(SettingUtils::NETWORK_SEARCH_SETTING_URI);
std::string key = SettingUtils::SETTINGS_NETWORK_SEARCH_AIRPLANE_MODE;
int32_t airplaneModeOff = 0;
std::string value = std::to_string(airplaneModeOff);
int32_t ret = settingHelper->Update(uri, key, value);
if (ret != TELEPHONY_SUCCESS) {
TELEPHONY_LOGE("NetworkSearchManager::UpdateRadioOn Update fail");
return ret;
}
SetRadioState(slotId, CORE_SERVICE_POWER_ON, 0);
AAFwk::Want want;
want.SetAction(EventFwk::CommonEventSupport::COMMON_EVENT_AIRPLANE_MODE_CHANGED);
want.SetParam("state", false);
EventFwk::CommonEventData data;
data.SetWant(want);
EventFwk::CommonEventPublishInfo publishInfo;
if (!EventFwk::CommonEventManager::PublishCommonEvent(data, publishInfo, nullptr)) {
TELEPHONY_LOGE("PublishCommonEvent fail");
return TELEPHONY_ERR_PUBLISH_BROADCAST_FAIL;
}
return TELEPHONY_SUCCESS;
}
int32_t NetworkSearchManager::GetPreferredNetworkValue(int32_t slotId) const int32_t NetworkSearchManager::GetPreferredNetworkValue(int32_t slotId) const
{ {
int32_t networkMode = PREFERRED_NETWORK_TYPE; int32_t networkMode = PREFERRED_NETWORK_TYPE;
@ -816,7 +846,7 @@ int32_t NetworkSearchManager::GetPreferredNetworkValue(int32_t slotId) const
Uri uri(SettingUtils::NETWORK_SEARCH_SETTING_PREFERRED_NETWORK_MODE_URI); Uri uri(SettingUtils::NETWORK_SEARCH_SETTING_PREFERRED_NETWORK_MODE_URI);
std::string key = SettingUtils::SETTINGS_NETWORK_SEARCH_PREFERRED_NETWORK_MODE + "_" + std::to_string(slotId); std::string key = SettingUtils::SETTINGS_NETWORK_SEARCH_PREFERRED_NETWORK_MODE + "_" + std::to_string(slotId);
std::string value = ""; std::string value = "";
if (!settingHelper->Query(uri, key, value)) { if (settingHelper->Query(uri, key, value) != TELEPHONY_SUCCESS) {
TELEPHONY_LOGI("Query %{public}s fail", key.c_str()); TELEPHONY_LOGI("Query %{public}s fail", key.c_str());
return networkMode; return networkMode;
} }
@ -1173,28 +1203,24 @@ void NetworkSearchManager::TriggerTimezoneRefresh(int32_t slotId)
TELEPHONY_LOGE("NetworkSearchManager::TriggerTimezoneRefresh slotId:%{public}d", slotId); TELEPHONY_LOGE("NetworkSearchManager::TriggerTimezoneRefresh slotId:%{public}d", slotId);
} }
bool NetworkSearchManager::GetAirplaneMode() int32_t NetworkSearchManager::GetAirplaneMode(bool &airplaneMode)
{ {
if (IS_SUPPORT_AIRPLANE_MODE == AIRPLANE_MODE_SUPPORT) {
TELEPHONY_LOGI("support airplane mode, return true");
return true;
}
std::shared_ptr<SettingUtils> settingHelper = SettingUtils::GetInstance(); std::shared_ptr<SettingUtils> settingHelper = SettingUtils::GetInstance();
if (settingHelper == nullptr) { if (settingHelper == nullptr) {
TELEPHONY_LOGI("settingHelper is null"); TELEPHONY_LOGI("settingHelper is null");
return false; return TELEPHONY_ERR_LOCAL_PTR_NULL;
} }
Uri uri(SettingUtils::NETWORK_SEARCH_SETTING_AIRPLANE_MODE_URI); Uri uri(SettingUtils::NETWORK_SEARCH_SETTING_URI);
std::string value = ""; std::string value = "";
std::string key = SettingUtils::SETTINGS_NETWORK_SEARCH_AIRPLANE_MODE; std::string key = SettingUtils::SETTINGS_NETWORK_SEARCH_AIRPLANE_MODE;
if (!settingHelper->Query(uri, key, value)) { if (settingHelper->Query(uri, key, value) != TELEPHONY_SUCCESS) {
TELEPHONY_LOGI("Query airplane mode fail"); TELEPHONY_LOGI("Query airplane mode fail");
return false; return TELEPHONY_ERR_DATABASE_READ_FAIL;
} }
bool airplaneMode = value == "1"; airplaneMode = value == "1";
TELEPHONY_LOGI("Get airplane mode:%{public}d", airplaneMode); TELEPHONY_LOGI("Get airplane mode:%{public}d", airplaneMode);
return airplaneMode; return TELEPHONY_SUCCESS;
} }
int32_t NetworkSearchManager::RegisterImsRegInfoCallback( int32_t NetworkSearchManager::RegisterImsRegInfoCallback(
@ -1279,5 +1305,29 @@ void NetworkSearchManager::InitSimRadioProtocol(int32_t slotId)
} }
simManager_->GetRadioProtocol(slotId); simManager_->GetRadioProtocol(slotId);
} }
int32_t NetworkSearchManager::SetLocalAirplaneMode(int32_t slotId, bool state)
{
auto inner = FindManagerInner(slotId);
if (inner == nullptr) {
TELEPHONY_LOGE("SetLocalAirplaneMode inner is nullptr, slotId:%{public}d", slotId);
return TELEPHONY_ERR_LOCAL_PTR_NULL;
}
inner->airplaneMode_ = state;
TELEPHONY_LOGD("SetLocalAirplaneMode slotId:%{public}d state:%{public}d", slotId, state);
return TELEPHONY_SUCCESS;
}
int32_t NetworkSearchManager::GetLocalAirplaneMode(int32_t slotId, bool &state)
{
auto inner = FindManagerInner(slotId);
if (inner == nullptr) {
TELEPHONY_LOGE("GetLocalAirplaneMode inner is nullptr, slotId:%{public}d", slotId);
return TELEPHONY_ERR_LOCAL_PTR_NULL;
}
state = inner->airplaneMode_;
TELEPHONY_LOGD("GetLocalAirplaneMode slotId:%{public}d state:%{public}d", slotId, state);
return TELEPHONY_ERR_SUCCESS;
}
} // namespace Telephony } // namespace Telephony
} // namespace OHOS } // namespace OHOS

View File

@ -317,7 +317,7 @@ bool NitzUpdate::IsAutoTimeZone()
Uri uri(SettingUtils::NETWORK_SEARCH_SETTING_AUTO_TIMEZONE_URI); Uri uri(SettingUtils::NETWORK_SEARCH_SETTING_AUTO_TIMEZONE_URI);
std::string key = SettingUtils::SETTINGS_NETWORK_SEARCH_AUTO_TIMEZONE; std::string key = SettingUtils::SETTINGS_NETWORK_SEARCH_AUTO_TIMEZONE;
std::string value; std::string value;
if (!settingHelper->Query(uri, key, value)) { if (settingHelper->Query(uri, key, value) != TELEPHONY_SUCCESS) {
TELEPHONY_LOGI("Query %{public}s fail", key.c_str()); TELEPHONY_LOGI("Query %{public}s fail", key.c_str());
return false; return false;
} }
@ -336,7 +336,7 @@ bool NitzUpdate::IsAutoTime()
Uri uri(SettingUtils::NETWORK_SEARCH_SETTING_AUTO_TIME_URI); Uri uri(SettingUtils::NETWORK_SEARCH_SETTING_AUTO_TIME_URI);
std::string key = SettingUtils::SETTINGS_NETWORK_SEARCH_AUTO_TIME; std::string key = SettingUtils::SETTINGS_NETWORK_SEARCH_AUTO_TIME;
std::string value = ""; std::string value = "";
if (!settingHelper->Query(uri, key, value)) { if (settingHelper->Query(uri, key, value) != TELEPHONY_SUCCESS) {
TELEPHONY_LOGI("Query %{public}s fail", key.c_str()); TELEPHONY_LOGI("Query %{public}s fail", key.c_str());
return false; return false;
} }

View File

@ -72,7 +72,9 @@ void RadioInfo::ProcessGetRadioState(const AppExecFwk::InnerEvent::Pointer &even
} }
NetworkUtils::RemoveCallbackFromMap(index); NetworkUtils::RemoveCallbackFromMap(index);
} else { } else {
if (nsm->GetRadioState(slotId_) != ModemPowerState::CORE_SERVICE_POWER_ON && !nsm->GetAirplaneMode()) { bool isAirplaneModeOn = false;
if (nsm->GetRadioState(slotId_) != ModemPowerState::CORE_SERVICE_POWER_ON &&
nsm->GetAirplaneMode(isAirplaneModeOn) == TELEPHONY_SUCCESS && !isAirplaneModeOn) {
nsm->SetRadioState(slotId_, static_cast<bool>(ModemPowerState::CORE_SERVICE_POWER_ON), 0); nsm->SetRadioState(slotId_, static_cast<bool>(ModemPowerState::CORE_SERVICE_POWER_ON), 0);
} }
if (nsm->GetRadioState(slotId_) == ModemPowerState::CORE_SERVICE_POWER_ON) { if (nsm->GetRadioState(slotId_) == ModemPowerState::CORE_SERVICE_POWER_ON) {
@ -310,13 +312,25 @@ void RadioInfo::AirplaneModeChange()
TELEPHONY_LOGE("networkSearchManager_ is nullptr slotId:%{public}d", slotId_); TELEPHONY_LOGE("networkSearchManager_ is nullptr slotId:%{public}d", slotId_);
return; return;
} }
bool airplaneMode = nsm->GetAirplaneMode(); bool isAirplaneModeOn = false;
if (nsm->GetRadioState(slotId_) == ModemPowerState::CORE_SERVICE_POWER_OFF && airplaneMode == false) { if (nsm->GetAirplaneMode(isAirplaneModeOn) != TELEPHONY_SUCCESS) {
TELEPHONY_LOGE("AirplaneModeChange GetAirplaneMode fail slotId:%{public}d", slotId_);
return;
}
bool lastAirplaneMode = false;
nsm->GetLocalAirplaneMode(slotId_, lastAirplaneMode);
if (isAirplaneModeOn == lastAirplaneMode) {
TELEPHONY_LOGE("airplaneMode is not change, slotId:%{public}d", slotId_);
return;
}
if (nsm->GetRadioState(slotId_) == ModemPowerState::CORE_SERVICE_POWER_OFF && isAirplaneModeOn == false) {
nsm->SetRadioState(slotId_, static_cast<bool>(ModemPowerState::CORE_SERVICE_POWER_ON), 0); nsm->SetRadioState(slotId_, static_cast<bool>(ModemPowerState::CORE_SERVICE_POWER_ON), 0);
} }
if (nsm->GetRadioState(slotId_) == ModemPowerState::CORE_SERVICE_POWER_ON && airplaneMode == true) { if (nsm->GetRadioState(slotId_) == ModemPowerState::CORE_SERVICE_POWER_ON && isAirplaneModeOn == true) {
nsm->SetRadioState(slotId_, static_cast<bool>(ModemPowerState::CORE_SERVICE_POWER_OFF), 0); nsm->SetRadioState(slotId_, static_cast<bool>(ModemPowerState::CORE_SERVICE_POWER_OFF), 0);
} }
nsm->SetLocalAirplaneMode(slotId_, isAirplaneModeOn);
TELEPHONY_LOGD("RadioInfo::AirplaneModeChange end. airplaneMode:%{public}d", isAirplaneModeOn);
} }
} // namespace Telephony } // namespace Telephony
} // namespace OHOS } // namespace OHOS

View File

@ -16,7 +16,7 @@
#include "setting_utils.h" #include "setting_utils.h"
#include "rdb_errno.h" #include "rdb_errno.h"
#include "telephony_errors.h"
#include "telephony_log_wrapper.h" #include "telephony_log_wrapper.h"
namespace OHOS { namespace OHOS {
@ -36,7 +36,7 @@ const std::string SettingUtils::NETWORK_SEARCH_SETTING_PREFERRED_NETWORK_MODE_UR
const std::string SettingUtils::SETTINGS_NETWORK_SEARCH_AUTO_TIME = "settings.telephony.autotime"; const std::string SettingUtils::SETTINGS_NETWORK_SEARCH_AUTO_TIME = "settings.telephony.autotime";
const std::string SettingUtils::SETTINGS_NETWORK_SEARCH_AUTO_TIMEZONE = "settings.telephony.autotimezone"; const std::string SettingUtils::SETTINGS_NETWORK_SEARCH_AUTO_TIMEZONE = "settings.telephony.autotimezone";
const std::string SettingUtils::SETTINGS_NETWORK_SEARCH_AIRPLANE_MODE = "settings.telephony.airplanemode"; const std::string SettingUtils::SETTINGS_NETWORK_SEARCH_AIRPLANE_MODE = "airplane_mode";
const std::string SettingUtils::SETTINGS_NETWORK_SEARCH_PREFERRED_NETWORK_MODE = const std::string SettingUtils::SETTINGS_NETWORK_SEARCH_PREFERRED_NETWORK_MODE =
"settings.telephony.preferrednetworkmode"; "settings.telephony.preferrednetworkmode";
@ -86,12 +86,12 @@ bool SettingUtils::RegisterSettingsObserver(
return true; return true;
} }
bool SettingUtils::Query(Uri uri, const std::string &key, std::string &value) int32_t SettingUtils::Query(Uri uri, const std::string &key, std::string &value)
{ {
TELEPHONY_LOGI("SettingUtils:Query"); TELEPHONY_LOGI("SettingUtils:Query");
if (settingHelper_ == nullptr) { if (settingHelper_ == nullptr) {
TELEPHONY_LOGE("settingHelper_ is null"); TELEPHONY_LOGE("settingHelper_ is null");
return false; return TELEPHONY_ERR_LOCAL_PTR_NULL;
} }
std::vector<std::string> columns; std::vector<std::string> columns;
@ -100,12 +100,12 @@ bool SettingUtils::Query(Uri uri, const std::string &key, std::string &value)
auto result = settingHelper_->Query(uri, predicates, columns); auto result = settingHelper_->Query(uri, predicates, columns);
if (result == nullptr) { if (result == nullptr) {
TELEPHONY_LOGE("SettingUtils: query error, result is null"); TELEPHONY_LOGE("SettingUtils: query error, result is null");
return false; return TELEPHONY_ERR_LOCAL_PTR_NULL;
} }
if (result->GoToFirstRow() != DataShare::E_OK) { if (result->GoToFirstRow() != DataShare::E_OK) {
TELEPHONY_LOGE("SettingUtils: query error, go to first row error"); TELEPHONY_LOGE("SettingUtils: query error, go to first row error");
return false; return TELEPHONY_ERR_DATABASE_READ_FAIL;
} }
int columnIndex = 0; int columnIndex = 0;
@ -113,15 +113,15 @@ bool SettingUtils::Query(Uri uri, const std::string &key, std::string &value)
result->GetString(columnIndex, value); result->GetString(columnIndex, value);
result->Close(); result->Close();
TELEPHONY_LOGI("SettingUtils: query success"); TELEPHONY_LOGI("SettingUtils: query success");
return true; return TELEPHONY_SUCCESS;
} }
bool SettingUtils::Insert(Uri uri, const std::string &key, const std::string &value) int32_t SettingUtils::Insert(Uri uri, const std::string &key, const std::string &value)
{ {
TELEPHONY_LOGI("SettingUtils: insert start"); TELEPHONY_LOGI("SettingUtils: insert start");
if (settingHelper_ == nullptr) { if (settingHelper_ == nullptr) {
TELEPHONY_LOGE("settingHelper_ is null"); TELEPHONY_LOGE("settingHelper_ is null");
return false; return TELEPHONY_ERR_LOCAL_PTR_NULL;
} }
DataShare::DataShareValuesBucket valuesBucket; DataShare::DataShareValuesBucket valuesBucket;
DataShare::DataShareValueObject keyObj(key); DataShare::DataShareValueObject keyObj(key);
@ -130,14 +130,14 @@ bool SettingUtils::Insert(Uri uri, const std::string &key, const std::string &va
valuesBucket.Put(SETTING_VALUE, valueObj); valuesBucket.Put(SETTING_VALUE, valueObj);
int32_t result = settingHelper_->Insert(uri, valuesBucket); int32_t result = settingHelper_->Insert(uri, valuesBucket);
if (result == RDB_INVALID_VALUE) { if (result == RDB_INVALID_VALUE) {
return false; return TELEPHONY_ERR_DATABASE_WRITE_FAIL;
} }
TELEPHONY_LOGI("SettingUtils: insert success"); TELEPHONY_LOGI("SettingUtils: insert success");
settingHelper_->NotifyChange(uri); settingHelper_->NotifyChange(uri);
return true; return TELEPHONY_SUCCESS;
} }
bool SettingUtils::Update(Uri uri, const std::string &key, const std::string &value) int32_t SettingUtils::Update(Uri uri, const std::string &key, const std::string &value)
{ {
TELEPHONY_LOGI("SettingUtils:update"); TELEPHONY_LOGI("SettingUtils:update");
if (settingHelper_ == nullptr) { if (settingHelper_ == nullptr) {
@ -145,8 +145,7 @@ bool SettingUtils::Update(Uri uri, const std::string &key, const std::string &va
return false; return false;
} }
std::string queryValue = ""; std::string queryValue = "";
bool ret = Query(uri, key, queryValue); if (Query(uri, key, queryValue) != TELEPHONY_SUCCESS) {
if (!ret) {
return Insert(uri, key, value); return Insert(uri, key, value);
} }
@ -157,11 +156,11 @@ bool SettingUtils::Update(Uri uri, const std::string &key, const std::string &va
predicates.EqualTo(SETTING_KEY, key); predicates.EqualTo(SETTING_KEY, key);
int32_t result = settingHelper_->Update(uri, predicates, valuesBucket); int32_t result = settingHelper_->Update(uri, predicates, valuesBucket);
if (result == RDB_INVALID_VALUE) { if (result == RDB_INVALID_VALUE) {
return false; return TELEPHONY_ERR_DATABASE_WRITE_FAIL;
} }
TELEPHONY_LOGI("SettingUtils: update success"); TELEPHONY_LOGI("SettingUtils: update success");
settingHelper_->NotifyChange(uri); settingHelper_->NotifyChange(uri);
return true; return TELEPHONY_SUCCESS;
} }
AutoTimeObserver::AutoTimeObserver(std::shared_ptr<NetworkSearchHandler> &networkSearchHandler) AutoTimeObserver::AutoTimeObserver(std::shared_ptr<NetworkSearchHandler> &networkSearchHandler)

View File

@ -11,9 +11,8 @@
# See the License for the specific language governing permissions and # See the License for the specific language governing permissions and
# limitations under the License. # limitations under the License.
import("//base/telephony/core_service/core_service_aafwk.gni")
import("//build/ohos.gni") import("//build/ohos.gni")
import("//drivers/hdf_core/adapter/uhdf2/uhdf.gni") SOURCE_DIR = "../../../.."
ohos_executable("tel_network_search_test") { ohos_executable("tel_network_search_test") {
install_enable = true install_enable = true
@ -24,24 +23,21 @@ ohos_executable("tel_network_search_test") {
"test_broadcast.cpp", "test_broadcast.cpp",
] ]
include_dirs = [ configs = [ "$SOURCE_DIR/core_service/utils:telephony_log_config" ]
"${ability_runtime_inner_api_path}/ability_manager/include",
"${ability_runtime_services_path}/abilitymgr/include",
]
configs = [ "//base/telephony/core_service/utils:telephony_log_config" ] deps =
[ "$SOURCE_DIR/core_service/interfaces/innerkits:tel_core_service_api" ]
deps = [ "${ability_runtime_path}/frameworks/native/ability/native:abilitykit_native" ]
external_deps = [ external_deps = [
"ability_base:want", "ability_base:want",
"ability_runtime:ability_manager",
"ability_runtime:abilitykit_native",
"ability_runtime:wantagent_innerkits", "ability_runtime:wantagent_innerkits",
"access_token:libaccesstoken_sdk", "access_token:libaccesstoken_sdk",
"access_token:libnativetoken", "access_token:libnativetoken",
"access_token:libtoken_setproc", "access_token:libtoken_setproc",
"c_utils:utils", "c_utils:utils",
"common_event_service:cesfwk_innerkits", "common_event_service:cesfwk_innerkits",
"core_service:tel_core_service_api",
"drivers_interface_ril:hril_innerkits", "drivers_interface_ril:hril_innerkits",
"eventhandler:libeventhandler", "eventhandler:libeventhandler",
"ipc:ipc_core", "ipc:ipc_core",

View File

@ -131,6 +131,7 @@ protected:
std::string fplmns_ = ""; std::string fplmns_ = "";
std::vector<std::shared_ptr<PlmnNetworkName>> pnnFiles_; std::vector<std::shared_ptr<PlmnNetworkName>> pnnFiles_;
std::vector<std::shared_ptr<OperatorPlmnInfo>> oplFiles_; std::vector<std::shared_ptr<OperatorPlmnInfo>> oplFiles_;
std::vector<std::shared_ptr<OperatorPlmnInfo>> opl5gFiles_;
int lengthOfMnc_ = DEFAULT_MNC; int lengthOfMnc_ = DEFAULT_MNC;
int indexOfMailbox_ = 1; int indexOfMailbox_ = 1;
int fileToGet_ = 0; int fileToGet_ = 0;
@ -140,6 +141,8 @@ protected:
bool waitResult_ = false; bool waitResult_ = false;
static std::mutex mtx_; static std::mutex mtx_;
std::condition_variable processWait_; std::condition_variable processWait_;
const int HEXADECIMAL = 16;
const size_t OPL_5G_LENGTH = 10;
const uint8_t BYTE_NUM = 0xFF; const uint8_t BYTE_NUM = 0xFF;
const uint8_t BYTE_NUM2 = 0x01; const uint8_t BYTE_NUM2 = 0x01;
const uint8_t BYTE_NUM3 = 0x0F; const uint8_t BYTE_NUM3 = 0x0F;

View File

@ -21,9 +21,7 @@
#include "i_network_search.h" #include "i_network_search.h"
#include "if_system_ability_manager.h" #include "if_system_ability_manager.h"
#include "radio_protocol_controller.h" #include "radio_protocol_controller.h"
#include "rdb_sim_helper.h"
#include "sim_constant.h" #include "sim_constant.h"
#include "sim_data.h"
#include "sim_file_manager.h" #include "sim_file_manager.h"
#include "sim_rdb_helper.h" #include "sim_rdb_helper.h"
#include "sim_state_manager.h" #include "sim_state_manager.h"

View File

@ -22,8 +22,6 @@
#include "sim_file_manager.h" #include "sim_file_manager.h"
#include "telephony_log_wrapper.h" #include "telephony_log_wrapper.h"
#include "sim_constant.h" #include "sim_constant.h"
#include "sim_data.h"
#include "rdb_sim_helper.h"
namespace OHOS { namespace OHOS {
namespace Telephony { namespace Telephony {

View File

@ -89,6 +89,7 @@ enum SimMessage {
MSG_SIM_OBTAIN_CDMA_SUBSCRIPTION_DONE, MSG_SIM_OBTAIN_CDMA_SUBSCRIPTION_DONE,
MSG_SIM_SMS_ON_RUIM, MSG_SIM_SMS_ON_RUIM,
MSG_SIM_OBTAIN_OPL_DONE, MSG_SIM_OBTAIN_OPL_DONE,
MSG_SIM_OBTAIN_OPL5G_DONE,
MSG_SIM_OBTAIN_IMPI_DONE, MSG_SIM_OBTAIN_IMPI_DONE,
MSG_SIM_OBTAIN_CSIM_SPN_DONE, MSG_SIM_OBTAIN_CSIM_SPN_DONE,
MSG_SIM_OBTAIN_IST_DONE, MSG_SIM_OBTAIN_IST_DONE,
@ -107,6 +108,7 @@ enum ElementaryFile {
ELEMENTARY_FILE_SPN_SHORT_CPHS = 0x6F18, ELEMENTARY_FILE_SPN_SHORT_CPHS = 0x6F18,
// 3GPP TS 51.011 V4.1.0 section 10 contents of the Elementary Files // 3GPP TS 51.011 V4.1.0 section 10 contents of the Elementary Files
ELEMENTARY_FILE_ICCID = 0x2FE2, ELEMENTARY_FILE_ICCID = 0x2FE2,
ELEMENTARY_FILE_OPL5G = 0x4F08,
ELEMENTARY_FILE_IMG = 0x4F20, ELEMENTARY_FILE_IMG = 0x4F20,
ELEMENTARY_FILE_HPLMN = 0x6F31, ELEMENTARY_FILE_HPLMN = 0x6F31,
ELEMENTARY_FILE_SST = 0x6F38, ELEMENTARY_FILE_SST = 0x6F38,

View File

@ -113,6 +113,7 @@ private:
bool ProcessGetEhplmnDone(const AppExecFwk::InnerEvent::Pointer &event); bool ProcessGetEhplmnDone(const AppExecFwk::InnerEvent::Pointer &event);
bool ProcessGetPnnDone(const AppExecFwk::InnerEvent::Pointer &event); bool ProcessGetPnnDone(const AppExecFwk::InnerEvent::Pointer &event);
bool ProcessGetOplDone(const AppExecFwk::InnerEvent::Pointer &event); bool ProcessGetOplDone(const AppExecFwk::InnerEvent::Pointer &event);
bool ProcessGetOpl5gDone(const AppExecFwk::InnerEvent::Pointer &event);
bool ProcessUpdateDone(const AppExecFwk::InnerEvent::Pointer &event); bool ProcessUpdateDone(const AppExecFwk::InnerEvent::Pointer &event);
bool ProcessSetCphsMailbox(const AppExecFwk::InnerEvent::Pointer &event); bool ProcessSetCphsMailbox(const AppExecFwk::InnerEvent::Pointer &event);
bool ProcessGetFplmnDone(const AppExecFwk::InnerEvent::Pointer &event); bool ProcessGetFplmnDone(const AppExecFwk::InnerEvent::Pointer &event);
@ -145,6 +146,7 @@ private:
std::string ParseSpn(const std::string &rawData, int curState); std::string ParseSpn(const std::string &rawData, int curState);
void ParsePnn(const std::vector<std::string> &records); void ParsePnn(const std::vector<std::string> &records);
void ParseOpl(const std::vector<std::string> &records); void ParseOpl(const std::vector<std::string> &records);
void ParseOpl5g(const std::vector<std::string> &records);
}; };
} // namespace Telephony } // namespace Telephony
} // namespace OHOS } // namespace OHOS

View File

@ -77,8 +77,8 @@ public:
int32_t GetActiveSimAccountInfoList(std::vector<IccAccountInfo> &iccAccountInfoList) override; int32_t GetActiveSimAccountInfoList(std::vector<IccAccountInfo> &iccAccountInfoList) override;
int32_t GetOperatorConfigs(int32_t slotId, OperatorConfig &poc) override; int32_t GetOperatorConfigs(int32_t slotId, OperatorConfig &poc) override;
int32_t HasOperatorPrivileges(const int32_t slotId, bool &hasOperatorPrivileges) override; int32_t HasOperatorPrivileges(const int32_t slotId, bool &hasOperatorPrivileges) override;
int32_t SimAuthentication(int32_t slotId, const std::string &aid, const std::string &authData, int32_t SimAuthentication(
SimAuthenticationResponse &response) override; int32_t slotId, AuthType authType, const std::string &authData, SimAuthenticationResponse &response) override;
int32_t GetRadioProtocolTech(int32_t slotId) override; int32_t GetRadioProtocolTech(int32_t slotId) override;
void GetRadioProtocol(int32_t slotId) override; void GetRadioProtocol(int32_t slotId) override;
// STK // STK
@ -135,6 +135,7 @@ public:
private: private:
bool IsValidSlotId(int32_t slotId); bool IsValidSlotId(int32_t slotId);
bool IsValidAuthType(AuthType authType);
bool IsValidSlotIdForDefault(int32_t slotId); bool IsValidSlotIdForDefault(int32_t slotId);
void InitMultiSimObject(); void InitMultiSimObject();
void InitSingleSimObject(); void InitSingleSimObject();

View File

@ -20,23 +20,6 @@ namespace OHOS {
namespace Telephony { namespace Telephony {
class SimRdbInfo { class SimRdbInfo {
public: public:
static constexpr const char *SIM_ID = "sim_id";
static constexpr const char *ICC_ID = "icc_id";
static constexpr const char *CARD_ID = "card_id";
static constexpr const char *SLOT_INDEX = "slot_index";
static constexpr const char *SHOW_NAME = "show_name";
static constexpr const char *PHONE_NUMBER = "phone_number";
static constexpr const char *COUNTRY_CODE = "country_code";
static constexpr const char *LANGUAGE = "language";
static constexpr const char *IMSI = "imsi";
static constexpr const char *CARD_TYPE = "card_type";
static constexpr const char *IMS_SWITCH = "ims_switch";
static constexpr const char *IS_ACTIVE = "is_active";
static constexpr const char *IS_MAIN_CARD = "is_main_card";
static constexpr const char *IS_VOICE_CARD = "is_voice_card";
static constexpr const char *IS_MESSAGE_CARD = "is_message_card";
static constexpr const char *IS_CELLULAR_DATA_CARD = "is_cellular_data_card";
inline static const std::string SIM_RDB_URI = "datashare:///com.ohos.simability";
inline static const std::string SIM_RDB_SELECTION = "datashare:///com.ohos.simability/sim/sim_info"; inline static const std::string SIM_RDB_SELECTION = "datashare:///com.ohos.simability/sim/sim_info";
inline static const std::string SIM_RDB_DEFAULT_SET_URI = inline static const std::string SIM_RDB_DEFAULT_SET_URI =
"datashare:///com.ohos.simability/sim/sim_info/set_card"; "datashare:///com.ohos.simability/sim/sim_info/set_card";

View File

@ -89,6 +89,10 @@ constexpr const char *FDN_PIN_LOCK = "P2";
// FDN lock type // FDN lock type
constexpr const char *FDN_PIN2_LOCK = "FD"; constexpr const char *FDN_PIN2_LOCK = "FD";
constexpr const char *USIM_AID = "USIM_AID";
constexpr const char *CDMA_FAKE_AID = "CDMA_FAKE_AID";
constexpr const char *GSM_FAKE_AID = "GSM_FAKE_AID";
struct UnlockData { struct UnlockData {
int32_t result = 0; int32_t result = 0;
int32_t remain = 0; int32_t remain = 0;
@ -122,7 +126,7 @@ public:
bool IsIccReady(); bool IsIccReady();
void RegisterCoreNotify(const std::shared_ptr<AppExecFwk::EventHandler> &handler, int what); void RegisterCoreNotify(const std::shared_ptr<AppExecFwk::EventHandler> &handler, int what);
void UnRegisterCoreNotify(const std::shared_ptr<AppExecFwk::EventHandler> &observerCallBack, int what); void UnRegisterCoreNotify(const std::shared_ptr<AppExecFwk::EventHandler> &observerCallBack, int what);
int32_t SimAuthentication(int32_t slotId, const std::string &aid, const std::string &authData); int32_t SimAuthentication(int32_t slotId, AuthType authType, const std::string &authData);
SimAuthenticationResponse GetSimAuthenticationResponse(); SimAuthenticationResponse GetSimAuthenticationResponse();
private: private:
@ -143,6 +147,7 @@ private:
void NotifySimLock(int slotId); void NotifySimLock(int slotId);
void GetUnlockSimLockResult(const AppExecFwk::InnerEvent::Pointer &event, int32_t slotId); void GetUnlockSimLockResult(const AppExecFwk::InnerEvent::Pointer &event, int32_t slotId);
void GetSimAuthenticationResult(int32_t slotId, const AppExecFwk::InnerEvent::Pointer &event); void GetSimAuthenticationResult(int32_t slotId, const AppExecFwk::InnerEvent::Pointer &event);
std::string GetAidByCardType(CardType type);
private: private:
int32_t oldSimType_ = ICC_UNKNOWN_TYPE; int32_t oldSimType_ = ICC_UNKNOWN_TYPE;

View File

@ -50,7 +50,7 @@ public:
void RegisterCoreNotify(const HANDLE &handler, int what); void RegisterCoreNotify(const HANDLE &handler, int what);
void UnRegisterCoreNotify(const HANDLE &observerCallBack, int what); void UnRegisterCoreNotify(const HANDLE &observerCallBack, int what);
int32_t SimAuthentication( int32_t SimAuthentication(
int32_t slotId, const std::string &aid, const std::string &authData, SimAuthenticationResponse &response); int32_t slotId, AuthType authType, const std::string &authData, SimAuthenticationResponse &response);
public: public:
static bool responseReady_; static bool responseReady_;

View File

@ -30,6 +30,7 @@ namespace Telephony {
static const int DECIMAL_MAX = 10; static const int DECIMAL_MAX = 10;
static const int HALF_LEN = 2; static const int HALF_LEN = 2;
static const int HALF_BYTE_LEN = 4; static const int HALF_BYTE_LEN = 4;
static const int LAC_RANGE_LEN = 6;
static const int UCS_FLAG = 0x81; static const int UCS_FLAG = 0x81;
static const int UCS_WIDE_FLAG = 0x82; static const int UCS_WIDE_FLAG = 0x82;
// Full Name IEI from TS 24.008 // Full Name IEI from TS 24.008

View File

@ -15,6 +15,8 @@
#include "icc_dialling_numbers_cache.h" #include "icc_dialling_numbers_cache.h"
#include "runner_pool.h"
namespace OHOS { namespace OHOS {
namespace Telephony { namespace Telephony {
IccDiallingNumbersCache::IccDiallingNumbersCache( IccDiallingNumbersCache::IccDiallingNumbersCache(
@ -42,7 +44,7 @@ void IccDiallingNumbersCache::Init()
return; return;
} }
std::shared_ptr<AppExecFwk::EventRunner> loaderLoop = AppExecFwk::EventRunner::Create("usimpdiallingnumbers"); std::shared_ptr<AppExecFwk::EventRunner> loaderLoop = RunnerPool::GetInstance().GetCommonRunner();
if (loaderLoop.get() == nullptr) { if (loaderLoop.get() == nullptr) {
TELEPHONY_LOGE("IccDiallingNumbersCache failed to create usimpdiallingnumbers loop"); TELEPHONY_LOGE("IccDiallingNumbersCache failed to create usimpdiallingnumbers loop");
return; return;
@ -54,7 +56,6 @@ void IccDiallingNumbersCache::Init()
} }
std::shared_ptr<IccFileController> fileController = simFileManager_->GetIccFileController(); std::shared_ptr<IccFileController> fileController = simFileManager_->GetIccFileController();
usimDiallingNumberSrv_->SetFileControllerAndDiallingNumberHandler(fileController, diallingNumbersHandler_); usimDiallingNumberSrv_->SetFileControllerAndDiallingNumberHandler(fileController, diallingNumbersHandler_);
loaderLoop->Run();
} }
void IccDiallingNumbersCache::ProcessEvent(const AppExecFwk::InnerEvent::Pointer &event) void IccDiallingNumbersCache::ProcessEvent(const AppExecFwk::InnerEvent::Pointer &event)

View File

@ -17,6 +17,7 @@
#include "core_service_errors.h" #include "core_service_errors.h"
#include "radio_event.h" #include "radio_event.h"
#include "runner_pool.h"
#include "telephony_errors.h" #include "telephony_errors.h"
namespace OHOS { namespace OHOS {
@ -36,7 +37,7 @@ void IccDiallingNumbersManager::Init()
return; return;
} }
eventLoopDiallingNumbers_ = AppExecFwk::EventRunner::Create("diallingNumbersCacheLoop"); eventLoopDiallingNumbers_ = RunnerPool::GetInstance().GetCommonRunner();
if (eventLoopDiallingNumbers_.get() == nullptr) { if (eventLoopDiallingNumbers_.get() == nullptr) {
TELEPHONY_LOGE("IccDiallingNumbersManager failed to create EventRunner"); TELEPHONY_LOGE("IccDiallingNumbersManager failed to create EventRunner");
return; return;
@ -53,7 +54,6 @@ void IccDiallingNumbersManager::Init()
return; return;
} }
eventLoopDiallingNumbers_->Run();
stateDiallingNumbers_ = HandleRunningState::STATE_RUNNING; stateDiallingNumbers_ = HandleRunningState::STATE_RUNNING;
diallingNumbersCache_->Init(); diallingNumbersCache_->Init();
@ -94,6 +94,7 @@ void IccDiallingNumbersManager::InitFdnCache()
{ {
TELEPHONY_LOGI("IccDiallingNumbersManager::InitFdnCache start"); TELEPHONY_LOGI("IccDiallingNumbersManager::InitFdnCache start");
std::thread initTask([&]() { std::thread initTask([&]() {
pthread_setname_np(pthread_self(), "init_fdn_cache");
std::vector<std::shared_ptr<DiallingNumbersInfo>> diallingNumbers; std::vector<std::shared_ptr<DiallingNumbersInfo>> diallingNumbers;
QueryIccDiallingNumbers(DiallingNumbersInfo::SIM_FDN, diallingNumbers); QueryIccDiallingNumbers(DiallingNumbersInfo::SIM_FDN, diallingNumbers);
}); });
@ -340,8 +341,7 @@ bool IccDiallingNumbersManager::IsValidType(int type)
std::shared_ptr<IccDiallingNumbersManager> IccDiallingNumbersManager::CreateInstance( std::shared_ptr<IccDiallingNumbersManager> IccDiallingNumbersManager::CreateInstance(
const std::shared_ptr<SimFileManager> &simFile, const std::shared_ptr<SimStateManager> &simState) const std::shared_ptr<SimFileManager> &simFile, const std::shared_ptr<SimStateManager> &simState)
{ {
std::shared_ptr<AppExecFwk::EventRunner> eventLoop = std::shared_ptr<AppExecFwk::EventRunner> eventLoop = RunnerPool::GetInstance().GetCommonRunner();
AppExecFwk::EventRunner::Create("diallingNumbersManagerLoop");
if (eventLoop.get() == nullptr) { if (eventLoop.get() == nullptr) {
TELEPHONY_LOGE("IccDiallingNumbersManager failed to create EventRunner"); TELEPHONY_LOGE("IccDiallingNumbersManager failed to create EventRunner");
return nullptr; return nullptr;
@ -356,7 +356,6 @@ std::shared_ptr<IccDiallingNumbersManager> IccDiallingNumbersManager::CreateInst
TELEPHONY_LOGE("IccDiallingNumbersManager::Init manager create nullptr."); TELEPHONY_LOGE("IccDiallingNumbersManager::Init manager create nullptr.");
return nullptr; return nullptr;
} }
eventLoop->Run();
return manager; return manager;
} }

View File

@ -14,12 +14,14 @@
*/ */
#include "icc_file.h" #include "icc_file.h"
#include "core_manager_inner.h"
#include "if_system_ability_manager.h" #include "if_system_ability_manager.h"
#include "inner_event.h" #include "inner_event.h"
#include "iservice_registry.h" #include "iservice_registry.h"
#include "radio_event.h"
#include "system_ability_definition.h" #include "system_ability_definition.h"
#include "telephony_state_registry_client.h" #include "telephony_state_registry_client.h"
#include "radio_event.h"
using namespace std; using namespace std;
using namespace OHOS::AppExecFwk; using namespace OHOS::AppExecFwk;
@ -204,21 +206,29 @@ std::string IccFile::ObtainSPN()
std::string IccFile::ObtainEons(const std::string &plmn, int32_t lac, bool longNameRequired) std::string IccFile::ObtainEons(const std::string &plmn, int32_t lac, bool longNameRequired)
{ {
std::vector<std::shared_ptr<OperatorPlmnInfo>> oplFiles = oplFiles_;
sptr<NetworkState> networkState = nullptr;
CoreManagerInner::GetInstance().GetNetworkStatus(slotId_, networkState);
if (networkState != nullptr && !(opl5gFiles_.empty())) {
NrState nrState = networkState->GetNrState();
if (nrState == NrState::NR_NSA_STATE_SA_ATTACHED) {
oplFiles = opl5gFiles_;
}
}
bool roaming = (plmn.compare(operatorNumeric_) == 0 ? false : true); bool roaming = (plmn.compare(operatorNumeric_) == 0 ? false : true);
TELEPHONY_LOGI("ObtainEons roaming:%{public}d", roaming); TELEPHONY_LOGI("ObtainEons roaming:%{public}d", roaming);
if (plmn.empty() || pnnFiles_.empty() || (oplFiles_.empty() && roaming)) { if (plmn.empty() || pnnFiles_.empty() || (oplFiles.empty() && roaming)) {
TELEPHONY_LOGE("ObtainEons is empty"); TELEPHONY_LOGE("ObtainEons is empty");
return ""; return "";
} }
int pnnIndex = 1; int pnnIndex = 1;
for (std::shared_ptr<OperatorPlmnInfo> opl : oplFiles_) { for (std::shared_ptr<OperatorPlmnInfo> opl : oplFiles) {
if (opl == nullptr) { if (opl == nullptr) {
continue; continue;
} }
pnnIndex = -1; pnnIndex = -1;
TELEPHONY_LOGI( TELEPHONY_LOGD("ObtainEons plmn:%{public}s, opl->plmnNumeric:%{public}s, lac:%{public}d, "
"ObtainEons plmn:%{public}s, opl->plmnNumeric:%{public}s, lac:%{public}d, " "opl->lacStart:%{public}d, opl->lacEnd:%{public}d, opl->pnnRecordId:%{public}d",
"opl->lacStart:%{public}d, opl->lacEnd:%{public}d, opl->pnnRecordId:%{public}d",
plmn.c_str(), opl->plmnNumeric.c_str(), lac, opl->lacStart, opl->lacEnd, opl->pnnRecordId); plmn.c_str(), opl->plmnNumeric.c_str(), lac, opl->lacStart, opl->lacEnd, opl->pnnRecordId);
if (plmn.compare(opl->plmnNumeric) == 0 && if (plmn.compare(opl->plmnNumeric) == 0 &&
((opl->lacStart == 0 && opl->lacEnd == 0xfffe) || (opl->lacStart <= lac && opl->lacEnd >= lac))) { ((opl->lacStart == 0 && opl->lacEnd == 0xfffe) || (opl->lacStart <= lac && opl->lacEnd >= lac))) {

View File

@ -21,9 +21,10 @@
#include <mutex> #include <mutex>
#include "inner_event.h" #include "inner_event.h"
#include "radio_event.h"
#include "runner_pool.h"
#include "sim_data_type.h" #include "sim_data_type.h"
#include "telephony_log_wrapper.h" #include "telephony_log_wrapper.h"
#include "radio_event.h"
namespace OHOS { namespace OHOS {
namespace Telephony { namespace Telephony {
@ -193,15 +194,12 @@ void IccOperatorPrivilegeController::Init(const int32_t slotId)
return; return;
} }
if (this->GetEventRunner() == nullptr) { if (this->GetEventRunner() == nullptr) {
auto runner = AppExecFwk::EventRunner::Create("UsimOperatorPrivilegeManager"); auto runner = RunnerPool::GetInstance().GetCommonRunner();
if (runner == nullptr) { if (runner == nullptr) {
TELEPHONY_LOGE("IccOperatorPrivilegeController::Init Create thread fail!"); TELEPHONY_LOGE("IccOperatorPrivilegeController::Init Create thread fail!");
return; return;
} }
this->SetEventRunner(runner); this->SetEventRunner(runner);
if (runner->Run() != ERR_OK) {
TELEPHONY_LOGE("runner->Run() fail!!");
}
} }
auto self = this->shared_from_this(); auto self = this->shared_from_this();
simStateManager_->RegisterCoreNotify(self, RadioEvent::RADIO_SIM_STATE_CHANGE); simStateManager_->RegisterCoreNotify(self, RadioEvent::RADIO_SIM_STATE_CHANGE);

View File

@ -20,6 +20,7 @@
#include "core_service_errors.h" #include "core_service_errors.h"
#include "core_service_hisysevent.h" #include "core_service_hisysevent.h"
#include "parameters.h" #include "parameters.h"
#include "sim_data.h"
#include "string_ex.h" #include "string_ex.h"
namespace OHOS { namespace OHOS {
@ -199,15 +200,15 @@ int32_t MultiSimController::UpdateDataByIccId(int slotId, const std::string &new
DataShare::DataShareValuesBucket values; DataShare::DataShareValuesBucket values;
DataShare::DataShareValueObject slotObj(slotId); DataShare::DataShareValueObject slotObj(slotId);
DataShare::DataShareValueObject valueObj(ACTIVE); DataShare::DataShareValueObject valueObj(ACTIVE);
values.Put(SimRdbInfo::SLOT_INDEX, slotObj); values.Put(SimData::SLOT_INDEX, slotObj);
values.Put(SimRdbInfo::IS_ACTIVE, valueObj); values.Put(SimData::IS_ACTIVE, valueObj);
const int32_t slotSingle = 1; const int32_t slotSingle = 1;
if (SIM_SLOT_COUNT == slotSingle) { if (SIM_SLOT_COUNT == slotSingle) {
DataShare::DataShareValueObject mainCardObj(MAIN_CARD); DataShare::DataShareValueObject mainCardObj(MAIN_CARD);
values.Put(SimRdbInfo::IS_MAIN_CARD, mainCardObj); values.Put(SimData::IS_MAIN_CARD, mainCardObj);
values.Put(SimRdbInfo::IS_VOICE_CARD, mainCardObj); values.Put(SimData::IS_VOICE_CARD, mainCardObj);
values.Put(SimRdbInfo::IS_MESSAGE_CARD, mainCardObj); values.Put(SimData::IS_MESSAGE_CARD, mainCardObj);
values.Put(SimRdbInfo::IS_CELLULAR_DATA_CARD, mainCardObj); values.Put(SimData::IS_CELLULAR_DATA_CARD, mainCardObj);
} }
return simDbHelper_->UpdateDataByIccId(newIccId, values); // finish re active return simDbHelper_->UpdateDataByIccId(newIccId, values); // finish re active
} }
@ -224,23 +225,23 @@ int32_t MultiSimController::InsertData(int slotId, const std::string &newIccId)
DataShare::DataShareValueObject slotObj(slotId); DataShare::DataShareValueObject slotObj(slotId);
DataShare::DataShareValueObject iccidObj(newIccId); DataShare::DataShareValueObject iccidObj(newIccId);
DataShare::DataShareValueObject valueObj(ACTIVE); DataShare::DataShareValueObject valueObj(ACTIVE);
values.Put(SimRdbInfo::SLOT_INDEX, slotObj); values.Put(SimData::SLOT_INDEX, slotObj);
values.Put(SimRdbInfo::ICC_ID, iccidObj); values.Put(SimData::ICC_ID, iccidObj);
values.Put(SimRdbInfo::CARD_ID, iccidObj); // iccId == cardId by now values.Put(SimData::CARD_ID, iccidObj); // iccId == cardId by now
values.Put(SimRdbInfo::IS_ACTIVE, valueObj); values.Put(SimData::IS_ACTIVE, valueObj);
const int32_t slotSingle = 1; const int32_t slotSingle = 1;
if (SIM_SLOT_COUNT == slotSingle) { if (SIM_SLOT_COUNT == slotSingle) {
DataShare::DataShareValueObject mainCardObj(MAIN_CARD); DataShare::DataShareValueObject mainCardObj(MAIN_CARD);
values.Put(SimRdbInfo::IS_MAIN_CARD, mainCardObj); values.Put(SimData::IS_MAIN_CARD, mainCardObj);
values.Put(SimRdbInfo::IS_VOICE_CARD, mainCardObj); values.Put(SimData::IS_VOICE_CARD, mainCardObj);
values.Put(SimRdbInfo::IS_MESSAGE_CARD, mainCardObj); values.Put(SimData::IS_MESSAGE_CARD, mainCardObj);
values.Put(SimRdbInfo::IS_CELLULAR_DATA_CARD, mainCardObj); values.Put(SimData::IS_CELLULAR_DATA_CARD, mainCardObj);
} else { } else {
DataShare::DataShareValueObject notMainCardObj(NOT_MAIN); DataShare::DataShareValueObject notMainCardObj(NOT_MAIN);
values.Put(SimRdbInfo::IS_MAIN_CARD, notMainCardObj); values.Put(SimData::IS_MAIN_CARD, notMainCardObj);
values.Put(SimRdbInfo::IS_VOICE_CARD, notMainCardObj); values.Put(SimData::IS_VOICE_CARD, notMainCardObj);
values.Put(SimRdbInfo::IS_MESSAGE_CARD, notMainCardObj); values.Put(SimData::IS_MESSAGE_CARD, notMainCardObj);
values.Put(SimRdbInfo::IS_CELLULAR_DATA_CARD, notMainCardObj); values.Put(SimData::IS_CELLULAR_DATA_CARD, notMainCardObj);
} }
int64_t id; int64_t id;
return simDbHelper_->InsertData(id, values); return simDbHelper_->InsertData(id, values);
@ -435,7 +436,7 @@ int32_t MultiSimController::SetActiveSim(int32_t slotId, int32_t enable, bool fo
std::lock_guard<std::mutex> lock(mutex_); std::lock_guard<std::mutex> lock(mutex_);
DataShare::DataShareValuesBucket values; DataShare::DataShareValuesBucket values;
DataShare::DataShareValueObject valueObj(enable); DataShare::DataShareValueObject valueObj(enable);
values.Put(SimRdbInfo::IS_ACTIVE, valueObj); values.Put(SimData::IS_ACTIVE, valueObj);
int32_t result = simDbHelper_->UpdateDataBySlotId(slotId, values); int32_t result = simDbHelper_->UpdateDataBySlotId(slotId, values);
if (result == INVALID_VALUE) { if (result == INVALID_VALUE) {
TELEPHONY_LOGE("MultiSimController::SetActiveSim failed by database"); TELEPHONY_LOGE("MultiSimController::SetActiveSim failed by database");
@ -780,7 +781,7 @@ int32_t MultiSimController::SetShowNumber(int32_t slotId, std::u16string number,
std::lock_guard<std::mutex> lock(mutex_); std::lock_guard<std::mutex> lock(mutex_);
DataShare::DataShareValuesBucket values; DataShare::DataShareValuesBucket values;
DataShare::DataShareValueObject valueObj(Str16ToStr8(number)); DataShare::DataShareValueObject valueObj(Str16ToStr8(number));
values.Put(SimRdbInfo::PHONE_NUMBER, valueObj); values.Put(SimData::PHONE_NUMBER, valueObj);
int32_t result = simDbHelper_->UpdateDataBySlotId(slotId, values); int32_t result = simDbHelper_->UpdateDataBySlotId(slotId, values);
if (result == INVALID_VALUE) { if (result == INVALID_VALUE) {
TELEPHONY_LOGE("MultiSimController::SetShowNumber set Data Base failed"); TELEPHONY_LOGE("MultiSimController::SetShowNumber set Data Base failed");
@ -822,7 +823,7 @@ int32_t MultiSimController::SetShowName(int32_t slotId, std::u16string name, boo
std::lock_guard<std::mutex> lock(mutex_); std::lock_guard<std::mutex> lock(mutex_);
DataShare::DataShareValuesBucket values; DataShare::DataShareValuesBucket values;
DataShare::DataShareValueObject valueObj(Str16ToStr8(name)); DataShare::DataShareValueObject valueObj(Str16ToStr8(name));
values.Put(SimRdbInfo::SHOW_NAME, valueObj); values.Put(SimData::SHOW_NAME, valueObj);
int32_t result = simDbHelper_->UpdateDataBySlotId(slotId, values); int32_t result = simDbHelper_->UpdateDataBySlotId(slotId, values);
if (result == INVALID_VALUE) { if (result == INVALID_VALUE) {
TELEPHONY_LOGE("MultiSimController::SetShowName set Data Base failed"); TELEPHONY_LOGE("MultiSimController::SetShowName set Data Base failed");
@ -855,8 +856,8 @@ bool MultiSimController::SetIccId(int32_t slotId, std::u16string iccId)
} }
DataShare::DataShareValuesBucket values; DataShare::DataShareValuesBucket values;
DataShare::DataShareValueObject iccidObj(Str16ToStr8(iccId)); DataShare::DataShareValueObject iccidObj(Str16ToStr8(iccId));
values.Put(SimRdbInfo::ICC_ID, iccidObj); values.Put(SimData::ICC_ID, iccidObj);
values.Put(SimRdbInfo::CARD_ID, iccidObj); // iccId == cardId by now values.Put(SimData::CARD_ID, iccidObj); // iccId == cardId by now
int32_t result = simDbHelper_->UpdateDataBySlotId(slotId, values); int32_t result = simDbHelper_->UpdateDataBySlotId(slotId, values);
if (result == INVALID_VALUE) { if (result == INVALID_VALUE) {
TELEPHONY_LOGE("MultiSimController::SetIccId set Data Base failed"); TELEPHONY_LOGE("MultiSimController::SetIccId set Data Base failed");
@ -930,7 +931,7 @@ int32_t MultiSimController::SaveImsSwitch(int32_t slotId, int32_t imsSwitchValue
} }
DataShare::DataShareValuesBucket values; DataShare::DataShareValuesBucket values;
DataShare::DataShareValueObject valueObj(imsSwitchValue); DataShare::DataShareValueObject valueObj(imsSwitchValue);
values.Put(SimRdbInfo::IMS_SWITCH, valueObj); values.Put(SimData::IMS_SWITCH, valueObj);
return simDbHelper_->UpdateDataByIccId(localCacheInfo_[slotId].iccId, values); return simDbHelper_->UpdateDataByIccId(localCacheInfo_[slotId].iccId, values);
} }

View File

@ -30,9 +30,6 @@ MultiSimMonitor::MultiSimMonitor(const std::shared_ptr<AppExecFwk::EventRunner>
: AppExecFwk::EventHandler(runner), controller_(controller), : AppExecFwk::EventHandler(runner), controller_(controller),
simStateManager_(simStateManager), simFileManager_(simFileManager) simStateManager_(simStateManager), simFileManager_(simFileManager)
{ {
if (runner != nullptr) {
runner->Run();
}
if (observerHandler_ == nullptr) { if (observerHandler_ == nullptr) {
observerHandler_ = std::make_unique<ObserverHandler>(); observerHandler_ = std::make_unique<ObserverHandler>();
} }

View File

@ -30,9 +30,6 @@ OperatorConfigCache::OperatorConfigCache(const std::shared_ptr<AppExecFwk::Event
std::shared_ptr<SimFileManager> simFileManager, int32_t slotId) std::shared_ptr<SimFileManager> simFileManager, int32_t slotId)
: AppExecFwk::EventHandler(runner), simFileManager_(simFileManager), slotId_(slotId) : AppExecFwk::EventHandler(runner), simFileManager_(simFileManager), slotId_(slotId)
{ {
if (runner != nullptr) {
runner->Run();
}
TELEPHONY_LOGI("OperatorConfigCache create"); TELEPHONY_LOGI("OperatorConfigCache create");
} }

View File

@ -27,11 +27,7 @@ std::condition_variable RadioProtocolController::cv_;
RadioProtocolController::RadioProtocolController(std::shared_ptr<Telephony::ITelRilManager> telRilManager, RadioProtocolController::RadioProtocolController(std::shared_ptr<Telephony::ITelRilManager> telRilManager,
const std::shared_ptr<AppExecFwk::EventRunner> &runner) const std::shared_ptr<AppExecFwk::EventRunner> &runner)
: AppExecFwk::EventHandler(runner), telRilManager_(telRilManager) : AppExecFwk::EventHandler(runner), telRilManager_(telRilManager)
{ {}
if (runner != nullptr) {
runner->Run();
}
}
void RadioProtocolController::Init() void RadioProtocolController::Init()
{ {

View File

@ -15,6 +15,7 @@
#include "sim_account_manager.h" #include "sim_account_manager.h"
#include "runner_pool.h"
#include "string_ex.h" #include "string_ex.h"
namespace OHOS { namespace OHOS {
@ -47,7 +48,7 @@ void SimAccountManager::Init(int32_t slotId)
TELEPHONY_LOGE("SimAccountManager::init SimAccountManager invalid slotId = %{public}d", slotId); TELEPHONY_LOGE("SimAccountManager::init SimAccountManager invalid slotId = %{public}d", slotId);
return; return;
} }
operatorConfigCacheRunner_ = AppExecFwk::EventRunner::Create("OperatorConfigCache"); operatorConfigCacheRunner_ = RunnerPool::GetInstance().GetSimDbAndFileRunner();
if (operatorConfigCacheRunner_.get() == nullptr) { if (operatorConfigCacheRunner_.get() == nullptr) {
TELEPHONY_LOGE("SimAccountManager::Init operatorConfigCacheRunner_ failed"); TELEPHONY_LOGE("SimAccountManager::Init operatorConfigCacheRunner_ failed");
return; return;
@ -58,7 +59,7 @@ void SimAccountManager::Init(int32_t slotId)
return; return;
} }
operatorConfigCache_->RegisterForIccChange(); operatorConfigCache_->RegisterForIccChange();
simStateTrackerRunner_ = AppExecFwk::EventRunner::Create("SimStateTracker"); simStateTrackerRunner_ = RunnerPool::GetInstance().GetSimDbAndFileRunner();
if (simStateTrackerRunner_.get() == nullptr) { if (simStateTrackerRunner_.get() == nullptr) {
TELEPHONY_LOGE("SimAccountManager::Init simStateTrackerRunner_ failed"); TELEPHONY_LOGE("SimAccountManager::Init simStateTrackerRunner_ failed");
return; return;
@ -111,7 +112,7 @@ int32_t SimAccountManager::HasOperatorPrivileges(const int32_t slotId, bool &has
} }
if (privilegesRunner_.get() == nullptr) { if (privilegesRunner_.get() == nullptr) {
TELEPHONY_LOGE("make privilegesRunner_"); TELEPHONY_LOGE("make privilegesRunner_");
privilegesRunner_ = AppExecFwk::EventRunner::Create("PrivilegeController"); privilegesRunner_ = RunnerPool::GetInstance().GetCommonRunner();
} }
if ((privilegesRunner_ == nullptr) || (telRilManager_ == nullptr) || (simStateManager_ == nullptr)) { if ((privilegesRunner_ == nullptr) || (telRilManager_ == nullptr) || (simStateManager_ == nullptr)) {
TELEPHONY_LOGE("has nullptr at privilegesRunner_ or telRilManager_ or simStateManager_"); TELEPHONY_LOGE("has nullptr at privilegesRunner_ or telRilManager_ or simStateManager_");

View File

@ -231,6 +231,10 @@ void SimFile::LoadSimFiles()
fileController_->ObtainAllLinearFixedFile(ELEMENTARY_FILE_OPL, eventOpl); fileController_->ObtainAllLinearFixedFile(ELEMENTARY_FILE_OPL, eventOpl);
fileToGet_++; fileToGet_++;
AppExecFwk::InnerEvent::Pointer eventOpl5g = BuildCallerInfo(MSG_SIM_OBTAIN_OPL5G_DONE);
fileController_->ObtainAllLinearFixedFile(ELEMENTARY_FILE_OPL5G, eventOpl5g);
fileToGet_++;
AppExecFwk::InnerEvent::Pointer phoneNumberEvent = AppExecFwk::InnerEvent::Pointer phoneNumberEvent =
CreateDiallingNumberPointer(MSG_SIM_OBTAIN_MSISDN_DONE, 0, 0, nullptr); CreateDiallingNumberPointer(MSG_SIM_OBTAIN_MSISDN_DONE, 0, 0, nullptr);
diallingNumberHandler_->GetDiallingNumbers( diallingNumberHandler_->GetDiallingNumbers(
@ -461,16 +465,50 @@ void SimFile::ParseOpl(const std::vector<std::string> &records)
} }
std::shared_ptr<OperatorPlmnInfo> file = std::make_shared<OperatorPlmnInfo>(); std::shared_ptr<OperatorPlmnInfo> file = std::make_shared<OperatorPlmnInfo>();
file->plmnNumeric = plmn; file->plmnNumeric = plmn;
int base = 16; // convert to hexadecimal if (!regex_match(dataOpl, std::regex("[0-9a-fA-F]+"))) {
file->lacStart = stoi(dataOpl.substr(MCCMNC_LEN, HALF_BYTE_LEN), 0, base); TELEPHONY_LOGI("InputValue is not a hexadecimal number");
file->lacEnd = stoi(dataOpl.substr(MCCMNC_LEN + HALF_BYTE_LEN, HALF_BYTE_LEN), 0, base); continue;
file->pnnRecordId = stoi(dataOpl.substr(MCCMNC_LEN + BYTE_LENGTH, HALF_LEN), 0, base); }
file->lacStart = stoi(dataOpl.substr(MCCMNC_LEN, HALF_BYTE_LEN), 0, HEXADECIMAL);
file->lacEnd = stoi(dataOpl.substr(MCCMNC_LEN + HALF_BYTE_LEN, HALF_BYTE_LEN), 0, HEXADECIMAL);
file->pnnRecordId = stoi(dataOpl.substr(MCCMNC_LEN + BYTE_LENGTH, HALF_LEN), 0, HEXADECIMAL);
TELEPHONY_LOGI("plmnNumeric: %{public}s, lacStart: %{public}d, lacEnd: %{public}d, pnnRecordId: %{public}d", TELEPHONY_LOGI("plmnNumeric: %{public}s, lacStart: %{public}d, lacEnd: %{public}d, pnnRecordId: %{public}d",
file->plmnNumeric.c_str(), file->lacStart, file->lacEnd, file->pnnRecordId); file->plmnNumeric.c_str(), file->lacStart, file->lacEnd, file->pnnRecordId);
oplFiles_.push_back(file); oplFiles_.push_back(file);
} }
} }
void SimFile::ParseOpl5g(const std::vector<std::string> &records)
{
opl5gFiles_.clear();
if (records.empty()) {
TELEPHONY_LOGI("ParseOpl5g records is empty");
return;
}
for (const auto &dataOpl : records) {
TELEPHONY_LOGD("ParseOpl5g: %{public}s", dataOpl.c_str());
if (dataOpl.size() != (OPL_5G_LENGTH + OPL_5G_LENGTH)) {
continue;
}
std::string plmn = SIMUtils::BcdPlmnConvertToString(dataOpl, 0);
if (plmn.empty()) {
continue;
}
std::shared_ptr<OperatorPlmnInfo> file = std::make_shared<OperatorPlmnInfo>();
file->plmnNumeric = plmn;
if (!regex_match(dataOpl, std::regex("[0-9a-fA-F]+"))) {
TELEPHONY_LOGI("InputValue is not a hexadecimal number");
continue;
}
file->lacStart = stoi(dataOpl.substr(MCCMNC_LEN, LAC_RANGE_LEN), 0, HEXADECIMAL);
file->lacEnd = stoi(dataOpl.substr(MCCMNC_LEN + LAC_RANGE_LEN, LAC_RANGE_LEN), 0, HEXADECIMAL);
file->pnnRecordId = stoi(dataOpl.substr(MCCMNC_LEN + LAC_RANGE_LEN + LAC_RANGE_LEN, HALF_LEN), 0, HEXADECIMAL);
TELEPHONY_LOGD("plmnNumeric: %{public}s, lacStart: %{public}d, lacEnd: %{public}d, pnnRecordId: %{public}d",
file->plmnNumeric.c_str(), file->lacStart, file->lacEnd, file->pnnRecordId);
opl5gFiles_.push_back(file);
}
}
std::shared_ptr<UsimFunctionHandle> SimFile::ObtainUsimFunctionHandle() std::shared_ptr<UsimFunctionHandle> SimFile::ObtainUsimFunctionHandle()
{ {
return UsimFunctionHandle_; return UsimFunctionHandle_;
@ -1274,9 +1312,6 @@ bool SimFile::ProcessGetOplDone(const AppExecFwk::InnerEvent::Pointer &event)
if (object->exception == nullptr) { if (object->exception == nullptr) {
ParseOpl(object->fileResults); ParseOpl(object->fileResults);
} }
for (std::string str : object->fileResults) {
TELEPHONY_LOGI("ProcessGetOplDone: %{public}s", str.c_str());
}
} else { } else {
TELEPHONY_LOGE("ProcessGetOplDone: get null pointer!!!"); TELEPHONY_LOGE("ProcessGetOplDone: get null pointer!!!");
} }
@ -1284,6 +1319,32 @@ bool SimFile::ProcessGetOplDone(const AppExecFwk::InnerEvent::Pointer &event)
return isFileProcessResponse; return isFileProcessResponse;
} }
bool SimFile::ProcessGetOpl5gDone(const AppExecFwk::InnerEvent::Pointer &event)
{
TELEPHONY_LOGD("ProcessGetOpl5gDone: start");
bool isFileProcessResponse = true;
if (event == nullptr) {
TELEPHONY_LOGE("event is nullptr!");
return isFileProcessResponse;
}
std::unique_ptr<ControllerToFileMsg> fd = event->GetUniqueObject<ControllerToFileMsg>();
if (fd != nullptr) {
if (fd->exception != nullptr) {
TELEPHONY_LOGE("ProcessGetOpl5gDone: get error result");
}
return isFileProcessResponse;
}
std::shared_ptr<MultiRecordResult> object = event->GetSharedObject<MultiRecordResult>();
if (object == nullptr) {
TELEPHONY_LOGE("ProcessGetOpl5gDone: get null pointer!!!");
return isFileProcessResponse;
}
if (object->exception == nullptr) {
ParseOpl5g(object->fileResults);
}
return isFileProcessResponse;
}
bool SimFile::ProcessUpdateDone(const AppExecFwk::InnerEvent::Pointer &event) bool SimFile::ProcessUpdateDone(const AppExecFwk::InnerEvent::Pointer &event)
{ {
bool isFileProcessResponse = false; bool isFileProcessResponse = false;
@ -1497,6 +1558,7 @@ void SimFile::InitMemberFunc()
memberFuncMap_[MSG_SIM_UPDATE_DONE] = &SimFile::ProcessUpdateDone; memberFuncMap_[MSG_SIM_UPDATE_DONE] = &SimFile::ProcessUpdateDone;
memberFuncMap_[MSG_SIM_OBTAIN_PNN_DONE] = &SimFile::ProcessGetPnnDone; memberFuncMap_[MSG_SIM_OBTAIN_PNN_DONE] = &SimFile::ProcessGetPnnDone;
memberFuncMap_[MSG_SIM_OBTAIN_OPL_DONE] = &SimFile::ProcessGetOplDone; memberFuncMap_[MSG_SIM_OBTAIN_OPL_DONE] = &SimFile::ProcessGetOplDone;
memberFuncMap_[MSG_SIM_OBTAIN_OPL5G_DONE] = &SimFile::ProcessGetOpl5gDone;
memberFuncMap_[MSG_SIM_OBTAIN_ALL_SMS_DONE] = &SimFile::ProcessGetAllSmsDone; memberFuncMap_[MSG_SIM_OBTAIN_ALL_SMS_DONE] = &SimFile::ProcessGetAllSmsDone;
memberFuncMap_[MSG_SIM_MARK_SMS_READ_DONE] = &SimFile::ProcessMarkSms; memberFuncMap_[MSG_SIM_MARK_SMS_READ_DONE] = &SimFile::ProcessMarkSms;
memberFuncMap_[MSG_SIM_SMS_ON_SIM] = &SimFile::ProcessSmsOnSim; memberFuncMap_[MSG_SIM_SMS_ON_SIM] = &SimFile::ProcessSmsOnSim;

View File

@ -17,6 +17,7 @@
#include "network_state.h" #include "network_state.h"
#include "radio_event.h" #include "radio_event.h"
#include "runner_pool.h"
namespace OHOS { namespace OHOS {
namespace Telephony { namespace Telephony {
@ -89,7 +90,7 @@ bool SimFileManager::InitSimFile(SimFileManager::IccType type)
return false; return false;
} }
if (eventLoopRecord_ == nullptr) { if (eventLoopRecord_ == nullptr) {
eventLoopRecord_ = AppExecFwk::EventRunner::Create("IccFile"); eventLoopRecord_ = RunnerPool::GetInstance().GetCommonRunner();
if (eventLoopRecord_.get() == nullptr) { if (eventLoopRecord_.get() == nullptr) {
TELEPHONY_LOGE("IccFile failed to create EventRunner"); TELEPHONY_LOGE("IccFile failed to create EventRunner");
return false; return false;
@ -116,7 +117,6 @@ bool SimFileManager::InitSimFile(SimFileManager::IccType type)
return false; return false;
} }
simFile_->SetRilAndFileController(telRilManager_, fileController_, diallingNumberHandler_); simFile_->SetRilAndFileController(telRilManager_, fileController_, diallingNumberHandler_);
eventLoopRecord_->Run();
simFile_->SetId(slotId_); simFile_->SetId(slotId_);
simFile_->Init(); simFile_->Init();
return true; return true;
@ -125,7 +125,7 @@ bool SimFileManager::InitSimFile(SimFileManager::IccType type)
bool SimFileManager::InitIccFileController(SimFileManager::IccType type) bool SimFileManager::InitIccFileController(SimFileManager::IccType type)
{ {
if (eventLoopFileController_ == nullptr) { if (eventLoopFileController_ == nullptr) {
eventLoopFileController_ = AppExecFwk::EventRunner::Create("SIMController"); eventLoopFileController_ = RunnerPool::GetInstance().GetCommonRunner();
if (eventLoopFileController_.get() == nullptr) { if (eventLoopFileController_.get() == nullptr) {
TELEPHONY_LOGE("SIMHandler failed to create EventRunner"); TELEPHONY_LOGE("SIMHandler failed to create EventRunner");
return false; return false;
@ -153,7 +153,6 @@ bool SimFileManager::InitIccFileController(SimFileManager::IccType type)
return false; return false;
} }
fileController_->SetRilManager(telRilManager_); fileController_->SetRilManager(telRilManager_);
eventLoopFileController_->Run();
return true; return true;
} }
@ -468,7 +467,7 @@ bool SimFileManager::InitDiallingNumberHandler()
diallingNumberHandler_->UpdateFileController(fileController_); diallingNumberHandler_->UpdateFileController(fileController_);
return true; return true;
} }
std::shared_ptr<AppExecFwk::EventRunner> loaderLoop = AppExecFwk::EventRunner::Create("msisdnLoader"); std::shared_ptr<AppExecFwk::EventRunner> loaderLoop = RunnerPool::GetInstance().GetCommonRunner();
if (loaderLoop.get() == nullptr) { if (loaderLoop.get() == nullptr) {
TELEPHONY_LOGE("SimFileManager failed to create diallingNumberloader loop"); TELEPHONY_LOGE("SimFileManager failed to create diallingNumberloader loop");
return false; return false;
@ -478,7 +477,6 @@ bool SimFileManager::InitDiallingNumberHandler()
TELEPHONY_LOGE("SimFileManager failed to create IccDiallingNumbersHandler."); TELEPHONY_LOGE("SimFileManager failed to create IccDiallingNumbersHandler.");
return false; return false;
} }
loaderLoop->Run();
return true; return true;
} }
@ -527,7 +525,7 @@ void SimFileManager::ProcessEvent(const AppExecFwk::InnerEvent::Pointer &event)
std::shared_ptr<SimFileManager> SimFileManager::CreateInstance( std::shared_ptr<SimFileManager> SimFileManager::CreateInstance(
const std::shared_ptr<ITelRilManager> &ril, const std::shared_ptr<SimStateManager> &simState) const std::shared_ptr<ITelRilManager> &ril, const std::shared_ptr<SimStateManager> &simState)
{ {
std::shared_ptr<AppExecFwk::EventRunner> eventLoop = AppExecFwk::EventRunner::Create("simFileMgrLoop"); std::shared_ptr<AppExecFwk::EventRunner> eventLoop = RunnerPool::GetInstance().GetCommonRunner();
if (eventLoop.get() == nullptr) { if (eventLoop.get() == nullptr) {
TELEPHONY_LOGE("SimFileManager failed to create EventRunner"); TELEPHONY_LOGE("SimFileManager failed to create EventRunner");
return nullptr; return nullptr;
@ -541,7 +539,7 @@ std::shared_ptr<SimFileManager> SimFileManager::CreateInstance(
TELEPHONY_LOGE("SimFileManager::Init manager create nullptr."); TELEPHONY_LOGE("SimFileManager::Init manager create nullptr.");
return nullptr; return nullptr;
} }
eventLoop->Run();
return manager; return manager;
} }

View File

@ -17,6 +17,7 @@
#include "core_service_errors.h" #include "core_service_errors.h"
#include "radio_event.h" #include "radio_event.h"
#include "runner_pool.h"
#include "telephony_errors.h" #include "telephony_errors.h"
namespace OHOS { namespace OHOS {
@ -92,7 +93,7 @@ void SimManager::InitMultiSimObject()
void SimManager::InitSingleSimObject() void SimManager::InitSingleSimObject()
{ {
controllerRunner_ = AppExecFwk::EventRunner::Create("MultiSimController"); controllerRunner_ = RunnerPool::GetInstance().GetCommonRunner();
if (controllerRunner_.get() == nullptr) { if (controllerRunner_.get() == nullptr) {
TELEPHONY_LOGE("SimManager::InitSingleSimObject get controllerRunner_ failed"); TELEPHONY_LOGE("SimManager::InitSingleSimObject get controllerRunner_ failed");
return; return;
@ -105,11 +106,7 @@ void SimManager::InitSingleSimObject()
} }
multiSimController_->Init(); multiSimController_->Init();
monitorRunner_ = AppExecFwk::EventRunner::Create("MultiSimMonitor"); monitorRunner_ = RunnerPool::GetInstance().GetSimDbAndFileRunner();
if (monitorRunner_.get() == nullptr) {
TELEPHONY_LOGE("get monitorRunner_ failed");
return;
}
multiSimMonitor_ = std::make_shared<MultiSimMonitor>( multiSimMonitor_ = std::make_shared<MultiSimMonitor>(
monitorRunner_, multiSimController_, simStateManager_, simFileManager_); monitorRunner_, multiSimController_, simStateManager_, simFileManager_);
if (multiSimMonitor_ == nullptr) { if (multiSimMonitor_ == nullptr) {
@ -499,14 +496,21 @@ int32_t SimManager::HasOperatorPrivileges(const int32_t slotId, bool &hasOperato
} }
int32_t SimManager::SimAuthentication( int32_t SimManager::SimAuthentication(
int32_t slotId, const std::string &aid, const std::string &authData, SimAuthenticationResponse &response) int32_t slotId, AuthType authType, const std::string &authData, SimAuthenticationResponse &response)
{ {
TELEPHONY_LOGI("SimManager::SimAuthentication slotId:%{public}d", slotId); if (!HasSimCardInner(slotId)) {
if ((!IsValidSlotId(slotId)) || (simStateManager_[slotId] == nullptr)) { TELEPHONY_LOGE("SimAuthentication has no sim card!");
return TELEPHONY_ERR_NO_SIM_CARD;
}
if (!IsValidAuthType(authType)) {
TELEPHONY_LOGE("SimAuthentication authType is invalid!");
return TELEPHONY_ERR_ARGUMENT_INVALID;
}
if (simStateManager_[slotId] == nullptr) {
TELEPHONY_LOGE("simStateManager_ can not be null!"); TELEPHONY_LOGE("simStateManager_ can not be null!");
return TELEPHONY_ERR_LOCAL_PTR_NULL; return TELEPHONY_ERR_LOCAL_PTR_NULL;
} }
return simStateManager_[slotId]->SimAuthentication(slotId, aid, authData, response); return simStateManager_[slotId]->SimAuthentication(slotId, authType, authData, response);
} }
int32_t SimManager::GetRadioProtocolTech(int32_t slotId) int32_t SimManager::GetRadioProtocolTech(int32_t slotId)
@ -982,6 +986,11 @@ bool SimManager::IsValidSlotId(int32_t slotId)
return true; return true;
} }
bool SimManager::IsValidAuthType(AuthType authType)
{
return (authType == AuthType::SIM_AUTH_EAP_SIM_TYPE || authType == AuthType::SIM_AUTH_EAP_AKA_TYPE);
}
bool SimManager::IsValidSlotIdForDefault(int32_t slotId) bool SimManager::IsValidSlotIdForDefault(int32_t slotId)
{ {
if ((slotId < DEFAULT_SIM_SLOT_ID_REMOVE) || (slotId >= slotCount_)) { if ((slotId < DEFAULT_SIM_SLOT_ID_REMOVE) || (slotId >= slotCount_)) {

View File

@ -15,6 +15,7 @@
#include "sim_rdb_helper.h" #include "sim_rdb_helper.h"
#include "sim_data.h"
#include "telephony_errors.h" #include "telephony_errors.h"
#include "telephony_types.h" #include "telephony_types.h"
@ -37,7 +38,7 @@ std::shared_ptr<DataShare::DataShareHelper> SimRdbHelper::CreateDataAHelper()
TELEPHONY_LOGE("SimRdbHelper GetSystemAbility Service Failed."); TELEPHONY_LOGE("SimRdbHelper GetSystemAbility Service Failed.");
return nullptr; return nullptr;
} }
return DataShare::DataShareHelper::Creator(remoteObj, SimRdbInfo::SIM_RDB_URI); return DataShare::DataShareHelper::Creator(remoteObj, SIM_URI);
} }
int SimRdbHelper::Insert(const DataShare::DataShareValuesBucket &values) int SimRdbHelper::Insert(const DataShare::DataShareValuesBucket &values)
@ -108,7 +109,7 @@ int32_t SimRdbHelper::GetDefaultMainCardSlotId()
int32_t mainCardSlotId = 0; int32_t mainCardSlotId = 0;
std::vector<std::string> colume; std::vector<std::string> colume;
DataShare::DataSharePredicates predicates; DataShare::DataSharePredicates predicates;
predicates.EqualTo(SimRdbInfo::IS_MAIN_CARD, std::to_string(static_cast<int32_t>(MAIN_CARD))); predicates.EqualTo(SimData::IS_MAIN_CARD, std::to_string(static_cast<int32_t>(MAIN_CARD)));
std::shared_ptr<DataShare::DataShareResultSet> result = Query(colume, predicates); std::shared_ptr<DataShare::DataShareResultSet> result = Query(colume, predicates);
if (result == nullptr) { if (result == nullptr) {
TELEPHONY_LOGE("SimRdbHelper::get nothing"); TELEPHONY_LOGE("SimRdbHelper::get nothing");
@ -120,7 +121,7 @@ int32_t SimRdbHelper::GetDefaultMainCardSlotId()
return mainCardSlotId; return mainCardSlotId;
} }
int index = 0; int index = 0;
result->GetColumnIndex(SimRdbInfo::SLOT_INDEX, index); result->GetColumnIndex(SimData::SLOT_INDEX, index);
result->GetInt(index, mainCardSlotId); result->GetInt(index, mainCardSlotId);
result->Close(); result->Close();
return mainCardSlotId; return mainCardSlotId;
@ -132,7 +133,7 @@ int32_t SimRdbHelper::GetDefaultMessageCardSlotId()
int32_t messageCardSlotId = 0; int32_t messageCardSlotId = 0;
std::vector<std::string> colume; std::vector<std::string> colume;
DataShare::DataSharePredicates predicates; DataShare::DataSharePredicates predicates;
predicates.EqualTo(SimRdbInfo::IS_MESSAGE_CARD, std::to_string(static_cast<int32_t>(MAIN_CARD))); predicates.EqualTo(SimData::IS_MESSAGE_CARD, std::to_string(static_cast<int32_t>(MAIN_CARD)));
std::shared_ptr<DataShare::DataShareResultSet> result = Query(colume, predicates); std::shared_ptr<DataShare::DataShareResultSet> result = Query(colume, predicates);
if (result == nullptr) { if (result == nullptr) {
TELEPHONY_LOGE("SimRdbHelper::get nothing"); TELEPHONY_LOGE("SimRdbHelper::get nothing");
@ -144,7 +145,7 @@ int32_t SimRdbHelper::GetDefaultMessageCardSlotId()
return messageCardSlotId; return messageCardSlotId;
} }
int index = 0; int index = 0;
result->GetColumnIndex(SimRdbInfo::SLOT_INDEX, index); result->GetColumnIndex(SimData::SLOT_INDEX, index);
result->GetInt(index, messageCardSlotId); result->GetInt(index, messageCardSlotId);
result->Close(); result->Close();
return messageCardSlotId; return messageCardSlotId;
@ -156,7 +157,7 @@ int32_t SimRdbHelper::GetDefaultCellularDataCardSlotId()
int32_t cellularDataCardSlotId = 0; int32_t cellularDataCardSlotId = 0;
std::vector<std::string> colume; std::vector<std::string> colume;
DataShare::DataSharePredicates predicates; DataShare::DataSharePredicates predicates;
predicates.EqualTo(SimRdbInfo::IS_CELLULAR_DATA_CARD, std::to_string(static_cast<int32_t>(MAIN_CARD))); predicates.EqualTo(SimData::IS_CELLULAR_DATA_CARD, std::to_string(static_cast<int32_t>(MAIN_CARD)));
std::shared_ptr<DataShare::DataShareResultSet> result = Query(colume, predicates); std::shared_ptr<DataShare::DataShareResultSet> result = Query(colume, predicates);
if (result == nullptr) { if (result == nullptr) {
TELEPHONY_LOGE("SimRdbHelper::get nothing"); TELEPHONY_LOGE("SimRdbHelper::get nothing");
@ -168,7 +169,7 @@ int32_t SimRdbHelper::GetDefaultCellularDataCardSlotId()
return cellularDataCardSlotId; return cellularDataCardSlotId;
} }
int index = 0; int index = 0;
result->GetColumnIndex(SimRdbInfo::SLOT_INDEX, index); result->GetColumnIndex(SimData::SLOT_INDEX, index);
result->GetInt(index, cellularDataCardSlotId); result->GetInt(index, cellularDataCardSlotId);
result->Close(); result->Close();
return cellularDataCardSlotId; return cellularDataCardSlotId;
@ -179,7 +180,7 @@ int32_t SimRdbHelper::GetDefaultVoiceCardSlotId()
int32_t voiceCardSlotId = INVALID_VALUE; int32_t voiceCardSlotId = INVALID_VALUE;
std::vector<std::string> colume; std::vector<std::string> colume;
DataShare::DataSharePredicates predicates; DataShare::DataSharePredicates predicates;
predicates.EqualTo(SimRdbInfo::IS_VOICE_CARD, std::to_string(static_cast<int32_t>(MAIN_CARD))); predicates.EqualTo(SimData::IS_VOICE_CARD, std::to_string(static_cast<int32_t>(MAIN_CARD)));
std::shared_ptr<DataShare::DataShareResultSet> result = Query(colume, predicates); std::shared_ptr<DataShare::DataShareResultSet> result = Query(colume, predicates);
if (result == nullptr) { if (result == nullptr) {
TELEPHONY_LOGE("SimRdbHelper::get nothing"); TELEPHONY_LOGE("SimRdbHelper::get nothing");
@ -191,7 +192,7 @@ int32_t SimRdbHelper::GetDefaultVoiceCardSlotId()
return voiceCardSlotId; return voiceCardSlotId;
} }
int index = 0; int index = 0;
result->GetColumnIndex(SimRdbInfo::SLOT_INDEX, index); result->GetColumnIndex(SimData::SLOT_INDEX, index);
result->GetInt(index, voiceCardSlotId); result->GetInt(index, voiceCardSlotId);
result->Close(); result->Close();
TELEPHONY_LOGI("SimRdbHelper::GetDefaultVoiceCardSlotId = %{public}d", voiceCardSlotId); TELEPHONY_LOGI("SimRdbHelper::GetDefaultVoiceCardSlotId = %{public}d", voiceCardSlotId);
@ -205,8 +206,8 @@ int32_t SimRdbHelper::SetDefaultMainCard(int32_t slotId)
DataShare::DataShareValuesBucket value; DataShare::DataShareValuesBucket value;
DataShare::DataShareValueObject slotObj(slotId); DataShare::DataShareValueObject slotObj(slotId);
DataShare::DataShareValueObject valueObj(static_cast<int>(DefaultCardType::MAIN)); DataShare::DataShareValueObject valueObj(static_cast<int>(DefaultCardType::MAIN));
value.Put(SimRdbInfo::SLOT_INDEX, slotObj); value.Put(SimData::SLOT_INDEX, slotObj);
value.Put(SimRdbInfo::CARD_TYPE, valueObj); value.Put(SimData::CARD_TYPE, valueObj);
std::shared_ptr<DataShare::DataShareHelper> dataShareHelper = CreateDataAHelper(); std::shared_ptr<DataShare::DataShareHelper> dataShareHelper = CreateDataAHelper();
if (dataShareHelper == nullptr) { if (dataShareHelper == nullptr) {
TELEPHONY_LOGE("SimRdbHelper::SetDefaultMainCard failed by nullptr"); TELEPHONY_LOGE("SimRdbHelper::SetDefaultMainCard failed by nullptr");
@ -226,8 +227,8 @@ int32_t SimRdbHelper::SetDefaultVoiceCard(int32_t slotId)
DataShare::DataShareValuesBucket value; DataShare::DataShareValuesBucket value;
DataShare::DataShareValueObject slotObj(slotId); DataShare::DataShareValueObject slotObj(slotId);
DataShare::DataShareValueObject valueObj(static_cast<int>(DefaultCardType::VOICE)); DataShare::DataShareValueObject valueObj(static_cast<int>(DefaultCardType::VOICE));
value.Put(SimRdbInfo::SLOT_INDEX, slotObj); value.Put(SimData::SLOT_INDEX, slotObj);
value.Put(SimRdbInfo::CARD_TYPE, valueObj); value.Put(SimData::CARD_TYPE, valueObj);
std::shared_ptr<DataShare::DataShareHelper> dataShareHelper = CreateDataAHelper(); std::shared_ptr<DataShare::DataShareHelper> dataShareHelper = CreateDataAHelper();
if (dataShareHelper == nullptr) { if (dataShareHelper == nullptr) {
TELEPHONY_LOGE("SimRdbHelper::SetDefaultVoiceCard failed by nullptr"); TELEPHONY_LOGE("SimRdbHelper::SetDefaultVoiceCard failed by nullptr");
@ -247,8 +248,8 @@ int32_t SimRdbHelper::SetDefaultMessageCard(int32_t slotId)
DataShare::DataShareValuesBucket value; DataShare::DataShareValuesBucket value;
DataShare::DataShareValueObject slotObj(slotId); DataShare::DataShareValueObject slotObj(slotId);
DataShare::DataShareValueObject valueObj(static_cast<int>(DefaultCardType::SMS)); DataShare::DataShareValueObject valueObj(static_cast<int>(DefaultCardType::SMS));
value.Put(SimRdbInfo::SLOT_INDEX, slotObj); value.Put(SimData::SLOT_INDEX, slotObj);
value.Put(SimRdbInfo::CARD_TYPE, valueObj); value.Put(SimData::CARD_TYPE, valueObj);
std::shared_ptr<DataShare::DataShareHelper> dataShareHelper = CreateDataAHelper(); std::shared_ptr<DataShare::DataShareHelper> dataShareHelper = CreateDataAHelper();
if (dataShareHelper == nullptr) { if (dataShareHelper == nullptr) {
TELEPHONY_LOGE("SimRdbHelper::SetDefaultMessageCard failed by nullptr"); TELEPHONY_LOGE("SimRdbHelper::SetDefaultMessageCard failed by nullptr");
@ -268,8 +269,8 @@ int32_t SimRdbHelper::SetDefaultCellularData(int32_t slotId)
DataShare::DataShareValuesBucket value; DataShare::DataShareValuesBucket value;
DataShare::DataShareValueObject slotObj(slotId); DataShare::DataShareValueObject slotObj(slotId);
DataShare::DataShareValueObject valueObj(static_cast<int>(DefaultCardType::DATA)); DataShare::DataShareValueObject valueObj(static_cast<int>(DefaultCardType::DATA));
value.Put(SimRdbInfo::SLOT_INDEX, slotObj); value.Put(SimData::SLOT_INDEX, slotObj);
value.Put(SimRdbInfo::CARD_TYPE, valueObj); value.Put(SimData::CARD_TYPE, valueObj);
std::shared_ptr<DataShare::DataShareHelper> dataShareHelper = CreateDataAHelper(); std::shared_ptr<DataShare::DataShareHelper> dataShareHelper = CreateDataAHelper();
if (dataShareHelper == nullptr) { if (dataShareHelper == nullptr) {
TELEPHONY_LOGE("SimRdbHelper::SetDefaultCellularData failed by nullptr"); TELEPHONY_LOGE("SimRdbHelper::SetDefaultCellularData failed by nullptr");
@ -292,37 +293,37 @@ void SimRdbHelper::SaveDataToBean(std::shared_ptr<DataShare::DataShareResultSet>
{ {
TELEPHONY_LOGI("SimRdbHelper::SaveDataToBean"); TELEPHONY_LOGI("SimRdbHelper::SaveDataToBean");
int index = 0; int index = 0;
result->GetColumnIndex(SimRdbInfo::SIM_ID, index); result->GetColumnIndex(SimData::SIM_ID, index);
result->GetInt(index, simBean.simId); result->GetInt(index, simBean.simId);
result->GetColumnIndex(SimRdbInfo::ICC_ID, index); result->GetColumnIndex(SimData::ICC_ID, index);
result->GetString(index, simBean.iccId); result->GetString(index, simBean.iccId);
result->GetColumnIndex(SimRdbInfo::CARD_ID, index); result->GetColumnIndex(SimData::CARD_ID, index);
result->GetString(index, simBean.cardId); result->GetString(index, simBean.cardId);
result->GetColumnIndex(SimRdbInfo::IMS_SWITCH, index); result->GetColumnIndex(SimData::IMS_SWITCH, index);
result->GetInt(index, simBean.imsSwitch); result->GetInt(index, simBean.imsSwitch);
result->GetColumnIndex(SimRdbInfo::SLOT_INDEX, index); result->GetColumnIndex(SimData::SLOT_INDEX, index);
result->GetInt(index, simBean.slotIndex); result->GetInt(index, simBean.slotIndex);
result->GetColumnIndex(SimRdbInfo::CARD_TYPE, index); result->GetColumnIndex(SimData::CARD_TYPE, index);
result->GetInt(index, simBean.cardType); result->GetInt(index, simBean.cardType);
result->GetColumnIndex(SimRdbInfo::SHOW_NAME, index); result->GetColumnIndex(SimData::SHOW_NAME, index);
result->GetString(index, simBean.showName); result->GetString(index, simBean.showName);
result->GetColumnIndex(SimRdbInfo::PHONE_NUMBER, index); result->GetColumnIndex(SimData::PHONE_NUMBER, index);
result->GetString(index, simBean.phoneNumber); result->GetString(index, simBean.phoneNumber);
result->GetColumnIndex(SimRdbInfo::COUNTRY_CODE, index); result->GetColumnIndex(SimData::COUNTRY_CODE, index);
result->GetString(index, simBean.countryCode); result->GetString(index, simBean.countryCode);
result->GetColumnIndex(SimRdbInfo::LANGUAGE, index); result->GetColumnIndex(SimData::LANGUAGE, index);
result->GetString(index, simBean.language); result->GetString(index, simBean.language);
result->GetColumnIndex(SimRdbInfo::IMSI, index); result->GetColumnIndex(SimData::IMSI, index);
result->GetString(index, simBean.imsi); result->GetString(index, simBean.imsi);
result->GetColumnIndex(SimRdbInfo::IS_MAIN_CARD, index); result->GetColumnIndex(SimData::IS_MAIN_CARD, index);
result->GetInt(index, simBean.isMainCard); result->GetInt(index, simBean.isMainCard);
result->GetColumnIndex(SimRdbInfo::IS_VOICE_CARD, index); result->GetColumnIndex(SimData::IS_VOICE_CARD, index);
result->GetInt(index, simBean.isVoiceCard); result->GetInt(index, simBean.isVoiceCard);
result->GetColumnIndex(SimRdbInfo::IS_MESSAGE_CARD, index); result->GetColumnIndex(SimData::IS_MESSAGE_CARD, index);
result->GetInt(index, simBean.isMessageCard); result->GetInt(index, simBean.isMessageCard);
result->GetColumnIndex(SimRdbInfo::IS_CELLULAR_DATA_CARD, index); result->GetColumnIndex(SimData::IS_CELLULAR_DATA_CARD, index);
result->GetInt(index, simBean.isCellularDataCard); result->GetInt(index, simBean.isCellularDataCard);
result->GetColumnIndex(SimRdbInfo::IS_ACTIVE, index); result->GetColumnIndex(SimData::IS_ACTIVE, index);
result->GetInt(index, simBean.isActive); result->GetInt(index, simBean.isActive);
} }
@ -332,7 +333,7 @@ int32_t SimRdbHelper::QueryDataBySlotId(int32_t slotId, SimRdbInfo &simBean)
std::string slot = std::to_string(slotId); std::string slot = std::to_string(slotId);
std::vector<std::string> colume; std::vector<std::string> colume;
DataShare::DataSharePredicates predicates; DataShare::DataSharePredicates predicates;
predicates.EqualTo(SimRdbInfo::SLOT_INDEX, slot); predicates.EqualTo(SimData::SLOT_INDEX, slot);
std::shared_ptr<DataShare::DataShareResultSet> result = Query(colume, predicates); std::shared_ptr<DataShare::DataShareResultSet> result = Query(colume, predicates);
if (result == nullptr) { if (result == nullptr) {
TELEPHONY_LOGE("SimRdbHelper::QueryDataBySlotId get nothing"); TELEPHONY_LOGE("SimRdbHelper::QueryDataBySlotId get nothing");
@ -352,7 +353,7 @@ int32_t SimRdbHelper::QueryDataByIccId(std::string iccId, SimRdbInfo &simBean)
TELEPHONY_LOGI("SimRdbHelper::QueryDataByIccId"); TELEPHONY_LOGI("SimRdbHelper::QueryDataByIccId");
std::vector<std::string> colume; std::vector<std::string> colume;
DataShare::DataSharePredicates predicates; DataShare::DataSharePredicates predicates;
predicates.EqualTo(SimRdbInfo::ICC_ID, iccId); predicates.EqualTo(SimData::ICC_ID, iccId);
std::shared_ptr<DataShare::DataShareResultSet> result = Query(colume, predicates); std::shared_ptr<DataShare::DataShareResultSet> result = Query(colume, predicates);
if (result == nullptr) { if (result == nullptr) {
TELEPHONY_LOGE("SimRdbHelper::QueryDataByIccId get nothing"); TELEPHONY_LOGE("SimRdbHelper::QueryDataByIccId get nothing");
@ -394,7 +395,7 @@ int32_t SimRdbHelper::QueryAllValidData(std::vector<SimRdbInfo> &vec)
std::vector<std::string> colume; std::vector<std::string> colume;
std::string id = std::to_string(DEACTIVE); std::string id = std::to_string(DEACTIVE);
DataShare::DataSharePredicates predicates; DataShare::DataSharePredicates predicates;
predicates.GreaterThan(SimRdbInfo::IS_ACTIVE, id); predicates.GreaterThan(SimData::IS_ACTIVE, id);
std::shared_ptr<DataShare::DataShareResultSet> result = Query(colume, predicates); std::shared_ptr<DataShare::DataShareResultSet> result = Query(colume, predicates);
if (result == nullptr) { if (result == nullptr) {
TELEPHONY_LOGE("SimRdbHelper::QueryAllValidData get nothing"); TELEPHONY_LOGE("SimRdbHelper::QueryAllValidData get nothing");
@ -416,7 +417,7 @@ int32_t SimRdbHelper::UpdateDataBySlotId(int32_t slotId, const DataShare::DataSh
TELEPHONY_LOGI("SimRdbHelper::UpdateDataBySlotId = %{public}d", slotId); TELEPHONY_LOGI("SimRdbHelper::UpdateDataBySlotId = %{public}d", slotId);
std::string slot = std::to_string(slotId); std::string slot = std::to_string(slotId);
DataShare::DataSharePredicates predicates; DataShare::DataSharePredicates predicates;
predicates.EqualTo(SimRdbInfo::SLOT_INDEX, slot); predicates.EqualTo(SimData::SLOT_INDEX, slot);
return Update(values, predicates); return Update(values, predicates);
} }
@ -424,7 +425,7 @@ int32_t SimRdbHelper::UpdateDataByIccId(std::string iccId, const DataShare::Data
{ {
TELEPHONY_LOGI("SimRdbHelper::UpdateDataByIccId"); TELEPHONY_LOGI("SimRdbHelper::UpdateDataByIccId");
DataShare::DataSharePredicates predicates; DataShare::DataSharePredicates predicates;
predicates.EqualTo(SimRdbInfo::ICC_ID, iccId); predicates.EqualTo(SimData::ICC_ID, iccId);
return Update(values, predicates); return Update(values, predicates);
} }
@ -434,7 +435,7 @@ int32_t SimRdbHelper::ForgetAllData()
DataShare::DataSharePredicates predicates; DataShare::DataSharePredicates predicates;
DataShare::DataShareValuesBucket value; DataShare::DataShareValuesBucket value;
DataShare::DataShareValueObject valueObj(DEACTIVE); DataShare::DataShareValueObject valueObj(DEACTIVE);
value.Put(SimRdbInfo::IS_ACTIVE, valueObj); value.Put(SimData::IS_ACTIVE, valueObj);
return Update(value, predicates); return Update(value, predicates);
} }
@ -442,10 +443,10 @@ int32_t SimRdbHelper::ForgetAllData(int32_t slotId)
{ {
TELEPHONY_LOGI("SimRdbHelper::ForgetAllData slotId = %{public}d", slotId); TELEPHONY_LOGI("SimRdbHelper::ForgetAllData slotId = %{public}d", slotId);
DataShare::DataSharePredicates predicates; DataShare::DataSharePredicates predicates;
predicates.EqualTo(SimRdbInfo::SLOT_INDEX, std::to_string(slotId)); predicates.EqualTo(SimData::SLOT_INDEX, std::to_string(slotId));
DataShare::DataShareValuesBucket value; DataShare::DataShareValuesBucket value;
DataShare::DataShareValueObject valueObj(DEACTIVE); DataShare::DataShareValueObject valueObj(DEACTIVE);
value.Put(SimRdbInfo::IS_ACTIVE, valueObj); value.Put(SimData::IS_ACTIVE, valueObj);
return Update(value, predicates); return Update(value, predicates);
} }
@ -453,7 +454,7 @@ int32_t SimRdbHelper::ClearData()
{ {
std::string id = std::to_string(INVALID_VALUE); std::string id = std::to_string(INVALID_VALUE);
DataShare::DataSharePredicates predicates; DataShare::DataSharePredicates predicates;
predicates.GreaterThan(SimRdbInfo::SIM_ID, id); predicates.GreaterThan(SimData::SIM_ID, id);
return Delete(predicates); return Delete(predicates);
} }
} // namespace Telephony } // namespace Telephony

View File

@ -16,6 +16,7 @@
#include "sim_sms_manager.h" #include "sim_sms_manager.h"
#include "telephony_errors.h" #include "telephony_errors.h"
#include "runner_pool.h"
namespace OHOS { namespace OHOS {
namespace Telephony { namespace Telephony {
@ -42,7 +43,7 @@ void SimSmsManager::Init(int slotId)
return; return;
} }
eventLoopSms_ = AppExecFwk::EventRunner::Create("simSmsController"); eventLoopSms_ = RunnerPool::GetInstance().GetCommonRunner();
if (eventLoopSms_.get() == nullptr) { if (eventLoopSms_.get() == nullptr) {
TELEPHONY_LOGE("simSmsController failed to create EventRunner"); TELEPHONY_LOGE("simSmsController failed to create EventRunner");
return; return;
@ -61,7 +62,6 @@ void SimSmsManager::Init(int slotId)
} }
smsController_->SetRilAndFileManager(telRilManager_, fileManager); smsController_->SetRilAndFileManager(telRilManager_, fileManager);
eventLoopSms_->Run();
stateSms_ = HandleRunningState::STATE_RUNNING; stateSms_ = HandleRunningState::STATE_RUNNING;
smsController_->Init(slotId_); smsController_->Init(slotId_);

View File

@ -294,7 +294,7 @@ void SimStateHandle::ObtainRealtimeIccStatus(int32_t slotId)
telRilManager_->GetSimStatus(slotId, event); // get sim card state telRilManager_->GetSimStatus(slotId, event); // get sim card state
} }
int32_t SimStateHandle::SimAuthentication(int32_t slotId, const std::string &aid, const std::string &authData) int32_t SimStateHandle::SimAuthentication(int32_t slotId, AuthType authType, const std::string &authData)
{ {
if (telRilManager_ == nullptr) { if (telRilManager_ == nullptr) {
TELEPHONY_LOGE("SimStateHandle::SimAuthentication() telRilManager_ is nullptr!!"); TELEPHONY_LOGE("SimStateHandle::SimAuthentication() telRilManager_ is nullptr!!");
@ -307,11 +307,30 @@ int32_t SimStateHandle::SimAuthentication(int32_t slotId, const std::string &aid
} }
event->SetOwner(shared_from_this()); event->SetOwner(shared_from_this());
SimAuthenticationRequestInfo requireInfo; SimAuthenticationRequestInfo requireInfo;
requireInfo.aid = aid; requireInfo.serial = static_cast<int32_t>(authType);
requireInfo.aid = GetAidByCardType(externalType_);
requireInfo.authData = authData; requireInfo.authData = authData;
return telRilManager_->SimAuthentication(slotId, requireInfo, event); return telRilManager_->SimAuthentication(slotId, requireInfo, event);
} }
std::string SimStateHandle::GetAidByCardType(CardType type)
{
switch (type) {
case CardType::SINGLE_MODE_RUIM_CARD:
return CDMA_FAKE_AID;
case CardType::SINGLE_MODE_SIM_CARD:
case CardType::DUAL_MODE_CG_CARD:
case CardType::CT_NATIONAL_ROAMING_CARD:
case CardType::CU_DUAL_MODE_CARD:
case CardType::DUAL_MODE_TELECOM_LTE_CARD:
case CardType::DUAL_MODE_UG_CARD:
return GSM_FAKE_AID;
default:
break;
}
return USIM_AID;
}
void SimStateHandle::GetSimCardData(const AppExecFwk::InnerEvent::Pointer &event, int32_t slotId) void SimStateHandle::GetSimCardData(const AppExecFwk::InnerEvent::Pointer &event, int32_t slotId)
{ {
TELEPHONY_LOGI("SimStateHandle::GetSimCardData slotId = %{public}d", slotId); TELEPHONY_LOGI("SimStateHandle::GetSimCardData slotId = %{public}d", slotId);

View File

@ -16,6 +16,7 @@
#include "sim_state_manager.h" #include "sim_state_manager.h"
#include "core_service_errors.h" #include "core_service_errors.h"
#include "runner_pool.h"
#include "telephony_errors.h" #include "telephony_errors.h"
#include "telephony_log_wrapper.h" #include "telephony_log_wrapper.h"
@ -43,7 +44,7 @@ void SimStateManager::Init(int32_t slotId)
TELEPHONY_LOGE("SimStateManager::Init telRilManager_ is null."); TELEPHONY_LOGE("SimStateManager::Init telRilManager_ is null.");
return; return;
} }
eventLoop_ = AppExecFwk::EventRunner::Create("SimStateHandle"); eventLoop_ = RunnerPool::GetInstance().GetCommonRunner();
if (eventLoop_.get() == nullptr) { if (eventLoop_.get() == nullptr) {
TELEPHONY_LOGE("SimStateHandle failed to create EventRunner"); TELEPHONY_LOGE("SimStateHandle failed to create EventRunner");
return; return;
@ -55,7 +56,7 @@ void SimStateManager::Init(int32_t slotId)
} }
simStateHandle_->SetRilManager(telRilManager_); simStateHandle_->SetRilManager(telRilManager_);
simStateHandle_->Init(slotId); simStateHandle_->Init(slotId);
eventLoop_->Run();
TELEPHONY_LOGI("SimStateManager::eventLoop_ is running"); TELEPHONY_LOGI("SimStateManager::eventLoop_ is running");
simStateRun_ = STATE_RUNNING; simStateRun_ = STATE_RUNNING;
} }
@ -457,7 +458,7 @@ int32_t SimStateManager::UnlockSimLock(int32_t slotId, const PersoLockInfo &lock
} }
int32_t SimStateManager::SimAuthentication( int32_t SimStateManager::SimAuthentication(
int32_t slotId, const std::string &aid, const std::string &authData, SimAuthenticationResponse &response) int32_t slotId, AuthType authType, const std::string &authData, SimAuthenticationResponse &response)
{ {
if (simStateHandle_ == nullptr) { if (simStateHandle_ == nullptr) {
TELEPHONY_LOGE("SimAuthentication(), simStateHandle_ is nullptr!!!"); TELEPHONY_LOGE("SimAuthentication(), simStateHandle_ is nullptr!!!");
@ -466,7 +467,7 @@ int32_t SimStateManager::SimAuthentication(
std::unique_lock<std::mutex> lck(ctx_); std::unique_lock<std::mutex> lck(ctx_);
responseReady_ = false; responseReady_ = false;
int32_t ret = SIM_AUTH_FAIL; int32_t ret = SIM_AUTH_FAIL;
ret = simStateHandle_->SimAuthentication(slotId, aid, authData); ret = simStateHandle_->SimAuthentication(slotId, authType, authData);
while (!responseReady_) { while (!responseReady_) {
TELEPHONY_LOGI("SimAuthentication::wait(), response = false"); TELEPHONY_LOGI("SimAuthentication::wait(), response = false");
if (cv_.wait_for(lck, std::chrono::seconds(WAIT_TIME_SECOND)) == std::cv_status::timeout) { if (cv_.wait_for(lck, std::chrono::seconds(WAIT_TIME_SECOND)) == std::cv_status::timeout) {

View File

@ -17,6 +17,7 @@
#include "core_manager_inner.h" #include "core_manager_inner.h"
#include "radio_event.h" #include "radio_event.h"
#include "thread"
namespace OHOS { namespace OHOS {
namespace Telephony { namespace Telephony {
@ -26,9 +27,6 @@ SimStateTracker::SimStateTracker(const std::shared_ptr<AppExecFwk::EventRunner>
: AppExecFwk::EventHandler(runner), simFileManager_(simFileManager), operatorConfigCache_(operatorConfigCache), : AppExecFwk::EventHandler(runner), simFileManager_(simFileManager), operatorConfigCache_(operatorConfigCache),
slotId_(slotId) slotId_(slotId)
{ {
if (runner != nullptr) {
runner->Run();
}
if (simFileManager == nullptr) { if (simFileManager == nullptr) {
TELEPHONY_LOGE("can not make OperatorConfigLoader"); TELEPHONY_LOGE("can not make OperatorConfigLoader");
} }
@ -71,7 +69,11 @@ void SimStateTracker::ProcessEvent(const AppExecFwk::InnerEvent::Pointer &event)
TELEPHONY_LOGE("sim is not exist"); TELEPHONY_LOGE("sim is not exist");
return; return;
} }
operatorConfigLoader_->LoadOperatorConfig(slotId_); std::thread loadOperatorConfigTask([&]() {
pthread_setname_np(pthread_self(), "load_operator_config");
operatorConfigLoader_->LoadOperatorConfig(slotId_);
});
loadOperatorConfigTask.detach();
} }
} }

View File

@ -15,6 +15,7 @@
#include "stk_manager.h" #include "stk_manager.h"
#include "runner_pool.h"
#include "telephony_errors.h" #include "telephony_errors.h"
#include "telephony_log_wrapper.h" #include "telephony_log_wrapper.h"
@ -40,9 +41,7 @@ void StkManager::Init(int slotId)
TELEPHONY_LOGE("StkManager[%{public}d]::Init() telRilManager or simStateManager_ is nullptr", slotId); TELEPHONY_LOGE("StkManager[%{public}d]::Init() telRilManager or simStateManager_ is nullptr", slotId);
return; return;
} }
std::string name = "StkController_"; stkEventLoop_ = RunnerPool::GetInstance().GetCommonRunner();
name.append(std::to_string(slotId));
stkEventLoop_ = AppExecFwk::EventRunner::Create(name.c_str());
if (stkEventLoop_.get() == nullptr) { if (stkEventLoop_.get() == nullptr) {
TELEPHONY_LOGE("StkManager[%{public}d]::Init() failed to create EventRunner", slotId); TELEPHONY_LOGE("StkManager[%{public}d]::Init() failed to create EventRunner", slotId);
return; return;
@ -53,7 +52,6 @@ void StkManager::Init(int slotId)
return; return;
} }
stkController_->Init(); stkController_->Init();
stkEventLoop_->Run();
TELEPHONY_LOGI("StkManager[%{public}d]::Init() success", slotId); TELEPHONY_LOGI("StkManager[%{public}d]::Init() success", slotId);
} }

View File

@ -51,6 +51,7 @@ std::string UsimFileController::ObtainUsimElementFilePath(int efId)
case ELEMENTARY_FILE_MBDN: case ELEMENTARY_FILE_MBDN:
case ELEMENTARY_FILE_PNN: case ELEMENTARY_FILE_PNN:
case ELEMENTARY_FILE_OPL: case ELEMENTARY_FILE_OPL:
case ELEMENTARY_FILE_OPL5G:
case ELEMENTARY_FILE_SPDI: case ELEMENTARY_FILE_SPDI:
case ELEMENTARY_FILE_SST: case ELEMENTARY_FILE_SST:
case ELEMENTARY_FILE_CFIS: case ELEMENTARY_FILE_CFIS:

View File

@ -10,15 +10,12 @@
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and # See the License for the specific language governing permissions and
# limitations under the License. # limitations under the License.
import("//base/telephony/core_service/core_service_aafwk.gni") SUBSYSTEM_DIR = "../../../.."
import("//base/telephony/core_service/telephony.gni")
import("//build/ohos.gni") import("//build/ohos.gni")
import("//drivers/hdf_core/adapter/uhdf2/uhdf.gni")
TELEPHONY_CORE_SERVICE_ROOT = "//base/telephony/core_service" TELEPHONY_CORE_SERVICE_ROOT = "$SUBSYSTEM_DIR/core_service"
TELEPHONY_SIM_ROOT = "//base/telephony/core_service/services/sim" TELEPHONY_SIM_ROOT = "$SUBSYSTEM_DIR/core_service/services/sim"
HDF_FRAMEWORKS = "//drivers/hdf/frameworks" TELEPHONY_FRAMEWORKS_ROOT = "$SUBSYSTEM_DIR/core_service/frameworks/native/"
TELEPHONY_FRAMEWORKS_ROOT = "//base/telephony/core_service/frameworks/native/"
ohos_executable("tel_sim_test") { ohos_executable("tel_sim_test") {
install_enable = true install_enable = true
@ -31,40 +28,26 @@ ohos_executable("tel_sim_test") {
] ]
include_dirs = [ include_dirs = [
"//base/telephony/telephony_data/sim/include",
"//base/telephony/telephony_data/common/include",
"$TELEPHONY_CORE_SERVICE_ROOT/base/include", "$TELEPHONY_CORE_SERVICE_ROOT/base/include",
"$TELEPHONY_CORE_SERVICE_ROOT/services/tel_ril/include", "$TELEPHONY_CORE_SERVICE_ROOT/services/tel_ril/include",
"$TELEPHONY_CORE_SERVICE_ROOT/interfaces/innerkits/include",
"$TELEPHONY_CORE_SERVICE_ROOT/interfaces/innerkits/state_registry",
"$TELEPHONY_CORE_SERVICE_ROOT/interfaces/innerkits/telephony_data",
"$TELEPHONY_SIM_ROOT/include", "$TELEPHONY_SIM_ROOT/include",
"$HDF_FRAMEWORKS/ability/sbuf/include",
"$HDF_FRAMEWORKS/core/shared/include",
"$HDF_FRAMEWORKS/core/host/include",
"$HDF_FRAMEWORKS/core/master/include",
"$HDF_FRAMEWORKS/include/core",
"$HDF_FRAMEWORKS/include/utils",
"$HDF_FRAMEWORKS/utils/include",
"$HDF_FRAMEWORKS/include/osal",
] ]
defines += [ defines = [
"TELEPHONY_LOG_TAG = \"CoreServiceSimTest\"", "TELEPHONY_LOG_TAG = \"CoreServiceSimTest\"",
"LOG_DOMAIN = 0xD000F00", "LOG_DOMAIN = 0xD000F00",
] ]
configs = [ "//base/telephony/core_service/utils:telephony_log_config" ] configs = [ "$SUBSYSTEM_DIR/core_service/utils:telephony_log_config" ]
deps = [ deps = [
"${ability_runtime_path}/frameworks/native/ability/native:abilitykit_native", "$SUBSYSTEM_DIR/core_service:tel_core_service",
"//base/telephony/core_service:tel_core_service", "$SUBSYSTEM_DIR/core_service/interfaces/innerkits:tel_core_service_api",
"//base/telephony/core_service/interfaces/innerkits:tel_core_service_api",
] ]
external_deps = [ external_deps = [
"ability_base:want", "ability_base:want",
"ability_runtime:abilitykit_native",
"access_token:libaccesstoken_sdk", "access_token:libaccesstoken_sdk",
"access_token:libnativetoken", "access_token:libnativetoken",
"access_token:libtoken_setproc", "access_token:libtoken_setproc",

View File

@ -283,7 +283,11 @@ int32_t TelRilSim::SimTransmitApduBasicChannelResponse(
int32_t TelRilSim::SimAuthenticationResponse( int32_t TelRilSim::SimAuthenticationResponse(
const HDI::Ril::V1_1::RilRadioResponseInfo &responseInfo, const HDI::Ril::V1_1::IccIoResultInfo &result) const HDI::Ril::V1_1::RilRadioResponseInfo &responseInfo, const HDI::Ril::V1_1::IccIoResultInfo &result)
{ {
return ResponseIccIo(responseInfo, result); std::shared_ptr<IccIoResultInfo> simAuthResp = std::make_shared<IccIoResultInfo>();
simAuthResp->sw1 = result.sw1;
simAuthResp->sw2 = result.sw2;
simAuthResp->response = result.response;
return Response<IccIoResultInfo>(TELEPHONY_LOG_FUNC_NAME, responseInfo, simAuthResp);
} }
int32_t TelRilSim::UnlockSimLockResponse( int32_t TelRilSim::UnlockSimLockResponse(
@ -459,6 +463,7 @@ int32_t TelRilSim::SimAuthentication(
const SimAuthenticationRequestInfo &reqInfo, const AppExecFwk::InnerEvent::Pointer &response) const SimAuthenticationRequestInfo &reqInfo, const AppExecFwk::InnerEvent::Pointer &response)
{ {
OHOS::HDI::Ril::V1_1::SimAuthenticationRequestInfo simAuthInfo; OHOS::HDI::Ril::V1_1::SimAuthenticationRequestInfo simAuthInfo;
simAuthInfo.serial = reqInfo.serial;
simAuthInfo.aid = reqInfo.aid; simAuthInfo.aid = reqInfo.aid;
simAuthInfo.authData = reqInfo.authData; simAuthInfo.authData = reqInfo.authData;
return Request(TELEPHONY_LOG_FUNC_NAME, response, HREQ_SIM_AUTHENTICATION, &HDI::Ril::V1_1::IRil::SimAuthentication, return Request(TELEPHONY_LOG_FUNC_NAME, response, HREQ_SIM_AUTHENTICATION, &HDI::Ril::V1_1::IRil::SimAuthentication,

View File

@ -11,12 +11,9 @@
# See the License for the specific language governing permissions and # See the License for the specific language governing permissions and
# limitations under the License. # limitations under the License.
import("//base/telephony/core_service/telephony.gni") TELEPHONY_CORE_SERVICE_ROOT = "../../.."
import("//build/ohos.gni") import("//build/ohos.gni")
import("//drivers/hdf_core/adapter/uhdf2/uhdf.gni") TELEPHONY_SIM_ROOT = "$TELEPHONY_CORE_SERVICE_ROOT/services/sim"
TELEPHONY_CORE_SERVICE_ROOT = "//base/telephony/core_service"
TELEPHONY_SIM_ROOT = "//base/telephony/core_service/services/sim"
ohos_executable("tel_ril_test") { ohos_executable("tel_ril_test") {
install_enable = true install_enable = true
@ -30,17 +27,14 @@ ohos_executable("tel_ril_test") {
"$TELEPHONY_SIM_ROOT/include", "$TELEPHONY_SIM_ROOT/include",
] ]
defines += [ defines = [
"TELEPHONY_LOG_TAG = \"CoreServiceRilTest\"", "TELEPHONY_LOG_TAG = \"CoreServiceRilTest\"",
"LOG_DOMAIN = 0xD000F00", "LOG_DOMAIN = 0xD000F00",
] ]
configs = [ "//base/telephony/core_service/utils:telephony_log_config" ] configs = [ "$TELEPHONY_CORE_SERVICE_ROOT/utils:telephony_log_config" ]
deps = [ deps = [ "$TELEPHONY_CORE_SERVICE_ROOT:tel_core_service" ]
"$hdf_uhdf_path/hdi:libhdi",
"//base/telephony/core_service:tel_core_service",
]
external_deps = [ external_deps = [
"c_utils:utils", "c_utils:utils",
@ -48,6 +42,7 @@ ohos_executable("tel_ril_test") {
"drivers_interface_ril:hril_innerkits", "drivers_interface_ril:hril_innerkits",
"drivers_interface_ril:ril_idl_headers", "drivers_interface_ril:ril_idl_headers",
"eventhandler:libeventhandler", "eventhandler:libeventhandler",
"hdf_core:libhdi",
"init:libbegetutil", "init:libbegetutil",
"ipc:ipc_core", "ipc:ipc_core",
"power_manager:powermgr_client", "power_manager:powermgr_client",

View File

@ -714,8 +714,27 @@ void TelRilTest::OnRequestSimAuthenticationTest(int32_t slotId,
std::cerr << "telRilManager is nullptr" << std::endl; std::cerr << "telRilManager is nullptr" << std::endl;
return; return;
} }
int32_t authType;
std::string aid;
std::string authData;
std::cout << "please enter the authType:" << std::endl;
std::cout << "SIM_AUTH_EAP_SIM_TYPE is 128" << std::endl;
std::cout << "SIM_AUTH_EAP_AKA_TYPE is 129" << std::endl;
std::cin >> authType;
std::cout << "please enter the aid:" << std::endl;
std::cout << "USIM_AID" << std::endl;
std::cout << "CDMA_FAKE_AID" << std::endl;
std::cout << "GSM_FAKE_AID" << std::endl;
std::cin >> aid;
std::cout << "please enter the authData base64 encoded:" << std::endl;
std::cin >> authData;
SimAuthenticationRequestInfo reqInfo; SimAuthenticationRequestInfo reqInfo;
telRilManager_->SimAuthentication(slotId, reqInfo, event); reqInfo.serial = authType;
reqInfo.aid = aid;
reqInfo.authData = authData;
int ret = telRilManager_->SimAuthentication(slotId, reqInfo, event);
TELEPHONY_LOGI("OnRequestSimAuthenticationTest ret = %{public}d", ret);
std::cout << "TelRilTest::OnRequestSimAuthenticationTest end" << std::endl; std::cout << "TelRilTest::OnRequestSimAuthenticationTest end" << std::endl;
} }

View File

@ -1,20 +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.
#declare build args
if (!defined(defines)) {
defines = []
}
defines += [ "CELLULAR_SUPPORT = true" ]

View File

@ -12,7 +12,7 @@
# limitations under the License. # limitations under the License.
#####################hydra-fuzz################### #####################hydra-fuzz###################
import("//base/telephony/core_service/telephony.gni") SUBSYSTEM_DIR = "../../../.."
import("//build/config/features.gni") import("//build/config/features.gni")
import("//build/ohos.gni") import("//build/ohos.gni")
import("//build/test.gni") import("//build/test.gni")
@ -22,23 +22,22 @@ ohos_fuzztest("AddIccDiallingNumbersFuzzTest") {
module_output_path = "core_service/AddIccDiallingNumbersFuzzTest" module_output_path = "core_service/AddIccDiallingNumbersFuzzTest"
module_out_path = module_output_path module_out_path = module_output_path
fuzz_config_file = fuzz_config_file =
"//base/telephony/core_service/test/fuzztest/addiccdiallingnumbers_fuzzer" "$SUBSYSTEM_DIR/core_service/test/fuzztest/addiccdiallingnumbers_fuzzer"
include_dirs = [ include_dirs = [
"//base/telephony/core_service/frameworks/js/napi/include", "$SUBSYSTEM_DIR/core_service/frameworks/js/napi/include",
"//base/telephony/core_service/frameworks/js/napi", "$SUBSYSTEM_DIR/core_service/frameworks/js/napi",
"//base/telephony/core_service/services/sim/include", "$SUBSYSTEM_DIR/core_service/services/sim/include",
"//base/telephony/core_service/services/core/include", "$SUBSYSTEM_DIR/core_service/services/core/include",
"//base/telephony/core_service/services/tel_ril/include", "$SUBSYSTEM_DIR/core_service/services/tel_ril/include",
"//base/telephony/core_service/test/fuzztest/common_fuzzer", "$SUBSYSTEM_DIR/core_service/test/fuzztest/common_fuzzer",
] ]
configs = [ "//base/telephony/core_service/utils:telephony_log_config" ] configs = [ "$SUBSYSTEM_DIR/core_service/utils:telephony_log_config" ]
deps = [ deps = [
"//base/telephony/core_service:tel_core_service", "$SUBSYSTEM_DIR/core_service:tel_core_service",
"//base/telephony/core_service/interfaces/innerkits:tel_core_service_api", "$SUBSYSTEM_DIR/core_service/interfaces/innerkits:tel_core_service_api",
"//foundation/arkui/napi:ace_napi",
] ]
external_deps = [ external_deps = [
@ -63,6 +62,7 @@ ohos_fuzztest("AddIccDiallingNumbersFuzzTest") {
"i18n:zone_util", "i18n:zone_util",
"init:libbegetutil", "init:libbegetutil",
"ipc:ipc_core", "ipc:ipc_core",
"napi:ace_napi",
"netmanager_base:net_conn_manager_if", "netmanager_base:net_conn_manager_if",
"netmanager_ext:net_tether_manager_if", "netmanager_ext:net_tether_manager_if",
"power_manager:powermgr_client", "power_manager:powermgr_client",
@ -71,7 +71,7 @@ ohos_fuzztest("AddIccDiallingNumbersFuzzTest") {
"safwk:system_ability_fwk", "safwk:system_ability_fwk",
"samgr:samgr_proxy", "samgr:samgr_proxy",
] ]
defines += [ defines = [
"TELEPHONY_LOG_TAG = \"CoreServiceFuzzTest\"", "TELEPHONY_LOG_TAG = \"CoreServiceFuzzTest\"",
"LOG_DOMAIN = 0xD000F00", "LOG_DOMAIN = 0xD000F00",
] ]
@ -88,8 +88,8 @@ ohos_fuzztest("AddIccDiallingNumbersFuzzTest") {
"-fno-omit-frame-pointer", "-fno-omit-frame-pointer",
] ]
sources = [ sources = [
"//base/telephony/core_service/frameworks/js/napi/napi_util.cpp", "$SUBSYSTEM_DIR/core_service/frameworks/js/napi/napi_util.cpp",
"//base/telephony/core_service/test/fuzztest/common_fuzzer/addcoreservicetoken_fuzzer.cpp", "$SUBSYSTEM_DIR/core_service/test/fuzztest/common_fuzzer/addcoreservicetoken_fuzzer.cpp",
"addiccdiallingnumbers_fuzzer.cpp", "addiccdiallingnumbers_fuzzer.cpp",
] ]
} }

View File

@ -39,6 +39,7 @@ bool IsServiceInited()
if (!g_isInited) { if (!g_isInited) {
auto onStart = [] { DelayedSingleton<CoreService>::GetInstance()->OnStart(); }; auto onStart = [] { DelayedSingleton<CoreService>::GetInstance()->OnStart(); };
std::thread startThread(onStart); std::thread startThread(onStart);
pthread_setname_np(startThread.native_handle(), "addiccdiallingnumbers_fuzzer");
startThread.join(); startThread.join();
sleep(SLEEP_TIME_SECONDS); sleep(SLEEP_TIME_SECONDS);

View File

@ -12,7 +12,7 @@
# limitations under the License. # limitations under the License.
#####################hydra-fuzz################### #####################hydra-fuzz###################
import("//base/telephony/core_service/telephony.gni") SUBSYSTEM_DIR = "../../../.."
import("//build/config/features.gni") import("//build/config/features.gni")
import("//build/ohos.gni") import("//build/ohos.gni")
import("//build/test.gni") import("//build/test.gni")
@ -22,24 +22,23 @@ ohos_fuzztest("GetSimEonsFuzzTest") {
module_output_path = "core_service/GetSimEonsFuzzTest" module_output_path = "core_service/GetSimEonsFuzzTest"
module_out_path = module_output_path module_out_path = module_output_path
fuzz_config_file = fuzz_config_file =
"//base/telephony/core_service/test/fuzztest/getsimeons_fuzzer" "$SUBSYSTEM_DIR/core_service/test/fuzztest/getsimeons_fuzzer"
include_dirs = [ include_dirs = [
"//base/telephony/core_service/frameworks/js/napi/include", "$SUBSYSTEM_DIR/core_service/frameworks/js/napi/include",
"//base/telephony/core_service/frameworks/js/napi", "$SUBSYSTEM_DIR/core_service/frameworks/js/napi",
"//base/telephony/core_service/services/core/include", "$SUBSYSTEM_DIR/core_service/services/core/include",
"//base/telephony/core_service/services/network_search/include", "$SUBSYSTEM_DIR/core_service/services/network_search/include",
"//base/telephony/core_service/services/sim/include", "$SUBSYSTEM_DIR/core_service/services/sim/include",
"//base/telephony/core_service/test/fuzztest/common_fuzzer", "$SUBSYSTEM_DIR/core_service/test/fuzztest/common_fuzzer",
"//base/telephony/core_service/services/tel_ril/include", "$SUBSYSTEM_DIR/core_service/services/tel_ril/include",
] ]
configs = [ "//base/telephony/core_service/utils:telephony_log_config" ] configs = [ "$SUBSYSTEM_DIR/core_service/utils:telephony_log_config" ]
deps = [ deps = [
"//base/telephony/core_service:tel_core_service", "$SUBSYSTEM_DIR/core_service:tel_core_service",
"//base/telephony/core_service/interfaces/innerkits:tel_core_service_api", "$SUBSYSTEM_DIR/core_service/interfaces/innerkits:tel_core_service_api",
"//foundation/arkui/napi:ace_napi",
] ]
external_deps = [ external_deps = [
@ -54,13 +53,14 @@ ohos_fuzztest("GetSimEonsFuzzTest") {
"hdf_core:libhdi", "hdf_core:libhdi",
"init:libbegetutil", "init:libbegetutil",
"ipc:ipc_core", "ipc:ipc_core",
"napi:ace_napi",
"netmanager_base:net_conn_manager_if", "netmanager_base:net_conn_manager_if",
"netmanager_ext:net_tether_manager_if", "netmanager_ext:net_tether_manager_if",
"power_manager:powermgr_client", "power_manager:powermgr_client",
"relational_store:native_rdb", "relational_store:native_rdb",
"samgr:samgr_proxy", "samgr:samgr_proxy",
] ]
defines += [ defines = [
"TELEPHONY_LOG_TAG = \"CoreServiceFuzzTest\"", "TELEPHONY_LOG_TAG = \"CoreServiceFuzzTest\"",
"LOG_DOMAIN = 0xD000F00", "LOG_DOMAIN = 0xD000F00",
] ]
@ -77,8 +77,8 @@ ohos_fuzztest("GetSimEonsFuzzTest") {
"-fno-omit-frame-pointer", "-fno-omit-frame-pointer",
] ]
sources = [ sources = [
"//base/telephony/core_service/frameworks/js/napi/napi_util.cpp", "$SUBSYSTEM_DIR/core_service/frameworks/js/napi/napi_util.cpp",
"//base/telephony/core_service/test/fuzztest/common_fuzzer/addcoreservicetoken_fuzzer.cpp", "$SUBSYSTEM_DIR/core_service/test/fuzztest/common_fuzzer/addcoreservicetoken_fuzzer.cpp",
"getsimeons_fuzzer.cpp", "getsimeons_fuzzer.cpp",
] ]
} }

View File

@ -39,6 +39,7 @@ bool IsServiceInited()
if (!g_isInited) { if (!g_isInited) {
auto onStart = [] { DelayedSingleton<CoreService>::GetInstance()->OnStart(); }; auto onStart = [] { DelayedSingleton<CoreService>::GetInstance()->OnStart(); };
std::thread startThread(onStart); std::thread startThread(onStart);
pthread_setname_np(startThread.native_handle(), "getsimeons_fuzzer");
startThread.join(); startThread.join();
sleep(SLEEP_TIME_SECONDS); sleep(SLEEP_TIME_SECONDS);

View File

@ -12,7 +12,7 @@
# limitations under the License. # limitations under the License.
#####################hydra-fuzz################### #####################hydra-fuzz###################
import("//base/telephony/core_service/telephony.gni") SUBSYSTEM_DIR = "../../../.."
import("//build/config/features.gni") import("//build/config/features.gni")
import("//build/ohos.gni") import("//build/ohos.gni")
import("//build/test.gni") import("//build/test.gni")
@ -22,24 +22,23 @@ ohos_fuzztest("HexVecToHexStrFuzzTest") {
module_output_path = "core_service/HexVecToHexStrFuzzTest" module_output_path = "core_service/HexVecToHexStrFuzzTest"
module_out_path = module_output_path module_out_path = module_output_path
fuzz_config_file = fuzz_config_file =
"//base/telephony/core_service/test/fuzztest/hexvectohexstr_fuzzer" "$SUBSYSTEM_DIR/core_service/test/fuzztest/hexvectohexstr_fuzzer"
include_dirs = [ include_dirs = [
"//base/telephony/core_service/frameworks/js/napi/include", "$SUBSYSTEM_DIR/core_service/frameworks/js/napi/include",
"//base/telephony/core_service/frameworks/js/napi", "$SUBSYSTEM_DIR/core_service/frameworks/js/napi",
"//base/telephony/core_service/services/core/include", "$SUBSYSTEM_DIR/core_service/services/core/include",
"//base/telephony/core_service/services/network_search/include", "$SUBSYSTEM_DIR/core_service/services/network_search/include",
"//base/telephony/core_service/services/sim/include", "$SUBSYSTEM_DIR/core_service/services/sim/include",
"//base/telephony/core_service/test/fuzztest/common_fuzzer", "$SUBSYSTEM_DIR/core_service/test/fuzztest/common_fuzzer",
"//base/telephony/core_service/services/tel_ril/include", "$SUBSYSTEM_DIR/core_service/services/tel_ril/include",
] ]
configs = [ "//base/telephony/core_service/utils:telephony_log_config" ] configs = [ "$SUBSYSTEM_DIR/core_service/utils:telephony_log_config" ]
deps = [ deps = [
"//base/telephony/core_service:tel_core_service", "$SUBSYSTEM_DIR/core_service:tel_core_service",
"//base/telephony/core_service/interfaces/innerkits:tel_core_service_api", "$SUBSYSTEM_DIR/core_service/interfaces/innerkits:tel_core_service_api",
"//foundation/arkui/napi:ace_napi",
] ]
external_deps = [ external_deps = [
@ -53,13 +52,14 @@ ohos_fuzztest("HexVecToHexStrFuzzTest") {
"drivers_interface_ril:ril_idl_headers", "drivers_interface_ril:ril_idl_headers",
"init:libbegetutil", "init:libbegetutil",
"ipc:ipc_core", "ipc:ipc_core",
"napi:ace_napi",
"netmanager_base:net_conn_manager_if", "netmanager_base:net_conn_manager_if",
"netmanager_ext:net_tether_manager_if", "netmanager_ext:net_tether_manager_if",
"power_manager:powermgr_client", "power_manager:powermgr_client",
"relational_store:native_rdb", "relational_store:native_rdb",
"samgr:samgr_proxy", "samgr:samgr_proxy",
] ]
defines += [ defines = [
"TELEPHONY_LOG_TAG = \"CoreServiceFuzzTest\"", "TELEPHONY_LOG_TAG = \"CoreServiceFuzzTest\"",
"LOG_DOMAIN = 0xD000F00", "LOG_DOMAIN = 0xD000F00",
] ]
@ -76,8 +76,8 @@ ohos_fuzztest("HexVecToHexStrFuzzTest") {
"-fno-omit-frame-pointer", "-fno-omit-frame-pointer",
] ]
sources = [ sources = [
"//base/telephony/core_service/frameworks/js/napi/napi_util.cpp", "$SUBSYSTEM_DIR/core_service/frameworks/js/napi/napi_util.cpp",
"//base/telephony/core_service/test/fuzztest/common_fuzzer/addcoreservicetoken_fuzzer.cpp", "$SUBSYSTEM_DIR/core_service/test/fuzztest/common_fuzzer/addcoreservicetoken_fuzzer.cpp",
"hexvectohexstr_fuzzer.cpp", "hexvectohexstr_fuzzer.cpp",
] ]
} }

View File

@ -12,7 +12,7 @@
# limitations under the License. # limitations under the License.
#####################hydra-fuzz################### #####################hydra-fuzz###################
import("//base/telephony/core_service/telephony.gni") SUBSYSTEM_DIR = "../../../.."
import("//build/config/features.gni") import("//build/config/features.gni")
import("//build/ohos.gni") import("//build/ohos.gni")
import("//build/test.gni") import("//build/test.gni")
@ -22,24 +22,23 @@ ohos_fuzztest("IsShowableAsciiOnlyFuzzTest") {
module_output_path = "core_service/IsShowableAsciiOnlyFuzzTest" module_output_path = "core_service/IsShowableAsciiOnlyFuzzTest"
module_out_path = module_output_path module_out_path = module_output_path
fuzz_config_file = fuzz_config_file =
"//base/telephony/core_service/test/fuzztest/isshowableasciionly_fuzzer" "$SUBSYSTEM_DIR/core_service/test/fuzztest/isshowableasciionly_fuzzer"
include_dirs = [ include_dirs = [
"//base/telephony/core_service/frameworks/js/napi/include", "$SUBSYSTEM_DIR/core_service/frameworks/js/napi/include",
"//base/telephony/core_service/frameworks/js/napi", "$SUBSYSTEM_DIR/core_service/frameworks/js/napi",
"//base/telephony/core_service/services/core/include", "$SUBSYSTEM_DIR/core_service/services/core/include",
"//base/telephony/core_service/services/network_search/include", "$SUBSYSTEM_DIR/core_service/services/network_search/include",
"//base/telephony/core_service/services/sim/include", "$SUBSYSTEM_DIR/core_service/services/sim/include",
"//base/telephony/core_service/test/fuzztest/common_fuzzer", "$SUBSYSTEM_DIR/core_service/test/fuzztest/common_fuzzer",
"//base/telephony/core_service/services/tel_ril/include", "$SUBSYSTEM_DIR/core_service/services/tel_ril/include",
] ]
configs = [ "//base/telephony/core_service/utils:telephony_log_config" ] configs = [ "$SUBSYSTEM_DIR/core_service/utils:telephony_log_config" ]
deps = [ deps = [
"//base/telephony/core_service:tel_core_service", "$SUBSYSTEM_DIR/core_service:tel_core_service",
"//base/telephony/core_service/interfaces/innerkits:tel_core_service_api", "$SUBSYSTEM_DIR/core_service/interfaces/innerkits:tel_core_service_api",
"//foundation/arkui/napi:ace_napi",
] ]
external_deps = [ external_deps = [
@ -53,13 +52,14 @@ ohos_fuzztest("IsShowableAsciiOnlyFuzzTest") {
"drivers_interface_ril:ril_idl_headers", "drivers_interface_ril:ril_idl_headers",
"init:libbegetutil", "init:libbegetutil",
"ipc:ipc_core", "ipc:ipc_core",
"napi:ace_napi",
"netmanager_base:net_conn_manager_if", "netmanager_base:net_conn_manager_if",
"netmanager_ext:net_tether_manager_if", "netmanager_ext:net_tether_manager_if",
"power_manager:powermgr_client", "power_manager:powermgr_client",
"relational_store:native_rdb", "relational_store:native_rdb",
"samgr:samgr_proxy", "samgr:samgr_proxy",
] ]
defines += [ defines = [
"TELEPHONY_LOG_TAG = \"CoreServiceFuzzTest\"", "TELEPHONY_LOG_TAG = \"CoreServiceFuzzTest\"",
"LOG_DOMAIN = 0xD000F00", "LOG_DOMAIN = 0xD000F00",
] ]
@ -76,8 +76,8 @@ ohos_fuzztest("IsShowableAsciiOnlyFuzzTest") {
"-fno-omit-frame-pointer", "-fno-omit-frame-pointer",
] ]
sources = [ sources = [
"//base/telephony/core_service/frameworks/js/napi/napi_util.cpp", "$SUBSYSTEM_DIR/core_service/frameworks/js/napi/napi_util.cpp",
"//base/telephony/core_service/test/fuzztest/common_fuzzer/addcoreservicetoken_fuzzer.cpp", "$SUBSYSTEM_DIR/core_service/test/fuzztest/common_fuzzer/addcoreservicetoken_fuzzer.cpp",
"isshowableasciionly_fuzzer.cpp", "isshowableasciionly_fuzzer.cpp",
] ]
} }

View File

@ -12,7 +12,7 @@
# limitations under the License. # limitations under the License.
#####################hydra-fuzz################### #####################hydra-fuzz###################
import("//base/telephony/core_service/telephony.gni") SUBSYSTEM_DIR = "../../../.."
import("//build/config/features.gni") import("//build/config/features.gni")
import("//build/ohos.gni") import("//build/ohos.gni")
import("//build/test.gni") import("//build/test.gni")
@ -22,24 +22,23 @@ ohos_fuzztest("IsValidNumberStringFuzzTest") {
module_output_path = "core_service/IsValidNumberStringFuzzTest" module_output_path = "core_service/IsValidNumberStringFuzzTest"
module_out_path = module_output_path module_out_path = module_output_path
fuzz_config_file = fuzz_config_file =
"//base/telephony/core_service/test/fuzztest/isvalidnumberstring_fuzzer" "$SUBSYSTEM_DIR/core_service/test/fuzztest/isvalidnumberstring_fuzzer"
include_dirs = [ include_dirs = [
"//base/telephony/core_service/frameworks/js/napi/include", "$SUBSYSTEM_DIR/core_service/frameworks/js/napi/include",
"//base/telephony/core_service/frameworks/js/napi", "$SUBSYSTEM_DIR/core_service/frameworks/js/napi",
"//base/telephony/core_service/services/core/include", "$SUBSYSTEM_DIR/core_service/services/core/include",
"//base/telephony/core_service/services/network_search/include", "$SUBSYSTEM_DIR/core_service/services/network_search/include",
"//base/telephony/core_service/services/sim/include", "$SUBSYSTEM_DIR/core_service/services/sim/include",
"//base/telephony/core_service/test/fuzztest/common_fuzzer", "$SUBSYSTEM_DIR/core_service/test/fuzztest/common_fuzzer",
"//base/telephony/core_service/services/tel_ril/include", "$SUBSYSTEM_DIR/core_service/services/tel_ril/include",
] ]
configs = [ "//base/telephony/core_service/utils:telephony_log_config" ] configs = [ "$SUBSYSTEM_DIR/core_service/utils:telephony_log_config" ]
deps = [ deps = [
"//base/telephony/core_service:tel_core_service", "$SUBSYSTEM_DIR/core_service:tel_core_service",
"//base/telephony/core_service/interfaces/innerkits:tel_core_service_api", "$SUBSYSTEM_DIR/core_service/interfaces/innerkits:tel_core_service_api",
"//foundation/arkui/napi:ace_napi",
] ]
external_deps = [ external_deps = [
@ -53,13 +52,14 @@ ohos_fuzztest("IsValidNumberStringFuzzTest") {
"drivers_interface_ril:ril_idl_headers", "drivers_interface_ril:ril_idl_headers",
"init:libbegetutil", "init:libbegetutil",
"ipc:ipc_core", "ipc:ipc_core",
"napi:ace_napi",
"netmanager_base:net_conn_manager_if", "netmanager_base:net_conn_manager_if",
"netmanager_ext:net_tether_manager_if", "netmanager_ext:net_tether_manager_if",
"power_manager:powermgr_client", "power_manager:powermgr_client",
"relational_store:native_rdb", "relational_store:native_rdb",
"samgr:samgr_proxy", "samgr:samgr_proxy",
] ]
defines += [ defines = [
"TELEPHONY_LOG_TAG = \"CoreServiceFuzzTest\"", "TELEPHONY_LOG_TAG = \"CoreServiceFuzzTest\"",
"LOG_DOMAIN = 0xD000F00", "LOG_DOMAIN = 0xD000F00",
] ]
@ -76,8 +76,8 @@ ohos_fuzztest("IsValidNumberStringFuzzTest") {
"-fno-omit-frame-pointer", "-fno-omit-frame-pointer",
] ]
sources = [ sources = [
"//base/telephony/core_service/frameworks/js/napi/napi_util.cpp", "$SUBSYSTEM_DIR/core_service/frameworks/js/napi/napi_util.cpp",
"//base/telephony/core_service/test/fuzztest/common_fuzzer/addcoreservicetoken_fuzzer.cpp", "$SUBSYSTEM_DIR/core_service/test/fuzztest/common_fuzzer/addcoreservicetoken_fuzzer.cpp",
"isvalidnumberstring_fuzzer.cpp", "isvalidnumberstring_fuzzer.cpp",
] ]
} }

View File

@ -12,7 +12,7 @@
# limitations under the License. # limitations under the License.
#####################hydra-fuzz################### #####################hydra-fuzz###################
import("//base/telephony/core_service/telephony.gni") SUBSYSTEM_DIR = "../../../.."
import("//build/config/features.gni") import("//build/config/features.gni")
import("//build/ohos.gni") import("//build/ohos.gni")
import("//build/test.gni") import("//build/test.gni")
@ -22,24 +22,23 @@ ohos_fuzztest("SendEnvelopeCmdFuzzTest") {
module_output_path = "core_service/SendEnvelopeCmdFuzzTest" module_output_path = "core_service/SendEnvelopeCmdFuzzTest"
module_out_path = module_output_path module_out_path = module_output_path
fuzz_config_file = fuzz_config_file =
"//base/telephony/core_service/test/fuzztest/sendenvelopecmd_fuzzer" "$SUBSYSTEM_DIR/core_service/test/fuzztest/sendenvelopecmd_fuzzer"
include_dirs = [ include_dirs = [
"//base/telephony/core_service/frameworks/js/napi/include", "$SUBSYSTEM_DIR/core_service/frameworks/js/napi/include",
"//base/telephony/core_service/frameworks/js/napi", "$SUBSYSTEM_DIR/core_service/frameworks/js/napi",
"//base/telephony/core_service/services/core/include", "$SUBSYSTEM_DIR/core_service/services/core/include",
"//base/telephony/core_service/services/network_search/include", "$SUBSYSTEM_DIR/core_service/services/network_search/include",
"//base/telephony/core_service/services/sim/include", "$SUBSYSTEM_DIR/core_service/services/sim/include",
"//base/telephony/core_service/test/fuzztest/common_fuzzer", "$SUBSYSTEM_DIR/core_service/test/fuzztest/common_fuzzer",
"//base/telephony/core_service/services/tel_ril/include", "$SUBSYSTEM_DIR/core_service/services/tel_ril/include",
] ]
configs = [ "//base/telephony/core_service/utils:telephony_log_config" ] configs = [ "$SUBSYSTEM_DIR/core_service/utils:telephony_log_config" ]
deps = [ deps = [
"//base/telephony/core_service:tel_core_service", "$SUBSYSTEM_DIR/core_service:tel_core_service",
"//base/telephony/core_service/interfaces/innerkits:tel_core_service_api", "$SUBSYSTEM_DIR/core_service/interfaces/innerkits:tel_core_service_api",
"//foundation/arkui/napi:ace_napi",
] ]
external_deps = [ external_deps = [
@ -54,13 +53,14 @@ ohos_fuzztest("SendEnvelopeCmdFuzzTest") {
"hdf_core:libhdi", "hdf_core:libhdi",
"init:libbegetutil", "init:libbegetutil",
"ipc:ipc_core", "ipc:ipc_core",
"napi:ace_napi",
"netmanager_base:net_conn_manager_if", "netmanager_base:net_conn_manager_if",
"netmanager_ext:net_tether_manager_if", "netmanager_ext:net_tether_manager_if",
"power_manager:powermgr_client", "power_manager:powermgr_client",
"relational_store:native_rdb", "relational_store:native_rdb",
"samgr:samgr_proxy", "samgr:samgr_proxy",
] ]
defines += [ defines = [
"TELEPHONY_LOG_TAG = \"CoreServiceFuzzTest\"", "TELEPHONY_LOG_TAG = \"CoreServiceFuzzTest\"",
"LOG_DOMAIN = 0xD000F00", "LOG_DOMAIN = 0xD000F00",
] ]
@ -77,8 +77,8 @@ ohos_fuzztest("SendEnvelopeCmdFuzzTest") {
"-fno-omit-frame-pointer", "-fno-omit-frame-pointer",
] ]
sources = [ sources = [
"//base/telephony/core_service/frameworks/js/napi/napi_util.cpp", "$SUBSYSTEM_DIR/core_service/frameworks/js/napi/napi_util.cpp",
"//base/telephony/core_service/test/fuzztest/common_fuzzer/addcoreservicetoken_fuzzer.cpp", "$SUBSYSTEM_DIR/core_service/test/fuzztest/common_fuzzer/addcoreservicetoken_fuzzer.cpp",
"sendenvelopecmd_fuzzer.cpp", "sendenvelopecmd_fuzzer.cpp",
] ]
} }

View File

@ -38,6 +38,7 @@ bool IsServiceInited()
if (!g_isInited) { if (!g_isInited) {
auto onStart = [] { DelayedSingleton<CoreService>::GetInstance()->OnStart(); }; auto onStart = [] { DelayedSingleton<CoreService>::GetInstance()->OnStart(); };
std::thread startThread(onStart); std::thread startThread(onStart);
pthread_setname_np(startThread.native_handle(), "sendenvelopecmd_fuzzer");
startThread.join(); startThread.join();
sleep(SLEEP_TIME_SECONDS); sleep(SLEEP_TIME_SECONDS);

View File

@ -12,7 +12,7 @@
# limitations under the License. # limitations under the License.
#####################hydra-fuzz################### #####################hydra-fuzz###################
import("//base/telephony/core_service/telephony.gni") SUBSYSTEM_DIR = "../../../.."
import("//build/config/features.gni") import("//build/config/features.gni")
import("//build/ohos.gni") import("//build/ohos.gni")
import("//build/test.gni") import("//build/test.gni")
@ -22,24 +22,23 @@ ohos_fuzztest("SendSmsMoreModeFuzzTest") {
module_output_path = "core_service/SendSmsMoreModeFuzzTest" module_output_path = "core_service/SendSmsMoreModeFuzzTest"
module_out_path = module_output_path module_out_path = module_output_path
fuzz_config_file = fuzz_config_file =
"//base/telephony/core_service/test/fuzztest/sendsmsmoremode_fuzzer" "$SUBSYSTEM_DIR/core_service/test/fuzztest/sendsmsmoremode_fuzzer"
include_dirs = [ include_dirs = [
"//base/telephony/core_service/frameworks/js/napi/include", "$SUBSYSTEM_DIR/core_service/frameworks/js/napi/include",
"//base/telephony/core_service/frameworks/js/napi", "$SUBSYSTEM_DIR/core_service/frameworks/js/napi",
"//base/telephony/core_service/services/core/include", "$SUBSYSTEM_DIR/core_service/services/core/include",
"//base/telephony/core_service/services/network_search/include", "$SUBSYSTEM_DIR/core_service/services/network_search/include",
"//base/telephony/core_service/services/sim/include", "$SUBSYSTEM_DIR/core_service/services/sim/include",
"//base/telephony/core_service/test/fuzztest/common_fuzzer", "$SUBSYSTEM_DIR/core_service/test/fuzztest/common_fuzzer",
"//base/telephony/core_service/services/tel_ril/include", "$SUBSYSTEM_DIR/core_service/services/tel_ril/include",
] ]
configs = [ "//base/telephony/core_service/utils:telephony_log_config" ] configs = [ "$SUBSYSTEM_DIR/core_service/utils:telephony_log_config" ]
deps = [ deps = [
"//base/telephony/core_service:tel_core_service", "$SUBSYSTEM_DIR/core_service:tel_core_service",
"//base/telephony/core_service/interfaces/innerkits:tel_core_service_api", "$SUBSYSTEM_DIR/core_service/interfaces/innerkits:tel_core_service_api",
"//foundation/arkui/napi:ace_napi",
] ]
external_deps = [ external_deps = [
@ -64,6 +63,7 @@ ohos_fuzztest("SendSmsMoreModeFuzzTest") {
"i18n:zone_util", "i18n:zone_util",
"init:libbegetutil", "init:libbegetutil",
"ipc:ipc_core", "ipc:ipc_core",
"napi:ace_napi",
"netmanager_base:net_conn_manager_if", "netmanager_base:net_conn_manager_if",
"netmanager_ext:net_tether_manager_if", "netmanager_ext:net_tether_manager_if",
"power_manager:powermgr_client", "power_manager:powermgr_client",
@ -72,7 +72,7 @@ ohos_fuzztest("SendSmsMoreModeFuzzTest") {
"safwk:system_ability_fwk", "safwk:system_ability_fwk",
"samgr:samgr_proxy", "samgr:samgr_proxy",
] ]
defines += [ defines = [
"TELEPHONY_LOG_TAG = \"CoreServiceFuzzTest\"", "TELEPHONY_LOG_TAG = \"CoreServiceFuzzTest\"",
"LOG_DOMAIN = 0xD000F00", "LOG_DOMAIN = 0xD000F00",
] ]
@ -89,8 +89,8 @@ ohos_fuzztest("SendSmsMoreModeFuzzTest") {
"-fno-omit-frame-pointer", "-fno-omit-frame-pointer",
] ]
sources = [ sources = [
"//base/telephony/core_service/frameworks/js/napi/napi_util.cpp", "$SUBSYSTEM_DIR/core_service/frameworks/js/napi/napi_util.cpp",
"//base/telephony/core_service/test/fuzztest/common_fuzzer/addcoreservicetoken_fuzzer.cpp", "$SUBSYSTEM_DIR/core_service/test/fuzztest/common_fuzzer/addcoreservicetoken_fuzzer.cpp",
"sendsmsmoremode_fuzzer.cpp", "sendsmsmoremode_fuzzer.cpp",
] ]
} }

View File

@ -12,7 +12,7 @@
# limitations under the License. # limitations under the License.
#####################hydra-fuzz################### #####################hydra-fuzz###################
import("//base/telephony/core_service/telephony.gni") SUBSYSTEM_DIR = "../../../.."
import("//build/config/features.gni") import("//build/config/features.gni")
import("//build/ohos.gni") import("//build/ohos.gni")
import("//build/test.gni") import("//build/test.gni")
@ -21,23 +21,23 @@ import("//build/test.gni")
ohos_fuzztest("SendTerminalResponseCmdFuzzTest") { ohos_fuzztest("SendTerminalResponseCmdFuzzTest") {
module_output_path = "core_service/SendTerminalResponseCmdFuzzTest" module_output_path = "core_service/SendTerminalResponseCmdFuzzTest"
module_out_path = module_output_path module_out_path = module_output_path
fuzz_config_file = "//base/telephony/core_service/test/fuzztest/sendterminalresponsecmd_fuzzer" fuzz_config_file =
"$SUBSYSTEM_DIR/core_service/test/fuzztest/sendterminalresponsecmd_fuzzer"
include_dirs = [ include_dirs = [
"//base/telephony/core_service/frameworks/js/napi/include", "$SUBSYSTEM_DIR/core_service/frameworks/js/napi/include",
"//base/telephony/core_service/frameworks/js/napi", "$SUBSYSTEM_DIR/core_service/frameworks/js/napi",
"//base/telephony/core_service/services/sim/include", "$SUBSYSTEM_DIR/core_service/services/sim/include",
"//base/telephony/core_service/services/core/include", "$SUBSYSTEM_DIR/core_service/services/core/include",
"//base/telephony/core_service/services/tel_ril/include", "$SUBSYSTEM_DIR/core_service/services/tel_ril/include",
"//base/telephony/core_service/test/fuzztest/common_fuzzer", "$SUBSYSTEM_DIR/core_service/test/fuzztest/common_fuzzer",
] ]
configs = [ "//base/telephony/core_service/utils:telephony_log_config" ] configs = [ "$SUBSYSTEM_DIR/core_service/utils:telephony_log_config" ]
deps = [ deps = [
"//base/telephony/core_service:tel_core_service", "$SUBSYSTEM_DIR/core_service:tel_core_service",
"//base/telephony/core_service/interfaces/innerkits:tel_core_service_api", "$SUBSYSTEM_DIR/core_service/interfaces/innerkits:tel_core_service_api",
"//foundation/arkui/napi:ace_napi",
] ]
external_deps = [ external_deps = [
@ -62,6 +62,7 @@ ohos_fuzztest("SendTerminalResponseCmdFuzzTest") {
"i18n:zone_util", "i18n:zone_util",
"init:libbegetutil", "init:libbegetutil",
"ipc:ipc_core", "ipc:ipc_core",
"napi:ace_napi",
"netmanager_base:net_conn_manager_if", "netmanager_base:net_conn_manager_if",
"netmanager_ext:net_tether_manager_if", "netmanager_ext:net_tether_manager_if",
"power_manager:powermgr_client", "power_manager:powermgr_client",
@ -70,7 +71,7 @@ ohos_fuzztest("SendTerminalResponseCmdFuzzTest") {
"safwk:system_ability_fwk", "safwk:system_ability_fwk",
"samgr:samgr_proxy", "samgr:samgr_proxy",
] ]
defines += [ defines = [
"TELEPHONY_LOG_TAG = \"CoreServiceFuzzTest\"", "TELEPHONY_LOG_TAG = \"CoreServiceFuzzTest\"",
"LOG_DOMAIN = 0xD000F00", "LOG_DOMAIN = 0xD000F00",
] ]
@ -87,8 +88,8 @@ ohos_fuzztest("SendTerminalResponseCmdFuzzTest") {
"-fno-omit-frame-pointer", "-fno-omit-frame-pointer",
] ]
sources = [ sources = [
"//base/telephony/core_service/frameworks/js/napi/napi_util.cpp", "$SUBSYSTEM_DIR/core_service/frameworks/js/napi/napi_util.cpp",
"//base/telephony/core_service/test/fuzztest/common_fuzzer/addcoreservicetoken_fuzzer.cpp", "$SUBSYSTEM_DIR/core_service/test/fuzztest/common_fuzzer/addcoreservicetoken_fuzzer.cpp",
"sendterminalresponsecmd_fuzzer.cpp", "sendterminalresponsecmd_fuzzer.cpp",
] ]
} }

View File

@ -37,6 +37,7 @@ bool IsServiceInited()
if (!g_isInited) { if (!g_isInited) {
auto onStart = [] { DelayedSingleton<CoreService>::GetInstance()->OnStart(); }; auto onStart = [] { DelayedSingleton<CoreService>::GetInstance()->OnStart(); };
std::thread startThread(onStart); std::thread startThread(onStart);
pthread_setname_np(startThread.native_handle(), "sendterminalresponsecmd_fuzzer");
startThread.join(); startThread.join();
sleep(SLEEP_TIME_SECONDS); sleep(SLEEP_TIME_SECONDS);

View File

@ -12,7 +12,7 @@
# limitations under the License. # limitations under the License.
#####################hydra-fuzz################### #####################hydra-fuzz###################
import("//base/telephony/core_service/telephony.gni") SUBSYSTEM_DIR = "../../../.."
import("//build/config/features.gni") import("//build/config/features.gni")
import("//build/ohos.gni") import("//build/ohos.gni")
import("//build/test.gni") import("//build/test.gni")
@ -22,24 +22,23 @@ ohos_fuzztest("SetAccessLimitFuzzTest") {
module_output_path = "core_service/SetAccessLimitFuzzTest" module_output_path = "core_service/SetAccessLimitFuzzTest"
module_out_path = module_output_path module_out_path = module_output_path
fuzz_config_file = fuzz_config_file =
"//base/telephony/core_service/test/fuzztest/setaccesslimit_fuzzer" "$SUBSYSTEM_DIR/core_service/test/fuzztest/setaccesslimit_fuzzer"
include_dirs = [ include_dirs = [
"//base/telephony/core_service/frameworks/js/napi/include", "$SUBSYSTEM_DIR/core_service/frameworks/js/napi/include",
"//base/telephony/core_service/frameworks/js/napi", "$SUBSYSTEM_DIR/core_service/frameworks/js/napi",
"//base/telephony/core_service/services/core/include", "$SUBSYSTEM_DIR/core_service/services/core/include",
"//base/telephony/core_service/services/network_search/include", "$SUBSYSTEM_DIR/core_service/services/network_search/include",
"//base/telephony/core_service/services/sim/include", "$SUBSYSTEM_DIR/core_service/services/sim/include",
"//base/telephony/core_service/test/fuzztest/common_fuzzer", "$SUBSYSTEM_DIR/core_service/test/fuzztest/common_fuzzer",
"//base/telephony/core_service/services/tel_ril/include", "$SUBSYSTEM_DIR/core_service/services/tel_ril/include",
] ]
configs = [ "//base/telephony/core_service/utils:telephony_log_config" ] configs = [ "$SUBSYSTEM_DIR/core_service/utils:telephony_log_config" ]
deps = [ deps = [
"//base/telephony/core_service:tel_core_service", "$SUBSYSTEM_DIR/core_service:tel_core_service",
"//base/telephony/core_service/interfaces/innerkits:tel_core_service_api", "$SUBSYSTEM_DIR/core_service/interfaces/innerkits:tel_core_service_api",
"//foundation/arkui/napi:ace_napi",
] ]
external_deps = [ external_deps = [
@ -53,13 +52,14 @@ ohos_fuzztest("SetAccessLimitFuzzTest") {
"drivers_interface_ril:ril_idl_headers", "drivers_interface_ril:ril_idl_headers",
"init:libbegetutil", "init:libbegetutil",
"ipc:ipc_core", "ipc:ipc_core",
"napi:ace_napi",
"netmanager_base:net_conn_manager_if", "netmanager_base:net_conn_manager_if",
"netmanager_ext:net_tether_manager_if", "netmanager_ext:net_tether_manager_if",
"power_manager:powermgr_client", "power_manager:powermgr_client",
"relational_store:native_rdb", "relational_store:native_rdb",
"samgr:samgr_proxy", "samgr:samgr_proxy",
] ]
defines += [ defines = [
"TELEPHONY_LOG_TAG = \"CoreServiceFuzzTest\"", "TELEPHONY_LOG_TAG = \"CoreServiceFuzzTest\"",
"LOG_DOMAIN = 0xD000F00", "LOG_DOMAIN = 0xD000F00",
] ]
@ -76,8 +76,8 @@ ohos_fuzztest("SetAccessLimitFuzzTest") {
"-fno-omit-frame-pointer", "-fno-omit-frame-pointer",
] ]
sources = [ sources = [
"//base/telephony/core_service/frameworks/js/napi/napi_util.cpp", "$SUBSYSTEM_DIR/core_service/frameworks/js/napi/napi_util.cpp",
"//base/telephony/core_service/test/fuzztest/common_fuzzer/addcoreservicetoken_fuzzer.cpp", "$SUBSYSTEM_DIR/core_service/test/fuzztest/common_fuzzer/addcoreservicetoken_fuzzer.cpp",
"setaccesslimit_fuzzer.cpp", "setaccesslimit_fuzzer.cpp",
] ]
} }

View File

@ -12,7 +12,7 @@
# limitations under the License. # limitations under the License.
#####################hydra-fuzz################### #####################hydra-fuzz###################
import("//base/telephony/core_service/telephony.gni") SUBSYSTEM_DIR = "../../../.."
import("//build/config/features.gni") import("//build/config/features.gni")
import("//build/ohos.gni") import("//build/ohos.gni")
import("//build/test.gni") import("//build/test.gni")
@ -22,25 +22,24 @@ ohos_fuzztest("SetShowNameFuzzTest") {
module_output_path = "core_service/SetShowNameFuzzTest" module_output_path = "core_service/SetShowNameFuzzTest"
module_out_path = module_output_path module_out_path = module_output_path
fuzz_config_file = fuzz_config_file =
"//base/telephony/core_service/test/fuzztest/setshowname_fuzzer" "$SUBSYSTEM_DIR/core_service/test/fuzztest/setshowname_fuzzer"
include_dirs = [ include_dirs = [
"//base/telephony/core_service/frameworks/js/napi/include", "$SUBSYSTEM_DIR/core_service/frameworks/js/napi/include",
"//base/telephony/core_service/frameworks/js/napi", "$SUBSYSTEM_DIR/core_service/frameworks/js/napi",
"//base/telephony/core_service/services/core/include", "$SUBSYSTEM_DIR/core_service/services/core/include",
"//base/telephony/core_service/services/network_search/include", "$SUBSYSTEM_DIR/core_service/services/network_search/include",
"//base/telephony/core_service/services/sim/include", "$SUBSYSTEM_DIR/core_service/services/sim/include",
"//base/telephony/core_service/test/fuzztest/common_fuzzer", "$SUBSYSTEM_DIR/core_service/test/fuzztest/common_fuzzer",
"//base/telephony/core_service/services/tel_ril/include", "$SUBSYSTEM_DIR/core_service/services/tel_ril/include",
"commonlibrary/c_utils/base/include", "commonlibrary/c_utils/base/include",
] ]
configs = [ "//base/telephony/core_service/utils:telephony_log_config" ] configs = [ "$SUBSYSTEM_DIR/core_service/utils:telephony_log_config" ]
deps = [ deps = [
"//base/telephony/core_service:tel_core_service", "$SUBSYSTEM_DIR/core_service:tel_core_service",
"//base/telephony/core_service/interfaces/innerkits:tel_core_service_api", "$SUBSYSTEM_DIR/core_service/interfaces/innerkits:tel_core_service_api",
"//foundation/arkui/napi:ace_napi",
] ]
external_deps = [ external_deps = [
@ -55,13 +54,14 @@ ohos_fuzztest("SetShowNameFuzzTest") {
"hdf_core:libhdi", "hdf_core:libhdi",
"init:libbegetutil", "init:libbegetutil",
"ipc:ipc_core", "ipc:ipc_core",
"napi:ace_napi",
"netmanager_base:net_conn_manager_if", "netmanager_base:net_conn_manager_if",
"netmanager_ext:net_tether_manager_if", "netmanager_ext:net_tether_manager_if",
"power_manager:powermgr_client", "power_manager:powermgr_client",
"relational_store:native_rdb", "relational_store:native_rdb",
"samgr:samgr_proxy", "samgr:samgr_proxy",
] ]
defines += [ defines = [
"TELEPHONY_LOG_TAG = \"CoreServiceFuzzTest\"", "TELEPHONY_LOG_TAG = \"CoreServiceFuzzTest\"",
"LOG_DOMAIN = 0xD000F00", "LOG_DOMAIN = 0xD000F00",
] ]
@ -78,8 +78,8 @@ ohos_fuzztest("SetShowNameFuzzTest") {
"-fno-omit-frame-pointer", "-fno-omit-frame-pointer",
] ]
sources = [ sources = [
"//base/telephony/core_service/frameworks/js/napi/napi_util.cpp", "$SUBSYSTEM_DIR/core_service/frameworks/js/napi/napi_util.cpp",
"//base/telephony/core_service/test/fuzztest/common_fuzzer/addcoreservicetoken_fuzzer.cpp", "$SUBSYSTEM_DIR/core_service/test/fuzztest/common_fuzzer/addcoreservicetoken_fuzzer.cpp",
"setshowname_fuzzer.cpp", "setshowname_fuzzer.cpp",
] ]
} }

View File

@ -39,6 +39,7 @@ bool IsServiceInited()
if (!g_isInited) { if (!g_isInited) {
auto onStart = [] { DelayedSingleton<CoreService>::GetInstance()->OnStart(); }; auto onStart = [] { DelayedSingleton<CoreService>::GetInstance()->OnStart(); };
std::thread startThread(onStart); std::thread startThread(onStart);
pthread_setname_np(startThread.native_handle(), "setshowname_fuzzer");
startThread.join(); startThread.join();
sleep(SLEEP_TIME_SECONDS); sleep(SLEEP_TIME_SECONDS);

View File

@ -12,7 +12,7 @@
# limitations under the License. # limitations under the License.
#####################hydra-fuzz################### #####################hydra-fuzz###################
import("//base/telephony/core_service/telephony.gni") SUBSYSTEM_DIR = "../../../.."
import("//build/config/features.gni") import("//build/config/features.gni")
import("//build/ohos.gni") import("//build/ohos.gni")
import("//build/test.gni") import("//build/test.gni")
@ -22,23 +22,22 @@ ohos_fuzztest("SetShowNumberFuzzTest") {
module_output_path = "core_service/SetShowNumberFuzzTest" module_output_path = "core_service/SetShowNumberFuzzTest"
module_out_path = module_output_path module_out_path = module_output_path
fuzz_config_file = fuzz_config_file =
"//base/telephony/core_service/test/fuzztest/setshownumber_fuzzer" "$SUBSYSTEM_DIR/core_service/test/fuzztest/setshownumber_fuzzer"
include_dirs = [ include_dirs = [
"//base/telephony/core_service/frameworks/js/napi/include", "$SUBSYSTEM_DIR/core_service/frameworks/js/napi/include",
"//base/telephony/core_service/frameworks/js/napi", "$SUBSYSTEM_DIR/core_service/frameworks/js/napi",
"//base/telephony/core_service/services/sim/include", "$SUBSYSTEM_DIR/core_service/services/sim/include",
"//base/telephony/core_service/services/core/include", "$SUBSYSTEM_DIR/core_service/services/core/include",
"//base/telephony/core_service/services/tel_ril/include", "$SUBSYSTEM_DIR/core_service/services/tel_ril/include",
"//base/telephony/core_service/test/fuzztest/common_fuzzer", "$SUBSYSTEM_DIR/core_service/test/fuzztest/common_fuzzer",
] ]
configs = [ "//base/telephony/core_service/utils:telephony_log_config" ] configs = [ "$SUBSYSTEM_DIR/core_service/utils:telephony_log_config" ]
deps = [ deps = [
"//base/telephony/core_service:tel_core_service", "$SUBSYSTEM_DIR/core_service:tel_core_service",
"//base/telephony/core_service/interfaces/innerkits:tel_core_service_api", "$SUBSYSTEM_DIR/core_service/interfaces/innerkits:tel_core_service_api",
"//foundation/arkui/napi:ace_napi",
] ]
external_deps = [ external_deps = [
@ -63,6 +62,7 @@ ohos_fuzztest("SetShowNumberFuzzTest") {
"i18n:zone_util", "i18n:zone_util",
"init:libbegetutil", "init:libbegetutil",
"ipc:ipc_core", "ipc:ipc_core",
"napi:ace_napi",
"netmanager_base:net_conn_manager_if", "netmanager_base:net_conn_manager_if",
"netmanager_ext:net_tether_manager_if", "netmanager_ext:net_tether_manager_if",
"power_manager:powermgr_client", "power_manager:powermgr_client",
@ -71,7 +71,7 @@ ohos_fuzztest("SetShowNumberFuzzTest") {
"safwk:system_ability_fwk", "safwk:system_ability_fwk",
"samgr:samgr_proxy", "samgr:samgr_proxy",
] ]
defines += [ defines = [
"TELEPHONY_LOG_TAG = \"CoreServiceFuzzTest\"", "TELEPHONY_LOG_TAG = \"CoreServiceFuzzTest\"",
"LOG_DOMAIN = 0xD000F00", "LOG_DOMAIN = 0xD000F00",
] ]
@ -88,8 +88,8 @@ ohos_fuzztest("SetShowNumberFuzzTest") {
"-fno-omit-frame-pointer", "-fno-omit-frame-pointer",
] ]
sources = [ sources = [
"//base/telephony/core_service/frameworks/js/napi/napi_util.cpp", "$SUBSYSTEM_DIR/core_service/frameworks/js/napi/napi_util.cpp",
"//base/telephony/core_service/test/fuzztest/common_fuzzer/addcoreservicetoken_fuzzer.cpp", "$SUBSYSTEM_DIR/core_service/test/fuzztest/common_fuzzer/addcoreservicetoken_fuzzer.cpp",
"setshownumber_fuzzer.cpp", "setshownumber_fuzzer.cpp",
] ]
} }

View File

@ -38,6 +38,7 @@ bool IsServiceInited()
if (!g_isInited) { if (!g_isInited) {
auto onStart = [] { DelayedSingleton<CoreService>::GetInstance()->OnStart(); }; auto onStart = [] { DelayedSingleton<CoreService>::GetInstance()->OnStart(); };
std::thread startThread(onStart); std::thread startThread(onStart);
pthread_setname_np(startThread.native_handle(), "setshownumber_fuzzer");
startThread.join(); startThread.join();
sleep(SLEEP_TIME_SECONDS); sleep(SLEEP_TIME_SECONDS);

View File

@ -12,7 +12,7 @@
# limitations under the License. # limitations under the License.
#####################hydra-fuzz################### #####################hydra-fuzz###################
import("//base/telephony/core_service/telephony.gni") SUBSYSTEM_DIR = "../../../.."
import("//build/config/features.gni") import("//build/config/features.gni")
import("//build/ohos.gni") import("//build/ohos.gni")
import("//build/test.gni") import("//build/test.gni")
@ -22,23 +22,22 @@ ohos_fuzztest("SetVoiceMailInfoFuzzTest") {
module_output_path = "core_service/SetVoiceMailInfoFuzzTest" module_output_path = "core_service/SetVoiceMailInfoFuzzTest"
module_out_path = module_output_path module_out_path = module_output_path
fuzz_config_file = fuzz_config_file =
"//base/telephony/core_service/test/fuzztest/setvoicemailinfo_fuzzer" "$SUBSYSTEM_DIR/core_service/test/fuzztest/setvoicemailinfo_fuzzer"
include_dirs = [ include_dirs = [
"//base/telephony/core_service/frameworks/js/napi/include", "$SUBSYSTEM_DIR/core_service/frameworks/js/napi/include",
"//base/telephony/core_service/services/core/include", "$SUBSYSTEM_DIR/core_service/services/core/include",
"//base/telephony/core_service/services/sim/include", "$SUBSYSTEM_DIR/core_service/services/sim/include",
"//base/telephony/core_service/services/tel_ril/include", "$SUBSYSTEM_DIR/core_service/services/tel_ril/include",
"//base/telephony/core_service/frameworks/js/napi", "$SUBSYSTEM_DIR/core_service/frameworks/js/napi",
"//base/telephony/core_service/test/fuzztest/common_fuzzer", "$SUBSYSTEM_DIR/core_service/test/fuzztest/common_fuzzer",
] ]
configs = [ "//base/telephony/core_service/utils:telephony_log_config" ] configs = [ "$SUBSYSTEM_DIR/core_service/utils:telephony_log_config" ]
deps = [ deps = [
"//base/telephony/core_service:tel_core_service", "$SUBSYSTEM_DIR/core_service:tel_core_service",
"//base/telephony/core_service/interfaces/innerkits:tel_core_service_api", "$SUBSYSTEM_DIR/core_service/interfaces/innerkits:tel_core_service_api",
"//foundation/arkui/napi:ace_napi",
] ]
external_deps = [ external_deps = [
@ -63,6 +62,7 @@ ohos_fuzztest("SetVoiceMailInfoFuzzTest") {
"i18n:zone_util", "i18n:zone_util",
"init:libbegetutil", "init:libbegetutil",
"ipc:ipc_core", "ipc:ipc_core",
"napi:ace_napi",
"netmanager_base:net_conn_manager_if", "netmanager_base:net_conn_manager_if",
"netmanager_ext:net_tether_manager_if", "netmanager_ext:net_tether_manager_if",
"power_manager:powermgr_client", "power_manager:powermgr_client",
@ -71,7 +71,7 @@ ohos_fuzztest("SetVoiceMailInfoFuzzTest") {
"safwk:system_ability_fwk", "safwk:system_ability_fwk",
"samgr:samgr_proxy", "samgr:samgr_proxy",
] ]
defines += [ defines = [
"TELEPHONY_LOG_TAG = \"CoreServiceFuzzTest\"", "TELEPHONY_LOG_TAG = \"CoreServiceFuzzTest\"",
"LOG_DOMAIN = 0xD000F00", "LOG_DOMAIN = 0xD000F00",
] ]
@ -88,8 +88,8 @@ ohos_fuzztest("SetVoiceMailInfoFuzzTest") {
"-fno-omit-frame-pointer", "-fno-omit-frame-pointer",
] ]
sources = [ sources = [
"//base/telephony/core_service/frameworks/js/napi/napi_util.cpp", "$SUBSYSTEM_DIR/core_service/frameworks/js/napi/napi_util.cpp",
"//base/telephony/core_service/test/fuzztest/common_fuzzer/addcoreservicetoken_fuzzer.cpp", "$SUBSYSTEM_DIR/core_service/test/fuzztest/common_fuzzer/addcoreservicetoken_fuzzer.cpp",
"setvoicemailinfo_fuzzer.cpp", "setvoicemailinfo_fuzzer.cpp",
] ]
} }

View File

@ -40,6 +40,7 @@ bool IsServiceInited()
if (!g_isInited) { if (!g_isInited) {
auto onStart = [] { DelayedSingleton<CoreService>::GetInstance()->OnStart(); }; auto onStart = [] { DelayedSingleton<CoreService>::GetInstance()->OnStart(); };
std::thread startThread(onStart); std::thread startThread(onStart);
pthread_setname_np(startThread.native_handle(), "setvoicemailinfo_fuzzer");
startThread.join(); startThread.join();
sleep(SLEEP_TIME_SECONDS); sleep(SLEEP_TIME_SECONDS);

View File

@ -12,7 +12,7 @@
# limitations under the License. # limitations under the License.
#####################hydra-fuzz################### #####################hydra-fuzz###################
import("//base/telephony/core_service/telephony.gni") SUBSYSTEM_DIR = "../../../.."
import("//build/config/features.gni") import("//build/config/features.gni")
import("//build/ohos.gni") import("//build/ohos.gni")
import("//build/test.gni") import("//build/test.gni")
@ -22,23 +22,22 @@ ohos_fuzztest("SimAuthenticationFuzzTest") {
module_output_path = "core_service/SimAuthenticationFuzzTest" module_output_path = "core_service/SimAuthenticationFuzzTest"
module_out_path = module_output_path module_out_path = module_output_path
fuzz_config_file = fuzz_config_file =
"//base/telephony/core_service/test/fuzztest/simauthentication_fuzzer" "$SUBSYSTEM_DIR/core_service/test/fuzztest/simauthentication_fuzzer"
include_dirs = [ include_dirs = [
"//base/telephony/core_service/frameworks/js/napi/include", "$SUBSYSTEM_DIR/core_service/frameworks/js/napi/include",
"//base/telephony/core_service/services/sim/include", "$SUBSYSTEM_DIR/core_service/services/sim/include",
"//base/telephony/core_service/services/core/include", "$SUBSYSTEM_DIR/core_service/services/core/include",
"//base/telephony/core_service/services/tel_ril/include", "$SUBSYSTEM_DIR/core_service/services/tel_ril/include",
"//base/telephony/core_service/frameworks/js/napi", "$SUBSYSTEM_DIR/core_service/frameworks/js/napi",
"//base/telephony/core_service/test/fuzztest/common_fuzzer", "$SUBSYSTEM_DIR/core_service/test/fuzztest/common_fuzzer",
] ]
configs = [ "//base/telephony/core_service/utils:telephony_log_config" ] configs = [ "$SUBSYSTEM_DIR/core_service/utils:telephony_log_config" ]
deps = [ deps = [
"//base/telephony/core_service:tel_core_service", "$SUBSYSTEM_DIR/core_service:tel_core_service",
"//base/telephony/core_service/interfaces/innerkits:tel_core_service_api", "$SUBSYSTEM_DIR/core_service/interfaces/innerkits:tel_core_service_api",
"//foundation/arkui/napi:ace_napi",
] ]
external_deps = [ external_deps = [
@ -63,6 +62,7 @@ ohos_fuzztest("SimAuthenticationFuzzTest") {
"i18n:zone_util", "i18n:zone_util",
"init:libbegetutil", "init:libbegetutil",
"ipc:ipc_core", "ipc:ipc_core",
"napi:ace_napi",
"netmanager_base:net_conn_manager_if", "netmanager_base:net_conn_manager_if",
"netmanager_ext:net_tether_manager_if", "netmanager_ext:net_tether_manager_if",
"power_manager:powermgr_client", "power_manager:powermgr_client",
@ -71,7 +71,7 @@ ohos_fuzztest("SimAuthenticationFuzzTest") {
"safwk:system_ability_fwk", "safwk:system_ability_fwk",
"samgr:samgr_proxy", "samgr:samgr_proxy",
] ]
defines += [ defines = [
"TELEPHONY_LOG_TAG = \"CoreServiceFuzzTest\"", "TELEPHONY_LOG_TAG = \"CoreServiceFuzzTest\"",
"LOG_DOMAIN = 0xD000F00", "LOG_DOMAIN = 0xD000F00",
] ]
@ -88,8 +88,8 @@ ohos_fuzztest("SimAuthenticationFuzzTest") {
"-fno-omit-frame-pointer", "-fno-omit-frame-pointer",
] ]
sources = [ sources = [
"//base/telephony/core_service/frameworks/js/napi/napi_util.cpp", "$SUBSYSTEM_DIR/core_service/frameworks/js/napi/napi_util.cpp",
"//base/telephony/core_service/test/fuzztest/common_fuzzer/addcoreservicetoken_fuzzer.cpp", "$SUBSYSTEM_DIR/core_service/test/fuzztest/common_fuzzer/addcoreservicetoken_fuzzer.cpp",
"simauthentication_fuzzer.cpp", "simauthentication_fuzzer.cpp",
] ]
} }

View File

@ -23,6 +23,7 @@
#include "addcoreservicetoken_fuzzer.h" #include "addcoreservicetoken_fuzzer.h"
#include "core_service.h" #include "core_service.h"
#include "napi_util.h" #include "napi_util.h"
#include "sim_file.h"
#include "system_ability_definition.h" #include "system_ability_definition.h"
#include "unistd.h" #include "unistd.h"
@ -33,12 +34,16 @@ constexpr int32_t SLOT_NUM = 2;
constexpr int32_t TYPE_NUM = 2; constexpr int32_t TYPE_NUM = 2;
constexpr int32_t TWO_INT_NUM = 2; constexpr int32_t TWO_INT_NUM = 2;
constexpr int32_t SLEEP_TIME_SECONDS = 10; constexpr int32_t SLEEP_TIME_SECONDS = 10;
constexpr int32_t SIM_AUTH_EAP_SIM_TYPE = 128;
constexpr int32_t SIM_AUTH_EAP_AKA_TYPE = 129;
bool g_flag = false;
bool IsServiceInited() bool IsServiceInited()
{ {
if (!g_isInited) { if (!g_isInited) {
auto onStart = [] { DelayedSingleton<CoreService>::GetInstance()->OnStart(); }; auto onStart = [] { DelayedSingleton<CoreService>::GetInstance()->OnStart(); };
std::thread startThread(onStart); std::thread startThread(onStart);
pthread_setname_np(startThread.native_handle(), "simauthentication_fuzzer");
startThread.join(); startThread.join();
sleep(SLEEP_TIME_SECONDS); sleep(SLEEP_TIME_SECONDS);
@ -141,17 +146,42 @@ void SimAuthentication(const uint8_t *data, size_t size)
} }
int32_t slotId = static_cast<int32_t>(size % SLOT_NUM); int32_t slotId = static_cast<int32_t>(size % SLOT_NUM);
std::string aid(reinterpret_cast<const char *>(data), size);
std::string authData(reinterpret_cast<const char *>(data), size); std::string authData(reinterpret_cast<const char *>(data), size);
MessageParcel dataMessageParcel; MessageParcel dataMessageParcel;
dataMessageParcel.WriteInt32(slotId); dataMessageParcel.WriteInt32(slotId);
dataMessageParcel.WriteString(aid); int32_t authType = static_cast<int32_t>(size % TYPE_NUM);
if (authType) {
dataMessageParcel.WriteInt32(SIM_AUTH_EAP_AKA_TYPE);
} else {
dataMessageParcel.WriteInt32(SIM_AUTH_EAP_SIM_TYPE);
}
dataMessageParcel.WriteString(authData); dataMessageParcel.WriteString(authData);
dataMessageParcel.RewindRead(0); dataMessageParcel.RewindRead(0);
MessageParcel reply; MessageParcel reply;
DelayedSingleton<CoreService>::GetInstance()->OnSimAuthentication(dataMessageParcel, reply); DelayedSingleton<CoreService>::GetInstance()->OnSimAuthentication(dataMessageParcel, reply);
} }
void ParseOpl5g(const uint8_t *data, size_t size)
{
if (!IsServiceInited()) {
return;
}
if (g_flag) {
return;
}
g_flag = true;
std::shared_ptr<TelRilManager> telRilManager = std::make_shared<TelRilManager>();
std::shared_ptr<Telephony::SimStateManager> simStateManager = std::make_shared<SimStateManager>(telRilManager);
std::shared_ptr<AppExecFwk::EventRunner> eventLoopRecord = AppExecFwk::EventRunner::Create("SimFile");
std::shared_ptr<SimFile> simFile = std::make_shared<SimFile>(eventLoopRecord, simStateManager);
std::string fileData(reinterpret_cast<const char *>(data), size);
std::vector<std::string> records;
records.push_back(fileData);
simFile->ParseOpl5g(records);
}
void DoSomethingInterestingWithMyAPI(const uint8_t *data, size_t size) void DoSomethingInterestingWithMyAPI(const uint8_t *data, size_t size)
{ {
if (data == nullptr || size == 0) { if (data == nullptr || size == 0) {
@ -164,6 +194,7 @@ void DoSomethingInterestingWithMyAPI(const uint8_t *data, size_t size)
GetVoiceMailNumber(data, size); GetVoiceMailNumber(data, size);
QueryIccDiallingNumbers(data, size); QueryIccDiallingNumbers(data, size);
SimAuthentication(data, size); SimAuthentication(data, size);
ParseOpl5g(data, size);
return; return;
} }
} // namespace OHOS } // namespace OHOS

View File

@ -12,7 +12,7 @@
# limitations under the License. # limitations under the License.
#####################hydra-fuzz################### #####################hydra-fuzz###################
import("//base/telephony/core_service/telephony.gni") SUBSYSTEM_DIR = "../../../.."
import("//build/config/features.gni") import("//build/config/features.gni")
import("//build/ohos.gni") import("//build/ohos.gni")
import("//build/test.gni") import("//build/test.gni")
@ -22,24 +22,23 @@ ohos_fuzztest("UnMarshallingFuzzTest") {
module_output_path = "core_service/UnMarshallingFuzzTest" module_output_path = "core_service/UnMarshallingFuzzTest"
module_out_path = module_output_path module_out_path = module_output_path
fuzz_config_file = fuzz_config_file =
"//base/telephony/core_service/test/fuzztest/unmarshalling_fuzzer" "$SUBSYSTEM_DIR/core_service/test/fuzztest/unmarshalling_fuzzer"
include_dirs = [ include_dirs = [
"//base/telephony/core_service/frameworks/js/napi/include", "$SUBSYSTEM_DIR/core_service/frameworks/js/napi/include",
"//base/telephony/core_service/frameworks/js/napi", "$SUBSYSTEM_DIR/core_service/frameworks/js/napi",
"//base/telephony/core_service/services/core/include", "$SUBSYSTEM_DIR/core_service/services/core/include",
"//base/telephony/core_service/services/network_search/include", "$SUBSYSTEM_DIR/core_service/services/network_search/include",
"//base/telephony/core_service/services/sim/include", "$SUBSYSTEM_DIR/core_service/services/sim/include",
"//base/telephony/core_service/test/fuzztest/common_fuzzer", "$SUBSYSTEM_DIR/core_service/test/fuzztest/common_fuzzer",
"//base/telephony/core_service/services/tel_ril/include", "$SUBSYSTEM_DIR/core_service/services/tel_ril/include",
] ]
configs = [ "//base/telephony/core_service/utils:telephony_log_config" ] configs = [ "$SUBSYSTEM_DIR/core_service/utils:telephony_log_config" ]
deps = [ deps = [
"//base/telephony/core_service:tel_core_service", "$SUBSYSTEM_DIR/core_service:tel_core_service",
"//base/telephony/core_service/interfaces/innerkits:tel_core_service_api", "$SUBSYSTEM_DIR/core_service/interfaces/innerkits:tel_core_service_api",
"//foundation/arkui/napi:ace_napi",
] ]
external_deps = [ external_deps = [
@ -53,13 +52,14 @@ ohos_fuzztest("UnMarshallingFuzzTest") {
"drivers_interface_ril:ril_idl_headers", "drivers_interface_ril:ril_idl_headers",
"init:libbegetutil", "init:libbegetutil",
"ipc:ipc_core", "ipc:ipc_core",
"napi:ace_napi",
"netmanager_base:net_conn_manager_if", "netmanager_base:net_conn_manager_if",
"netmanager_ext:net_tether_manager_if", "netmanager_ext:net_tether_manager_if",
"power_manager:powermgr_client", "power_manager:powermgr_client",
"relational_store:native_rdb", "relational_store:native_rdb",
"samgr:samgr_proxy", "samgr:samgr_proxy",
] ]
defines += [ defines = [
"TELEPHONY_LOG_TAG = \"CoreServiceFuzzTest\"", "TELEPHONY_LOG_TAG = \"CoreServiceFuzzTest\"",
"LOG_DOMAIN = 0xD000F00", "LOG_DOMAIN = 0xD000F00",
] ]
@ -76,8 +76,8 @@ ohos_fuzztest("UnMarshallingFuzzTest") {
"-fno-omit-frame-pointer", "-fno-omit-frame-pointer",
] ]
sources = [ sources = [
"//base/telephony/core_service/frameworks/js/napi/napi_util.cpp", "$SUBSYSTEM_DIR/core_service/frameworks/js/napi/napi_util.cpp",
"//base/telephony/core_service/test/fuzztest/common_fuzzer/addcoreservicetoken_fuzzer.cpp", "$SUBSYSTEM_DIR/core_service/test/fuzztest/common_fuzzer/addcoreservicetoken_fuzzer.cpp",
"unmarshalling_fuzzer.cpp", "unmarshalling_fuzzer.cpp",
] ]
} }

View File

@ -12,7 +12,7 @@
# limitations under the License. # limitations under the License.
#####################hydra-fuzz################### #####################hydra-fuzz###################
import("//base/telephony/core_service/telephony.gni") SUBSYSTEM_DIR = "../../../.."
import("//build/config/features.gni") import("//build/config/features.gni")
import("//build/ohos.gni") import("//build/ohos.gni")
import("//build/test.gni") import("//build/test.gni")
@ -21,23 +21,22 @@ import("//build/test.gni")
ohos_fuzztest("UpdateIccDiallingNumbersFuzzTest") { ohos_fuzztest("UpdateIccDiallingNumbersFuzzTest") {
module_output_path = "core_service/UpdateIccDiallingNumbersFuzzTest" module_output_path = "core_service/UpdateIccDiallingNumbersFuzzTest"
module_out_path = module_output_path module_out_path = module_output_path
fuzz_config_file = "//base/telephony/core_service/test/fuzztest/updateiccdiallingnumbers_fuzzer" fuzz_config_file = "$SUBSYSTEM_DIR/core_service/test/fuzztest/updateiccdiallingnumbers_fuzzer"
include_dirs = [ include_dirs = [
"//base/telephony/core_service/frameworks/js/napi/include", "$SUBSYSTEM_DIR/core_service/frameworks/js/napi/include",
"//base/telephony/core_service/frameworks/js/napi", "$SUBSYSTEM_DIR/core_service/frameworks/js/napi",
"//base/telephony/core_service/services/sim/include", "$SUBSYSTEM_DIR/core_service/services/sim/include",
"//base/telephony/core_service/services/core/include", "$SUBSYSTEM_DIR/core_service/services/core/include",
"//base/telephony/core_service/services/tel_ril/include", "$SUBSYSTEM_DIR/core_service/services/tel_ril/include",
"//base/telephony/core_service/test/fuzztest/common_fuzzer", "$SUBSYSTEM_DIR/core_service/test/fuzztest/common_fuzzer",
] ]
configs = [ "//base/telephony/core_service/utils:telephony_log_config" ] configs = [ "$SUBSYSTEM_DIR/core_service/utils:telephony_log_config" ]
deps = [ deps = [
"//base/telephony/core_service:tel_core_service", "$SUBSYSTEM_DIR/core_service:tel_core_service",
"//base/telephony/core_service/interfaces/innerkits:tel_core_service_api", "$SUBSYSTEM_DIR/core_service/interfaces/innerkits:tel_core_service_api",
"//foundation/arkui/napi:ace_napi",
] ]
external_deps = [ external_deps = [
@ -62,6 +61,7 @@ ohos_fuzztest("UpdateIccDiallingNumbersFuzzTest") {
"i18n:zone_util", "i18n:zone_util",
"init:libbegetutil", "init:libbegetutil",
"ipc:ipc_core", "ipc:ipc_core",
"napi:ace_napi",
"netmanager_base:net_conn_manager_if", "netmanager_base:net_conn_manager_if",
"netmanager_ext:net_tether_manager_if", "netmanager_ext:net_tether_manager_if",
"power_manager:powermgr_client", "power_manager:powermgr_client",
@ -70,7 +70,7 @@ ohos_fuzztest("UpdateIccDiallingNumbersFuzzTest") {
"safwk:system_ability_fwk", "safwk:system_ability_fwk",
"samgr:samgr_proxy", "samgr:samgr_proxy",
] ]
defines += [ defines = [
"TELEPHONY_LOG_TAG = \"CoreServiceFuzzTest\"", "TELEPHONY_LOG_TAG = \"CoreServiceFuzzTest\"",
"LOG_DOMAIN = 0xD000F00", "LOG_DOMAIN = 0xD000F00",
] ]
@ -87,8 +87,8 @@ ohos_fuzztest("UpdateIccDiallingNumbersFuzzTest") {
"-fno-omit-frame-pointer", "-fno-omit-frame-pointer",
] ]
sources = [ sources = [
"//base/telephony/core_service/frameworks/js/napi/napi_util.cpp", "$SUBSYSTEM_DIR/core_service/frameworks/js/napi/napi_util.cpp",
"//base/telephony/core_service/test/fuzztest/common_fuzzer/addcoreservicetoken_fuzzer.cpp", "$SUBSYSTEM_DIR/core_service/test/fuzztest/common_fuzzer/addcoreservicetoken_fuzzer.cpp",
"updateiccdiallingnumbers_fuzzer.cpp", "updateiccdiallingnumbers_fuzzer.cpp",
] ]
} }

View File

@ -40,6 +40,7 @@ bool IsServiceInited()
if (!g_isInited) { if (!g_isInited) {
auto onStart = [] { DelayedSingleton<CoreService>::GetInstance()->OnStart(); }; auto onStart = [] { DelayedSingleton<CoreService>::GetInstance()->OnStart(); };
std::thread startThread(onStart); std::thread startThread(onStart);
pthread_setname_np(startThread.native_handle(), "updateiccdiallingnumbers_fuzzer");
startThread.join(); startThread.join();
sleep(SLEEP_TIME_SECONDS); sleep(SLEEP_TIME_SECONDS);

View File

@ -12,7 +12,7 @@
# limitations under the License. # limitations under the License.
#####################hydra-fuzz################### #####################hydra-fuzz###################
import("//base/telephony/core_service/telephony.gni") SUBSYSTEM_DIR = "../../../.."
import("//build/config/features.gni") import("//build/config/features.gni")
import("//build/ohos.gni") import("//build/ohos.gni")
import("//build/test.gni") import("//build/test.gni")
@ -22,23 +22,22 @@ ohos_fuzztest("UpdateSmsIccFuzzTest") {
module_output_path = "core_service/UpdateSmsIccFuzzTest" module_output_path = "core_service/UpdateSmsIccFuzzTest"
module_out_path = module_output_path module_out_path = module_output_path
fuzz_config_file = fuzz_config_file =
"//base/telephony/core_service/test/fuzztest/updatesmsicc_fuzzer" "$SUBSYSTEM_DIR/core_service/test/fuzztest/updatesmsicc_fuzzer"
include_dirs = [ include_dirs = [
"//base/telephony/core_service/frameworks/js/napi/include", "$SUBSYSTEM_DIR/core_service/frameworks/js/napi/include",
"//base/telephony/core_service/frameworks/js/napi", "$SUBSYSTEM_DIR/core_service/frameworks/js/napi",
"//base/telephony/core_service/services/sim/include", "$SUBSYSTEM_DIR/core_service/services/sim/include",
"//base/telephony/core_service/services/core/include", "$SUBSYSTEM_DIR/core_service/services/core/include",
"//base/telephony/core_service/services/tel_ril/include", "$SUBSYSTEM_DIR/core_service/services/tel_ril/include",
"//base/telephony/core_service/test/fuzztest/common_fuzzer", "$SUBSYSTEM_DIR/core_service/test/fuzztest/common_fuzzer",
] ]
configs = [ "//base/telephony/core_service/utils:telephony_log_config" ] configs = [ "$SUBSYSTEM_DIR/core_service/utils:telephony_log_config" ]
deps = [ deps = [
"//base/telephony/core_service:tel_core_service", "$SUBSYSTEM_DIR/core_service:tel_core_service",
"//base/telephony/core_service/interfaces/innerkits:tel_core_service_api", "$SUBSYSTEM_DIR/core_service/interfaces/innerkits:tel_core_service_api",
"//foundation/arkui/napi:ace_napi",
] ]
external_deps = [ external_deps = [
@ -63,6 +62,7 @@ ohos_fuzztest("UpdateSmsIccFuzzTest") {
"i18n:zone_util", "i18n:zone_util",
"init:libbegetutil", "init:libbegetutil",
"ipc:ipc_core", "ipc:ipc_core",
"napi:ace_napi",
"netmanager_base:net_conn_manager_if", "netmanager_base:net_conn_manager_if",
"netmanager_ext:net_tether_manager_if", "netmanager_ext:net_tether_manager_if",
"power_manager:powermgr_client", "power_manager:powermgr_client",
@ -71,7 +71,7 @@ ohos_fuzztest("UpdateSmsIccFuzzTest") {
"safwk:system_ability_fwk", "safwk:system_ability_fwk",
"samgr:samgr_proxy", "samgr:samgr_proxy",
] ]
defines += [ defines = [
"TELEPHONY_LOG_TAG = \"CoreServiceFuzzTest\"", "TELEPHONY_LOG_TAG = \"CoreServiceFuzzTest\"",
"LOG_DOMAIN = 0xD000F00", "LOG_DOMAIN = 0xD000F00",
] ]
@ -88,8 +88,8 @@ ohos_fuzztest("UpdateSmsIccFuzzTest") {
"-fno-omit-frame-pointer", "-fno-omit-frame-pointer",
] ]
sources = [ sources = [
"//base/telephony/core_service/frameworks/js/napi/napi_util.cpp", "$SUBSYSTEM_DIR/core_service/frameworks/js/napi/napi_util.cpp",
"//base/telephony/core_service/test/fuzztest/common_fuzzer/addcoreservicetoken_fuzzer.cpp", "$SUBSYSTEM_DIR/core_service/test/fuzztest/common_fuzzer/addcoreservicetoken_fuzzer.cpp",
"updatesmsicc_fuzzer.cpp", "updatesmsicc_fuzzer.cpp",
] ]
} }

View File

@ -12,7 +12,7 @@
# limitations under the License. # limitations under the License.
#####################hydra-fuzz################### #####################hydra-fuzz###################
import("//base/telephony/core_service/telephony.gni") SUBSYSTEM_DIR = "../../../.."
import("//build/config/features.gni") import("//build/config/features.gni")
import("//build/ohos.gni") import("//build/ohos.gni")
import("//build/test.gni") import("//build/test.gni")
@ -22,24 +22,23 @@ ohos_fuzztest("UpdateVoiceMailFuzzTest") {
module_output_path = "core_service/UpdateVoiceMailFuzzTest" module_output_path = "core_service/UpdateVoiceMailFuzzTest"
module_out_path = module_output_path module_out_path = module_output_path
fuzz_config_file = fuzz_config_file =
"//base/telephony/core_service/test/fuzztest/updatevoicemail_fuzzer" "$SUBSYSTEM_DIR/core_service/test/fuzztest/updatevoicemail_fuzzer"
include_dirs = [ include_dirs = [
"//base/telephony/core_service/frameworks/js/napi/include", "$SUBSYSTEM_DIR/core_service/frameworks/js/napi/include",
"//base/telephony/core_service/frameworks/js/napi", "$SUBSYSTEM_DIR/core_service/frameworks/js/napi",
"//base/telephony/core_service/services/core/include", "$SUBSYSTEM_DIR/core_service/services/core/include",
"//base/telephony/core_service/services/network_search/include", "$SUBSYSTEM_DIR/core_service/services/network_search/include",
"//base/telephony/core_service/services/sim/include", "$SUBSYSTEM_DIR/core_service/services/sim/include",
"//base/telephony/core_service/test/fuzztest/common_fuzzer", "$SUBSYSTEM_DIR/core_service/test/fuzztest/common_fuzzer",
"//base/telephony/core_service/services/tel_ril/include", "$SUBSYSTEM_DIR/core_service/services/tel_ril/include",
] ]
configs = [ "//base/telephony/core_service/utils:telephony_log_config" ] configs = [ "$SUBSYSTEM_DIR/core_service/utils:telephony_log_config" ]
deps = [ deps = [
"//base/telephony/core_service:tel_core_service", "$SUBSYSTEM_DIR/core_service:tel_core_service",
"//base/telephony/core_service/interfaces/innerkits:tel_core_service_api", "$SUBSYSTEM_DIR/core_service/interfaces/innerkits:tel_core_service_api",
"//foundation/arkui/napi:ace_napi",
] ]
external_deps = [ external_deps = [
@ -64,6 +63,7 @@ ohos_fuzztest("UpdateVoiceMailFuzzTest") {
"i18n:zone_util", "i18n:zone_util",
"init:libbegetutil", "init:libbegetutil",
"ipc:ipc_core", "ipc:ipc_core",
"napi:ace_napi",
"netmanager_base:net_conn_manager_if", "netmanager_base:net_conn_manager_if",
"netmanager_ext:net_tether_manager_if", "netmanager_ext:net_tether_manager_if",
"power_manager:powermgr_client", "power_manager:powermgr_client",
@ -72,7 +72,7 @@ ohos_fuzztest("UpdateVoiceMailFuzzTest") {
"safwk:system_ability_fwk", "safwk:system_ability_fwk",
"samgr:samgr_proxy", "samgr:samgr_proxy",
] ]
defines += [ defines = [
"TELEPHONY_LOG_TAG = \"CoreServiceFuzzTest\"", "TELEPHONY_LOG_TAG = \"CoreServiceFuzzTest\"",
"LOG_DOMAIN = 0xD000F00", "LOG_DOMAIN = 0xD000F00",
] ]
@ -89,8 +89,8 @@ ohos_fuzztest("UpdateVoiceMailFuzzTest") {
"-fno-omit-frame-pointer", "-fno-omit-frame-pointer",
] ]
sources = [ sources = [
"//base/telephony/core_service/frameworks/js/napi/napi_util.cpp", "$SUBSYSTEM_DIR/core_service/frameworks/js/napi/napi_util.cpp",
"//base/telephony/core_service/test/fuzztest/common_fuzzer/addcoreservicetoken_fuzzer.cpp", "$SUBSYSTEM_DIR/core_service/test/fuzztest/common_fuzzer/addcoreservicetoken_fuzzer.cpp",
"updatevoicemail_fuzzer.cpp", "updatevoicemail_fuzzer.cpp",
] ]
} }

View File

@ -12,6 +12,7 @@
# limitations under the License. # limitations under the License.
import("//build/test.gni") import("//build/test.gni")
SOURCE_DIR = "../../../"
ohos_unittest("tel_core_service_gtest") { ohos_unittest("tel_core_service_gtest") {
install_enable = true install_enable = true
@ -21,7 +22,7 @@ ohos_unittest("tel_core_service_gtest") {
module_out_path = part_name + "/" + test_module module_out_path = part_name + "/" + test_module
sources = [ sources = [
"//base/telephony/core_service/frameworks/native/src/i_network_search_callback_stub.cpp", "$SOURCE_DIR/frameworks/native/src/i_network_search_callback_stub.cpp",
"core_service_test_helper.cpp", "core_service_test_helper.cpp",
"ims_reg_info_callback_gtest.cpp", "ims_reg_info_callback_gtest.cpp",
"network_search_test.cpp", "network_search_test.cpp",
@ -32,27 +33,20 @@ ohos_unittest("tel_core_service_gtest") {
] ]
include_dirs = [ include_dirs = [
"//base/telephony/telephony_data/sim/include", "$SOURCE_DIR/services/core/include",
"//base/telephony/telephony_data/common/include", "$SOURCE_DIR/utils/log/include",
"//base/telephony/core_service/services/core/include", "$SOURCE_DIR/utils/preferences/include",
"//base/telephony/core_service/utils/log/include", "$SOURCE_DIR/services/sim/include",
"//base/telephony/core_service/utils/preferences/include", "$SOURCE_DIR/services/network_search/include",
"//base/telephony/core_service/common/sim", "$SOURCE_DIR/services/tel_ril/include",
"//base/telephony/core_service/services/sim/include",
"//base/telephony/core_service/services/network_search/include",
"//base/telephony/core_service/common/network_search",
"//base/telephony/core_service/common/core",
"//commonlibrary/c_utils/base/include",
"//base/telephony/core_service/services/tel_ril/include",
"//drivers/hdf_core/adapter/uhdf2/include/hdi",
] ]
configs = [ "//base/telephony/core_service/utils:telephony_log_config" ] configs = [ "$SOURCE_DIR/utils:telephony_log_config" ]
deps = [ deps = [
"//base/telephony/core_service:tel_core_service", "$SOURCE_DIR:tel_core_service",
"//base/telephony/core_service/interfaces/innerkits:tel_core_service_api", "$SOURCE_DIR/interfaces/innerkits:tel_core_service_api",
"//base/telephony/core_service/utils:libtel_common", "$SOURCE_DIR/utils:libtel_common",
"//third_party/googletest:gtest_main", "//third_party/googletest:gtest_main",
"//third_party/jsoncpp:jsoncpp", "//third_party/jsoncpp:jsoncpp",
] ]

View File

@ -24,10 +24,11 @@ constexpr static const int32_t WAIT_TIME_SECOND = 5;
bool CoreServiceTestHelper::Run(void (*func)(CoreServiceTestHelper &), CoreServiceTestHelper &helper) bool CoreServiceTestHelper::Run(void (*func)(CoreServiceTestHelper &), CoreServiceTestHelper &helper)
{ {
std::thread t(func, std::ref(helper)); std::thread t(func, std::ref(helper));
pthread_setname_np(t.native_handle(), "core_service_test_helper");
t.detach(); t.detach();
return WaitForResult(WAIT_TIME_SECOND); return WaitForResult(WAIT_TIME_SECOND);
} }
void CoreServiceTestHelper::NotifyAll() void CoreServiceTestHelper::NotifyAll()
{ {
std::unique_lock<std::mutex> lock(mtx_); std::unique_lock<std::mutex> lock(mtx_);

View File

@ -3336,9 +3336,9 @@ HWTEST_F(SimTest, Telephony_Sim_UnlockSimLock_0300, Function | MediumTest | Leve
void SimAuthenticationTestFunc(CoreServiceTestHelper &helper) void SimAuthenticationTestFunc(CoreServiceTestHelper &helper)
{ {
SimAuthenticationResponse response = { 0 }; SimAuthenticationResponse response = { 0 };
std::string aid = "aa"; AuthType authType = AuthType::SIM_AUTH_EAP_SIM_TYPE;
std::string authData = "1234"; std::string authData = "1234";
int32_t result = CoreServiceClient::GetInstance().SimAuthentication(SimTest::slotId_, aid, authData, response); int32_t result = CoreServiceClient::GetInstance().SimAuthentication(SimTest::slotId_, authType, authData, response);
helper.SetBoolResult(result == 0); helper.SetBoolResult(result == 0);
helper.NotifyAll(); helper.NotifyAll();
} }
@ -3369,9 +3369,10 @@ void SimAuthenticationTestFunc1(CoreServiceTestHelper &helper)
{ {
AccessToken token; AccessToken token;
SimAuthenticationResponse response = { 0 }; SimAuthenticationResponse response = { 0 };
std::string aid = "aa"; AuthType authType = AuthType::SIM_AUTH_EAP_SIM_TYPE;
std::string authData = "1234"; std::string authData = "1234";
int32_t result = CoreServiceClient::GetInstance().SimAuthentication(SimTest::slotId1_, aid, authData, response); int32_t result =
CoreServiceClient::GetInstance().SimAuthentication(SimTest::slotId1_, authType, authData, response);
helper.SetBoolResult(result == 0); helper.SetBoolResult(result == 0);
helper.NotifyAll(); helper.NotifyAll();
} }
@ -3418,6 +3419,70 @@ HWTEST_F(SimTest, Telephony_Sim_SimAuthentication_0300, Function | MediumTest |
} }
} }
void SimAuthenticationTestFunc2(CoreServiceTestHelper &helper)
{
SimAuthenticationResponse response = { 0 };
AuthType authType = AuthType::SIM_AUTH_EAP_AKA_TYPE;
std::string authData = "1234";
int32_t result = CoreServiceClient::GetInstance().SimAuthentication(SimTest::slotId_, authType, authData, response);
helper.SetBoolResult(result == 0);
helper.NotifyAll();
}
/**
* @tc.number Telephony_Sim_SimAuthentication_0400
* @tc.name Sim authentication
* @tc.desc Function test
*/
HWTEST_F(SimTest, Telephony_Sim_SimAuthentication_0400, Function | MediumTest | Level3)
{
AccessToken token;
if (!SimTest::HasSimCard(slotId_)) {
TELEPHONY_LOGI("TelephonyTestService has no sim card");
} else {
CoreServiceTestHelper helper;
if (!helper.Run(SimAuthenticationTestFunc2, std::ref(helper))) {
TELEPHONY_LOGI("Interface out of time");
EXPECT_TRUE(true);
} else {
bool result = helper.GetBoolResult();
EXPECT_TRUE(result);
}
}
}
void SimAuthenticationTestFunc3(CoreServiceTestHelper &helper)
{
SimAuthenticationResponse response = { 0 };
AuthType authType = static_cast<AuthType>(0);
std::string authData = "1234";
int32_t result = CoreServiceClient::GetInstance().SimAuthentication(SimTest::slotId_, authType, authData, response);
helper.SetBoolResult(result == 0);
helper.NotifyAll();
}
/**
* @tc.number Telephony_Sim_SimAuthentication_0500
* @tc.name Sim authentication
* @tc.desc Function test
*/
HWTEST_F(SimTest, Telephony_Sim_SimAuthentication_0500, Function | MediumTest | Level3)
{
AccessToken token;
if (!SimTest::HasSimCard(slotId_)) {
TELEPHONY_LOGI("TelephonyTestService has no sim card");
} else {
CoreServiceTestHelper helper;
if (!helper.Run(SimAuthenticationTestFunc3, std::ref(helper))) {
TELEPHONY_LOGI("Interface out of time");
EXPECT_TRUE(true);
} else {
bool result = helper.GetBoolResult();
EXPECT_FALSE(result);
}
}
}
/** /**
* @tc.number Telephony_Sim_GetPrimarySlotId_0100 * @tc.number Telephony_Sim_GetPrimarySlotId_0100
* @tc.name Get primary slotId * @tc.name Get primary slotId
@ -4093,7 +4158,8 @@ HWTEST_F(SimTest, Telephony_Sim_CoreService_0200, Function | MediumTest | Level3
EXPECT_NE(mCoreService->UnlockSimLock(0, mPersoLockInfo, mLockStatusResponse), TELEPHONY_ERR_SUCCESS); EXPECT_NE(mCoreService->UnlockSimLock(0, mPersoLockInfo, mLockStatusResponse), TELEPHONY_ERR_SUCCESS);
mCoreService->SendUpdateCellLocationRequest(0); mCoreService->SendUpdateCellLocationRequest(0);
SimAuthenticationResponse mSimAuthenticationResponse; SimAuthenticationResponse mSimAuthenticationResponse;
EXPECT_NE(mCoreService->SimAuthentication(0, "", "", mSimAuthenticationResponse), TELEPHONY_ERR_SUCCESS); EXPECT_NE(mCoreService->SimAuthentication(0, AuthType::SIM_AUTH_EAP_SIM_TYPE, "", mSimAuthenticationResponse),
TELEPHONY_ERR_SUCCESS);
const sptr<ImsRegInfoCallback> mImsRegInfoCallback = nullptr; const sptr<ImsRegInfoCallback> mImsRegInfoCallback = nullptr;
EXPECT_NE(mCoreService->RegisterImsRegInfoCallback(0, ImsServiceType::TYPE_VOICE, mImsRegInfoCallback), EXPECT_NE(mCoreService->RegisterImsRegInfoCallback(0, ImsServiceType::TYPE_VOICE, mImsRegInfoCallback),
TELEPHONY_ERR_SUCCESS); TELEPHONY_ERR_SUCCESS);
@ -4238,7 +4304,8 @@ HWTEST_F(SimTest, Telephony_Sim_CoreService_0500, Function | MediumTest | Level3
EXPECT_NE(mCoreService->UnlockSimLock(0, mPersoLockInfo, mLockStatusResponse), TELEPHONY_ERR_SUCCESS); EXPECT_NE(mCoreService->UnlockSimLock(0, mPersoLockInfo, mLockStatusResponse), TELEPHONY_ERR_SUCCESS);
mCoreService->SendUpdateCellLocationRequest(0); mCoreService->SendUpdateCellLocationRequest(0);
SimAuthenticationResponse mSimAuthenticationResponse; SimAuthenticationResponse mSimAuthenticationResponse;
EXPECT_NE(mCoreService->SimAuthentication(0, "", "", mSimAuthenticationResponse), TELEPHONY_ERR_SUCCESS); EXPECT_NE(mCoreService->SimAuthentication(0, AuthType::SIM_AUTH_EAP_SIM_TYPE, "", mSimAuthenticationResponse),
TELEPHONY_ERR_SUCCESS);
const sptr<ImsRegInfoCallback> mImsRegInfoCallback = nullptr; const sptr<ImsRegInfoCallback> mImsRegInfoCallback = nullptr;
EXPECT_NE(mCoreService->RegisterImsRegInfoCallback(0, ImsServiceType::TYPE_VOICE, mImsRegInfoCallback), EXPECT_NE(mCoreService->RegisterImsRegInfoCallback(0, ImsServiceType::TYPE_VOICE, mImsRegInfoCallback),
TELEPHONY_ERR_SUCCESS); TELEPHONY_ERR_SUCCESS);

View File

@ -413,6 +413,7 @@ HWTEST_F(BranchTest, Telephony_SimFile_002, Function | MediumTest | Level1)
EXPECT_TRUE(simFile->ProcessGetEhplmnDone(event)); EXPECT_TRUE(simFile->ProcessGetEhplmnDone(event));
EXPECT_TRUE(simFile->ProcessGetPnnDone(event)); EXPECT_TRUE(simFile->ProcessGetPnnDone(event));
EXPECT_TRUE(simFile->ProcessGetOplDone(event)); EXPECT_TRUE(simFile->ProcessGetOplDone(event));
EXPECT_TRUE(simFile->ProcessGetOpl5gDone(event));
EXPECT_FALSE(simFile->ProcessUpdateDone(event)); EXPECT_FALSE(simFile->ProcessUpdateDone(event));
EXPECT_TRUE(simFile->ProcessSetCphsMailbox(event)); EXPECT_TRUE(simFile->ProcessSetCphsMailbox(event));
EXPECT_TRUE(simFile->ProcessGetFplmnDone(event)); EXPECT_TRUE(simFile->ProcessGetFplmnDone(event));
@ -504,6 +505,12 @@ HWTEST_F(BranchTest, Telephony_SimFile_004, Function | MediumTest | Level1)
simFile->ParseOpl(emptyRecords); simFile->ParseOpl(emptyRecords);
simFile->ParsePnn(records); simFile->ParsePnn(records);
simFile->ParseOpl(records); simFile->ParseOpl(records);
std::vector<std::string> invalidRecords = { "64F0100000GGGG02", "64F0000000GGGG01" };
simFile->ParseOpl(invalidRecords);
std::vector<std::string> invalidPlmnRecords = { "F640100000FFFE02", "F640000000FFFE01" };
simFile->ParseOpl(invalidPlmnRecords);
std::vector<std::string> records5g = { "64F0100000FFFE02", "64F0000000FFFE01" };
simFile->ParseOpl(records5g);
SimFile::SpnStatus newStatus; SimFile::SpnStatus newStatus;
EXPECT_TRUE(simFile->IsContinueGetSpn(false, SimFile::SpnStatus::OBTAIN_SPN_NONE, newStatus)); EXPECT_TRUE(simFile->IsContinueGetSpn(false, SimFile::SpnStatus::OBTAIN_SPN_NONE, newStatus));
EXPECT_TRUE(simFile->IsContinueGetSpn(true, SimFile::SpnStatus::OBTAIN_SPN_NONE, newStatus)); EXPECT_TRUE(simFile->IsContinueGetSpn(true, SimFile::SpnStatus::OBTAIN_SPN_NONE, newStatus));
@ -522,6 +529,35 @@ HWTEST_F(BranchTest, Telephony_SimFile_004, Function | MediumTest | Level1)
EXPECT_EQ(simFile->ParseSpn("", 0), ""); EXPECT_EQ(simFile->ParseSpn("", 0), "");
} }
/**
* @tc.number Telephony_SimFile_005
* @tc.name test error branch
* @tc.desc Function test
*/
HWTEST_F(BranchTest, Telephony_SimFile_005, Function | MediumTest | Level1)
{
std::shared_ptr<TelRilManager> telRilManager = std::make_shared<TelRilManager>();
telRilManager->OnInit();
std::shared_ptr<Telephony::SimStateManager> simStateManager = std::make_shared<SimStateManager>(telRilManager);
std::shared_ptr<AppExecFwk::EventRunner> eventLoopRecord = AppExecFwk::EventRunner::Create("SimFile");
std::shared_ptr<SimFile> simFile = std::make_shared<SimFile>(eventLoopRecord, simStateManager);
std::vector<std::string> emptyRecords = {};
simFile->ParseOpl5g(emptyRecords);
EXPECT_TRUE(simFile->opl5gFiles_.empty());
std::vector<std::string> records = { "46000", "46002", "46004", "46007", "46008" };
simFile->ParseOpl5g(records);
EXPECT_TRUE(simFile->opl5gFiles_.empty());
std::vector<std::string> invalidRecords = { "64F010000000GGGGGG02", "64F000000000GGGGGG01" };
simFile->ParseOpl5g(invalidRecords);
EXPECT_TRUE(simFile->opl5gFiles_.empty());
std::vector<std::string> invalidPlmnRecords = { "F64010000000FFFFFE02", "F64000000000FFFFFE01" };
simFile->ParseOpl5g(invalidPlmnRecords);
EXPECT_TRUE(simFile->opl5gFiles_.empty());
std::vector<std::string> records5g = { "64F010000000FFFFFE02", "64F000000000FFFFFE01" };
simFile->ParseOpl5g(records5g);
EXPECT_FALSE(simFile->opl5gFiles_.empty());
}
/** /**
* @tc.number Telephony_ISimFile_001 * @tc.number Telephony_ISimFile_001
* @tc.name test error branch * @tc.name test error branch
@ -689,6 +725,9 @@ HWTEST_F(BranchTest, Telephony_CoreManagerInner_001, Function | MediumTest | Lev
EXPECT_GT(mInner.GetLinkBandwidthInfo(0, 0, 0, nullptr), TELEPHONY_ERR_SUCCESS); EXPECT_GT(mInner.GetLinkBandwidthInfo(0, 0, 0, nullptr), TELEPHONY_ERR_SUCCESS);
LinkBandwidthRule mLinkBandwidthRule; LinkBandwidthRule mLinkBandwidthRule;
EXPECT_GT(mInner.SetLinkBandwidthReportingRule(0, 0, mLinkBandwidthRule, nullptr), TELEPHONY_ERR_SUCCESS); EXPECT_GT(mInner.SetLinkBandwidthReportingRule(0, 0, mLinkBandwidthRule, nullptr), TELEPHONY_ERR_SUCCESS);
bool airplaneMode = false;
EXPECT_GT(mInner.GetAirplaneMode(airplaneMode), TELEPHONY_ERR_SUCCESS);
EXPECT_GT(mInner.UpdateRadioOn(INVALID_SLOTID), TELEPHONY_ERR_SUCCESS);
} }
/** /**
@ -1247,9 +1286,6 @@ HWTEST_F(BranchTest, Telephony_SimManager_003, Function | MediumTest | Level1)
bool boolResult = false; bool boolResult = false;
EXPECT_GT(simManager->HasOperatorPrivileges(0, boolResult), TELEPHONY_ERR_SUCCESS); EXPECT_GT(simManager->HasOperatorPrivileges(0, boolResult), TELEPHONY_ERR_SUCCESS);
EXPECT_GT(simManager->HasOperatorPrivileges(INVALID_SLOTID, boolResult), TELEPHONY_ERR_SUCCESS); EXPECT_GT(simManager->HasOperatorPrivileges(INVALID_SLOTID, boolResult), TELEPHONY_ERR_SUCCESS);
SimAuthenticationResponse mResponse;
EXPECT_NE(simManager->SimAuthentication(0, "", "", mResponse), TELEPHONY_ERR_SUCCESS);
EXPECT_NE(simManager->SimAuthentication(INVALID_SLOTID, "", "", mResponse), TELEPHONY_ERR_SUCCESS);
int32_t testRadioProtocolTech = static_cast<int32_t>(RadioProtocolTech::RADIO_PROTOCOL_TECH_UNKNOWN); int32_t testRadioProtocolTech = static_cast<int32_t>(RadioProtocolTech::RADIO_PROTOCOL_TECH_UNKNOWN);
EXPECT_EQ(simManager->GetRadioProtocolTech(0), testRadioProtocolTech); EXPECT_EQ(simManager->GetRadioProtocolTech(0), testRadioProtocolTech);
EXPECT_EQ(simManager->GetRadioProtocolTech(INVALID_SLOTID), testRadioProtocolTech); EXPECT_EQ(simManager->GetRadioProtocolTech(INVALID_SLOTID), testRadioProtocolTech);
@ -1304,6 +1340,13 @@ HWTEST_F(BranchTest, Telephony_SimManager_004, Function | MediumTest | Level1)
std::string testString = ""; std::string testString = "";
EXPECT_NE(simManager->ObtainSpnCondition(0, true, testString), TELEPHONY_ERR_SUCCESS); EXPECT_NE(simManager->ObtainSpnCondition(0, true, testString), TELEPHONY_ERR_SUCCESS);
EXPECT_NE(simManager->ObtainSpnCondition(INVALID_SLOTID, true, testString), TELEPHONY_ERR_SUCCESS); EXPECT_NE(simManager->ObtainSpnCondition(INVALID_SLOTID, true, testString), TELEPHONY_ERR_SUCCESS);
SimAuthenticationResponse mResponse;
EXPECT_NE(simManager->SimAuthentication(0, static_cast<AuthType>(0), "", mResponse), TELEPHONY_ERR_SUCCESS);
EXPECT_NE(
simManager->SimAuthentication(INVALID_SLOTID, static_cast<AuthType>(0), "", mResponse), TELEPHONY_ERR_SUCCESS);
EXPECT_NE(simManager->SimAuthentication(0, AuthType::SIM_AUTH_EAP_SIM_TYPE, "", mResponse), TELEPHONY_ERR_SUCCESS);
EXPECT_NE(simManager->SimAuthentication(INVALID_SLOTID, AuthType::SIM_AUTH_EAP_SIM_TYPE, "", mResponse),
TELEPHONY_ERR_SUCCESS);
} }
/** /**
@ -1343,12 +1386,33 @@ HWTEST_F(BranchTest, Telephony_SimStateManager_001, Function | MediumTest | Leve
PersoLockInfo mPersoLockInfo; PersoLockInfo mPersoLockInfo;
EXPECT_GT(simStateManager->UnlockSimLock(0, mPersoLockInfo, mLockStatusResponse), TELEPHONY_ERR_SUCCESS); EXPECT_GT(simStateManager->UnlockSimLock(0, mPersoLockInfo, mLockStatusResponse), TELEPHONY_ERR_SUCCESS);
SimAuthenticationResponse mResponse; SimAuthenticationResponse mResponse;
EXPECT_NE(simStateManager->SimAuthentication(0, "", "", mResponse), TELEPHONY_ERR_SUCCESS); EXPECT_NE(
simStateManager->SimAuthentication(0, AuthType::SIM_AUTH_EAP_SIM_TYPE, "", mResponse), TELEPHONY_ERR_SUCCESS);
auto simStateManagerTwo = std::make_shared<SimStateManager>(telRilManager); auto simStateManagerTwo = std::make_shared<SimStateManager>(telRilManager);
simStateManager->simStateHandle_ = std::make_shared<SimStateHandle>(runner, simStateManagerTwo); simStateManager->simStateHandle_ = std::make_shared<SimStateHandle>(runner, simStateManagerTwo);
EXPECT_GE(simStateManager->GetCardType(), CardType::UNKNOWN_CARD); EXPECT_GE(simStateManager->GetCardType(), CardType::UNKNOWN_CARD);
EXPECT_GT(simStateManager->UnlockSimLock(0, mPersoLockInfo, mLockStatusResponse), TELEPHONY_ERR_SUCCESS); EXPECT_GT(simStateManager->UnlockSimLock(0, mPersoLockInfo, mLockStatusResponse), TELEPHONY_ERR_SUCCESS);
EXPECT_NE(simStateManager->SimAuthentication(0, "", "", mResponse), TELEPHONY_ERR_SUCCESS); }
/**
* @tc.number Telephony_SimStateHandle_001
* @tc.name test error branch
* @tc.desc Function test
*/
HWTEST_F(BranchTest, Telephony_SimStateHandle_001, Function | MediumTest | Level1)
{
std::shared_ptr<TelRilManager> telRilManager = std::make_shared<TelRilManager>();
std::shared_ptr<Telephony::SimStateManager> simStateManager = std::make_shared<SimStateManager>(telRilManager);
std::shared_ptr<AppExecFwk::EventRunner> runner = AppExecFwk::EventRunner::Create("test");
auto simStateHandle = std::make_shared<SimStateHandle>(runner, simStateManager);
EXPECT_EQ(simStateHandle->GetAidByCardType(CardType::SINGLE_MODE_RUIM_CARD), CDMA_FAKE_AID);
EXPECT_EQ(simStateHandle->GetAidByCardType(CardType::SINGLE_MODE_SIM_CARD), GSM_FAKE_AID);
EXPECT_EQ(simStateHandle->GetAidByCardType(CardType::DUAL_MODE_CG_CARD), GSM_FAKE_AID);
EXPECT_EQ(simStateHandle->GetAidByCardType(CardType::CT_NATIONAL_ROAMING_CARD), GSM_FAKE_AID);
EXPECT_EQ(simStateHandle->GetAidByCardType(CardType::CU_DUAL_MODE_CARD), GSM_FAKE_AID);
EXPECT_EQ(simStateHandle->GetAidByCardType(CardType::DUAL_MODE_TELECOM_LTE_CARD), GSM_FAKE_AID);
EXPECT_EQ(simStateHandle->GetAidByCardType(CardType::DUAL_MODE_UG_CARD), GSM_FAKE_AID);
EXPECT_EQ(simStateHandle->GetAidByCardType(CardType::UNKNOWN_CARD), USIM_AID);
} }
/** /**
@ -1621,6 +1685,9 @@ HWTEST_F(BranchTest, Telephony_NetworkSearchManager_001, Function | MediumTest |
EXPECT_TRUE(cellInfo.empty()); EXPECT_TRUE(cellInfo.empty());
EXPECT_NE(networkSearchManager->SendUpdateCellLocationRequest(INVALID_SLOTID), TELEPHONY_ERR_SUCCESS); EXPECT_NE(networkSearchManager->SendUpdateCellLocationRequest(INVALID_SLOTID), TELEPHONY_ERR_SUCCESS);
EXPECT_TRUE(networkSearchManager->GetCellLocation(INVALID_SLOTID) == nullptr); EXPECT_TRUE(networkSearchManager->GetCellLocation(INVALID_SLOTID) == nullptr);
bool airplaneMode = false;
EXPECT_NE(networkSearchManager->GetAirplaneMode(airplaneMode), TELEPHONY_ERR_SUCCESS);
EXPECT_NE(networkSearchManager->UpdateRadioOn(INVALID_SLOTID), TELEPHONY_ERR_SUCCESS);
} }
/** /**
@ -1667,6 +1734,9 @@ HWTEST_F(BranchTest, Telephony_NetworkSearchManager_002, Function | MediumTest |
networkSearchManager->SetNrOptionMode(INVALID_SLOTID, NrMode::NR_MODE_UNKNOWN); networkSearchManager->SetNrOptionMode(INVALID_SLOTID, NrMode::NR_MODE_UNKNOWN);
networkSearchManager->SetFrequencyType(INVALID_SLOTID, FrequencyType::FREQ_TYPE_MMWAVE); networkSearchManager->SetFrequencyType(INVALID_SLOTID, FrequencyType::FREQ_TYPE_MMWAVE);
networkSearchManager->SetRadioFirstPowerOn(INVALID_SLOTID, true); networkSearchManager->SetRadioFirstPowerOn(INVALID_SLOTID, true);
networkSearchManager->SetLocalAirplaneMode(INVALID_SLOTID, true);
bool state = false;
networkSearchManager->GetLocalAirplaneMode(INVALID_SLOTID, state);
EXPECT_TRUE(networkSearchManager->GetNetworkSearchInformationValue(INVALID_SLOTID) == nullptr); EXPECT_TRUE(networkSearchManager->GetNetworkSearchInformationValue(INVALID_SLOTID) == nullptr);
EXPECT_TRUE(networkSearchManager->GetNetworkSearchState(INVALID_SLOTID) != nullptr); EXPECT_TRUE(networkSearchManager->GetNetworkSearchState(INVALID_SLOTID) != nullptr);
EXPECT_TRUE(networkSearchManager->IsRadioFirstPowerOn(INVALID_SLOTID)); EXPECT_TRUE(networkSearchManager->IsRadioFirstPowerOn(INVALID_SLOTID));
@ -1890,6 +1960,7 @@ HWTEST_F(BranchTest, Telephony_UsimFileController_001, Function | MediumTest | L
EXPECT_NE(uSimFileController->ObtainElementFilePath(ELEMENTARY_FILE_MBDN), ""); EXPECT_NE(uSimFileController->ObtainElementFilePath(ELEMENTARY_FILE_MBDN), "");
EXPECT_NE(uSimFileController->ObtainElementFilePath(ELEMENTARY_FILE_PNN), ""); EXPECT_NE(uSimFileController->ObtainElementFilePath(ELEMENTARY_FILE_PNN), "");
EXPECT_NE(uSimFileController->ObtainElementFilePath(ELEMENTARY_FILE_OPL), ""); EXPECT_NE(uSimFileController->ObtainElementFilePath(ELEMENTARY_FILE_OPL), "");
EXPECT_NE(uSimFileController->ObtainElementFilePath(ELEMENTARY_FILE_OPL5G), "");
EXPECT_NE(uSimFileController->ObtainElementFilePath(ELEMENTARY_FILE_SPDI), ""); EXPECT_NE(uSimFileController->ObtainElementFilePath(ELEMENTARY_FILE_SPDI), "");
EXPECT_NE(uSimFileController->ObtainElementFilePath(ELEMENTARY_FILE_SST), ""); EXPECT_NE(uSimFileController->ObtainElementFilePath(ELEMENTARY_FILE_SST), "");
EXPECT_NE(uSimFileController->ObtainElementFilePath(ELEMENTARY_FILE_CFIS), ""); EXPECT_NE(uSimFileController->ObtainElementFilePath(ELEMENTARY_FILE_CFIS), "");

View File

@ -12,6 +12,7 @@
# limitations under the License. # limitations under the License.
import("//build/test.gni") import("//build/test.gni")
SOURCE_DIR = "../../../"
ohos_unittest("tel_ril_gtest") { ohos_unittest("tel_ril_gtest") {
install_enable = true install_enable = true
@ -21,26 +22,20 @@ ohos_unittest("tel_ril_gtest") {
module_out_path = part_name + "/" + test_module module_out_path = part_name + "/" + test_module
sources = [ sources = [
"//base/telephony/core_service/frameworks/native/src/i_network_search_callback_stub.cpp", "$SOURCE_DIR/frameworks/native/src/i_network_search_callback_stub.cpp",
"tel_ril_test.cpp", "tel_ril_test.cpp",
] ]
include_dirs = [ include_dirs = [
"//base/telephony/core_service/utils/common/include", "$SOURCE_DIR/utils/common/include",
"//base/telephony/core_service/utils/log/include", "$SOURCE_DIR/utils/log/include",
"//base/telephony/core_service/common/sim", "$SOURCE_DIR/services/tel_ril/include",
"//base/telephony/core_service/common/network_search", "$SOURCE_DIR/services/sim/include",
"//base/telephony/core_service/common/core",
"//base/telephony/core_service/services/tel_ril/include",
"//base/telephony/core_service/services/sim/include",
"//drivers/hdf_core/adapter/uhdf2/include/hdi",
"//commonlibrary/c_utils/base/include",
] ]
deps = [ deps = [
"//base/telephony/core_service:tel_core_service", "$SOURCE_DIR:tel_core_service",
"//base/telephony/core_service/interfaces/innerkits:tel_core_service_api", "$SOURCE_DIR/interfaces/innerkits:tel_core_service_api",
"//drivers/hdf_core/adapter/uhdf2/hdi:libhdi",
"//third_party/googletest:gtest_main", "//third_party/googletest:gtest_main",
] ]
@ -52,6 +47,7 @@ ohos_unittest("tel_ril_gtest") {
"drivers_interface_ril:hril_innerkits", "drivers_interface_ril:hril_innerkits",
"drivers_interface_ril:ril_idl_headers", "drivers_interface_ril:ril_idl_headers",
"eventhandler:libeventhandler", "eventhandler:libeventhandler",
"hdf_core:libhdi",
"init:libbegetutil", "init:libbegetutil",
"ipc:ipc_core", "ipc:ipc_core",
"power_manager:powermgr_client", "power_manager:powermgr_client",

Some files were not shown because too many files have changed in this diff Show More