mirror of
https://gitee.com/openharmony/telephony_core_service
synced 2024-11-23 08:00:07 +00:00
Merge branch 'master' of gitee.com:openharmony/telephony_core_service into master
Signed-off-by: 王星博 <wangxingbo11@h-partners.com>
This commit is contained in:
commit
7496ae9f34
15
BUILD.gn
15
BUILD.gn
@ -120,6 +120,9 @@ ohos_shared_library("tel_core_service") {
|
||||
"services/core/src/core_service_hisysevent.cpp",
|
||||
"services/core/src/core_service_stub.cpp",
|
||||
]
|
||||
if (core_service_support_esim) {
|
||||
sources += [ "$TELEPHONY_SIM_ROOT/src/esim_file.cpp" ]
|
||||
}
|
||||
|
||||
include_dirs = [
|
||||
"$TELEPHONY_SIM_ROOT/include",
|
||||
@ -129,8 +132,16 @@ ohos_shared_library("tel_core_service") {
|
||||
"services/core/include",
|
||||
"services/satellite_service_interaction/include",
|
||||
"utils/log/include",
|
||||
"utils/codec/include",
|
||||
]
|
||||
|
||||
if (core_service_support_esim) {
|
||||
include_dirs += [
|
||||
"utils/codec/include",
|
||||
"utils/vcard/include",
|
||||
]
|
||||
}
|
||||
|
||||
configs = [ "utils:telephony_log_config" ]
|
||||
|
||||
defines = [
|
||||
@ -150,6 +161,10 @@ ohos_shared_library("tel_core_service") {
|
||||
"//third_party/openssl:libcrypto_shared",
|
||||
]
|
||||
|
||||
if (core_service_support_esim) {
|
||||
deps += [ "utils:libtel_vcard" ]
|
||||
}
|
||||
|
||||
external_deps = [
|
||||
"ability_base:want",
|
||||
"ability_base:zuri",
|
||||
|
@ -52,6 +52,7 @@
|
||||
"hicollie",
|
||||
"hilog",
|
||||
"hisysevent",
|
||||
"hitrace",
|
||||
"i18n",
|
||||
"init",
|
||||
"ipc",
|
||||
@ -84,9 +85,12 @@
|
||||
],
|
||||
"fwk_group": [
|
||||
"//base/telephony/core_service/interfaces/innerkits:tel_core_service_api",
|
||||
"//base/telephony/core_service/frameworks/cj/telephony_radio:cj_radio_ffi",
|
||||
"//base/telephony/core_service/frameworks/cj/telephony_sim:cj_sim_ffi",
|
||||
"//base/telephony/core_service/frameworks/js/network_search:radio",
|
||||
"//base/telephony/core_service/frameworks/js/sim:sim",
|
||||
"//base/telephony/core_service/frameworks/js/vcard:vcard"
|
||||
"//base/telephony/core_service/frameworks/js/vcard:vcard",
|
||||
"//base/telephony/core_service/frameworks/js/esim:esim"
|
||||
],
|
||||
"service_group": [
|
||||
"//base/telephony/core_service:tel_core_service",
|
||||
|
65
frameworks/cj/telephony_radio/BUILD.gn
Normal file
65
frameworks/cj/telephony_radio/BUILD.gn
Normal file
@ -0,0 +1,65 @@
|
||||
# Copyright (C) 2024 Huawei Device Co., Ltd.
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
import("//build/ohos.gni")
|
||||
SUBSYSTEM_DIR = "../../../.."
|
||||
import("$SUBSYSTEM_DIR/core_service/telephony_core_service.gni")
|
||||
|
||||
ohos_shared_library("cj_radio_ffi") {
|
||||
sanitize = {
|
||||
cfi = true
|
||||
cfi_cross_dso = true
|
||||
debug = false
|
||||
}
|
||||
|
||||
branch_protector_ret = "pac_ret"
|
||||
|
||||
include_dirs = [
|
||||
"$SUBSYSTEM_DIR/core_service/interfaces/kits/native",
|
||||
"$SUBSYSTEM_DIR/core_service/interfaces/innerkits/include",
|
||||
]
|
||||
|
||||
sources = [
|
||||
"src/telephony_radio_callback.cpp",
|
||||
"src/telephony_radio_ffi.cpp",
|
||||
"src/telephony_radio_impl.cpp",
|
||||
]
|
||||
|
||||
configs = [ "$SUBSYSTEM_DIR/core_service/utils:telephony_log_config" ]
|
||||
|
||||
deps = [
|
||||
"$SUBSYSTEM_DIR/core_service/interfaces/innerkits:tel_core_service_api",
|
||||
"$SUBSYSTEM_DIR/core_service/utils:libtel_common",
|
||||
]
|
||||
|
||||
external_deps = [
|
||||
"ability_runtime:abilitykit_native",
|
||||
"c_utils:utils",
|
||||
"hilog:libhilog",
|
||||
"init:libbegetutil",
|
||||
"ipc:ipc_single",
|
||||
"napi:ace_napi",
|
||||
"napi:cj_bind_ffi",
|
||||
]
|
||||
|
||||
defines = [
|
||||
"TELEPHONY_LOG_TAG = \"CoreServiceRadioFfiApi\"",
|
||||
"LOG_DOMAIN = 0xD001F04",
|
||||
]
|
||||
|
||||
defines += telephony_extra_defines
|
||||
|
||||
innerapi_tags = [ "platformsdk" ]
|
||||
part_name = "core_service"
|
||||
subsystem_name = "telephony"
|
||||
}
|
@ -0,0 +1,77 @@
|
||||
/*
|
||||
* Copyright (c) 2024 Huawei Device Co., Ltd.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#include "telephony_radio_callback.h"
|
||||
|
||||
namespace OHOS {
|
||||
namespace Telephony {
|
||||
GetNetworkSearchModeCallback::GetNetworkSearchModeCallback(GetSelectModeContext *asyncContext)
|
||||
: asyncContext_(asyncContext)
|
||||
{}
|
||||
|
||||
int32_t WrapNetworkSelectionMode(int32_t mode)
|
||||
{
|
||||
switch (mode) {
|
||||
case NATIVE_NETWORK_SELECTION_AUTOMATIC:
|
||||
return NETWORK_SELECTION_AUTOMATIC;
|
||||
case NATIVE_NETWORK_SELECTION_MANUAL:
|
||||
return NETWORK_SELECTION_MANUAL;
|
||||
default:
|
||||
return NETWORK_SELECTION_UNKNOWN;
|
||||
}
|
||||
}
|
||||
|
||||
void GetNetworkSearchModeCallback::OnGetNetworkModeCallback(const int32_t searchModel, const int32_t errorCode)
|
||||
{
|
||||
TELEPHONY_LOGD("OnGetNetworkModeCallback searchModel = %{public}d", searchModel);
|
||||
if (asyncContext_ == nullptr) {
|
||||
TELEPHONY_LOGE("OnGetNetworkModeCallback asyncContext null");
|
||||
return;
|
||||
}
|
||||
std::unique_lock<std::mutex> callbackLock(asyncContext_->callbackMutex);
|
||||
asyncContext_->resolved = errorCode == TELEPHONY_ERR_SUCCESS;
|
||||
if (asyncContext_->resolved) {
|
||||
asyncContext_->selectMode = WrapNetworkSelectionMode(searchModel);
|
||||
} else {
|
||||
asyncContext_->errorCode = TELEPHONY_ERR_RIL_CMD_FAIL;
|
||||
}
|
||||
asyncContext_->callbackEnd = true;
|
||||
asyncContext_->cv.notify_all();
|
||||
}
|
||||
|
||||
GetRadioStateCallback::GetRadioStateCallback(IsRadioOnContext *context)
|
||||
: asyncContext_(context)
|
||||
{}
|
||||
|
||||
void GetRadioStateCallback::OnGetRadioStateCallback(const bool isOn, const int32_t errorCode)
|
||||
{
|
||||
TELEPHONY_LOGD("OnGetRadioStateCallback isOn = %{public}d", isOn);
|
||||
if (asyncContext_ == nullptr) {
|
||||
TELEPHONY_LOGE("OnGetRadioStateCallback asyncContext null");
|
||||
return;
|
||||
}
|
||||
std::unique_lock<std::mutex> callbackLock(asyncContext_->callbackMutex);
|
||||
asyncContext_->resolved = errorCode == TELEPHONY_ERR_SUCCESS;
|
||||
if (asyncContext_->resolved) {
|
||||
asyncContext_->isRadioOn = isOn;
|
||||
} else {
|
||||
asyncContext_->errorCode = TELEPHONY_ERR_RIL_CMD_FAIL;
|
||||
}
|
||||
asyncContext_->callbackEnd = true;
|
||||
asyncContext_->cv.notify_all();
|
||||
TELEPHONY_LOGD("OnGetRadioStateCallback end");
|
||||
}
|
||||
} // namespace Telephony
|
||||
} // namespace OHOS
|
44
frameworks/cj/telephony_radio/src/telephony_radio_callback.h
Normal file
44
frameworks/cj/telephony_radio/src/telephony_radio_callback.h
Normal file
@ -0,0 +1,44 @@
|
||||
/*
|
||||
* Copyright (c) 2024 Huawei Device Co., Ltd.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#ifndef TELEPHONY_RADIO_CALLBACK_H
|
||||
#define TELEPHONY_RADIO_CALLBACK_H
|
||||
|
||||
#include "i_network_search_callback_stub.h"
|
||||
#include "telephony_log_wrapper.h"
|
||||
#include "telephony_radio_utils.h"
|
||||
|
||||
namespace OHOS {
|
||||
namespace Telephony {
|
||||
class GetNetworkSearchModeCallback : public INetworkSearchCallbackStub {
|
||||
public:
|
||||
explicit GetNetworkSearchModeCallback(GetSelectModeContext *asyncContext);
|
||||
void OnGetNetworkModeCallback(const int32_t searchModel, const int32_t errorCode) override;
|
||||
|
||||
private:
|
||||
GetSelectModeContext *asyncContext_;
|
||||
};
|
||||
|
||||
class GetRadioStateCallback : public INetworkSearchCallbackStub {
|
||||
public:
|
||||
explicit GetRadioStateCallback(IsRadioOnContext *context);
|
||||
void OnGetRadioStateCallback(const bool isOn, const int32_t errorCode) override;
|
||||
|
||||
private:
|
||||
IsRadioOnContext *asyncContext_;
|
||||
};
|
||||
} // namespace Telephony
|
||||
} // namespace OHOS
|
||||
#endif
|
70
frameworks/cj/telephony_radio/src/telephony_radio_ffi.cpp
Normal file
70
frameworks/cj/telephony_radio/src/telephony_radio_ffi.cpp
Normal file
@ -0,0 +1,70 @@
|
||||
/*
|
||||
* Copyright (c) 2024 Huawei Device Co., Ltd.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#include "telephony_radio_ffi.h"
|
||||
|
||||
using namespace OHOS::FFI;
|
||||
|
||||
namespace OHOS {
|
||||
namespace Telephony {
|
||||
extern "C" {
|
||||
|
||||
CNetworkRadioTech FfiTelephonyRadioGetRadioTech(int32_t slotId, int32_t *errCode)
|
||||
{
|
||||
return TelephonyRadioImpl::GetRadioTech(slotId, *errCode);
|
||||
}
|
||||
|
||||
CNetworkState FfiTelephonyRadioGetNetworkState(int32_t slotId, int32_t *errCode)
|
||||
{
|
||||
return TelephonyRadioImpl::GetNetworkState(slotId, *errCode);
|
||||
}
|
||||
|
||||
int32_t FfiTelephonyRadioGetNetworkSelectionMode(int32_t slotId, int32_t *errCode)
|
||||
{
|
||||
return TelephonyRadioImpl::GetNetworkSelectionMode(slotId, *errCode);
|
||||
}
|
||||
|
||||
char* FfiTelephonyRadioGetISOCountryCodeForNetwork(int32_t slotId, int32_t *errCode)
|
||||
{
|
||||
return TelephonyRadioImpl::GetISOCountryCodeForNetwork(slotId, *errCode);
|
||||
}
|
||||
|
||||
int32_t FfiTelephonyRadioGetPrimarySlotId(int32_t *errCode)
|
||||
{
|
||||
return TelephonyRadioImpl::GetPrimarySlotId(*errCode);
|
||||
}
|
||||
|
||||
CArraySignalInformation FfiTelephonyRadioGetSignalInfoList(int32_t slotId, int32_t *errCode)
|
||||
{
|
||||
return TelephonyRadioImpl::GetSignalInfoList(slotId, *errCode);
|
||||
}
|
||||
|
||||
bool FfiTelephonyRadioIsNRSupported()
|
||||
{
|
||||
return TelephonyRadioImpl::IsNRSupported();
|
||||
}
|
||||
|
||||
bool FfiTelephonyRadioIsRadioOn(int32_t slotId, int32_t *errCode)
|
||||
{
|
||||
return TelephonyRadioImpl::IsRadioOn(slotId, *errCode);
|
||||
}
|
||||
|
||||
char* FfiTelephonyRadioGetOperatorName(int32_t slotId, int32_t *errCode)
|
||||
{
|
||||
return TelephonyRadioImpl::GetOperatorName(slotId, *errCode);
|
||||
}
|
||||
}
|
||||
} // namespace Telephony
|
||||
} // namespace OHOS
|
39
frameworks/cj/telephony_radio/src/telephony_radio_ffi.h
Normal file
39
frameworks/cj/telephony_radio/src/telephony_radio_ffi.h
Normal file
@ -0,0 +1,39 @@
|
||||
/*
|
||||
* Copyright (c) 2024 Huawei Device Co., Ltd.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#ifndef TELEPHONY_RADIO_FFI_H
|
||||
#define TELEPHONY_RADIO_FFI_H
|
||||
|
||||
#include "ffi_remote_data.h"
|
||||
#include "telephony_radio_impl.h"
|
||||
#include "telephony_radio_utils.h"
|
||||
|
||||
namespace OHOS {
|
||||
namespace Telephony {
|
||||
extern "C" {
|
||||
FFI_EXPORT CNetworkRadioTech FfiTelephonyRadioGetRadioTech(int32_t slotId, int32_t *errCode);
|
||||
FFI_EXPORT CNetworkState FfiTelephonyRadioGetNetworkState(int32_t slotId, int32_t *errCode);
|
||||
FFI_EXPORT int32_t FfiTelephonyRadioGetNetworkSelectionMode(int32_t slotId, int32_t *errCode);
|
||||
FFI_EXPORT char* FfiTelephonyRadioGetISOCountryCodeForNetwork(int32_t slotId, int32_t *errCode);
|
||||
FFI_EXPORT int32_t FfiTelephonyRadioGetPrimarySlotId(int32_t *errCode);
|
||||
FFI_EXPORT CArraySignalInformation FfiTelephonyRadioGetSignalInfoList(int32_t slotId, int32_t *errCode);
|
||||
FFI_EXPORT bool FfiTelephonyRadioIsNRSupported();
|
||||
FFI_EXPORT bool FfiTelephonyRadioIsRadioOn(int32_t slotId, int32_t *errCode);
|
||||
FFI_EXPORT char* FfiTelephonyRadioGetOperatorName(int32_t slotId, int32_t *errCode);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
399
frameworks/cj/telephony_radio/src/telephony_radio_impl.cpp
Normal file
399
frameworks/cj/telephony_radio/src/telephony_radio_impl.cpp
Normal file
@ -0,0 +1,399 @@
|
||||
/*
|
||||
* Copyright (c) 2024 Huawei Device Co., Ltd.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
|
||||
#include "telephony_radio_impl.h"
|
||||
|
||||
#include "core_service_client.h"
|
||||
#include "telephony_config.h"
|
||||
#include "telephony_ext_utils_wrapper.h"
|
||||
#include "telephony_log_wrapper.h"
|
||||
|
||||
namespace OHOS {
|
||||
namespace Telephony {
|
||||
|
||||
static int32_t ConvertCJErrCode(int32_t errCode)
|
||||
{
|
||||
switch (errCode) {
|
||||
case TELEPHONY_ERR_ARGUMENT_MISMATCH:
|
||||
case TELEPHONY_ERR_ARGUMENT_INVALID:
|
||||
case TELEPHONY_ERR_ARGUMENT_NULL:
|
||||
case TELEPHONY_ERR_SLOTID_INVALID:
|
||||
case ERROR_SLOT_ID_INVALID:
|
||||
// 83000001
|
||||
return CJ_ERROR_TELEPHONY_ARGUMENT_ERROR;
|
||||
case TELEPHONY_ERR_DESCRIPTOR_MISMATCH:
|
||||
case TELEPHONY_ERR_WRITE_DESCRIPTOR_TOKEN_FAIL:
|
||||
case TELEPHONY_ERR_WRITE_DATA_FAIL:
|
||||
case TELEPHONY_ERR_WRITE_REPLY_FAIL:
|
||||
case TELEPHONY_ERR_READ_DATA_FAIL:
|
||||
case TELEPHONY_ERR_IPC_CONNECT_STUB_FAIL:
|
||||
case TELEPHONY_ERR_REGISTER_CALLBACK_FAIL:
|
||||
case TELEPHONY_ERR_CALLBACK_ALREADY_REGISTERED:
|
||||
case TELEPHONY_ERR_UNINIT:
|
||||
case TELEPHONY_ERR_UNREGISTER_CALLBACK_FAIL:
|
||||
// 83000002
|
||||
return CJ_ERROR_TELEPHONY_SERVICE_ERROR;
|
||||
case TELEPHONY_ERR_VCARD_FILE_INVALID:
|
||||
case TELEPHONY_ERR_FAIL:
|
||||
case TELEPHONY_ERR_MEMCPY_FAIL:
|
||||
case TELEPHONY_ERR_MEMSET_FAIL:
|
||||
case TELEPHONY_ERR_STRCPY_FAIL:
|
||||
case TELEPHONY_ERR_LOCAL_PTR_NULL:
|
||||
case TELEPHONY_ERR_SUBSCRIBE_BROADCAST_FAIL:
|
||||
case TELEPHONY_ERR_PUBLISH_BROADCAST_FAIL:
|
||||
case TELEPHONY_ERR_ADD_DEATH_RECIPIENT_FAIL:
|
||||
case TELEPHONY_ERR_STRTOINT_FAIL:
|
||||
case TELEPHONY_ERR_RIL_CMD_FAIL:
|
||||
case TELEPHONY_ERR_DATABASE_WRITE_FAIL:
|
||||
case TELEPHONY_ERR_DATABASE_READ_FAIL:
|
||||
case TELEPHONY_ERR_UNKNOWN_NETWORK_TYPE:
|
||||
case ERROR_SERVICE_UNAVAILABLE:
|
||||
case ERROR_NATIVE_API_EXECUTE_FAIL:
|
||||
// 83000003
|
||||
return CJ_ERROR_TELEPHONY_SYSTEM_ERROR;
|
||||
case TELEPHONY_ERR_NO_SIM_CARD:
|
||||
// 83000004
|
||||
return CJ_ERROR_TELEPHONY_NO_SIM_CARD;
|
||||
case TELEPHONY_ERR_AIRPLANE_MODE_ON:
|
||||
// 83000005
|
||||
return CJ_ERROR_TELEPHONY_AIRPLANE_MODE_ON;
|
||||
case TELEPHONY_ERR_NETWORK_NOT_IN_SERVICE:
|
||||
// 83000006
|
||||
return CJ_ERROR_TELEPHONY_NETWORK_NOT_IN_SERVICE;
|
||||
case TELEPHONY_ERR_PERMISSION_ERR:
|
||||
// 201
|
||||
return CJ_ERROR_TELEPHONY_PERMISSION_DENIED;
|
||||
case TELEPHONY_ERR_ILLEGAL_USE_OF_SYSTEM_API:
|
||||
// 202
|
||||
return CJ_ERROR_TELEPHONY_PERMISSION_DENIED;
|
||||
default:
|
||||
return errCode;
|
||||
}
|
||||
}
|
||||
|
||||
static inline bool IsValidSlotId(int32_t slotId)
|
||||
{
|
||||
return ((slotId >= DEFAULT_SIM_SLOT_ID) && (slotId < SIM_SLOT_COUNT));
|
||||
}
|
||||
|
||||
static inline bool IsValidSlotIdEx(int32_t slotId)
|
||||
{
|
||||
// One more slot for VSim.
|
||||
return ((slotId >= DEFAULT_SIM_SLOT_ID) && (slotId < SIM_SLOT_COUNT + 1));
|
||||
}
|
||||
|
||||
static int32_t WrapRadioTech(int32_t radioTechType)
|
||||
{
|
||||
RadioTech techType = static_cast<RadioTech>(radioTechType);
|
||||
switch (techType) {
|
||||
case RadioTech::RADIO_TECHNOLOGY_GSM:
|
||||
return static_cast<int32_t>(RatType::RADIO_TECHNOLOGY_GSM);
|
||||
case RadioTech::RADIO_TECHNOLOGY_LTE:
|
||||
return static_cast<int32_t>(RatType::RADIO_TECHNOLOGY_LTE);
|
||||
case RadioTech::RADIO_TECHNOLOGY_WCDMA:
|
||||
return static_cast<int32_t>(RatType::RADIO_TECHNOLOGY_WCDMA);
|
||||
case RadioTech::RADIO_TECHNOLOGY_1XRTT:
|
||||
return static_cast<int32_t>(RatType::RADIO_TECHNOLOGY_1XRTT);
|
||||
case RadioTech::RADIO_TECHNOLOGY_HSPA:
|
||||
return static_cast<int32_t>(RatType::RADIO_TECHNOLOGY_HSPA);
|
||||
case RadioTech::RADIO_TECHNOLOGY_HSPAP:
|
||||
return static_cast<int32_t>(RatType::RADIO_TECHNOLOGY_HSPAP);
|
||||
case RadioTech::RADIO_TECHNOLOGY_TD_SCDMA:
|
||||
return static_cast<int32_t>(RatType::RADIO_TECHNOLOGY_TD_SCDMA);
|
||||
case RadioTech::RADIO_TECHNOLOGY_EVDO:
|
||||
return static_cast<int32_t>(RatType::RADIO_TECHNOLOGY_EVDO);
|
||||
case RadioTech::RADIO_TECHNOLOGY_EHRPD:
|
||||
return static_cast<int32_t>(RatType::RADIO_TECHNOLOGY_EHRPD);
|
||||
case RadioTech::RADIO_TECHNOLOGY_LTE_CA:
|
||||
return static_cast<int32_t>(RatType::RADIO_TECHNOLOGY_LTE_CA);
|
||||
case RadioTech::RADIO_TECHNOLOGY_IWLAN:
|
||||
return static_cast<int32_t>(RatType::RADIO_TECHNOLOGY_IWLAN);
|
||||
case RadioTech::RADIO_TECHNOLOGY_NR:
|
||||
return static_cast<int32_t>(RatType::RADIO_TECHNOLOGY_NR);
|
||||
default:
|
||||
return static_cast<int32_t>(RatType::RADIO_TECHNOLOGY_UNKNOWN);
|
||||
}
|
||||
}
|
||||
|
||||
static int32_t WrapRegState(int32_t nativeState)
|
||||
{
|
||||
RegServiceState state = static_cast<RegServiceState>(nativeState);
|
||||
switch (state) {
|
||||
case RegServiceState::REG_STATE_IN_SERVICE: {
|
||||
return RegStatus::REGISTRATION_STATE_IN_SERVICE;
|
||||
}
|
||||
case RegServiceState::REG_STATE_EMERGENCY_ONLY: {
|
||||
return RegStatus::REGISTRATION_STATE_EMERGENCY_CALL_ONLY;
|
||||
}
|
||||
case RegServiceState::REG_STATE_POWER_OFF: {
|
||||
return RegStatus::REGISTRATION_STATE_POWER_OFF;
|
||||
}
|
||||
default:
|
||||
return RegStatus::REGISTRATION_STATE_NO_SERVICE;
|
||||
}
|
||||
}
|
||||
|
||||
static int32_t WrapSignalInformationType(SignalInformation::NetworkType type)
|
||||
{
|
||||
switch (type) {
|
||||
case SignalInformation::NetworkType::GSM:
|
||||
return static_cast<int32_t>(NetworkType::NETWORK_TYPE_GSM);
|
||||
case SignalInformation::NetworkType::CDMA:
|
||||
return static_cast<int32_t>(NetworkType::NETWORK_TYPE_CDMA);
|
||||
case SignalInformation::NetworkType::LTE:
|
||||
return static_cast<int32_t>(NetworkType::NETWORK_TYPE_LTE);
|
||||
case SignalInformation::NetworkType::WCDMA:
|
||||
return static_cast<int32_t>(NetworkType::NETWORK_TYPE_WCDMA);
|
||||
case SignalInformation::NetworkType::TDSCDMA:
|
||||
return static_cast<int32_t>(NetworkType::NETWORK_TYPE_TDSCDMA);
|
||||
case SignalInformation::NetworkType::NR:
|
||||
return static_cast<int32_t>(NetworkType::NETWORK_TYPE_NR);
|
||||
default:
|
||||
return static_cast<int32_t>(NetworkType::NETWORK_TYPE_UNKNOWN);
|
||||
}
|
||||
}
|
||||
|
||||
static std::string ToUtf8(std::u16string str16)
|
||||
{
|
||||
std::wstring_convert<std::codecvt_utf8_utf16<char16_t>, char16_t> convert;
|
||||
// std::u16string -> std::string
|
||||
std::string result = convert.to_bytes(str16);
|
||||
return result;
|
||||
}
|
||||
|
||||
CNetworkRadioTech TelephonyRadioImpl::GetRadioTech(int32_t slotId, int32_t &errCode)
|
||||
{
|
||||
int32_t psRadioTech = static_cast<int32_t>(RadioTech::RADIO_TECHNOLOGY_INVALID);
|
||||
int32_t csRadioTech = static_cast<int32_t>(RadioTech::RADIO_TECHNOLOGY_INVALID);
|
||||
CNetworkRadioTech networkRadioTech = {
|
||||
.csRadioTech = WrapRadioTech(csRadioTech),
|
||||
.psRadioTech = WrapRadioTech(psRadioTech)
|
||||
};
|
||||
if (!IsValidSlotId(slotId)) {
|
||||
TELEPHONY_LOGE("TelephonyRadioImpl::GetRadioTech slotId is invalid");
|
||||
errCode = ConvertCJErrCode(ERROR_SLOT_ID_INVALID);
|
||||
return networkRadioTech;
|
||||
}
|
||||
int32_t psResult =
|
||||
DelayedRefSingleton<CoreServiceClient>::GetInstance().GetPsRadioTech(slotId, psRadioTech);
|
||||
int32_t csResult =
|
||||
DelayedRefSingleton<CoreServiceClient>::GetInstance().GetCsRadioTech(slotId, csRadioTech);
|
||||
if (psResult == TELEPHONY_SUCCESS && csResult == TELEPHONY_SUCCESS) {
|
||||
networkRadioTech.csRadioTech = WrapRadioTech(csRadioTech);
|
||||
networkRadioTech.psRadioTech = WrapRadioTech(psRadioTech);
|
||||
}
|
||||
errCode = ConvertCJErrCode(csResult);
|
||||
return networkRadioTech;
|
||||
}
|
||||
|
||||
CNetworkState TelephonyRadioImpl::GetNetworkState(int32_t slotId, int32_t &errCode)
|
||||
{
|
||||
CNetworkState cnetworkState = {
|
||||
.longOperatorName = nullptr,
|
||||
.shortOperatorName = nullptr,
|
||||
.plmnNumeric = nullptr,
|
||||
.isRoaming = false,
|
||||
.isCaActive = false,
|
||||
.nsaState = static_cast<int32_t>(NsaState::NSA_STATE_NOT_SUPPORT)
|
||||
};
|
||||
if (!IsValidSlotIdEx(slotId)) {
|
||||
TELEPHONY_LOGE("NativeGetNetworkState slotId is invalid");
|
||||
errCode = ConvertCJErrCode(ERROR_SLOT_ID_INVALID);
|
||||
return cnetworkState;
|
||||
}
|
||||
sptr<NetworkState> networkState = nullptr;
|
||||
int32_t result = DelayedRefSingleton<CoreServiceClient>::GetInstance().GetNetworkState(slotId, networkState);
|
||||
errCode = ConvertCJErrCode(result);
|
||||
if (errCode != TELEPHONY_SUCCESS) {
|
||||
TELEPHONY_LOGE("NativeGetNetworkState errorCode = %{public}d", result);
|
||||
return cnetworkState;
|
||||
}
|
||||
if (networkState == nullptr) {
|
||||
TELEPHONY_LOGE("NativeGetNetworkState networkState is nullptr");
|
||||
errCode = ConvertCJErrCode(ERROR_NATIVE_API_EXECUTE_FAIL);
|
||||
return cnetworkState;
|
||||
}
|
||||
cnetworkState.longOperatorName = MallocCString(networkState->GetLongOperatorName());
|
||||
cnetworkState.shortOperatorName = MallocCString(networkState->GetShortOperatorName());
|
||||
cnetworkState.plmnNumeric = MallocCString(networkState->GetPlmnNumeric());
|
||||
cnetworkState.isRoaming = networkState->IsRoaming();
|
||||
cnetworkState.isEmergency = networkState->IsEmergency();
|
||||
cnetworkState.regState = WrapRegState(static_cast<int32_t>(networkState->GetRegStatus()));
|
||||
cnetworkState.cfgTech = WrapRadioTech(static_cast<int32_t>(networkState->GetCfgTech()));
|
||||
return cnetworkState;
|
||||
}
|
||||
|
||||
int32_t TelephonyRadioImpl::GetNetworkSelectionMode(int32_t slotId, int32_t &errCode)
|
||||
{
|
||||
int32_t selectMode = NETWORK_SELECTION_UNKNOWN;
|
||||
if (!IsValidSlotId(slotId)) {
|
||||
TELEPHONY_LOGE("NativeGetNetworkSelectionMode slotId is invalid");
|
||||
errCode = ConvertCJErrCode(ERROR_SLOT_ID_INVALID);
|
||||
return selectMode;
|
||||
}
|
||||
auto selectModeContext = std::make_unique<GetSelectModeContext>();
|
||||
auto asyncContext = static_cast<GetSelectModeContext *>(selectModeContext.get());
|
||||
asyncContext->slotId = slotId;
|
||||
std::unique_ptr<GetNetworkSearchModeCallback> callback =
|
||||
std::make_unique<GetNetworkSearchModeCallback>(asyncContext);
|
||||
std::unique_lock<std::mutex> callbackLock(asyncContext->callbackMutex);
|
||||
asyncContext->errorCode = DelayedRefSingleton<CoreServiceClient>::GetInstance().GetNetworkSelectionMode(
|
||||
asyncContext->slotId, callback.release());
|
||||
if (asyncContext->errorCode == TELEPHONY_SUCCESS) {
|
||||
asyncContext->cv.wait_for(
|
||||
callbackLock,
|
||||
std::chrono::seconds(WAIT_TIME_SECOND),
|
||||
[asyncContext] { return asyncContext->callbackEnd; });
|
||||
TELEPHONY_LOGI("NativeGetNetworkSelectionMode after callback end");
|
||||
}
|
||||
errCode = ConvertCJErrCode(asyncContext->errorCode);
|
||||
selectMode = asyncContext->selectMode;
|
||||
return selectMode;
|
||||
}
|
||||
|
||||
char* TelephonyRadioImpl::GetISOCountryCodeForNetwork(int32_t slotId, int32_t &errCode)
|
||||
{
|
||||
if (!IsValidSlotId(slotId)) {
|
||||
TELEPHONY_LOGE("NativeGetCountryCode slotId is invalid");
|
||||
errCode = ConvertCJErrCode(ERROR_SLOT_ID_INVALID);
|
||||
return nullptr;
|
||||
}
|
||||
std::u16string countryCode;
|
||||
errCode =
|
||||
DelayedRefSingleton<CoreServiceClient>::GetInstance().GetIsoCountryCodeForNetwork(slotId, countryCode);
|
||||
std::string code = ToUtf8(countryCode);
|
||||
char* result = MallocCString(code);
|
||||
errCode = ConvertCJErrCode(errCode);
|
||||
return result;
|
||||
}
|
||||
|
||||
int32_t TelephonyRadioImpl::GetPrimarySlotId(int32_t &errCode)
|
||||
{
|
||||
int32_t slotId = DEFAULT_SIM_SLOT_ID;
|
||||
errCode =
|
||||
DelayedRefSingleton<CoreServiceClient>::GetInstance().GetPrimarySlotId(slotId);
|
||||
errCode = ConvertCJErrCode(errCode);
|
||||
return slotId;
|
||||
}
|
||||
|
||||
CArraySignalInformation TelephonyRadioImpl::GetSignalInfoList(int32_t slotId, int32_t &errCode)
|
||||
{
|
||||
std::vector<sptr<SignalInformation>> signalInfoList;
|
||||
CArraySignalInformation csignalInfoList = {
|
||||
.head = nullptr,
|
||||
.size = 0
|
||||
};
|
||||
if (!IsValidSlotIdEx(slotId)) {
|
||||
TELEPHONY_LOGE("NativeGetSignalInfoList slotId is invalid");
|
||||
errCode = ConvertCJErrCode(ERROR_SLOT_ID_INVALID);
|
||||
return csignalInfoList;
|
||||
}
|
||||
errCode =
|
||||
DelayedRefSingleton<CoreServiceClient>::GetInstance().GetSignalInfoList(slotId, signalInfoList);
|
||||
errCode = ConvertCJErrCode(errCode);
|
||||
size_t infoSize = signalInfoList.size();
|
||||
TELEPHONY_LOGD("NativeGetSignalInfoList size = %{public}zu", signalInfoList.size());
|
||||
CSignalInformation* head = nullptr;
|
||||
if (infoSize > 0) {
|
||||
head = reinterpret_cast<CSignalInformation *>(malloc(sizeof(CSignalInformation) * infoSize));
|
||||
}
|
||||
if (head == nullptr && infoSize > 0) {
|
||||
TELEPHONY_LOGE("NativeGetSignalInfoList malloc failed!");
|
||||
return csignalInfoList;
|
||||
}
|
||||
int i = 0;
|
||||
for (const sptr<SignalInformation> infoItem : signalInfoList) {
|
||||
int32_t signalType = static_cast<int32_t>(NetworkType::NETWORK_TYPE_UNKNOWN);
|
||||
int32_t signalLevel = 0;
|
||||
int32_t signalIntensity = 0;
|
||||
if (infoItem != nullptr) {
|
||||
signalType = WrapSignalInformationType(infoItem->GetNetworkType());
|
||||
signalLevel = infoItem->GetSignalLevel();
|
||||
signalIntensity = infoItem->GetSignalIntensity();
|
||||
}
|
||||
head[i].signalType = signalType;
|
||||
head[i].signalLevel = signalLevel;
|
||||
head[i].dBm = signalIntensity;
|
||||
i++;
|
||||
}
|
||||
csignalInfoList.size = static_cast<int64_t>(infoSize);
|
||||
csignalInfoList.head = head;
|
||||
return csignalInfoList;
|
||||
}
|
||||
|
||||
bool TelephonyRadioImpl::IsNRSupported()
|
||||
{
|
||||
bool isNrSupported = false;
|
||||
TelephonyConfig telephonyConfig;
|
||||
isNrSupported =
|
||||
telephonyConfig.IsCapabilitySupport(
|
||||
static_cast<int32_t>(TelephonyConfig::ConfigType::MODEM_CAP_SUPPORT_NR));
|
||||
#ifdef OHOS_BUILD_ENABLE_TELEPHONY_EXT
|
||||
TELEPHONY_EXT_UTILS_WRAPPER.InitTelephonyExtUtilsWrapper();
|
||||
if (TELEPHONY_EXT_UTILS_WRAPPER.isChipsetNrSupported_ != nullptr) {
|
||||
isNrSupported = isNrSupported && TELEPHONY_EXT_UTILS_WRAPPER.isChipsetNrSupported_();
|
||||
}
|
||||
#endif
|
||||
return isNrSupported;
|
||||
}
|
||||
|
||||
bool TelephonyRadioImpl::IsRadioOn(int32_t slotId, int32_t &errCode)
|
||||
{
|
||||
bool result = false;
|
||||
if (!IsValidSlotId(slotId)) {
|
||||
TELEPHONY_LOGE("NativeIsRadioOn slotId is invalid");
|
||||
errCode = ConvertCJErrCode(ERROR_SLOT_ID_INVALID);
|
||||
return result;
|
||||
}
|
||||
auto radioOnContext = std::make_unique<IsRadioOnContext>();
|
||||
auto asyncContext = static_cast<IsRadioOnContext *>(radioOnContext.get());
|
||||
asyncContext->slotId = slotId;
|
||||
std::unique_ptr<GetRadioStateCallback> callback = std::make_unique<GetRadioStateCallback>(asyncContext);
|
||||
std::unique_lock<std::mutex> callbackLock(asyncContext->callbackMutex);
|
||||
asyncContext->errorCode =
|
||||
DelayedRefSingleton<CoreServiceClient>::GetInstance().GetRadioState(slotId, callback.release());
|
||||
if (asyncContext->errorCode == TELEPHONY_SUCCESS) {
|
||||
asyncContext->cv.wait_for(
|
||||
callbackLock,
|
||||
std::chrono::seconds(WAIT_TIME_SECOND),
|
||||
[asyncContext] { return asyncContext->callbackEnd; });
|
||||
TELEPHONY_LOGI("NativeIsRadioOn after callback end");
|
||||
}
|
||||
errCode = ConvertCJErrCode(asyncContext->errorCode);
|
||||
result = asyncContext->isRadioOn;
|
||||
return result;
|
||||
}
|
||||
|
||||
char* TelephonyRadioImpl::GetOperatorName(int32_t slotId, int32_t &errCode)
|
||||
{
|
||||
if (!IsValidSlotId(slotId)) {
|
||||
TELEPHONY_LOGE("NativeGetOperatorName slotId is invalid");
|
||||
errCode = ConvertCJErrCode(ERROR_SLOT_ID_INVALID);
|
||||
return nullptr;
|
||||
}
|
||||
std::u16string u16OperatorName = u"";
|
||||
errCode =
|
||||
DelayedRefSingleton<CoreServiceClient>::GetInstance().GetOperatorName(slotId, u16OperatorName);
|
||||
errCode = ConvertCJErrCode(errCode);
|
||||
std::string operatorName = ToUtf8(u16OperatorName);
|
||||
if (operatorName.size() > BUF_SIZE) {
|
||||
operatorName = operatorName.substr(0, BUF_SIZE);
|
||||
}
|
||||
char* result = MallocCString(operatorName);
|
||||
return result;
|
||||
}
|
||||
}
|
||||
}
|
45
frameworks/cj/telephony_radio/src/telephony_radio_impl.h
Normal file
45
frameworks/cj/telephony_radio/src/telephony_radio_impl.h
Normal file
@ -0,0 +1,45 @@
|
||||
/*
|
||||
* Copyright (c) 2024 Huawei Device Co., Ltd.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
#ifndef TELEPHONY_RADIO_IMPL_H
|
||||
#define TELEPHONY_RADIO_IMPL_H
|
||||
|
||||
#include "telephony_radio_utils.h"
|
||||
|
||||
#include "network_search_types.h"
|
||||
#include "network_state.h"
|
||||
#include "signal_information.h"
|
||||
#include "telephony_napi_common_error.h"
|
||||
#include "telephony_radio_callback.h"
|
||||
#include "telephony_types.h"
|
||||
|
||||
namespace OHOS {
|
||||
namespace Telephony {
|
||||
|
||||
class TelephonyRadioImpl {
|
||||
public:
|
||||
static CNetworkRadioTech GetRadioTech(int32_t slotId, int32_t &errCode);
|
||||
static CNetworkState GetNetworkState(int32_t slotId, int32_t &errCode);
|
||||
static int32_t GetNetworkSelectionMode(int32_t slotId, int32_t &errCode);
|
||||
static char* GetISOCountryCodeForNetwork(int32_t slotId, int32_t &errCode);
|
||||
static int32_t GetPrimarySlotId(int32_t &errCode);
|
||||
static CArraySignalInformation GetSignalInfoList(int32_t slotId, int32_t &errCode);
|
||||
static bool IsNRSupported();
|
||||
static bool IsRadioOn(int32_t slotId, int32_t &errCode);
|
||||
static char* GetOperatorName(int32_t slotId, int32_t &errCode);
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
350
frameworks/cj/telephony_radio/src/telephony_radio_utils.h
Normal file
350
frameworks/cj/telephony_radio/src/telephony_radio_utils.h
Normal file
@ -0,0 +1,350 @@
|
||||
/*
|
||||
* Copyright (c) 2024 Huawei Device Co., Ltd.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#ifndef TELEPHONY_RADIO_UTILS_H
|
||||
#define TELEPHONY_RADIO_UTILS_H
|
||||
|
||||
#include <condition_variable>
|
||||
#include <locale>
|
||||
#include <mutex>
|
||||
#include <string>
|
||||
|
||||
#include "telephony_errors.h"
|
||||
#include "telephony_napi_common_error.h"
|
||||
#include "telephony_types.h"
|
||||
|
||||
namespace OHOS {
|
||||
namespace Telephony {
|
||||
constexpr int DEFAULT_ERROR = ERROR_SERVICE_UNAVAILABLE;
|
||||
constexpr int BUF_SIZE = 32;
|
||||
constexpr int WAIT_TIME_SECOND = 60 * 3;
|
||||
|
||||
inline char* MallocCString(const std::string& origin)
|
||||
{
|
||||
if (origin.empty()) {
|
||||
return nullptr;
|
||||
}
|
||||
auto lenth = origin.length() + 1;
|
||||
char* res = static_cast<char*>(malloc(sizeof(char) * lenth));
|
||||
if (res == nullptr) {
|
||||
return nullptr;
|
||||
}
|
||||
return std::char_traits<char>::copy(res, origin.c_str(), lenth);
|
||||
}
|
||||
|
||||
struct CNetworkRadioTech {
|
||||
int32_t psRadioTech;
|
||||
int32_t csRadioTech;
|
||||
};
|
||||
|
||||
enum class NetworkType : int32_t {
|
||||
/**
|
||||
* Indicates unknown network type.
|
||||
*/
|
||||
NETWORK_TYPE_UNKNOWN,
|
||||
|
||||
/**
|
||||
* Indicates that the network type is GSM.
|
||||
*/
|
||||
NETWORK_TYPE_GSM,
|
||||
|
||||
/**
|
||||
* Indicates that the network type is CDMA.
|
||||
*/
|
||||
NETWORK_TYPE_CDMA,
|
||||
|
||||
/**
|
||||
* Indicates that the network type is WCDMA.
|
||||
*/
|
||||
NETWORK_TYPE_WCDMA,
|
||||
|
||||
/**
|
||||
* Indicates that the network type is TD-SCDMA.
|
||||
*/
|
||||
NETWORK_TYPE_TDSCDMA,
|
||||
|
||||
/**
|
||||
* Indicates that the network type is LTE.
|
||||
*/
|
||||
NETWORK_TYPE_LTE,
|
||||
|
||||
/**
|
||||
* Indicates that the network type is 5G NR.
|
||||
*/
|
||||
NETWORK_TYPE_NR
|
||||
};
|
||||
|
||||
enum class RatType : int32_t {
|
||||
/**
|
||||
* Indicates the invalid value.
|
||||
*/
|
||||
RADIO_TECHNOLOGY_INVALID = -1,
|
||||
|
||||
/**
|
||||
* Indicates unknown radio access technology (RAT).
|
||||
*/
|
||||
RADIO_TECHNOLOGY_UNKNOWN = 0,
|
||||
|
||||
/**
|
||||
* Indicates that RAT is global system for mobile communications (GSM),
|
||||
* including GSM, general packet radio system (GPRS), and enhanced data rates
|
||||
* for GSM evolution (EDGE).
|
||||
*/
|
||||
RADIO_TECHNOLOGY_GSM = 1,
|
||||
|
||||
/**
|
||||
* Indicates that RAT is code division multiple access (CDMA), including
|
||||
* Interim Standard 95 (IS95) and Single-Carrier Radio Transmission Technology
|
||||
* (1xRTT).
|
||||
*/
|
||||
RADIO_TECHNOLOGY_1XRTT = 2,
|
||||
|
||||
/**
|
||||
* Indicates that RAT is wideband code division multiple address (WCDMA).
|
||||
*/
|
||||
RADIO_TECHNOLOGY_WCDMA = 3,
|
||||
|
||||
/**
|
||||
* Indicates that RAT is high-speed packet access (HSPA), including HSPA,
|
||||
* high-speed downlink packet access (HSDPA), and high-speed uplink packet
|
||||
* access (HSUPA).
|
||||
*/
|
||||
RADIO_TECHNOLOGY_HSPA = 4,
|
||||
|
||||
/**
|
||||
* Indicates that RAT is evolved high-speed packet access (HSPA+), including
|
||||
* HSPA+ and dual-carrier HSPA+ (DC-HSPA+).
|
||||
*/
|
||||
RADIO_TECHNOLOGY_HSPAP = 5,
|
||||
|
||||
/**
|
||||
* Indicates that RAT is time division-synchronous code division multiple
|
||||
* access (TD-SCDMA).
|
||||
*/
|
||||
RADIO_TECHNOLOGY_TD_SCDMA = 6,
|
||||
|
||||
/**
|
||||
* Indicates that RAT is evolution data only (EVDO), including EVDO Rev.0,
|
||||
* EVDO Rev.A, and EVDO Rev.B.
|
||||
*/
|
||||
RADIO_TECHNOLOGY_EVDO = 7,
|
||||
|
||||
/**
|
||||
* Indicates that RAT is evolved high rate packet data (EHRPD).
|
||||
*/
|
||||
RADIO_TECHNOLOGY_EHRPD = 8,
|
||||
|
||||
/**
|
||||
* Indicates that RAT is long term evolution (LTE).
|
||||
*/
|
||||
RADIO_TECHNOLOGY_LTE = 9,
|
||||
|
||||
/**
|
||||
* Indicates that RAT is LTE carrier aggregation (LTE-CA).
|
||||
*/
|
||||
RADIO_TECHNOLOGY_LTE_CA = 10,
|
||||
|
||||
/**
|
||||
* Indicates that RAT is interworking WLAN (I-WLAN).
|
||||
*/
|
||||
RADIO_TECHNOLOGY_IWLAN = 11,
|
||||
|
||||
/**
|
||||
* Indicates that RAT is 5G new radio (NR).
|
||||
*/
|
||||
RADIO_TECHNOLOGY_NR = 12,
|
||||
|
||||
/**
|
||||
* Indicates the max value.
|
||||
*/
|
||||
RADIO_TECHNOLOGY_MAX = RADIO_TECHNOLOGY_NR,
|
||||
};
|
||||
|
||||
enum class NsaState : int32_t {
|
||||
/**
|
||||
* Indicates that a device is idle under or is connected to an LTE cell that does not support NSA.
|
||||
*/
|
||||
NSA_STATE_NOT_SUPPORT = 1,
|
||||
|
||||
/**
|
||||
* Indicates that a device is idle under an LTE cell supporting NSA but not NR coverage detection.
|
||||
*/
|
||||
NSA_STATE_NO_DETECT = 2,
|
||||
|
||||
/**
|
||||
* Indicates that a device is connected to an LTE network under an LTE cell
|
||||
* that supports NSA and NR coverage detection.
|
||||
*/
|
||||
NSA_STATE_CONNECTED_DETECT = 3,
|
||||
|
||||
/**
|
||||
* Indicates that a device is idle under an LTE cell supporting NSA and NR coverage detection.
|
||||
*/
|
||||
NSA_STATE_IDLE_DETECT = 4,
|
||||
|
||||
/**
|
||||
* Indicates that a device is connected to an LTE + NR network under an LTE cell that supports NSA.
|
||||
*/
|
||||
NSA_STATE_DUAL_CONNECTED = 5,
|
||||
|
||||
/**
|
||||
* Indicates that a device is idle under or is connected to an NG-RAN cell while being attached to 5GC.
|
||||
*/
|
||||
NSA_STATE_SA_ATTACHED = 6
|
||||
};
|
||||
|
||||
enum CJErrorCode {
|
||||
/**
|
||||
* The input parameter value is out of range.
|
||||
*/
|
||||
CJ_ERROR_TELEPHONY_ARGUMENT_ERROR = 8300001,
|
||||
|
||||
/**
|
||||
* Operation failed. Cannot connect to service.
|
||||
*/
|
||||
CJ_ERROR_TELEPHONY_SERVICE_ERROR = 8300002,
|
||||
|
||||
/**
|
||||
* System internal error.
|
||||
*/
|
||||
CJ_ERROR_TELEPHONY_SYSTEM_ERROR = 8300003,
|
||||
|
||||
/**
|
||||
* Do not have sim card.
|
||||
*/
|
||||
CJ_ERROR_TELEPHONY_NO_SIM_CARD = 8300004,
|
||||
|
||||
/**
|
||||
* Airplane mode is on.
|
||||
*/
|
||||
CJ_ERROR_TELEPHONY_AIRPLANE_MODE_ON = 8300005,
|
||||
|
||||
/**
|
||||
* Network not in service.
|
||||
*/
|
||||
CJ_ERROR_TELEPHONY_NETWORK_NOT_IN_SERVICE = 8300006,
|
||||
|
||||
/**
|
||||
* Unknown error code.
|
||||
*/
|
||||
CJ_ERROR_TELEPHONY_UNKNOW_ERROR = 8300999,
|
||||
|
||||
/**
|
||||
* SIM card is not activated.
|
||||
*/
|
||||
CJ_ERROR_SIM_CARD_IS_NOT_ACTIVE = 8301001,
|
||||
|
||||
/**
|
||||
* SIM card operation error.
|
||||
*/
|
||||
CJ_ERROR_SIM_CARD_OPERATION_ERROR = 8301002,
|
||||
|
||||
/**
|
||||
* Operator config error.
|
||||
*/
|
||||
CJ_ERROR_OPERATOR_CONFIG_ERROR = 8301003,
|
||||
|
||||
/**
|
||||
* Permission verification failed, usually the result returned by VerifyAccessToken.
|
||||
*/
|
||||
CJ_ERROR_TELEPHONY_PERMISSION_DENIED = 201,
|
||||
|
||||
/**
|
||||
* Permission verification failed, application which is not a system application uses system API.
|
||||
*/
|
||||
CJ_ERROR_ILLEGAL_USE_OF_SYSTEM_API = 202,
|
||||
};
|
||||
|
||||
struct CNetworkState {
|
||||
char* longOperatorName;
|
||||
char* shortOperatorName;
|
||||
char* plmnNumeric;
|
||||
bool isRoaming;
|
||||
int32_t regState;
|
||||
int32_t cfgTech;
|
||||
int32_t nsaState;
|
||||
bool isCaActive;
|
||||
bool isEmergency;
|
||||
};
|
||||
|
||||
struct CSignalInformation {
|
||||
int32_t signalType;
|
||||
int32_t signalLevel;
|
||||
int32_t dBm;
|
||||
};
|
||||
|
||||
struct CArraySignalInformation {
|
||||
CSignalInformation* head;
|
||||
int64_t size;
|
||||
};
|
||||
|
||||
struct CallbackContext {
|
||||
std::mutex callbackMutex;
|
||||
std::condition_variable cv;
|
||||
bool callbackEnd = false;
|
||||
bool sendRequest = false;
|
||||
bool resolved = false;
|
||||
int32_t errorCode = ERROR_DEFAULT;
|
||||
};
|
||||
|
||||
struct GetSelectModeContext : CallbackContext {
|
||||
int32_t slotId = DEFAULT_SIM_SLOT_ID;
|
||||
int32_t selectMode = DEFAULT_ERROR;
|
||||
};
|
||||
|
||||
struct IsRadioOnContext : CallbackContext {
|
||||
int32_t slotId = DEFAULT_SIM_SLOT_ID;
|
||||
bool isRadioOn = false;
|
||||
bool sendRequestSlot2 = false;
|
||||
};
|
||||
|
||||
enum NativeSelectionMode { NATIVE_NETWORK_SELECTION_AUTOMATIC = 0, NATIVE_NETWORK_SELECTION_MANUAL = 1 };
|
||||
|
||||
enum NetworkSelectionMode {
|
||||
/** Unknown network selection modes. */
|
||||
NETWORK_SELECTION_UNKNOWN,
|
||||
|
||||
/** Automatic network selection modes. */
|
||||
NETWORK_SELECTION_AUTOMATIC,
|
||||
|
||||
/** Manual network selection modes. */
|
||||
NETWORK_SELECTION_MANUAL
|
||||
};
|
||||
|
||||
enum RegStatus {
|
||||
/**
|
||||
* Indicates a state in which a device cannot use any service.
|
||||
*/
|
||||
REGISTRATION_STATE_NO_SERVICE = 0,
|
||||
|
||||
/**
|
||||
* Indicates a state in which a device can use services properly.
|
||||
*/
|
||||
REGISTRATION_STATE_IN_SERVICE = 1,
|
||||
|
||||
/**
|
||||
* Indicates a state in which a device can use only the emergency call service.
|
||||
*/
|
||||
REGISTRATION_STATE_EMERGENCY_CALL_ONLY = 2,
|
||||
|
||||
/**
|
||||
* Indicates that the cellular radio is powered off.
|
||||
*/
|
||||
REGISTRATION_STATE_POWER_OFF = 3
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
62
frameworks/cj/telephony_sim/BUILD.gn
Normal file
62
frameworks/cj/telephony_sim/BUILD.gn
Normal file
@ -0,0 +1,62 @@
|
||||
# Copyright (C) 2024 Huawei Device Co., Ltd.
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
import("//build/ohos.gni")
|
||||
SUBSYSTEM_DIR = "../../../../"
|
||||
import("$SUBSYSTEM_DIR/core_service/telephony_core_service.gni")
|
||||
|
||||
ohos_shared_library("cj_sim_ffi") {
|
||||
sanitize = {
|
||||
cfi = true
|
||||
cfi_cross_dso = true
|
||||
debug = false
|
||||
}
|
||||
|
||||
branch_protector_ret = "pac_ret"
|
||||
|
||||
include_dirs = [
|
||||
"$SUBSYSTEM_DIR/core_service/interfaces/kits/native",
|
||||
"$SUBSYSTEM_DIR/core_service/interfaces/innerkits/include",
|
||||
]
|
||||
|
||||
sources = [
|
||||
"src/telephony_sim_ffi.cpp",
|
||||
"src/telephony_sim_impl.cpp",
|
||||
]
|
||||
|
||||
configs = [ "$SUBSYSTEM_DIR/core_service/utils:telephony_log_config" ]
|
||||
|
||||
deps = [
|
||||
"$SUBSYSTEM_DIR/core_service/interfaces/innerkits:tel_core_service_api",
|
||||
"$SUBSYSTEM_DIR/core_service/utils:libtel_common",
|
||||
]
|
||||
|
||||
external_deps = [
|
||||
"ability_runtime:abilitykit_native",
|
||||
"c_utils:utils",
|
||||
"hilog:libhilog",
|
||||
"init:libbegetutil",
|
||||
"ipc:ipc_single",
|
||||
"napi:ace_napi",
|
||||
"napi:cj_bind_ffi",
|
||||
]
|
||||
|
||||
defines = [
|
||||
"TELEPHONY_LOG_TAG = \"CoreServiceSimFfiApi\"",
|
||||
"LOG_DOMAIN = 0xD001F04",
|
||||
]
|
||||
|
||||
innerapi_tags = [ "platformsdk" ]
|
||||
part_name = "core_service"
|
||||
subsystem_name = "telephony"
|
||||
}
|
100
frameworks/cj/telephony_sim/src/telephony_sim_ffi.cpp
Normal file
100
frameworks/cj/telephony_sim/src/telephony_sim_ffi.cpp
Normal file
@ -0,0 +1,100 @@
|
||||
/*
|
||||
* Copyright (c) 2024 Huawei Device Co., Ltd.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#include "telephony_sim_ffi.h"
|
||||
|
||||
using namespace OHOS::FFI;
|
||||
|
||||
namespace OHOS {
|
||||
namespace Telephony {
|
||||
extern "C" {
|
||||
|
||||
bool FfiTelephonySimIsSimActive(int32_t slotId, int32_t *errCode)
|
||||
{
|
||||
return TelephonySimImpl::IsSimActive(slotId, *errCode);
|
||||
}
|
||||
|
||||
int32_t FfiTelephonySimGetDefaultVoiceSlotId()
|
||||
{
|
||||
return TelephonySimImpl::getDefaultVoiceSlotId();
|
||||
}
|
||||
|
||||
bool FfiTelephonySimHasOperatorPrivileges(int32_t slotId, int32_t *errCode)
|
||||
{
|
||||
return TelephonySimImpl::hasOperatorPrivileges(slotId, *errCode);
|
||||
}
|
||||
|
||||
char* FfiTelephonySimGetISOCountryCodeForSim(int32_t slotId, int32_t *errCode)
|
||||
{
|
||||
return TelephonySimImpl::getISOCountryCodeForSim(slotId, *errCode);
|
||||
}
|
||||
|
||||
char* FfiTelephonySimGetSimOperatorNumeric(int32_t slotId, int32_t *errCode)
|
||||
{
|
||||
return TelephonySimImpl::getSimOperatorNumeric(slotId, *errCode);
|
||||
}
|
||||
|
||||
char* FfiTelephonySimGetSimSpn(int32_t slotId, int32_t *errCode)
|
||||
{
|
||||
return TelephonySimImpl::getSimSpn(slotId, *errCode);
|
||||
}
|
||||
|
||||
int32_t FfiTelephonySimGetSimState(int32_t slotId, int32_t *errCode)
|
||||
{
|
||||
return TelephonySimImpl::getSimState(slotId, *errCode);
|
||||
}
|
||||
|
||||
int32_t FfiTelephonySimGetCardType(int32_t slotId, int32_t *errCode)
|
||||
{
|
||||
return TelephonySimImpl::getCardType(slotId, *errCode);
|
||||
}
|
||||
|
||||
bool FfiTelephonySimHasSimCard(int32_t slotId, int32_t *errCode)
|
||||
{
|
||||
return TelephonySimImpl::hasSimCard(slotId, *errCode);
|
||||
}
|
||||
|
||||
CIccAccountInfo FfiTelephonySimGetSimAccountInfo(int32_t slotId, int32_t *errCode)
|
||||
{
|
||||
return TelephonySimImpl::getSimAccountInfo(slotId, *errCode);
|
||||
}
|
||||
|
||||
CArryIccAccountInfo FfiTelephonySimGetActiveSimAccountInfoList(int32_t *errCode)
|
||||
{
|
||||
return TelephonySimImpl::getActiveSimAccountInfoList(*errCode);
|
||||
}
|
||||
|
||||
int32_t FfiTelephonySimGetMaxSimCount()
|
||||
{
|
||||
return TelephonySimImpl::getMaxSimCount();
|
||||
}
|
||||
|
||||
char* FfiTelephonySimGetOpKey(int32_t slotId, int32_t *errCode)
|
||||
{
|
||||
return TelephonySimImpl::getOpKey(slotId, *errCode);
|
||||
}
|
||||
|
||||
char* FfiTelephonySimGetOpName(int32_t slotId, int32_t *errCode)
|
||||
{
|
||||
return TelephonySimImpl::getOpName(slotId, *errCode);
|
||||
}
|
||||
|
||||
int32_t FfiTelephonySimGetDefaultVoiceSimId(int32_t *errCode)
|
||||
{
|
||||
return TelephonySimImpl::getDefaultVoiceSimId(*errCode);
|
||||
}
|
||||
}
|
||||
} // namespace Telephony
|
||||
} // namespace OHOS
|
44
frameworks/cj/telephony_sim/src/telephony_sim_ffi.h
Normal file
44
frameworks/cj/telephony_sim/src/telephony_sim_ffi.h
Normal file
@ -0,0 +1,44 @@
|
||||
/*
|
||||
* Copyright (c) 2024 Huawei Device Co., Ltd.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#ifndef TELEPHONY_SIM_FFI_H
|
||||
#define TELEPHONY_SIM_FFI_H
|
||||
|
||||
#include "ffi_remote_data.h"
|
||||
#include "telephony_sim_impl.h"
|
||||
|
||||
namespace OHOS {
|
||||
namespace Telephony {
|
||||
extern "C" {
|
||||
FFI_EXPORT bool FfiTelephonySimIsSimActive(int32_t slotId, int32_t *errCode);
|
||||
FFI_EXPORT int32_t FfiTelephonySimGetDefaultVoiceSlotId();
|
||||
FFI_EXPORT bool FfiTelephonySimHasOperatorPrivileges(int32_t slotId, int32_t *errCode);
|
||||
FFI_EXPORT char* FfiTelephonySimGetISOCountryCodeForSim(int32_t slotId, int32_t *errCode);
|
||||
FFI_EXPORT char* FfiTelephonySimGetSimOperatorNumeric(int32_t slotId, int32_t *errCode);
|
||||
FFI_EXPORT char* FfiTelephonySimGetSimSpn(int32_t slotId, int32_t *errCode);
|
||||
FFI_EXPORT int32_t FfiTelephonySimGetSimState(int32_t slotId, int32_t *errCode);
|
||||
FFI_EXPORT int32_t FfiTelephonySimGetCardType(int32_t slotId, int32_t *errCode);
|
||||
FFI_EXPORT bool FfiTelephonySimHasSimCard(int32_t slotId, int32_t *errCode);
|
||||
FFI_EXPORT CIccAccountInfo FfiTelephonySimGetSimAccountInfo(int32_t slotId, int32_t *errCode);
|
||||
FFI_EXPORT CArryIccAccountInfo FfiTelephonySimGetActiveSimAccountInfoList(int32_t *errCode);
|
||||
FFI_EXPORT int32_t FfiTelephonySimGetMaxSimCount();
|
||||
FFI_EXPORT char* FfiTelephonySimGetOpKey(int32_t slotId, int32_t *errCode);
|
||||
FFI_EXPORT char* FfiTelephonySimGetOpName(int32_t slotId, int32_t *errCode);
|
||||
FFI_EXPORT int32_t FfiTelephonySimGetDefaultVoiceSimId(int32_t *errCode);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
347
frameworks/cj/telephony_sim/src/telephony_sim_impl.cpp
Normal file
347
frameworks/cj/telephony_sim/src/telephony_sim_impl.cpp
Normal file
@ -0,0 +1,347 @@
|
||||
/*
|
||||
* Copyright (c) 2024 Huawei Device Co., Ltd.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
|
||||
#include "telephony_sim_impl.h"
|
||||
|
||||
#include "core_service_client.h"
|
||||
#include "telephony_log_wrapper.h"
|
||||
|
||||
namespace OHOS {
|
||||
namespace Telephony {
|
||||
|
||||
inline char* MallocCString(const std::string& origin)
|
||||
{
|
||||
if (origin.empty()) {
|
||||
return nullptr;
|
||||
}
|
||||
auto lenth = origin.length() + 1;
|
||||
char* res = static_cast<char*>(malloc(sizeof(char) * lenth));
|
||||
if (res == nullptr) {
|
||||
return nullptr;
|
||||
}
|
||||
return std::char_traits<char>::copy(res, origin.c_str(), lenth);
|
||||
}
|
||||
|
||||
static int32_t ConvertCJErrCode(int32_t errCode)
|
||||
{
|
||||
switch (errCode) {
|
||||
case TELEPHONY_ERR_ARGUMENT_MISMATCH:
|
||||
case TELEPHONY_ERR_ARGUMENT_INVALID:
|
||||
case TELEPHONY_ERR_ARGUMENT_NULL:
|
||||
case TELEPHONY_ERR_SLOTID_INVALID:
|
||||
case ERROR_SLOT_ID_INVALID:
|
||||
// 83000001
|
||||
return CJ_ERROR_TELEPHONY_ARGUMENT_ERROR;
|
||||
case TELEPHONY_ERR_DESCRIPTOR_MISMATCH:
|
||||
case TELEPHONY_ERR_WRITE_DESCRIPTOR_TOKEN_FAIL:
|
||||
case TELEPHONY_ERR_WRITE_DATA_FAIL:
|
||||
case TELEPHONY_ERR_WRITE_REPLY_FAIL:
|
||||
case TELEPHONY_ERR_READ_DATA_FAIL:
|
||||
case TELEPHONY_ERR_IPC_CONNECT_STUB_FAIL:
|
||||
case TELEPHONY_ERR_REGISTER_CALLBACK_FAIL:
|
||||
case TELEPHONY_ERR_CALLBACK_ALREADY_REGISTERED:
|
||||
case TELEPHONY_ERR_UNINIT:
|
||||
case TELEPHONY_ERR_UNREGISTER_CALLBACK_FAIL:
|
||||
// 83000002
|
||||
return CJ_ERROR_TELEPHONY_SERVICE_ERROR;
|
||||
case TELEPHONY_ERR_VCARD_FILE_INVALID:
|
||||
case TELEPHONY_ERR_FAIL:
|
||||
case TELEPHONY_ERR_MEMCPY_FAIL:
|
||||
case TELEPHONY_ERR_MEMSET_FAIL:
|
||||
case TELEPHONY_ERR_STRCPY_FAIL:
|
||||
case TELEPHONY_ERR_LOCAL_PTR_NULL:
|
||||
case TELEPHONY_ERR_SUBSCRIBE_BROADCAST_FAIL:
|
||||
case TELEPHONY_ERR_PUBLISH_BROADCAST_FAIL:
|
||||
case TELEPHONY_ERR_ADD_DEATH_RECIPIENT_FAIL:
|
||||
case TELEPHONY_ERR_STRTOINT_FAIL:
|
||||
case TELEPHONY_ERR_RIL_CMD_FAIL:
|
||||
case TELEPHONY_ERR_DATABASE_WRITE_FAIL:
|
||||
case TELEPHONY_ERR_DATABASE_READ_FAIL:
|
||||
case TELEPHONY_ERR_UNKNOWN_NETWORK_TYPE:
|
||||
case ERROR_SERVICE_UNAVAILABLE:
|
||||
case ERROR_NATIVE_API_EXECUTE_FAIL:
|
||||
// 83000003
|
||||
return CJ_ERROR_TELEPHONY_SYSTEM_ERROR;
|
||||
case TELEPHONY_ERR_NO_SIM_CARD:
|
||||
// 83000004
|
||||
return CJ_ERROR_TELEPHONY_NO_SIM_CARD;
|
||||
case TELEPHONY_ERR_AIRPLANE_MODE_ON:
|
||||
// 83000005
|
||||
return CJ_ERROR_TELEPHONY_AIRPLANE_MODE_ON;
|
||||
case TELEPHONY_ERR_NETWORK_NOT_IN_SERVICE:
|
||||
// 83000006
|
||||
return CJ_ERROR_TELEPHONY_NETWORK_NOT_IN_SERVICE;
|
||||
case TELEPHONY_ERR_PERMISSION_ERR:
|
||||
// 201
|
||||
return CJ_ERROR_TELEPHONY_PERMISSION_DENIED;
|
||||
case TELEPHONY_ERR_ILLEGAL_USE_OF_SYSTEM_API:
|
||||
// 202
|
||||
return CJ_ERROR_TELEPHONY_PERMISSION_DENIED;
|
||||
default:
|
||||
return errCode;
|
||||
}
|
||||
}
|
||||
|
||||
static inline bool IsValidSlotId(int32_t slotId)
|
||||
{
|
||||
return ((slotId >= DEFAULT_SIM_SLOT_ID) && (slotId < SIM_SLOT_COUNT));
|
||||
}
|
||||
|
||||
static inline bool IsValidSlotIdEx(int32_t slotId)
|
||||
{
|
||||
// One more slot for VSim.
|
||||
return ((slotId >= DEFAULT_SIM_SLOT_ID) && (slotId < SIM_SLOT_COUNT + 1));
|
||||
}
|
||||
|
||||
static std::string ToUtf8(std::u16string str16)
|
||||
{
|
||||
std::wstring_convert<std::codecvt_utf8_utf16<char16_t>, char16_t> convert;
|
||||
// 将std::u16string转换为std::string
|
||||
std::string result = convert.to_bytes(str16);
|
||||
return result;
|
||||
}
|
||||
|
||||
bool TelephonySimImpl::IsSimActive(int32_t slotId, int32_t &errCode)
|
||||
{
|
||||
bool result = false;
|
||||
if (!IsValidSlotId(slotId)) {
|
||||
TELEPHONY_LOGE("NativeIsSimActive slotId is invalid");
|
||||
errCode = ConvertCJErrCode(ERROR_SLOT_ID_INVALID);
|
||||
return result;
|
||||
}
|
||||
result = DelayedRefSingleton<CoreServiceClient>::GetInstance().IsSimActive(slotId);
|
||||
return result;
|
||||
}
|
||||
|
||||
int32_t TelephonySimImpl::getDefaultVoiceSlotId()
|
||||
{
|
||||
int32_t slotId = -1;
|
||||
slotId = DelayedRefSingleton<CoreServiceClient>::GetInstance().GetDefaultVoiceSlotId();
|
||||
return slotId;
|
||||
}
|
||||
|
||||
bool TelephonySimImpl::hasOperatorPrivileges(int32_t slotId, int32_t &errCode)
|
||||
{
|
||||
bool hasOperatorPrivileges = false;
|
||||
if (!IsValidSlotId(slotId)) {
|
||||
TELEPHONY_LOGE("NativeHasOperatorPrivileges slotId is invalid");
|
||||
errCode = ConvertCJErrCode(ERROR_SLOT_ID_INVALID);
|
||||
return hasOperatorPrivileges;
|
||||
}
|
||||
errCode = DelayedRefSingleton<CoreServiceClient>::GetInstance().HasOperatorPrivileges(
|
||||
slotId, hasOperatorPrivileges);
|
||||
errCode = ConvertCJErrCode(errCode);
|
||||
return hasOperatorPrivileges;
|
||||
}
|
||||
|
||||
char* TelephonySimImpl::getISOCountryCodeForSim(int32_t slotId, int32_t &errCode)
|
||||
{
|
||||
if (!IsValidSlotId(slotId)) {
|
||||
TELEPHONY_LOGE("NativeGetIsoForSim slotId is invalid");
|
||||
errCode = ConvertCJErrCode(ERROR_SLOT_ID_INVALID);
|
||||
return nullptr;
|
||||
}
|
||||
std::u16string countryCode = u"";
|
||||
std::string operatorName;
|
||||
errCode = DelayedRefSingleton<CoreServiceClient>::GetInstance().GetISOCountryCodeForSim(
|
||||
slotId, countryCode);
|
||||
operatorName = errCode == ERROR_NONE ? ToUtf8(countryCode) : "";
|
||||
errCode = ConvertCJErrCode(errCode);
|
||||
char* result = MallocCString(operatorName);
|
||||
return result;
|
||||
}
|
||||
|
||||
char* TelephonySimImpl::getSimOperatorNumeric(int32_t slotId, int32_t &errCode)
|
||||
{
|
||||
if (!IsValidSlotId(slotId)) {
|
||||
TELEPHONY_LOGE("NativeGetSimOperatorNumeric slotId is invalid");
|
||||
errCode = ConvertCJErrCode(ERROR_SLOT_ID_INVALID);
|
||||
return nullptr;
|
||||
}
|
||||
std::u16string u16OperatorNumeric = u"";
|
||||
errCode = DelayedRefSingleton<CoreServiceClient>::GetInstance().GetSimOperatorNumeric(
|
||||
slotId, u16OperatorNumeric);
|
||||
std::string operatorNumeric = errCode == ERROR_NONE ? ToUtf8(u16OperatorNumeric) : "";
|
||||
errCode = ConvertCJErrCode(errCode);
|
||||
char* result = MallocCString(operatorNumeric);
|
||||
return result;
|
||||
}
|
||||
|
||||
char* TelephonySimImpl::getSimSpn(int32_t slotId, int32_t &errCode)
|
||||
{
|
||||
if (!IsValidSlotId(slotId)) {
|
||||
TELEPHONY_LOGE("NativeGetSimSpn slotId is invalid");
|
||||
errCode = ConvertCJErrCode(ERROR_SLOT_ID_INVALID);
|
||||
return nullptr;
|
||||
}
|
||||
std::u16string u16Spn = u"";
|
||||
errCode = DelayedRefSingleton<CoreServiceClient>::GetInstance().GetSimSpn(slotId, u16Spn);
|
||||
std::string spn = errCode == ERROR_NONE ? ToUtf8(u16Spn) : "";
|
||||
errCode = ConvertCJErrCode(errCode);
|
||||
char* result = MallocCString(spn);
|
||||
return result;
|
||||
}
|
||||
|
||||
int32_t TelephonySimImpl::getSimState(int32_t slotId, int32_t &errCode)
|
||||
{
|
||||
SimState simState = SimState::SIM_STATE_UNKNOWN;
|
||||
if (!IsValidSlotId(slotId)) {
|
||||
TELEPHONY_LOGE("slotId is invalid");
|
||||
errCode = ConvertCJErrCode(ERROR_SLOT_ID_INVALID);
|
||||
return static_cast<int32_t>(simState);
|
||||
}
|
||||
errCode =
|
||||
DelayedRefSingleton<CoreServiceClient>::GetInstance().GetSimState(slotId, simState);
|
||||
errCode = ConvertCJErrCode(errCode);
|
||||
return static_cast<int32_t>(simState);
|
||||
}
|
||||
|
||||
int32_t TelephonySimImpl::getCardType(int32_t slotId, int32_t &errCode)
|
||||
{
|
||||
CardType cardType = CardType::UNKNOWN_CARD;
|
||||
if (!IsValidSlotId(slotId)) {
|
||||
TELEPHONY_LOGE("NativeGetCardType slotId is invalid");
|
||||
errCode = ConvertCJErrCode(ERROR_SLOT_ID_INVALID);
|
||||
return static_cast<int32_t>(cardType);
|
||||
}
|
||||
errCode =
|
||||
DelayedRefSingleton<CoreServiceClient>::GetInstance().GetCardType(slotId, cardType);
|
||||
errCode = ConvertCJErrCode(errCode);
|
||||
return static_cast<int32_t>(cardType);
|
||||
}
|
||||
|
||||
bool TelephonySimImpl::hasSimCard(int32_t slotId, int32_t &errCode)
|
||||
{
|
||||
bool hasSimCard = false;
|
||||
if (!IsValidSlotIdEx(slotId)) {
|
||||
TELEPHONY_LOGE("slotId is invalid");
|
||||
errCode = ConvertCJErrCode(ERROR_SLOT_ID_INVALID);
|
||||
return hasSimCard;
|
||||
}
|
||||
errCode = DelayedRefSingleton<CoreServiceClient>::GetInstance().HasSimCard(slotId, hasSimCard);
|
||||
errCode = ConvertCJErrCode(errCode);
|
||||
return hasSimCard;
|
||||
}
|
||||
|
||||
static void IccAccountInfoConversion(CIccAccountInfo &accountInfo, const IccAccountInfo &iccAccountInfo)
|
||||
{
|
||||
accountInfo.simId = iccAccountInfo.simId;
|
||||
accountInfo.slotIndex = iccAccountInfo.slotIndex;
|
||||
accountInfo.isEsim = iccAccountInfo.isEsim;
|
||||
accountInfo.isActive = iccAccountInfo.isActive;
|
||||
accountInfo.iccId = MallocCString(ToUtf8(iccAccountInfo.iccId));
|
||||
accountInfo.showName = MallocCString(ToUtf8(iccAccountInfo.showName));
|
||||
accountInfo.showNumber = MallocCString(ToUtf8(iccAccountInfo.showNumber));
|
||||
}
|
||||
|
||||
CIccAccountInfo TelephonySimImpl::getSimAccountInfo(int32_t slotId, int32_t &errCode)
|
||||
{
|
||||
CIccAccountInfo accountInfo = {
|
||||
.simId = 0,
|
||||
.slotIndex = 0,
|
||||
.isEsim = false,
|
||||
.isActive = false,
|
||||
.iccId = nullptr,
|
||||
.showName = nullptr,
|
||||
.showNumber = nullptr
|
||||
};
|
||||
if (!IsValidSlotIdEx(slotId)) {
|
||||
TELEPHONY_LOGE("NativeGetSimAccountInfo slotId is invalid");
|
||||
errCode = ConvertCJErrCode(ERROR_SLOT_ID_INVALID);
|
||||
return accountInfo;
|
||||
}
|
||||
IccAccountInfo operInfo;
|
||||
errCode =
|
||||
DelayedRefSingleton<CoreServiceClient>::GetInstance().GetSimAccountInfo(slotId, operInfo);
|
||||
if (errCode == ERROR_NONE) {
|
||||
IccAccountInfoConversion(accountInfo, operInfo);
|
||||
}
|
||||
errCode = ConvertCJErrCode(errCode);
|
||||
return accountInfo;
|
||||
}
|
||||
|
||||
CArryIccAccountInfo TelephonySimImpl::getActiveSimAccountInfoList(int32_t &errCode)
|
||||
{
|
||||
std::vector<IccAccountInfo> activeInfo;
|
||||
CArryIccAccountInfo accountInfoList = {
|
||||
.head = nullptr,
|
||||
.size = 0
|
||||
};
|
||||
errCode = DelayedRefSingleton<CoreServiceClient>::GetInstance().GetActiveSimAccountInfoList(activeInfo);
|
||||
if (errCode == ERROR_NONE) {
|
||||
size_t infoSize = activeInfo.size();
|
||||
CIccAccountInfo* head = nullptr;
|
||||
if (infoSize > 0) {
|
||||
head = reinterpret_cast<CIccAccountInfo *>(malloc(sizeof(CIccAccountInfo) * infoSize));
|
||||
}
|
||||
if (head == nullptr && infoSize > 0) {
|
||||
TELEPHONY_LOGE("NativeGetSimAccountInfo malloc failed!");
|
||||
return accountInfoList;
|
||||
}
|
||||
for (size_t i = 0; i < infoSize; i++) {
|
||||
IccAccountInfoConversion(head[i], activeInfo.at(i));
|
||||
}
|
||||
accountInfoList.head = head;
|
||||
accountInfoList.size = static_cast<int64_t>(infoSize);
|
||||
}
|
||||
errCode = ConvertCJErrCode(errCode);
|
||||
return accountInfoList;
|
||||
}
|
||||
|
||||
int32_t TelephonySimImpl::getMaxSimCount()
|
||||
{
|
||||
return DelayedRefSingleton<CoreServiceClient>::GetInstance().GetMaxSimCount();
|
||||
}
|
||||
|
||||
char* TelephonySimImpl::getOpKey(int32_t slotId, int32_t &errCode)
|
||||
{
|
||||
if (!IsValidSlotId(slotId)) {
|
||||
TELEPHONY_LOGE("NativeGetOpKey slotId is invalid");
|
||||
errCode = ConvertCJErrCode(ERROR_SLOT_ID_INVALID);
|
||||
return nullptr;
|
||||
}
|
||||
std::u16string u16Opkey = u"";
|
||||
errCode = DelayedRefSingleton<CoreServiceClient>::GetInstance().GetOpKey(slotId, u16Opkey);
|
||||
std::string opkey = errCode == ERROR_NONE ? ToUtf8(u16Opkey) : "";
|
||||
errCode = ConvertCJErrCode(errCode);
|
||||
char* result = MallocCString(opkey);
|
||||
return result;
|
||||
}
|
||||
|
||||
char* TelephonySimImpl::getOpName(int32_t slotId, int32_t &errCode)
|
||||
{
|
||||
if (!IsValidSlotId(slotId)) {
|
||||
TELEPHONY_LOGE("NativeGetOpName slotId is invalid");
|
||||
errCode = ConvertCJErrCode(ERROR_SLOT_ID_INVALID);
|
||||
return nullptr;
|
||||
}
|
||||
std::u16string u16OpName = u"";
|
||||
errCode = DelayedRefSingleton<CoreServiceClient>::GetInstance().GetOpName(slotId, u16OpName);
|
||||
std::string opName = errCode == ERROR_NONE ? ToUtf8(u16OpName) : "";
|
||||
errCode = ConvertCJErrCode(errCode);
|
||||
char* result = MallocCString(opName);
|
||||
return result;
|
||||
}
|
||||
|
||||
int32_t TelephonySimImpl::getDefaultVoiceSimId(int32_t &errCode)
|
||||
{
|
||||
int32_t simId = 0;
|
||||
errCode = DelayedRefSingleton<CoreServiceClient>::GetInstance().GetDefaultVoiceSimId(simId);
|
||||
errCode = ConvertCJErrCode(errCode);
|
||||
return simId;
|
||||
}
|
||||
}
|
||||
}
|
47
frameworks/cj/telephony_sim/src/telephony_sim_impl.h
Normal file
47
frameworks/cj/telephony_sim/src/telephony_sim_impl.h
Normal file
@ -0,0 +1,47 @@
|
||||
/*
|
||||
* Copyright (c) 2024 Huawei Device Co., Ltd.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
#ifndef TELEPHONY_SIM_IMPL_H
|
||||
#define TELEPHONY_SIM_IMPL_H
|
||||
|
||||
#include "sim_state_type.h"
|
||||
#include "telephony_napi_common_error.h"
|
||||
#include "telephony_sim_utils.h"
|
||||
#include "telephony_types.h"
|
||||
|
||||
namespace OHOS {
|
||||
namespace Telephony {
|
||||
|
||||
class TelephonySimImpl {
|
||||
public:
|
||||
static bool IsSimActive(int32_t slotId, int32_t &errCode);
|
||||
static int32_t getDefaultVoiceSlotId();
|
||||
static bool hasOperatorPrivileges(int32_t slotId, int32_t &errCode);
|
||||
static char* getISOCountryCodeForSim(int32_t slotId, int32_t &errCode);
|
||||
static char* getSimOperatorNumeric(int32_t slotId, int32_t &errCode);
|
||||
static char* getSimSpn(int32_t slotId, int32_t &errCode);
|
||||
static int32_t getSimState(int32_t slotId, int32_t &errCode);
|
||||
static int32_t getCardType(int32_t slotId, int32_t &errCode);
|
||||
static bool hasSimCard(int32_t slotId, int32_t &errCode);
|
||||
static CIccAccountInfo getSimAccountInfo(int32_t slotId, int32_t &errCode);
|
||||
static CArryIccAccountInfo getActiveSimAccountInfoList(int32_t &errCode);
|
||||
static int32_t getMaxSimCount();
|
||||
static char* getOpKey(int32_t slotId, int32_t &errCode);
|
||||
static char* getOpName(int32_t slotId, int32_t &errCode);
|
||||
static int32_t getDefaultVoiceSimId(int32_t &errCode);
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
130
frameworks/cj/telephony_sim/src/telephony_sim_utils.h
Normal file
130
frameworks/cj/telephony_sim/src/telephony_sim_utils.h
Normal file
@ -0,0 +1,130 @@
|
||||
/*
|
||||
* Copyright (c) 2024 Huawei Device Co., Ltd.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#ifndef TELEPHONY_RADIO_UTILS_H
|
||||
#define TELEPHONY_RADIO_UTILS_H
|
||||
|
||||
#include <condition_variable>
|
||||
#include <locale>
|
||||
#include <mutex>
|
||||
#include <string>
|
||||
|
||||
#include "telephony_errors.h"
|
||||
#include "telephony_napi_common_error.h"
|
||||
#include "telephony_types.h"
|
||||
|
||||
namespace OHOS {
|
||||
namespace Telephony {
|
||||
enum CJErrorCode {
|
||||
/**
|
||||
* The input parameter value is out of range.
|
||||
*/
|
||||
CJ_ERROR_TELEPHONY_ARGUMENT_ERROR = 8300001,
|
||||
|
||||
/**
|
||||
* Operation failed. Cannot connect to service.
|
||||
*/
|
||||
CJ_ERROR_TELEPHONY_SERVICE_ERROR = 8300002,
|
||||
|
||||
/**
|
||||
* System internal error.
|
||||
*/
|
||||
CJ_ERROR_TELEPHONY_SYSTEM_ERROR = 8300003,
|
||||
|
||||
/**
|
||||
* Do not have sim card.
|
||||
*/
|
||||
CJ_ERROR_TELEPHONY_NO_SIM_CARD = 8300004,
|
||||
|
||||
/**
|
||||
* Airplane mode is on.
|
||||
*/
|
||||
CJ_ERROR_TELEPHONY_AIRPLANE_MODE_ON = 8300005,
|
||||
|
||||
/**
|
||||
* Network not in service.
|
||||
*/
|
||||
CJ_ERROR_TELEPHONY_NETWORK_NOT_IN_SERVICE = 8300006,
|
||||
|
||||
/**
|
||||
* Unknown error code.
|
||||
*/
|
||||
CJ_ERROR_TELEPHONY_UNKNOW_ERROR = 8300999,
|
||||
|
||||
/**
|
||||
* SIM card is not activated.
|
||||
*/
|
||||
CJ_ERROR_SIM_CARD_IS_NOT_ACTIVE = 8301001,
|
||||
|
||||
/**
|
||||
* SIM card operation error.
|
||||
*/
|
||||
CJ_ERROR_SIM_CARD_OPERATION_ERROR = 8301002,
|
||||
|
||||
/**
|
||||
* Operator config error.
|
||||
*/
|
||||
CJ_ERROR_OPERATOR_CONFIG_ERROR = 8301003,
|
||||
|
||||
/**
|
||||
* Permission verification failed, usually the result returned by VerifyAccessToken.
|
||||
*/
|
||||
CJ_ERROR_TELEPHONY_PERMISSION_DENIED = 201,
|
||||
|
||||
/**
|
||||
* Permission verification failed, application which is not a system application uses system API.
|
||||
*/
|
||||
CJ_ERROR_ILLEGAL_USE_OF_SYSTEM_API = 202,
|
||||
};
|
||||
|
||||
struct CIccAccountInfo {
|
||||
/**
|
||||
* SIM Id for card
|
||||
*/
|
||||
int32_t simId;
|
||||
/**
|
||||
* Slot index for card
|
||||
*/
|
||||
int32_t slotIndex;
|
||||
/**
|
||||
* Mark card is eSim or not
|
||||
*/
|
||||
bool isEsim;
|
||||
/**
|
||||
* Active status for card
|
||||
*/
|
||||
bool isActive;
|
||||
/**
|
||||
* IccId for card
|
||||
*/
|
||||
char* iccId;
|
||||
/**
|
||||
* Show name for card
|
||||
*/
|
||||
char* showName;
|
||||
/**
|
||||
* Show number for card
|
||||
*/
|
||||
char* showNumber;
|
||||
};
|
||||
|
||||
struct CArryIccAccountInfo {
|
||||
CIccAccountInfo* head;
|
||||
int64_t size;
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
69
frameworks/js/esim/BUILD.gn
Normal file
69
frameworks/js/esim/BUILD.gn
Normal file
@ -0,0 +1,69 @@
|
||||
# Copyright (C) 2024 Huawei Device Co., Ltd.
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
import("//build/ohos.gni")
|
||||
SUBSYSTEM_DIR = "../../../../"
|
||||
import("$SUBSYSTEM_DIR/core_service/telephony_core_service.gni")
|
||||
|
||||
ohos_shared_library("esim") {
|
||||
sanitize = {
|
||||
cfi = true
|
||||
cfi_cross_dso = true
|
||||
debug = false
|
||||
}
|
||||
branch_protector_ret = "pac_ret"
|
||||
if (core_service_support_esim) {
|
||||
include_dirs = [
|
||||
"include",
|
||||
"$SUBSYSTEM_DIR/core_service/frameworks/js/napi",
|
||||
"$SUBSYSTEM_DIR/core_service/interfaces/kits/native",
|
||||
"$SUBSYSTEM_DIR/core_service/interfaces/innerkits/include",
|
||||
]
|
||||
|
||||
sources = [
|
||||
"$SUBSYSTEM_DIR/core_service/frameworks/js/napi/napi_util.cpp",
|
||||
"$SUBSYSTEM_DIR/core_service/frameworks/native/src/download_profile_config_info_parcel.cpp",
|
||||
"$SUBSYSTEM_DIR/core_service/frameworks/native/src/download_profile_result_parcel.cpp",
|
||||
"$SUBSYSTEM_DIR/core_service/frameworks/native/src/downloadable_profile_parcel.cpp",
|
||||
"$SUBSYSTEM_DIR/core_service/frameworks/native/src/euicc_info_parcel.cpp",
|
||||
"$SUBSYSTEM_DIR/core_service/frameworks/native/src/get_downloadable_profiles_result_parcel.cpp",
|
||||
"$SUBSYSTEM_DIR/core_service/frameworks/native/src/profile_info_list_parcel.cpp",
|
||||
"$SUBSYSTEM_DIR/core_service/frameworks/native/src/profile_metadata_result_parcel.cpp",
|
||||
"$SUBSYSTEM_DIR/core_service/frameworks/native/src/response_esim_result.cpp",
|
||||
"src/napi_esim.cpp",
|
||||
]
|
||||
}
|
||||
|
||||
configs = [ "$SUBSYSTEM_DIR/core_service/utils:telephony_log_config" ]
|
||||
|
||||
deps = [
|
||||
"$SUBSYSTEM_DIR/core_service/interfaces/innerkits:tel_core_service_api",
|
||||
"$SUBSYSTEM_DIR/core_service/utils:libtel_common",
|
||||
]
|
||||
|
||||
external_deps = [
|
||||
"ability_runtime:abilitykit_native",
|
||||
"c_utils:utils",
|
||||
"hilog:libhilog",
|
||||
"init:libbegetutil",
|
||||
"ipc:ipc_single",
|
||||
"napi:ace_napi",
|
||||
]
|
||||
|
||||
defines = [
|
||||
"TELEPHONY_LOG_TAG = \"CoreServiceEsimJsApi\"",
|
||||
"LOG_DOMAIN = 0xD001F04",
|
||||
]
|
||||
subsystem_name = "telephony"
|
||||
part_name = "core_service"
|
||||
relative_install_dir = "module/telephony"
|
||||
}
|
128
frameworks/js/esim/include/napi_esim.h
Normal file
128
frameworks/js/esim/include/napi_esim.h
Normal file
@ -0,0 +1,128 @@
|
||||
/*
|
||||
* Copyright (C) 2024 Huawei Device Co., Ltd.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#ifndef OHOS_NAPI_ESIM_H
|
||||
#define OHOS_NAPI_ESIM_H
|
||||
|
||||
#include <array>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
#include "base_context.h"
|
||||
#include "download_profile_config_info_parcel.h"
|
||||
#include "download_profile_result_parcel.h"
|
||||
#include "downloadable_profile_parcel.h"
|
||||
#include "esim_state_type.h"
|
||||
#include "euicc_info_parcel.h"
|
||||
#include "get_downloadable_profiles_result_parcel.h"
|
||||
#include "profile_info_list_parcel.h"
|
||||
#include "profile_metadata_result_parcel.h"
|
||||
#include "response_esim_result.h"
|
||||
#include "telephony_napi_common_error.h"
|
||||
#include "telephony_types.h"
|
||||
|
||||
namespace OHOS {
|
||||
namespace Telephony {
|
||||
const int32_t DEFAULT_ERROR = -1;
|
||||
|
||||
template<typename T>
|
||||
struct AsyncContext {
|
||||
BaseContext context;
|
||||
int32_t slotId = ERROR_DEFAULT;
|
||||
T callbackVal;
|
||||
};
|
||||
|
||||
struct AsyncContextInfo {
|
||||
AsyncContext<int32_t> asyncContext;
|
||||
std::string inputStr = "";
|
||||
};
|
||||
|
||||
struct AsyncCommonInfo {
|
||||
AsyncContext<int32_t> asyncContext;
|
||||
};
|
||||
|
||||
struct AsyncEuiccInfo {
|
||||
AsyncContext<napi_value> asyncContext;
|
||||
EuiccInfo result;
|
||||
};
|
||||
|
||||
struct AsyncEuiccProfileInfoList {
|
||||
AsyncContext<napi_value> asyncContext;
|
||||
GetEuiccProfileInfoListResult result;
|
||||
};
|
||||
|
||||
struct AsyncSwitchProfileInfo {
|
||||
AsyncContext<int32_t> asyncContext;
|
||||
int32_t portIndex = ERROR_DEFAULT;
|
||||
std::string iccid = "";
|
||||
bool forceDeactivateSim = false;
|
||||
};
|
||||
|
||||
struct AsyncAccessRule {
|
||||
std::string certificateHashHexStr = "";
|
||||
std::string packageName = "";
|
||||
int32_t accessType = ERROR_DEFAULT;
|
||||
};
|
||||
|
||||
struct AsyncDownloadableProfile {
|
||||
std::string encodedActivationCode = "";
|
||||
std::string confirmationCode = "";
|
||||
std::string carrierName = "";
|
||||
std::vector<AsyncAccessRule> accessRules{};
|
||||
};
|
||||
|
||||
struct AsyncDownloadProfileInfo {
|
||||
AsyncContext<napi_value> asyncContext;
|
||||
int32_t portIndex = ERROR_DEFAULT;
|
||||
AsyncDownloadableProfile profile;
|
||||
bool switchAfterDownload = false;
|
||||
bool forceDeactivateSim = false;
|
||||
DownloadProfileResult result;
|
||||
};
|
||||
|
||||
struct AsyncDefaultProfileList {
|
||||
AsyncContext<napi_value> asyncContext;
|
||||
int32_t portIndex = ERROR_DEFAULT;
|
||||
bool forceDeactivateSim = false;
|
||||
GetDownloadableProfilesResult result;
|
||||
};
|
||||
|
||||
struct AsyncProfileNickname {
|
||||
AsyncContext<int32_t> asyncContext;
|
||||
std::string iccid = "";
|
||||
std::string nickname = "";
|
||||
};
|
||||
|
||||
struct AsyncCancelSession {
|
||||
AsyncContext<napi_value> asyncContext;
|
||||
std::string transactionId = "";
|
||||
int32_t cancelReason = static_cast<int32_t>(CancelReason::CANCEL_REASON_POSTPONED);
|
||||
ResponseEsimResult responseResult;
|
||||
};
|
||||
|
||||
struct AsyncProfileMetadataInfo {
|
||||
AsyncContext<napi_value> asyncContext;
|
||||
int32_t portIndex = ERROR_DEFAULT;
|
||||
AsyncDownloadableProfile profile;
|
||||
bool forceDeactivateSim = false;
|
||||
GetDownloadableProfileMetadataResult result;
|
||||
};
|
||||
|
||||
struct AsyncResetMemory {
|
||||
AsyncContext<int32_t> asyncContext;
|
||||
int32_t option = ERROR_DEFAULT;
|
||||
};
|
||||
} // namespace Telephony
|
||||
} // namespace OHOS
|
||||
#endif // OHOS_NAPI_ESIM_H
|
1574
frameworks/js/esim/src/napi_esim.cpp
Normal file
1574
frameworks/js/esim/src/napi_esim.cpp
Normal file
File diff suppressed because it is too large
Load Diff
@ -103,6 +103,14 @@ napi_value GetNapiValue(napi_env env, T val)
|
||||
return result;
|
||||
}
|
||||
|
||||
template<typename T, std::enable_if_t<std::is_same_v<T, uint32_t>, int32_t> = 0>
|
||||
napi_value GetNapiValue(napi_env env, T val)
|
||||
{
|
||||
napi_value result = nullptr;
|
||||
NAPI_CALL(env, napi_create_uint32(env, val, &result));
|
||||
return result;
|
||||
}
|
||||
|
||||
template<typename T, std::enable_if_t<std::is_same_v<T, int64_t>, int64_t> = 0>
|
||||
napi_value GetNapiValue(napi_env env, T val)
|
||||
{
|
||||
@ -151,6 +159,12 @@ napi_status NapiValueToCppValue(napi_env env, napi_value arg, napi_valuetype arg
|
||||
return napi_invalid_arg;
|
||||
}
|
||||
|
||||
template<typename T, std::enable_if_t<std::is_same_v<T, bool>, int32_t> = 0>
|
||||
napi_valuetype GetInputArgvType(T *)
|
||||
{
|
||||
return napi_boolean;
|
||||
}
|
||||
|
||||
template<typename... Ts, size_t N>
|
||||
std::optional<NapiError> MatchParameters(
|
||||
napi_env env, const napi_value (&argv)[N], size_t argc, std::tuple<Ts...> &theTuple)
|
||||
|
@ -2590,8 +2590,8 @@ static napi_value IsNrSupported(napi_env env, napi_callback_info info)
|
||||
telephonyConfig.IsCapabilitySupport(static_cast<int32_t>(TelephonyConfig::ConfigType::MODEM_CAP_SUPPORT_NR));
|
||||
#ifdef OHOS_BUILD_ENABLE_TELEPHONY_EXT
|
||||
TELEPHONY_EXT_UTILS_WRAPPER.InitTelephonyExtUtilsWrapper();
|
||||
if (TELEPHONY_EXT_UTILS_WRAPPER.isNrSupported_ != nullptr) {
|
||||
TELEPHONY_EXT_UTILS_WRAPPER.isNrSupported_(isNrSupported);
|
||||
if (TELEPHONY_EXT_UTILS_WRAPPER.isChipsetNrSupported_ != nullptr) {
|
||||
isNrSupported = isNrSupported && TELEPHONY_EXT_UTILS_WRAPPER.isChipsetNrSupported_();
|
||||
}
|
||||
#endif
|
||||
TELEPHONY_LOGD("isNrSupported:%{public}d", isNrSupported);
|
||||
|
@ -66,11 +66,12 @@ sptr<ICoreService> CoreServiceClient::GetProxy()
|
||||
return proxy_;
|
||||
}
|
||||
|
||||
void CoreServiceClient::OnRemoteDied(const wptr<IRemoteObject> &remote)
|
||||
__attribute__((no_sanitize("cfi"))) void CoreServiceClient::OnRemoteDied(const wptr<IRemoteObject> &remote)
|
||||
{
|
||||
RemoveDeathRecipient(remote, true);
|
||||
}
|
||||
|
||||
__attribute__((no_sanitize("cfi")))
|
||||
void CoreServiceClient::RemoveDeathRecipient(const wptr<IRemoteObject> &remote, bool isRemoteDied)
|
||||
{
|
||||
if (isRemoteDied && remote == nullptr) {
|
||||
@ -1083,6 +1084,153 @@ int32_t CoreServiceClient::GetSimIO(int32_t slotId, int32_t command,
|
||||
}
|
||||
|
||||
#ifdef CORE_SERVICE_SUPPORT_ESIM
|
||||
int32_t CoreServiceClient::GetEid(int32_t slotId, std::u16string &eId)
|
||||
{
|
||||
auto proxy = GetProxy();
|
||||
if (proxy == nullptr) {
|
||||
TELEPHONY_LOGE("proxy is null!");
|
||||
return TELEPHONY_ERR_IPC_CONNECT_STUB_FAIL;
|
||||
}
|
||||
return proxy->GetEid(slotId, eId);
|
||||
}
|
||||
|
||||
int32_t CoreServiceClient::GetEuiccProfileInfoList(int32_t slotId, GetEuiccProfileInfoListResult &euiccProfileInfoList)
|
||||
{
|
||||
auto proxy = GetProxy();
|
||||
if (proxy == nullptr) {
|
||||
TELEPHONY_LOGE("proxy is null!");
|
||||
return TELEPHONY_ERR_IPC_CONNECT_STUB_FAIL;
|
||||
}
|
||||
return proxy->GetEuiccProfileInfoList(slotId, euiccProfileInfoList);
|
||||
}
|
||||
|
||||
int32_t CoreServiceClient::GetEuiccInfo(int32_t slotId, EuiccInfo &eUiccInfo)
|
||||
{
|
||||
auto proxy = GetProxy();
|
||||
if (proxy == nullptr) {
|
||||
TELEPHONY_LOGE("proxy is null!");
|
||||
return TELEPHONY_ERR_IPC_CONNECT_STUB_FAIL;
|
||||
}
|
||||
return proxy->GetEuiccInfo(slotId, eUiccInfo);
|
||||
}
|
||||
|
||||
int32_t CoreServiceClient::DisableProfile(
|
||||
int32_t slotId, int32_t portIndex, const std::u16string &iccId, bool refresh, ResultState &enumResult)
|
||||
{
|
||||
auto proxy = GetProxy();
|
||||
if (proxy == nullptr) {
|
||||
TELEPHONY_LOGE("proxy is null!");
|
||||
return TELEPHONY_ERR_IPC_CONNECT_STUB_FAIL;
|
||||
}
|
||||
return proxy->DisableProfile(slotId, portIndex, iccId, refresh, enumResult);
|
||||
}
|
||||
|
||||
int32_t CoreServiceClient::GetSmdsAddress(int32_t slotId, int32_t portIndex, std::u16string &smdsAddress)
|
||||
{
|
||||
auto proxy = GetProxy();
|
||||
if (proxy == nullptr) {
|
||||
TELEPHONY_LOGE("proxy is null!");
|
||||
return TELEPHONY_ERR_IPC_CONNECT_STUB_FAIL;
|
||||
}
|
||||
return proxy->GetSmdsAddress(slotId, portIndex, smdsAddress);
|
||||
}
|
||||
|
||||
int32_t CoreServiceClient::GetRulesAuthTable(
|
||||
int32_t slotId, int32_t portIndex, EuiccRulesAuthTable &eUiccRulesAuthTable)
|
||||
{
|
||||
auto proxy = GetProxy();
|
||||
if (proxy == nullptr) {
|
||||
TELEPHONY_LOGE("proxy is null!");
|
||||
return TELEPHONY_ERR_IPC_CONNECT_STUB_FAIL;
|
||||
}
|
||||
return proxy->GetRulesAuthTable(slotId, portIndex, eUiccRulesAuthTable);
|
||||
}
|
||||
|
||||
int32_t CoreServiceClient::GetEuiccChallenge(
|
||||
int32_t slotId, int32_t portIndex, ResponseEsimResult &responseResult)
|
||||
{
|
||||
auto proxy = GetProxy();
|
||||
if (proxy == nullptr) {
|
||||
TELEPHONY_LOGE("proxy is null!");
|
||||
return TELEPHONY_ERR_IPC_CONNECT_STUB_FAIL;
|
||||
}
|
||||
return proxy->GetEuiccChallenge(slotId, portIndex, responseResult);
|
||||
}
|
||||
|
||||
int32_t CoreServiceClient::GetDefaultSmdpAddress(int32_t slotId, std::u16string &defaultSmdpAddress)
|
||||
{
|
||||
auto proxy = GetProxy();
|
||||
if (proxy == nullptr) {
|
||||
TELEPHONY_LOGE("proxy is null!");
|
||||
return TELEPHONY_ERR_IPC_CONNECT_STUB_FAIL;
|
||||
}
|
||||
return proxy->GetDefaultSmdpAddress(slotId, defaultSmdpAddress);
|
||||
}
|
||||
|
||||
int32_t CoreServiceClient::CancelSession(
|
||||
int32_t slotId, const std::u16string &transactionId, CancelReason cancelReason, ResponseEsimResult &responseResult)
|
||||
{
|
||||
auto proxy = GetProxy();
|
||||
if (proxy == nullptr) {
|
||||
TELEPHONY_LOGE("proxy is null!");
|
||||
return TELEPHONY_ERR_IPC_CONNECT_STUB_FAIL;
|
||||
}
|
||||
return proxy->CancelSession(slotId, transactionId, cancelReason, responseResult);
|
||||
}
|
||||
|
||||
int32_t CoreServiceClient::GetProfile(
|
||||
int32_t slotId, int32_t portIndex, const std::u16string &iccId, EuiccProfile &eUiccProfile)
|
||||
{
|
||||
auto proxy = GetProxy();
|
||||
if (proxy == nullptr) {
|
||||
TELEPHONY_LOGE("proxy is null!");
|
||||
return TELEPHONY_ERR_IPC_CONNECT_STUB_FAIL;
|
||||
}
|
||||
return proxy->GetProfile(slotId, portIndex, iccId, eUiccProfile);
|
||||
}
|
||||
|
||||
int32_t CoreServiceClient::ResetMemory(int32_t slotId, ResetOption resetOption, ResultState &enumResult)
|
||||
{
|
||||
auto proxy = GetProxy();
|
||||
if (proxy == nullptr) {
|
||||
TELEPHONY_LOGE("proxy is null!");
|
||||
return TELEPHONY_ERR_IPC_CONNECT_STUB_FAIL;
|
||||
}
|
||||
return proxy->ResetMemory(slotId, resetOption, enumResult);
|
||||
}
|
||||
|
||||
int32_t CoreServiceClient::SetDefaultSmdpAddress(
|
||||
int32_t slotId, const std::u16string &defaultSmdpAddress, ResultState &enumResult)
|
||||
{
|
||||
auto proxy = GetProxy();
|
||||
if (proxy == nullptr) {
|
||||
TELEPHONY_LOGE("proxy is null!");
|
||||
return TELEPHONY_ERR_IPC_CONNECT_STUB_FAIL;
|
||||
}
|
||||
return proxy->SetDefaultSmdpAddress(slotId, defaultSmdpAddress, enumResult);
|
||||
}
|
||||
|
||||
bool CoreServiceClient::IsEsimSupported(int32_t slotId)
|
||||
{
|
||||
auto proxy = GetProxy();
|
||||
if (proxy == nullptr) {
|
||||
TELEPHONY_LOGE("proxy is null!");
|
||||
return false;
|
||||
}
|
||||
return proxy->IsEsimSupported(slotId);
|
||||
}
|
||||
|
||||
int32_t CoreServiceClient::SendApduData(
|
||||
int32_t slotId, const std::u16string &aid, const std::u16string &apduData, ResponseEsimResult &responseResult)
|
||||
{
|
||||
auto proxy = GetProxy();
|
||||
if (proxy == nullptr) {
|
||||
TELEPHONY_LOGE("proxy is null!");
|
||||
return TELEPHONY_ERR_IPC_CONNECT_STUB_FAIL;
|
||||
}
|
||||
return proxy->SendApduData(slotId, aid, apduData, responseResult);
|
||||
}
|
||||
|
||||
int32_t CoreServiceClient::PrepareDownload(int32_t slotId, const DownLoadConfigInfo &downLoadConfigInfo,
|
||||
ResponseEsimResult &responseResult)
|
||||
{
|
||||
|
@ -15,6 +15,9 @@
|
||||
|
||||
#include "core_service_proxy.h"
|
||||
|
||||
#ifdef CORE_SERVICE_SUPPORT_ESIM
|
||||
#include "esim_state_type.h"
|
||||
#endif
|
||||
#include "network_search_types.h"
|
||||
#include "parameter.h"
|
||||
#include "sim_state_type.h"
|
||||
@ -26,6 +29,9 @@
|
||||
namespace OHOS {
|
||||
namespace Telephony {
|
||||
constexpr int32_t MAX_SIZE = 1000;
|
||||
#ifdef CORE_SERVICE_SUPPORT_ESIM
|
||||
constexpr uint32_t ESIM_MAX_SIZE = 1000;
|
||||
#endif
|
||||
bool CoreServiceProxy::WriteInterfaceToken(MessageParcel &data)
|
||||
{
|
||||
if (!data.WriteInterfaceToken(CoreServiceProxy::GetDescriptor())) {
|
||||
@ -3190,6 +3196,578 @@ int32_t CoreServiceProxy::GetSimIO(int32_t slotId, int32_t command,
|
||||
}
|
||||
|
||||
#ifdef CORE_SERVICE_SUPPORT_ESIM
|
||||
int32_t CoreServiceProxy::GetEid(int32_t slotId, std::u16string &eId)
|
||||
{
|
||||
MessageParcel data;
|
||||
MessageParcel reply;
|
||||
MessageOption option;
|
||||
if (!WriteInterfaceToken(data)) {
|
||||
TELEPHONY_LOGE("WriteInterfaceToken is false");
|
||||
return TELEPHONY_ERR_WRITE_DESCRIPTOR_TOKEN_FAIL;
|
||||
}
|
||||
if (!data.WriteInt32(slotId)) {
|
||||
return TELEPHONY_ERR_WRITE_DATA_FAIL;
|
||||
}
|
||||
auto remote = Remote();
|
||||
if (remote == nullptr) {
|
||||
TELEPHONY_LOGE("Remote is null");
|
||||
return TELEPHONY_ERR_IPC_CONNECT_STUB_FAIL;
|
||||
}
|
||||
int32_t sendRequestRet =
|
||||
remote->SendRequest(static_cast<uint32_t>(CoreServiceInterfaceCode::GET_EID), data, reply, option);
|
||||
if (sendRequestRet != ERR_NONE) {
|
||||
TELEPHONY_LOGE("GetEid failed, error code is %{public}d", sendRequestRet);
|
||||
return TELEPHONY_ERR_IPC_CONNECT_STUB_FAIL;
|
||||
}
|
||||
int32_t result = reply.ReadInt32();
|
||||
if (result == TELEPHONY_ERR_SUCCESS) {
|
||||
eId = reply.ReadString16();
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
void CoreServiceProxy::ReadEuiccProfileFromReply(MessageParcel &reply, EuiccProfile &euiccProfile)
|
||||
{
|
||||
euiccProfile.iccId = reply.ReadString16();
|
||||
euiccProfile.nickName = reply.ReadString16();
|
||||
euiccProfile.serviceProviderName = reply.ReadString16();
|
||||
euiccProfile.profileName = reply.ReadString16();
|
||||
euiccProfile.state = static_cast<ProfileState>(reply.ReadInt32());
|
||||
euiccProfile.profileClass = static_cast<ProfileClass>(reply.ReadInt32());
|
||||
euiccProfile.carrierId.mcc = reply.ReadString16();
|
||||
euiccProfile.carrierId.mnc = reply.ReadString16();
|
||||
euiccProfile.carrierId.gid1 = reply.ReadString16();
|
||||
euiccProfile.carrierId.gid2 = reply.ReadString16();
|
||||
euiccProfile.policyRules = static_cast<PolicyRules>(reply.ReadInt32());
|
||||
|
||||
uint32_t accessRulesSize = reply.ReadUint32();
|
||||
if (accessRulesSize >= ESIM_MAX_SIZE) {
|
||||
TELEPHONY_LOGE("over max size");
|
||||
return;
|
||||
}
|
||||
euiccProfile.accessRules.resize(accessRulesSize);
|
||||
for (uint32_t j = 0; j < accessRulesSize; ++j) {
|
||||
AccessRule &rule = euiccProfile.accessRules[j];
|
||||
rule.certificateHashHexStr = reply.ReadString16();
|
||||
rule.packageName = reply.ReadString16();
|
||||
rule.accessType = reply.ReadInt32();
|
||||
}
|
||||
}
|
||||
|
||||
int32_t CoreServiceProxy::GetEuiccProfileInfoList(int32_t slotId, GetEuiccProfileInfoListResult &euiccProfileInfoList)
|
||||
{
|
||||
MessageParcel data;
|
||||
MessageParcel reply;
|
||||
MessageOption option;
|
||||
if (!WriteInterfaceToken(data)) {
|
||||
TELEPHONY_LOGE("WriteInterfaceToken is false");
|
||||
return TELEPHONY_ERR_WRITE_DESCRIPTOR_TOKEN_FAIL;
|
||||
}
|
||||
if (!data.WriteInt32(slotId)) {
|
||||
return TELEPHONY_ERR_WRITE_DATA_FAIL;
|
||||
}
|
||||
auto remote = Remote();
|
||||
if (remote == nullptr) {
|
||||
TELEPHONY_LOGE("Remote is null");
|
||||
return TELEPHONY_ERR_IPC_CONNECT_STUB_FAIL;
|
||||
}
|
||||
int32_t sendRequestRet = remote->SendRequest(
|
||||
static_cast<uint32_t>(CoreServiceInterfaceCode::GET_EUICC_PROFILE_INFO_LIST), data, reply, option);
|
||||
if (sendRequestRet != ERR_NONE) {
|
||||
TELEPHONY_LOGE("GetEuiccProfileInfoList failed, error code is %{public}d", sendRequestRet);
|
||||
return TELEPHONY_ERR_IPC_CONNECT_STUB_FAIL;
|
||||
}
|
||||
int32_t result = reply.ReadInt32();
|
||||
if (result == TELEPHONY_ERR_SUCCESS) {
|
||||
uint32_t profileCount = reply.ReadUint32();
|
||||
if (profileCount >= ESIM_MAX_SIZE) {
|
||||
TELEPHONY_LOGE("over max size");
|
||||
return TELEPHONY_ERR_READ_DATA_FAIL;
|
||||
}
|
||||
euiccProfileInfoList.profiles.resize(profileCount);
|
||||
for (uint32_t i = 0; i < profileCount; ++i) {
|
||||
EuiccProfile &euiccProfile = euiccProfileInfoList.profiles[i];
|
||||
ReadEuiccProfileFromReply(reply, euiccProfile);
|
||||
}
|
||||
euiccProfileInfoList.isRemovable = reply.ReadBool();
|
||||
euiccProfileInfoList.result = static_cast<ResultState>(reply.ReadInt32());
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
int32_t CoreServiceProxy::GetEuiccInfo(int32_t slotId, EuiccInfo &eUiccInfo)
|
||||
{
|
||||
MessageParcel data;
|
||||
MessageParcel reply;
|
||||
MessageOption option;
|
||||
if (!WriteInterfaceToken(data)) {
|
||||
TELEPHONY_LOGE("WriteInterfaceToken is false");
|
||||
return TELEPHONY_ERR_WRITE_DESCRIPTOR_TOKEN_FAIL;
|
||||
}
|
||||
if (data.WriteInt32(slotId)) {
|
||||
return TELEPHONY_ERR_IPC_CONNECT_STUB_FAIL;
|
||||
}
|
||||
auto remote = Remote();
|
||||
if (remote == nullptr) {
|
||||
TELEPHONY_LOGE("Remote is null");
|
||||
return TELEPHONY_ERR_IPC_CONNECT_STUB_FAIL;
|
||||
}
|
||||
int32_t sendRequestRet = remote->SendRequest(
|
||||
static_cast<uint32_t>(CoreServiceInterfaceCode::GET_EUICC_INFO), data, reply, option);
|
||||
if (sendRequestRet != ERR_NONE) {
|
||||
TELEPHONY_LOGE("GetEuiccInfo failed, error code is %{public}d", sendRequestRet);
|
||||
return TELEPHONY_ERR_IPC_CONNECT_STUB_FAIL;
|
||||
}
|
||||
int32_t result = reply.ReadInt32();
|
||||
if (result == TELEPHONY_ERR_SUCCESS) {
|
||||
eUiccInfo.osVersion = reply.ReadString16();
|
||||
eUiccInfo.response = reply.ReadString16();
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
int32_t CoreServiceProxy::DisableProfile(
|
||||
int32_t slotId, int32_t portIndex, const std::u16string &iccId, bool refresh, ResultState &enumResult)
|
||||
{
|
||||
MessageParcel data;
|
||||
MessageParcel reply;
|
||||
MessageOption option;
|
||||
if (!WriteInterfaceToken(data)) {
|
||||
TELEPHONY_LOGE("WriteInterfaceToken is false");
|
||||
return TELEPHONY_ERR_WRITE_DESCRIPTOR_TOKEN_FAIL;
|
||||
}
|
||||
if (!data.WriteInt32(slotId)) {
|
||||
TELEPHONY_LOGE("WriteInt32 slotId is false");
|
||||
return TELEPHONY_ERR_WRITE_DATA_FAIL;
|
||||
}
|
||||
if (!data.WriteInt32(portIndex)) {
|
||||
TELEPHONY_LOGE("WriteInt32 portIndex is false");
|
||||
return TELEPHONY_ERR_WRITE_DATA_FAIL;
|
||||
}
|
||||
if (!data.WriteString16(iccId)) {
|
||||
TELEPHONY_LOGE("WriteString16 iccId is false");
|
||||
return TELEPHONY_ERR_WRITE_DATA_FAIL;
|
||||
}
|
||||
if (!data.WriteBool(refresh)) {
|
||||
TELEPHONY_LOGE("WriteBool refresh is false");
|
||||
return TELEPHONY_ERR_WRITE_REPLY_FAIL;
|
||||
}
|
||||
auto remote = Remote();
|
||||
if (remote == nullptr) {
|
||||
TELEPHONY_LOGE("Remote is null");
|
||||
return TELEPHONY_ERR_IPC_CONNECT_STUB_FAIL;
|
||||
}
|
||||
int32_t profileResult =
|
||||
remote->SendRequest(static_cast<uint32_t>(CoreServiceInterfaceCode::DISABLE_PROFILE), data, reply, option);
|
||||
if (profileResult != ERR_NONE) {
|
||||
TELEPHONY_LOGE("DisableProfile senRequest failed, error code is %{public}d", profileResult);
|
||||
return TELEPHONY_ERR_IPC_CONNECT_STUB_FAIL;
|
||||
}
|
||||
int32_t result = reply.ReadInt32();
|
||||
if (result == TELEPHONY_ERR_SUCCESS) {
|
||||
enumResult = static_cast<ResultState>(reply.ReadInt32());
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
int32_t CoreServiceProxy::GetSmdsAddress(int32_t slotId, int32_t portIndex, std::u16string &smdsAddress)
|
||||
{
|
||||
MessageParcel data;
|
||||
MessageParcel reply;
|
||||
MessageOption option;
|
||||
if (!WriteInterfaceToken(data)) {
|
||||
TELEPHONY_LOGE("WriteInterfaceToken is false");
|
||||
return TELEPHONY_ERR_WRITE_DESCRIPTOR_TOKEN_FAIL;
|
||||
}
|
||||
if (!data.WriteInt32(slotId)) {
|
||||
TELEPHONY_LOGE("WriteInt32 slotId is false");
|
||||
return TELEPHONY_ERR_WRITE_DATA_FAIL;
|
||||
}
|
||||
if (!data.WriteInt32(portIndex)) {
|
||||
TELEPHONY_LOGE("WriteInt32 portIndex is false");
|
||||
return TELEPHONY_ERR_WRITE_DATA_FAIL;
|
||||
}
|
||||
auto remote = Remote();
|
||||
if (remote == nullptr) {
|
||||
TELEPHONY_LOGE("Remote is null");
|
||||
return TELEPHONY_ERR_IPC_CONNECT_STUB_FAIL;
|
||||
}
|
||||
int32_t addressResult =
|
||||
remote->SendRequest(static_cast<uint32_t>(CoreServiceInterfaceCode::GET_SMDSADDRESS), data, reply, option);
|
||||
if (addressResult != ERR_NONE) {
|
||||
TELEPHONY_LOGE("GetSmdsAddress sendRequest failed, error code is %{public}d", addressResult);
|
||||
return TELEPHONY_ERR_IPC_CONNECT_STUB_FAIL;
|
||||
}
|
||||
int32_t result = reply.ReadInt32();
|
||||
if (result == TELEPHONY_ERR_SUCCESS) {
|
||||
smdsAddress = reply.ReadString16();
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
int32_t CoreServiceProxy::ParseRulesAuthTableReply(MessageParcel &reply, EuiccRulesAuthTable &eUiccRulesAuthTable)
|
||||
{
|
||||
int32_t result = reply.ReadInt32();
|
||||
if (result == TELEPHONY_ERR_SUCCESS) {
|
||||
uint32_t policyRulesSize = reply.ReadUint32();
|
||||
if (policyRulesSize > ESIM_MAX_SIZE) {
|
||||
return TELEPHONY_ERR_FAIL;
|
||||
}
|
||||
eUiccRulesAuthTable.policyRules.resize(policyRulesSize);
|
||||
for (uint32_t i = 0; i < policyRulesSize; ++i) {
|
||||
eUiccRulesAuthTable.policyRules[i] = reply.ReadInt32();
|
||||
}
|
||||
uint32_t carrierIdsSize = reply.ReadUint32();
|
||||
if (carrierIdsSize > ESIM_MAX_SIZE) {
|
||||
return TELEPHONY_ERR_FAIL;
|
||||
}
|
||||
eUiccRulesAuthTable.carrierIds.resize(carrierIdsSize);
|
||||
for (uint32_t j = 0; j < carrierIdsSize; ++j) {
|
||||
CarrierIdentifier &ci = eUiccRulesAuthTable.carrierIds[j];
|
||||
ci.mcc = reply.ReadString16();
|
||||
ci.mnc = reply.ReadString16();
|
||||
ci.spn = reply.ReadString16();
|
||||
ci.imsi = reply.ReadString16();
|
||||
ci.gid1 = reply.ReadString16();
|
||||
ci.gid2 = reply.ReadString16();
|
||||
ci.carrierId = reply.ReadInt32();
|
||||
ci.specificCarrierId = reply.ReadInt32();
|
||||
}
|
||||
uint32_t policyRuleFlagsSize = reply.ReadUint32();
|
||||
if (policyRuleFlagsSize > ESIM_MAX_SIZE) {
|
||||
return TELEPHONY_ERR_FAIL;
|
||||
}
|
||||
eUiccRulesAuthTable.policyRuleFlags.resize(policyRuleFlagsSize);
|
||||
for (uint32_t k = 0; k < policyRuleFlagsSize; ++k) {
|
||||
eUiccRulesAuthTable.policyRuleFlags[k] = reply.ReadInt32();
|
||||
}
|
||||
eUiccRulesAuthTable.position = reply.ReadInt32();
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
int32_t CoreServiceProxy::GetRulesAuthTable(
|
||||
int32_t slotId, int32_t portIndex, EuiccRulesAuthTable &eUiccRulesAuthTable)
|
||||
{
|
||||
MessageParcel data;
|
||||
MessageParcel reply;
|
||||
MessageOption option;
|
||||
if (!WriteInterfaceToken(data)) {
|
||||
TELEPHONY_LOGE("WriteInterfaceToken is false");
|
||||
return TELEPHONY_ERR_WRITE_DESCRIPTOR_TOKEN_FAIL;
|
||||
}
|
||||
if (!data.WriteInt32(slotId)) {
|
||||
TELEPHONY_LOGE("WriteInt32 slotId is false");
|
||||
return TELEPHONY_ERR_WRITE_DATA_FAIL;
|
||||
}
|
||||
if (!data.WriteInt32(portIndex)) {
|
||||
TELEPHONY_LOGE("WriteInt32 portIndex is false");
|
||||
return TELEPHONY_ERR_WRITE_DATA_FAIL;
|
||||
}
|
||||
auto remote = Remote();
|
||||
if (remote == nullptr) {
|
||||
TELEPHONY_LOGE("Remote is null");
|
||||
return TELEPHONY_ERR_IPC_CONNECT_STUB_FAIL;
|
||||
}
|
||||
int32_t getRulesResult =
|
||||
remote->SendRequest(static_cast<uint32_t>(CoreServiceInterfaceCode::GET_RULES_AUTH_TABLE), data, reply, option);
|
||||
if (getRulesResult != ERR_NONE) {
|
||||
TELEPHONY_LOGE("DisableProfile sendRequest failed, error code is %{public}d", getRulesResult);
|
||||
return TELEPHONY_ERR_IPC_CONNECT_STUB_FAIL;
|
||||
}
|
||||
return ParseRulesAuthTableReply(reply, eUiccRulesAuthTable);
|
||||
}
|
||||
|
||||
int32_t CoreServiceProxy::GetEuiccChallenge(
|
||||
int32_t slotId, int32_t portIndex, ResponseEsimResult &responseResult)
|
||||
{
|
||||
MessageParcel data;
|
||||
MessageParcel reply;
|
||||
MessageOption option;
|
||||
if (!WriteInterfaceToken(data)) {
|
||||
TELEPHONY_LOGE("WriteInterfaceToken is false");
|
||||
return TELEPHONY_ERR_WRITE_DESCRIPTOR_TOKEN_FAIL;
|
||||
}
|
||||
if (!data.WriteInt32(slotId)) {
|
||||
TELEPHONY_LOGE("WriteInt32 slotId is false");
|
||||
return TELEPHONY_ERR_WRITE_DATA_FAIL;
|
||||
}
|
||||
if (!data.WriteInt32(portIndex)) {
|
||||
TELEPHONY_LOGE("WriteInt32 portIndex is false");
|
||||
return TELEPHONY_ERR_WRITE_DATA_FAIL;
|
||||
}
|
||||
auto remote = Remote();
|
||||
if (remote == nullptr) {
|
||||
TELEPHONY_LOGE("Remote is null");
|
||||
return TELEPHONY_ERR_IPC_CONNECT_STUB_FAIL;
|
||||
}
|
||||
int32_t euiccResult =
|
||||
remote->SendRequest(static_cast<uint32_t>(CoreServiceInterfaceCode::GET_EUICC_CHALLENGE), data, reply, option);
|
||||
if (euiccResult != ERR_NONE) {
|
||||
TELEPHONY_LOGE("GetEuiccChallenge sendRequest failed, error code is %{public}d", euiccResult);
|
||||
return TELEPHONY_ERR_IPC_CONNECT_STUB_FAIL;
|
||||
}
|
||||
int32_t result = reply.ReadInt32();
|
||||
if (result == TELEPHONY_ERR_SUCCESS) {
|
||||
responseResult.resultCode = static_cast<ResultState>(reply.ReadInt32());
|
||||
responseResult.response = reply.ReadString16();
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
int32_t CoreServiceProxy::GetDefaultSmdpAddress(int32_t slotId, std::u16string &defaultSmdpAddress)
|
||||
{
|
||||
MessageParcel data;
|
||||
MessageParcel reply;
|
||||
MessageOption option;
|
||||
if (!WriteInterfaceToken(data)) {
|
||||
TELEPHONY_LOGE("WriteInterfaceToken is false");
|
||||
return TELEPHONY_ERR_WRITE_DESCRIPTOR_TOKEN_FAIL;
|
||||
}
|
||||
if (!data.WriteInt32(slotId)) {
|
||||
TELEPHONY_LOGE("WriteInt32 slotId is false");
|
||||
return TELEPHONY_ERR_WRITE_DATA_FAIL;
|
||||
}
|
||||
auto remote = Remote();
|
||||
if (remote == nullptr) {
|
||||
TELEPHONY_LOGE("Remote is null");
|
||||
return TELEPHONY_ERR_IPC_CONNECT_STUB_FAIL;
|
||||
}
|
||||
int32_t sendResult =
|
||||
remote->SendRequest(static_cast<uint32_t>(CoreServiceInterfaceCode::REQUEST_DEFAULT_SMDP_ADDRESS), data,
|
||||
reply, option);
|
||||
if (sendResult != ERR_NONE) {
|
||||
TELEPHONY_LOGE("GetDefaultSmdpAddress failed, error code is %{public}d", sendResult);
|
||||
return TELEPHONY_ERR_IPC_CONNECT_STUB_FAIL;
|
||||
}
|
||||
int32_t result = reply.ReadInt32();
|
||||
if (result == TELEPHONY_ERR_SUCCESS) {
|
||||
defaultSmdpAddress = reply.ReadString16();
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
int32_t CoreServiceProxy::CancelSession(
|
||||
int32_t slotId, const std::u16string &transactionId, CancelReason cancelReason, ResponseEsimResult &responseResult)
|
||||
{
|
||||
MessageParcel data;
|
||||
MessageParcel reply;
|
||||
MessageOption option;
|
||||
if (!WriteInterfaceToken(data)) {
|
||||
TELEPHONY_LOGE("WriteInterfaceToken is false");
|
||||
return TELEPHONY_ERR_WRITE_DESCRIPTOR_TOKEN_FAIL;
|
||||
}
|
||||
if (!data.WriteInt32(slotId)) {
|
||||
TELEPHONY_LOGE("WriteInt32 slotId is false");
|
||||
return TELEPHONY_ERR_WRITE_DATA_FAIL;
|
||||
}
|
||||
if (!data.WriteString16(transactionId)) {
|
||||
TELEPHONY_LOGE("WriteString16 transactionId is false");
|
||||
return TELEPHONY_ERR_WRITE_DATA_FAIL;
|
||||
}
|
||||
if (!data.WriteInt32(static_cast<int32_t>(cancelReason))) {
|
||||
TELEPHONY_LOGE("WriteInt32 cancelReason is false");
|
||||
return TELEPHONY_ERR_WRITE_DATA_FAIL;
|
||||
}
|
||||
auto remote = Remote();
|
||||
if (remote == nullptr) {
|
||||
TELEPHONY_LOGE("Remote is null");
|
||||
return TELEPHONY_ERR_IPC_CONNECT_STUB_FAIL;
|
||||
}
|
||||
int32_t sendResult = remote->SendRequest(static_cast<uint32_t>(CoreServiceInterfaceCode::CANCEL_SESSION),
|
||||
data, reply, option);
|
||||
if (sendResult != ERR_NONE) {
|
||||
TELEPHONY_LOGE("CancelSession failed, error code is %{public}d", sendResult);
|
||||
return TELEPHONY_ERR_IPC_CONNECT_STUB_FAIL;
|
||||
}
|
||||
int32_t result = reply.ReadInt32();
|
||||
if (result == TELEPHONY_ERR_SUCCESS) {
|
||||
responseResult.resultCode = static_cast<ResultState>(reply.ReadInt32());
|
||||
responseResult.response = reply.ReadString16();
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
int32_t CoreServiceProxy::GetProfile(
|
||||
int32_t slotId, int32_t portIndex, const std::u16string &iccId, EuiccProfile &eUiccProfile)
|
||||
{
|
||||
MessageParcel data;
|
||||
MessageParcel reply;
|
||||
MessageOption option;
|
||||
if (!WriteInterfaceToken(data)) {
|
||||
TELEPHONY_LOGE("WriteInterfaceToken is false");
|
||||
return TELEPHONY_ERR_WRITE_DESCRIPTOR_TOKEN_FAIL;
|
||||
}
|
||||
if (!data.WriteInt32(slotId)) {
|
||||
TELEPHONY_LOGE("WriteInt32 slotId is false");
|
||||
return TELEPHONY_ERR_WRITE_DATA_FAIL;
|
||||
}
|
||||
if (!data.WriteInt32(portIndex)) {
|
||||
TELEPHONY_LOGE("WriteInt32 portIndex is false");
|
||||
return TELEPHONY_ERR_WRITE_DATA_FAIL;
|
||||
}
|
||||
if (!data.WriteString16(iccId)) {
|
||||
TELEPHONY_LOGE("WriteString16 iccId is false");
|
||||
return TELEPHONY_ERR_WRITE_DATA_FAIL;
|
||||
}
|
||||
auto remote = Remote();
|
||||
if (remote == nullptr) {
|
||||
TELEPHONY_LOGE("Remote is null");
|
||||
return TELEPHONY_ERR_IPC_CONNECT_STUB_FAIL;
|
||||
}
|
||||
int32_t resultSend =
|
||||
remote->SendRequest(static_cast<uint32_t>(CoreServiceInterfaceCode::GET_PROFILE), data, reply, option);
|
||||
if (resultSend != ERR_NONE) {
|
||||
TELEPHONY_LOGE("GetProfile sendRequest failed, error code is %{public}d", resultSend);
|
||||
return TELEPHONY_ERR_IPC_CONNECT_STUB_FAIL;
|
||||
}
|
||||
int32_t result = reply.ReadInt32();
|
||||
if (result == TELEPHONY_ERR_SUCCESS) {
|
||||
ReadEuiccProfileFromReply(reply, eUiccProfile);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
int32_t CoreServiceProxy::ResetMemory(int32_t slotId, ResetOption resetOption, ResultState &enumResult)
|
||||
{
|
||||
MessageParcel data;
|
||||
MessageParcel reply;
|
||||
MessageOption option;
|
||||
if (!WriteInterfaceToken(data)) {
|
||||
TELEPHONY_LOGE("WriteInterfaceToken is false");
|
||||
return TELEPHONY_ERR_WRITE_DESCRIPTOR_TOKEN_FAIL;
|
||||
}
|
||||
if (!data.WriteInt32(slotId)) {
|
||||
TELEPHONY_LOGE("WriteInt32 slotId is false");
|
||||
return TELEPHONY_ERR_WRITE_DATA_FAIL;
|
||||
}
|
||||
if (!data.WriteInt32(static_cast<int32_t>(resetOption))) {
|
||||
TELEPHONY_LOGE("WriteInt32 resetOption is false");
|
||||
return TELEPHONY_ERR_WRITE_DATA_FAIL;
|
||||
}
|
||||
auto remote = Remote();
|
||||
if (remote == nullptr) {
|
||||
TELEPHONY_LOGE("Remote is null");
|
||||
return TELEPHONY_ERR_IPC_CONNECT_STUB_FAIL;
|
||||
}
|
||||
int32_t requestResult =
|
||||
remote->SendRequest(static_cast<uint32_t>(CoreServiceInterfaceCode::RESET_MEMORY), data, reply, option);
|
||||
if (requestResult != ERR_NONE) {
|
||||
TELEPHONY_LOGE("ResetMemory failed, error code is %{public}d", requestResult);
|
||||
return TELEPHONY_ERR_IPC_CONNECT_STUB_FAIL;
|
||||
}
|
||||
int32_t result = reply.ReadInt32();
|
||||
if (result == TELEPHONY_ERR_SUCCESS) {
|
||||
enumResult = static_cast<ResultState>(reply.ReadInt32());
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
int32_t CoreServiceProxy::SetDefaultSmdpAddress(
|
||||
int32_t slotId, const std::u16string &defaultSmdpAddress, ResultState &enumResult)
|
||||
{
|
||||
MessageParcel data;
|
||||
MessageParcel reply;
|
||||
MessageOption option;
|
||||
if (!WriteInterfaceToken(data)) {
|
||||
TELEPHONY_LOGE("WriteInterfaceToken is false");
|
||||
return TELEPHONY_ERR_WRITE_DESCRIPTOR_TOKEN_FAIL;
|
||||
}
|
||||
if (!data.WriteInt32(slotId)) {
|
||||
TELEPHONY_LOGE("WriteInt32 slotId is false");
|
||||
return TELEPHONY_ERR_WRITE_DATA_FAIL;
|
||||
}
|
||||
if (!data.WriteString16(defaultSmdpAddress)) {
|
||||
TELEPHONY_LOGE("WriteString16 defaultSmdpAddress is false");
|
||||
return TELEPHONY_ERR_WRITE_DATA_FAIL;
|
||||
}
|
||||
auto remote = Remote();
|
||||
if (remote == nullptr) {
|
||||
TELEPHONY_LOGE("Remote is null");
|
||||
return TELEPHONY_ERR_IPC_CONNECT_STUB_FAIL;
|
||||
}
|
||||
int32_t requestResult =
|
||||
remote->SendRequest(static_cast<uint32_t>(CoreServiceInterfaceCode::SET_DEFAULT_SMDP_ADDRESS),
|
||||
data, reply, option);
|
||||
if (requestResult != ERR_NONE) {
|
||||
TELEPHONY_LOGE("SetDefaultSmdpAddress failed, error code is %{public}d", requestResult);
|
||||
return TELEPHONY_ERR_IPC_CONNECT_STUB_FAIL;
|
||||
}
|
||||
int32_t result = reply.ReadInt32();
|
||||
if (result == TELEPHONY_ERR_SUCCESS) {
|
||||
enumResult = static_cast<ResultState>(reply.ReadInt32());
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
bool CoreServiceProxy::IsEsimSupported(int32_t slotId)
|
||||
{
|
||||
MessageParcel data;
|
||||
MessageParcel reply;
|
||||
MessageOption option;
|
||||
if (!WriteInterfaceToken(data)) {
|
||||
TELEPHONY_LOGE("WriteInterfaceToken is false");
|
||||
return false;
|
||||
}
|
||||
if (!data.WriteInt32(slotId)) {
|
||||
TELEPHONY_LOGE("WriteInt32 slotId is false");
|
||||
return false;
|
||||
}
|
||||
auto remote = Remote();
|
||||
if (remote == nullptr) {
|
||||
TELEPHONY_LOGE("Remote is null");
|
||||
return false;
|
||||
}
|
||||
int32_t requestResult =
|
||||
remote->SendRequest(static_cast<uint32_t>(CoreServiceInterfaceCode::IS_ESIM_SUPPORTED), data, reply, option);
|
||||
if (requestResult != ERR_NONE) {
|
||||
TELEPHONY_LOGE("IsEsimSupported sendRequest failed, error code is %{public}d", requestResult);
|
||||
return false;
|
||||
}
|
||||
return reply.ReadBool();
|
||||
}
|
||||
|
||||
int32_t CoreServiceProxy::SendApduData(
|
||||
int32_t slotId, const std::u16string &aid, const std::u16string &apduData, ResponseEsimResult &responseResult)
|
||||
{
|
||||
MessageParcel data;
|
||||
MessageParcel reply;
|
||||
MessageOption option;
|
||||
if (!WriteInterfaceToken(data)) {
|
||||
TELEPHONY_LOGE("WriteInterfaceToken is false");
|
||||
return TELEPHONY_ERR_IPC_CONNECT_STUB_FAIL;
|
||||
}
|
||||
if (!data.WriteInt32(slotId)) {
|
||||
TELEPHONY_LOGE("WriteInt32 slotId is false");
|
||||
return TELEPHONY_ERR_WRITE_DATA_FAIL;
|
||||
}
|
||||
if (!data.WriteString16(aid)) {
|
||||
TELEPHONY_LOGE("WriteString16 aid is false");
|
||||
return TELEPHONY_ERR_WRITE_DATA_FAIL;
|
||||
}
|
||||
if (!data.WriteString16(apduData)) {
|
||||
TELEPHONY_LOGE("WriteString16 apduData is false");
|
||||
return TELEPHONY_ERR_WRITE_DATA_FAIL;
|
||||
}
|
||||
auto remote = Remote();
|
||||
if (remote == nullptr) {
|
||||
TELEPHONY_LOGE("Remote is null");
|
||||
return TELEPHONY_ERR_IPC_CONNECT_STUB_FAIL;
|
||||
}
|
||||
int32_t requestResult =
|
||||
remote->SendRequest(static_cast<uint32_t>(CoreServiceInterfaceCode::SEND_APDU_DATA), data, reply, option);
|
||||
if (requestResult != ERR_NONE) {
|
||||
TELEPHONY_LOGE("SendApduData sendRequest failed, error code is %{public}d", requestResult);
|
||||
return TELEPHONY_ERR_IPC_CONNECT_STUB_FAIL;
|
||||
}
|
||||
int32_t result = reply.ReadInt32();
|
||||
if (result == TELEPHONY_ERR_SUCCESS) {
|
||||
responseResult.resultCode = static_cast<ResultState>(reply.ReadInt32());
|
||||
responseResult.response = reply.ReadString16();
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
int32_t CoreServiceProxy::PrepareDownload(int32_t slotId, const DownLoadConfigInfo &downLoadConfigInfo,
|
||||
ResponseEsimResult &responseResult)
|
||||
{
|
||||
|
@ -0,0 +1,56 @@
|
||||
/*
|
||||
* Copyright (C) 2024 Huawei Device Co., Ltd.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#include "download_profile_config_info_parcel.h"
|
||||
|
||||
#include "telephony_log_wrapper.h"
|
||||
|
||||
namespace OHOS {
|
||||
namespace Telephony {
|
||||
bool DownloadProfileConfigInfo::ReadFromParcel(Parcel &parcel)
|
||||
{
|
||||
if (!parcel.ReadInt32(portIndex_) ||
|
||||
!parcel.ReadBool(isSwitchAfterDownload_) ||
|
||||
!parcel.ReadBool(isForceDeactivateSim_)) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
bool DownloadProfileConfigInfo::Marshalling(Parcel &parcel) const
|
||||
{
|
||||
if (!parcel.WriteInt32(portIndex_) ||
|
||||
!parcel.WriteBool(isSwitchAfterDownload_) ||
|
||||
!parcel.WriteBool(isForceDeactivateSim_)) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
DownloadProfileConfigInfo *DownloadProfileConfigInfo::Unmarshalling(Parcel &parcel)
|
||||
{
|
||||
DownloadProfileConfigInfo *info = new (std::nothrow) DownloadProfileConfigInfo();
|
||||
if (info == nullptr) {
|
||||
return nullptr;
|
||||
}
|
||||
if (!info->ReadFromParcel(parcel)) {
|
||||
TELEPHONY_LOGE("DownloadProfileConfigInfo:read from parcel failed");
|
||||
delete info;
|
||||
info = nullptr;
|
||||
}
|
||||
return info;
|
||||
}
|
||||
} // namespace OHOS
|
||||
} // namespace Telephony
|
60
frameworks/native/src/download_profile_result_parcel.cpp
Normal file
60
frameworks/native/src/download_profile_result_parcel.cpp
Normal file
@ -0,0 +1,60 @@
|
||||
/*
|
||||
* Copyright (C) 2024 Huawei Device Co., Ltd.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#include "download_profile_result_parcel.h"
|
||||
|
||||
#include "telephony_log_wrapper.h"
|
||||
|
||||
namespace OHOS {
|
||||
namespace Telephony {
|
||||
bool DownloadProfileResult::ReadFromParcel(Parcel &parcel)
|
||||
{
|
||||
int32_t resultValue;
|
||||
int32_t resolvableErrorsValue;
|
||||
if (!parcel.ReadInt32(resultValue) ||
|
||||
!parcel.ReadInt32(resolvableErrorsValue) ||
|
||||
!parcel.ReadUint32(cardId_)) {
|
||||
return false;
|
||||
}
|
||||
result_ = static_cast<ResultState>(resultValue);
|
||||
resolvableErrors_ = static_cast<ResolvableErrors>(resolvableErrorsValue);
|
||||
return true;
|
||||
}
|
||||
|
||||
bool DownloadProfileResult::Marshalling(Parcel &parcel) const
|
||||
{
|
||||
if (!parcel.WriteInt32(static_cast<int32_t>(result_)) ||
|
||||
!parcel.WriteInt32(static_cast<int32_t>(resolvableErrors_)) ||
|
||||
!parcel.WriteUint32(cardId_)) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
DownloadProfileResult *DownloadProfileResult::Unmarshalling(Parcel &parcel)
|
||||
{
|
||||
DownloadProfileResult *downloadProfileResult = new (std::nothrow) DownloadProfileResult();
|
||||
if (downloadProfileResult == nullptr) {
|
||||
return nullptr;
|
||||
}
|
||||
if (!downloadProfileResult->ReadFromParcel(parcel)) {
|
||||
TELEPHONY_LOGE("DownloadProfileResult:read from parcel failed");
|
||||
delete downloadProfileResult;
|
||||
downloadProfileResult = nullptr;
|
||||
}
|
||||
return downloadProfileResult;
|
||||
}
|
||||
} // namespace OHOS
|
||||
} // namespace Telephony
|
79
frameworks/native/src/downloadable_profile_parcel.cpp
Normal file
79
frameworks/native/src/downloadable_profile_parcel.cpp
Normal file
@ -0,0 +1,79 @@
|
||||
/*
|
||||
* Copyright (C) 2024 Huawei Device Co., Ltd.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#include "downloadable_profile_parcel.h"
|
||||
|
||||
#include "telephony_log_wrapper.h"
|
||||
|
||||
namespace OHOS {
|
||||
namespace Telephony {
|
||||
constexpr uint32_t MAX_SIZE = 1000;
|
||||
bool DownloadableProfile::ReadFromParcel(Parcel &parcel)
|
||||
{
|
||||
if (!parcel.ReadString16(encodedActivationCode_) || !parcel.ReadString16(confirmationCode_) ||
|
||||
!parcel.ReadString16(carrierName_)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
uint32_t size;
|
||||
if (!parcel.ReadUint32(size)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (size > MAX_SIZE) {
|
||||
TELEPHONY_LOGE("over max size");
|
||||
return false;
|
||||
}
|
||||
accessRules_.resize(size);
|
||||
for (auto &rule : accessRules_) {
|
||||
if (!parcel.ReadString16(rule.certificateHashHexStr_) || !parcel.ReadString16(rule.packageName_) ||
|
||||
!parcel.ReadInt32(rule.accessType_)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
bool DownloadableProfile::Marshalling(Parcel &parcel) const
|
||||
{
|
||||
if (!parcel.WriteString16(encodedActivationCode_) || !parcel.WriteString16(confirmationCode_) ||
|
||||
!parcel.WriteString16(carrierName_) ||
|
||||
!parcel.WriteUint32(static_cast<uint32_t>(accessRules_.size()))) {
|
||||
return false;
|
||||
}
|
||||
for (auto const &rule : accessRules_) {
|
||||
if (!parcel.WriteString16(rule.certificateHashHexStr_) || !parcel.WriteString16(rule.packageName_) ||
|
||||
!parcel.WriteInt32(rule.accessType_)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
DownloadableProfile *DownloadableProfile::Unmarshalling(Parcel &parcel)
|
||||
{
|
||||
DownloadableProfile *downloadableProfile = new (std::nothrow) DownloadableProfile();
|
||||
if (downloadableProfile == nullptr) {
|
||||
return nullptr;
|
||||
}
|
||||
if (!downloadableProfile->ReadFromParcel(parcel)) {
|
||||
TELEPHONY_LOGE("DownloadableProfile:read from parcel failed");
|
||||
delete downloadableProfile;
|
||||
downloadableProfile = nullptr;
|
||||
}
|
||||
return downloadableProfile;
|
||||
}
|
||||
} // namespace OHOS
|
||||
} // namespace Telephony
|
327
frameworks/native/src/esim_service_client.cpp
Normal file
327
frameworks/native/src/esim_service_client.cpp
Normal file
@ -0,0 +1,327 @@
|
||||
/*
|
||||
* Copyright (C) 2024 Huawei Device Co., Ltd.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#include "esim_service_client.h"
|
||||
|
||||
#include "esim_service_proxy.h"
|
||||
#include "if_system_ability_manager.h"
|
||||
#include "iservice_registry.h"
|
||||
#include "string_ex.h"
|
||||
#include "system_ability_definition.h"
|
||||
#include "telephony_errors.h"
|
||||
#include "telephony_log_wrapper.h"
|
||||
#include "telephony_types.h"
|
||||
|
||||
namespace OHOS {
|
||||
namespace Telephony {
|
||||
constexpr int32_t TELEPHONY_ESIM_SERVICE_SYS_ABILITY_ID = 66250;
|
||||
constexpr int32_t WAIT_REMOTE_TIME_SEC = 4;
|
||||
std::mutex g_loadMutex;
|
||||
std::condition_variable g_cv;
|
||||
void EsimServiceClientCallback::OnLoadSystemAbilitySuccess(
|
||||
int32_t systemAbilityId, const sptr<IRemoteObject> &remoteObject)
|
||||
{
|
||||
TELEPHONY_LOGI("Loading system ability succeeded");
|
||||
std::unique_lock<std::mutex> lock(g_loadMutex);
|
||||
remoteObject_ = remoteObject;
|
||||
g_cv.notify_one();
|
||||
}
|
||||
|
||||
void EsimServiceClientCallback::OnLoadSystemAbilityFail(int32_t systemAbilityId)
|
||||
{
|
||||
TELEPHONY_LOGE("Loading system ability failed");
|
||||
isLoadSAFailed_ = true;
|
||||
}
|
||||
|
||||
bool EsimServiceClientCallback::IsFailed()
|
||||
{
|
||||
return isLoadSAFailed_;
|
||||
}
|
||||
|
||||
const sptr<IRemoteObject> &EsimServiceClientCallback::GetRemoteObject() const
|
||||
{
|
||||
return remoteObject_;
|
||||
}
|
||||
|
||||
EsimServiceClient::EsimServiceClient() = default;
|
||||
|
||||
EsimServiceClient::~EsimServiceClient()
|
||||
{
|
||||
RemoveDeathRecipient(nullptr, false);
|
||||
}
|
||||
|
||||
sptr<IEsimService> EsimServiceClient::GetProxy()
|
||||
{
|
||||
std::lock_guard<std::mutex> lock(mutexProxy_);
|
||||
if (proxy_ != nullptr) {
|
||||
return proxy_;
|
||||
}
|
||||
|
||||
sptr<ISystemAbilityManager> sam = SystemAbilityManagerClient::GetInstance().GetSystemAbilityManager();
|
||||
if (sam == nullptr) {
|
||||
TELEPHONY_LOGE("Failed to get system ability manager");
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
sptr<EsimServiceClientCallback> callback = new (std::nothrow) EsimServiceClientCallback();
|
||||
if (callback == nullptr) {
|
||||
return nullptr;
|
||||
}
|
||||
int32_t result = sam->LoadSystemAbility(TELEPHONY_ESIM_SERVICE_SYS_ABILITY_ID, callback);
|
||||
if (result != ERR_OK) {
|
||||
TELEPHONY_LOGE("LoadSystemAbility failed : %{public}d", result);
|
||||
return nullptr;
|
||||
}
|
||||
{
|
||||
std::unique_lock<std::mutex> uniqueLock(g_loadMutex);
|
||||
g_cv.wait_for(uniqueLock, std::chrono::seconds(WAIT_REMOTE_TIME_SEC),
|
||||
[&callback]() { return callback->GetRemoteObject() != nullptr || callback->IsFailed(); });
|
||||
}
|
||||
|
||||
TELEPHONY_LOGI("SystemAbilityManagerClient LoadSystemAbility.");
|
||||
|
||||
auto remote = callback->GetRemoteObject();
|
||||
if (remote == nullptr) {
|
||||
TELEPHONY_LOGE("Failed to get service");
|
||||
return nullptr;
|
||||
}
|
||||
deathRecipient_ = new (std::nothrow) EsimServiceDeathRecipient(*this);
|
||||
if (deathRecipient_ == nullptr) {
|
||||
TELEPHONY_LOGE("recipient is null");
|
||||
return nullptr;
|
||||
}
|
||||
if ((remote->IsProxyObject()) && (!remote->AddDeathRecipient(deathRecipient_))) {
|
||||
TELEPHONY_LOGE("Failed to add death recipient");
|
||||
return nullptr;
|
||||
}
|
||||
proxy_ = iface_cast<IEsimService>(remote);
|
||||
if (proxy_ == nullptr) {
|
||||
TELEPHONY_LOGE("Get remote service proxy failed");
|
||||
return nullptr;
|
||||
}
|
||||
TELEPHONY_LOGD("Succeed to connect esim service");
|
||||
return proxy_;
|
||||
}
|
||||
|
||||
void EsimServiceClient::OnRemoteDied(const wptr<IRemoteObject> &remote)
|
||||
{
|
||||
RemoveDeathRecipient(remote, true);
|
||||
}
|
||||
|
||||
void EsimServiceClient::RemoveDeathRecipient(const wptr<IRemoteObject> &remote, bool isRemoteDied)
|
||||
{
|
||||
if (isRemoteDied && remote == nullptr) {
|
||||
TELEPHONY_LOGE("Remote died, remote is nullptr");
|
||||
return;
|
||||
}
|
||||
std::lock_guard<std::mutex> lock(mutexProxy_);
|
||||
if (proxy_ == nullptr) {
|
||||
TELEPHONY_LOGE("proxy_ is nullptr");
|
||||
return;
|
||||
}
|
||||
auto serviceRemote = proxy_->AsObject();
|
||||
if (serviceRemote == nullptr) {
|
||||
TELEPHONY_LOGE("serviceRemote is nullptr");
|
||||
return;
|
||||
}
|
||||
if (isRemoteDied && serviceRemote != remote.promote()) {
|
||||
TELEPHONY_LOGE("Remote died serviceRemote is not same");
|
||||
return;
|
||||
}
|
||||
serviceRemote->RemoveDeathRecipient(deathRecipient_);
|
||||
proxy_ = nullptr;
|
||||
TELEPHONY_LOGI("RemoveDeathRecipient success");
|
||||
}
|
||||
|
||||
int32_t EsimServiceClient::GetEid(int32_t slotId, std::string &eId)
|
||||
{
|
||||
auto proxy = GetProxy();
|
||||
if (proxy == nullptr) {
|
||||
TELEPHONY_LOGE("proxy is null!");
|
||||
return TELEPHONY_ERR_IPC_CONNECT_STUB_FAIL;
|
||||
}
|
||||
return proxy->GetEid(slotId, eId);
|
||||
}
|
||||
|
||||
int32_t EsimServiceClient::GetOsuStatus(int32_t slotId, int32_t &osuStatus)
|
||||
{
|
||||
auto proxy = GetProxy();
|
||||
if (proxy == nullptr) {
|
||||
TELEPHONY_LOGE("proxy is null!");
|
||||
return TELEPHONY_ERR_IPC_CONNECT_STUB_FAIL;
|
||||
}
|
||||
return proxy->GetOsuStatus(slotId, osuStatus);
|
||||
}
|
||||
|
||||
int32_t EsimServiceClient::StartOsu(int32_t slotId, int32_t &startOsuResult)
|
||||
{
|
||||
auto proxy = GetProxy();
|
||||
if (proxy == nullptr) {
|
||||
TELEPHONY_LOGE("proxy is null!");
|
||||
return TELEPHONY_ERR_IPC_CONNECT_STUB_FAIL;
|
||||
}
|
||||
return proxy->StartOsu(slotId, startOsuResult);
|
||||
}
|
||||
|
||||
int32_t EsimServiceClient::GetDownloadableProfileMetadata(
|
||||
int32_t slotId, int32_t portIndex, const DownloadableProfile &profile,
|
||||
bool forceDeactivateSim, GetDownloadableProfileMetadataResult &profileMetadataResult)
|
||||
{
|
||||
auto proxy = GetProxy();
|
||||
if (proxy == nullptr) {
|
||||
TELEPHONY_LOGE("proxy is null!");
|
||||
return TELEPHONY_ERR_IPC_CONNECT_STUB_FAIL;
|
||||
}
|
||||
return proxy->GetDownloadableProfileMetadata(
|
||||
slotId, portIndex, profile, forceDeactivateSim, profileMetadataResult);
|
||||
}
|
||||
|
||||
int32_t EsimServiceClient::GetDownloadableProfiles(
|
||||
int32_t slotId, int32_t portIndex, bool forceDeactivateSim, GetDownloadableProfilesResult &profileListResult)
|
||||
{
|
||||
auto proxy = GetProxy();
|
||||
if (proxy == nullptr) {
|
||||
TELEPHONY_LOGE("proxy is null!");
|
||||
return TELEPHONY_ERR_IPC_CONNECT_STUB_FAIL;
|
||||
}
|
||||
return proxy->GetDownloadableProfiles(slotId, portIndex, forceDeactivateSim, profileListResult);
|
||||
}
|
||||
|
||||
int32_t EsimServiceClient::DownloadProfile(int32_t slotId, DownloadProfileConfigInfo configInfo,
|
||||
const DownloadableProfile &profile, DownloadProfileResult &downloadProfileResult)
|
||||
{
|
||||
auto proxy = GetProxy();
|
||||
if (proxy == nullptr) {
|
||||
TELEPHONY_LOGE("proxy is null!");
|
||||
return TELEPHONY_ERR_IPC_CONNECT_STUB_FAIL;
|
||||
}
|
||||
return proxy->DownloadProfile(slotId, configInfo, profile, downloadProfileResult);
|
||||
}
|
||||
|
||||
int32_t EsimServiceClient::GetEuiccProfileInfoList(int32_t slotId, GetEuiccProfileInfoListResult &euiccProfileInfoList)
|
||||
{
|
||||
auto proxy = GetProxy();
|
||||
if (proxy == nullptr) {
|
||||
TELEPHONY_LOGE("proxy is null!");
|
||||
return TELEPHONY_ERR_IPC_CONNECT_STUB_FAIL;
|
||||
}
|
||||
return proxy->GetEuiccProfileInfoList(slotId, euiccProfileInfoList);
|
||||
}
|
||||
|
||||
int32_t EsimServiceClient::GetEuiccInfo(int32_t slotId, EuiccInfo &eUiccInfo)
|
||||
{
|
||||
auto proxy = GetProxy();
|
||||
if (proxy == nullptr) {
|
||||
TELEPHONY_LOGE("proxy is null!");
|
||||
return TELEPHONY_ERR_IPC_CONNECT_STUB_FAIL;
|
||||
}
|
||||
return proxy->GetEuiccInfo(slotId, eUiccInfo);
|
||||
}
|
||||
|
||||
int32_t EsimServiceClient::DeleteProfile(int32_t slotId, const std::string &iccId, int32_t &deleteProfileResult)
|
||||
{
|
||||
auto proxy = GetProxy();
|
||||
if (proxy == nullptr) {
|
||||
TELEPHONY_LOGE("proxy is null!");
|
||||
return TELEPHONY_ERR_IPC_CONNECT_STUB_FAIL;
|
||||
}
|
||||
return proxy->DeleteProfile(slotId, iccId, deleteProfileResult);
|
||||
}
|
||||
|
||||
int32_t EsimServiceClient::SwitchToProfile(int32_t slotId, int32_t portIndex,
|
||||
const std::string &iccId, bool forceDeactivateSim, int32_t &switchToProfileResult)
|
||||
{
|
||||
auto proxy = GetProxy();
|
||||
if (proxy == nullptr) {
|
||||
TELEPHONY_LOGE("proxy is null!");
|
||||
return TELEPHONY_ERR_IPC_CONNECT_STUB_FAIL;
|
||||
}
|
||||
return proxy->SwitchToProfile(slotId, portIndex, iccId, forceDeactivateSim, switchToProfileResult);
|
||||
}
|
||||
|
||||
int32_t EsimServiceClient::SetProfileNickname(int32_t slotId, const std::string &iccId,
|
||||
const std::string &nickname, int32_t &setProfileNicknameResult)
|
||||
{
|
||||
auto proxy = GetProxy();
|
||||
if (proxy == nullptr) {
|
||||
TELEPHONY_LOGE("proxy is null!");
|
||||
return TELEPHONY_ERR_IPC_CONNECT_STUB_FAIL;
|
||||
}
|
||||
return proxy->SetProfileNickname(slotId, iccId, nickname, setProfileNicknameResult);
|
||||
}
|
||||
|
||||
int32_t EsimServiceClient::ResetMemory(int32_t slotId, int32_t resetOption, int32_t &resetMemoryResult)
|
||||
{
|
||||
auto proxy = GetProxy();
|
||||
if (proxy == nullptr) {
|
||||
TELEPHONY_LOGE("proxy is null!");
|
||||
return TELEPHONY_ERR_IPC_CONNECT_STUB_FAIL;
|
||||
}
|
||||
return proxy->ResetMemory(slotId, resetOption, resetMemoryResult);
|
||||
}
|
||||
|
||||
int32_t EsimServiceClient::ReserveProfilesForFactoryRestore(int32_t slotId, int32_t &restoreResult)
|
||||
{
|
||||
auto proxy = GetProxy();
|
||||
if (proxy == nullptr) {
|
||||
TELEPHONY_LOGE("proxy is null!");
|
||||
return TELEPHONY_ERR_IPC_CONNECT_STUB_FAIL;
|
||||
}
|
||||
return proxy->ReserveProfilesForFactoryRestore(slotId, restoreResult);
|
||||
}
|
||||
|
||||
int32_t EsimServiceClient::SetDefaultSmdpAddress(
|
||||
int32_t slotId, const std::string &defaultSmdpAddress, int32_t &setDefaultSmdpAddressResult)
|
||||
{
|
||||
auto proxy = GetProxy();
|
||||
if (proxy == nullptr) {
|
||||
TELEPHONY_LOGE("proxy is null!");
|
||||
return TELEPHONY_ERR_IPC_CONNECT_STUB_FAIL;
|
||||
}
|
||||
return proxy->SetDefaultSmdpAddress(slotId, defaultSmdpAddress, setDefaultSmdpAddressResult);
|
||||
}
|
||||
|
||||
int32_t EsimServiceClient::GetDefaultSmdpAddress(int32_t slotId, std::string &defaultSmdpAddress)
|
||||
{
|
||||
auto proxy = GetProxy();
|
||||
if (proxy == nullptr) {
|
||||
TELEPHONY_LOGE("proxy is null!");
|
||||
return TELEPHONY_ERR_IPC_CONNECT_STUB_FAIL;
|
||||
}
|
||||
return proxy->GetDefaultSmdpAddress(slotId, defaultSmdpAddress);
|
||||
}
|
||||
|
||||
int32_t EsimServiceClient::CancelSession(
|
||||
int32_t slotId, const std::string &transactionId, int32_t cancelReason, ResponseEsimResult &responseResult)
|
||||
{
|
||||
auto proxy = GetProxy();
|
||||
if (proxy == nullptr) {
|
||||
TELEPHONY_LOGE("proxy is null!");
|
||||
return TELEPHONY_ERR_IPC_CONNECT_STUB_FAIL;
|
||||
}
|
||||
return proxy->CancelSession(slotId, transactionId, cancelReason, responseResult);
|
||||
}
|
||||
|
||||
bool EsimServiceClient::IsEsimSupported(int32_t slotId)
|
||||
{
|
||||
auto proxy = GetProxy();
|
||||
if (proxy == nullptr) {
|
||||
TELEPHONY_LOGE("proxy is null!");
|
||||
return false;
|
||||
}
|
||||
return proxy->IsEsimSupported(slotId);
|
||||
}
|
||||
} // namespace Telephony
|
||||
} // namespace OHOS
|
46
frameworks/native/src/euicc_info_parcel.cpp
Normal file
46
frameworks/native/src/euicc_info_parcel.cpp
Normal file
@ -0,0 +1,46 @@
|
||||
/*
|
||||
* Copyright (C) 2024 Huawei Device Co., Ltd.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#include "euicc_info_parcel.h"
|
||||
|
||||
#include "telephony_log_wrapper.h"
|
||||
|
||||
namespace OHOS {
|
||||
namespace Telephony {
|
||||
bool EuiccInfo::ReadFromParcel(Parcel &parcel)
|
||||
{
|
||||
return parcel.ReadString16(osVersion_) && parcel.ReadString16(response_);
|
||||
}
|
||||
|
||||
bool EuiccInfo::Marshalling(Parcel &parcel) const
|
||||
{
|
||||
return parcel.WriteString16(osVersion_) && parcel.WriteString16(response_);
|
||||
}
|
||||
|
||||
EuiccInfo *EuiccInfo::Unmarshalling(Parcel &parcel)
|
||||
{
|
||||
EuiccInfo *info = new (std::nothrow) EuiccInfo();
|
||||
if (info == nullptr) {
|
||||
return nullptr;
|
||||
}
|
||||
if (!info->ReadFromParcel(parcel)) {
|
||||
TELEPHONY_LOGE("Euiccinfo:read from parcel failed");
|
||||
delete info;
|
||||
info = nullptr;
|
||||
}
|
||||
return info;
|
||||
}
|
||||
} // namespace OHOS
|
||||
} // namespace Telephony
|
@ -0,0 +1,109 @@
|
||||
/*
|
||||
* Copyright (C) 2024 Huawei Device Co., Ltd.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#include "get_downloadable_profiles_result_parcel.h"
|
||||
|
||||
#include "telephony_log_wrapper.h"
|
||||
|
||||
namespace OHOS {
|
||||
namespace Telephony {
|
||||
constexpr uint32_t MAX_SIZE = 1000;
|
||||
bool GetDownloadableProfilesResult::ReadFromParcel(Parcel &parcel)
|
||||
{
|
||||
int32_t resultValue;
|
||||
if (!parcel.ReadInt32(resultValue)) {
|
||||
return false;
|
||||
}
|
||||
result_ = static_cast<ResultState>(resultValue);
|
||||
|
||||
uint32_t size;
|
||||
if (!parcel.ReadUint32(size)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (size > MAX_SIZE) {
|
||||
TELEPHONY_LOGE("over max size");
|
||||
return false;
|
||||
}
|
||||
downloadableProfiles_.resize(size);
|
||||
for (auto &profile : downloadableProfiles_) {
|
||||
if (!parcel.ReadString16(profile.encodedActivationCode_) ||
|
||||
!parcel.ReadString16(profile.confirmationCode_) ||
|
||||
!parcel.ReadString16(profile.carrierName_)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
uint32_t count;
|
||||
if (!parcel.ReadUint32(count)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (count > MAX_SIZE) {
|
||||
TELEPHONY_LOGE("over max size");
|
||||
return false;
|
||||
}
|
||||
profile.accessRules_.resize(count);
|
||||
for (auto &rule : profile.accessRules_) {
|
||||
if (!parcel.ReadString16(rule.certificateHashHexStr_) ||
|
||||
!parcel.ReadString16(rule.packageName_) ||
|
||||
!parcel.ReadInt32(rule.accessType_)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
bool GetDownloadableProfilesResult::Marshalling(Parcel &parcel) const
|
||||
{
|
||||
if (!parcel.WriteInt32(static_cast<int32_t>(result_)) ||
|
||||
!parcel.WriteUint32(static_cast<uint32_t>(downloadableProfiles_.size()))) {
|
||||
return false;
|
||||
}
|
||||
|
||||
for (auto const &profile : downloadableProfiles_) {
|
||||
if (!parcel.WriteString16(profile.encodedActivationCode_) ||
|
||||
!parcel.WriteString16(profile.confirmationCode_) ||
|
||||
!parcel.WriteString16(profile.carrierName_) ||
|
||||
!parcel.WriteUint32(static_cast<uint32_t>(profile.accessRules_.size()))) {
|
||||
return false;
|
||||
}
|
||||
|
||||
for (auto const &rule : profile.accessRules_) {
|
||||
if (!parcel.WriteString16(rule.certificateHashHexStr_) ||
|
||||
!parcel.WriteString16(rule.packageName_) ||
|
||||
!parcel.WriteInt32(rule.accessType_)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
GetDownloadableProfilesResult *GetDownloadableProfilesResult::Unmarshalling(Parcel &parcel)
|
||||
{
|
||||
GetDownloadableProfilesResult *downloadableProfilesResult = new (std::nothrow) GetDownloadableProfilesResult();
|
||||
if (downloadableProfilesResult == nullptr) {
|
||||
return nullptr;
|
||||
}
|
||||
if (!downloadableProfilesResult->ReadFromParcel(parcel)) {
|
||||
TELEPHONY_LOGE("GetDownloadableProfilesResult:read from parcel failed");
|
||||
delete downloadableProfilesResult;
|
||||
downloadableProfilesResult = nullptr;
|
||||
}
|
||||
return downloadableProfilesResult;
|
||||
}
|
||||
} // namespace OHOS
|
||||
} // namespace Telephony
|
132
frameworks/native/src/profile_info_list_parcel.cpp
Normal file
132
frameworks/native/src/profile_info_list_parcel.cpp
Normal file
@ -0,0 +1,132 @@
|
||||
/*
|
||||
* Copyright (C) 2024 Huawei Device Co., Ltd.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#include "profile_info_list_parcel.h"
|
||||
|
||||
#include "telephony_log_wrapper.h"
|
||||
|
||||
namespace OHOS {
|
||||
namespace Telephony {
|
||||
constexpr uint32_t MAX_SIZE = 1000;
|
||||
bool GetEuiccProfileInfoListResult::ReadProfileFromParcel(Parcel &parcel, EuiccProfile &profile)
|
||||
{
|
||||
int32_t stateValue;
|
||||
int32_t profileClassValue;
|
||||
int32_t policyRulesValue;
|
||||
if (!parcel.ReadString16(profile.iccId_) || !parcel.ReadString16(profile.nickName_) ||
|
||||
!parcel.ReadString16(profile.serviceProviderName_) || !parcel.ReadString16(profile.profileName_) ||
|
||||
!parcel.ReadInt32(stateValue) || !parcel.ReadInt32(profileClassValue) ||
|
||||
!parcel.ReadString16(profile.carrierId_.mcc_) || !parcel.ReadString16(profile.carrierId_.mnc_) ||
|
||||
!parcel.ReadString16(profile.carrierId_.gid1_) || !parcel.ReadString16(profile.carrierId_.gid2_) ||
|
||||
!parcel.ReadInt32(policyRulesValue)) {
|
||||
return false;
|
||||
}
|
||||
profile.state_ = static_cast<ProfileState>(stateValue);
|
||||
profile.profileClass_ = static_cast<ProfileClass>(profileClassValue);
|
||||
profile.policyRules_ = static_cast<PolicyRules>(policyRulesValue);
|
||||
|
||||
uint32_t count;
|
||||
if (!parcel.ReadUint32(count)) {
|
||||
return false;
|
||||
}
|
||||
if (count > MAX_SIZE) {
|
||||
TELEPHONY_LOGE("over max size");
|
||||
return false;
|
||||
}
|
||||
profile.accessRules_.resize(count);
|
||||
for (auto &rule : profile.accessRules_) {
|
||||
if (!parcel.ReadString16(rule.certificateHashHexStr_) ||
|
||||
!parcel.ReadString16(rule.packageName_) || !parcel.ReadInt32(rule.accessType_)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
bool GetEuiccProfileInfoListResult::ReadFromParcel(Parcel &parcel)
|
||||
{
|
||||
int32_t resultValue;
|
||||
if (!parcel.ReadInt32(resultValue)) {
|
||||
return false;
|
||||
}
|
||||
result_ = static_cast<ResultState>(resultValue);
|
||||
|
||||
uint32_t size;
|
||||
if (!parcel.ReadUint32(size)) {
|
||||
return false;
|
||||
}
|
||||
if (size > MAX_SIZE) {
|
||||
TELEPHONY_LOGE("over max size");
|
||||
return false;
|
||||
}
|
||||
profiles_.resize(size);
|
||||
for (auto &profile : profiles_) {
|
||||
if (!ReadProfileFromParcel(parcel, profile)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
bool GetEuiccProfileInfoListResult::Marshalling(Parcel &parcel) const
|
||||
{
|
||||
if (!parcel.WriteInt32(static_cast<int32_t>(result_)) ||
|
||||
!parcel.WriteUint32(static_cast<uint32_t>(profiles_.size()))) {
|
||||
return false;
|
||||
}
|
||||
for (auto const &profile : profiles_) {
|
||||
int32_t stateValue = static_cast<int32_t>(profile.state_);
|
||||
int32_t profileClassValue = static_cast<int32_t>(profile.profileClass_);
|
||||
int32_t policyRulesValue = static_cast<int32_t>(profile.policyRules_);
|
||||
if (!parcel.WriteString16(profile.iccId_) ||
|
||||
!parcel.WriteString16(profile.nickName_) ||
|
||||
!parcel.WriteString16(profile.serviceProviderName_) ||
|
||||
!parcel.WriteString16(profile.profileName_) ||
|
||||
!parcel.WriteInt32(stateValue) ||
|
||||
!parcel.WriteInt32(profileClassValue) ||
|
||||
!parcel.WriteString16(profile.carrierId_.mcc_) ||
|
||||
!parcel.WriteString16(profile.carrierId_.mnc_) ||
|
||||
!parcel.WriteString16(profile.carrierId_.gid1_) ||
|
||||
!parcel.WriteString16(profile.carrierId_.gid2_) ||
|
||||
!parcel.WriteInt32(policyRulesValue) ||
|
||||
!parcel.WriteUint32(static_cast<uint32_t>(profile.accessRules_.size()))) {
|
||||
return false;
|
||||
}
|
||||
for (auto const &rule : profile.accessRules_) {
|
||||
if (!parcel.WriteString16(rule.certificateHashHexStr_) ||
|
||||
!parcel.WriteString16(rule.packageName_) ||
|
||||
!parcel.WriteInt32(rule.accessType_)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
GetEuiccProfileInfoListResult *GetEuiccProfileInfoListResult::Unmarshalling(Parcel &parcel)
|
||||
{
|
||||
GetEuiccProfileInfoListResult *euiccProfileInfoListResult = new (std::nothrow) GetEuiccProfileInfoListResult();
|
||||
if (euiccProfileInfoListResult == nullptr) {
|
||||
return nullptr;
|
||||
}
|
||||
if (!euiccProfileInfoListResult->ReadFromParcel(parcel)) {
|
||||
TELEPHONY_LOGE("GetEuiccProfileInfoListResult:read from parcel failed");
|
||||
delete euiccProfileInfoListResult;
|
||||
euiccProfileInfoListResult = nullptr;
|
||||
}
|
||||
return euiccProfileInfoListResult;
|
||||
}
|
||||
} // namespace OHOS
|
||||
} // namespace Telephony
|
98
frameworks/native/src/profile_metadata_result_parcel.cpp
Normal file
98
frameworks/native/src/profile_metadata_result_parcel.cpp
Normal file
@ -0,0 +1,98 @@
|
||||
/*
|
||||
* Copyright (C) 2024 Huawei Device Co., Ltd.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#include "profile_metadata_result_parcel.h"
|
||||
|
||||
#include "telephony_log_wrapper.h"
|
||||
|
||||
namespace OHOS {
|
||||
namespace Telephony {
|
||||
constexpr uint32_t MAX_SIZE = 1000;
|
||||
bool GetDownloadableProfileMetadataResult::ReadFromParcel(Parcel &parcel)
|
||||
{
|
||||
if (!parcel.ReadString16(downloadableProfiles_.encodedActivationCode_) ||
|
||||
!parcel.ReadString16(downloadableProfiles_.confirmationCode_) ||
|
||||
!parcel.ReadString16(downloadableProfiles_.carrierName_)) {
|
||||
return false;
|
||||
}
|
||||
uint32_t size;
|
||||
if (!parcel.ReadUint32(size)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (size > MAX_SIZE) {
|
||||
TELEPHONY_LOGE("over max size");
|
||||
return false;
|
||||
}
|
||||
downloadableProfiles_.accessRules_.resize(size);
|
||||
for (auto &rule : downloadableProfiles_.accessRules_) {
|
||||
if (!parcel.ReadString16(rule.certificateHashHexStr_) ||
|
||||
!parcel.ReadString16(rule.packageName_) ||
|
||||
!parcel.ReadInt32(rule.accessType_)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
int32_t resolvableErrorsValue;
|
||||
int32_t resultValue;
|
||||
if (!parcel.ReadInt32(pprType_) || !parcel.ReadBool(pprFlag_) ||
|
||||
!parcel.ReadInt32(resolvableErrorsValue) || !parcel.ReadInt32(resultValue)) {
|
||||
return false;
|
||||
}
|
||||
resolvableErrors_ = static_cast<ResolvableErrors>(resolvableErrorsValue);
|
||||
result_ = static_cast<ResultState>(resultValue);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool GetDownloadableProfileMetadataResult::Marshalling(Parcel &parcel) const
|
||||
{
|
||||
if (!parcel.WriteString16(downloadableProfiles_.encodedActivationCode_) ||
|
||||
!parcel.WriteString16(downloadableProfiles_.confirmationCode_) ||
|
||||
!parcel.WriteString16(downloadableProfiles_.carrierName_) ||
|
||||
!parcel.WriteUint32(static_cast<uint32_t>(downloadableProfiles_.accessRules_.size()))) {
|
||||
return false;
|
||||
}
|
||||
for (auto const &rule : downloadableProfiles_.accessRules_) {
|
||||
if (!parcel.WriteString16(rule.certificateHashHexStr_) ||
|
||||
!parcel.WriteString16(rule.packageName_) ||
|
||||
!parcel.WriteInt32(rule.accessType_)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
if (!parcel.WriteInt32(pprType_) || !parcel.WriteBool(pprFlag_) ||
|
||||
!parcel.WriteInt32(static_cast<int32_t>(resolvableErrors_)) ||
|
||||
!parcel.WriteInt32(static_cast<int32_t>(result_))) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
GetDownloadableProfileMetadataResult *GetDownloadableProfileMetadataResult::Unmarshalling(Parcel &parcel)
|
||||
{
|
||||
GetDownloadableProfileMetadataResult *metaData = new (std::nothrow) GetDownloadableProfileMetadataResult();
|
||||
if (metaData == nullptr) {
|
||||
return nullptr;
|
||||
}
|
||||
if (!metaData->ReadFromParcel(parcel)) {
|
||||
TELEPHONY_LOGE("GetDownloadableProfileMetadataResult:read from parcel failed");
|
||||
delete metaData;
|
||||
metaData = nullptr;
|
||||
}
|
||||
return metaData;
|
||||
}
|
||||
} // namespace OHOS
|
||||
} // namespace Telephony
|
55
frameworks/native/src/response_esim_result.cpp
Normal file
55
frameworks/native/src/response_esim_result.cpp
Normal file
@ -0,0 +1,55 @@
|
||||
/*
|
||||
* Copyright (C) 2024 Huawei Device Co., Ltd.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#include "response_esim_result.h"
|
||||
|
||||
#include "telephony_log_wrapper.h"
|
||||
|
||||
namespace OHOS {
|
||||
namespace Telephony {
|
||||
bool ResponseEsimResult::ReadFromParcel(Parcel &parcel)
|
||||
{
|
||||
int32_t resultValue;
|
||||
if (!parcel.ReadInt32(resultValue) || !parcel.ReadString16(response_)) {
|
||||
return false;
|
||||
}
|
||||
resultCode_ = static_cast<ResultState>(resultValue);
|
||||
return true;
|
||||
}
|
||||
|
||||
bool ResponseEsimResult::Marshalling(Parcel &parcel) const
|
||||
{
|
||||
if (!parcel.WriteInt32(static_cast<int32_t>(resultCode_)) ||
|
||||
!parcel.WriteString16(response_)) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
ResponseEsimResult *ResponseEsimResult::Unmarshalling(Parcel &parcel)
|
||||
{
|
||||
ResponseEsimResult *responseEsimResult = new (std::nothrow) ResponseEsimResult();
|
||||
if (responseEsimResult == nullptr) {
|
||||
return nullptr;
|
||||
}
|
||||
if (!responseEsimResult->ReadFromParcel(parcel)) {
|
||||
TELEPHONY_LOGE("ResponseEsimResult:read from parcel failed");
|
||||
delete responseEsimResult;
|
||||
responseEsimResult = nullptr;
|
||||
}
|
||||
return responseEsimResult;
|
||||
}
|
||||
} // namespace OHOS
|
||||
} // namespace Telephony
|
@ -10,7 +10,9 @@
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
import("//build/config/components/idl_tool/idl.gni")
|
||||
import("//build/ohos.gni")
|
||||
import("../../../core_service/telephony_core_service.gni")
|
||||
|
||||
SUBSYSTEM_DIR = "../../../"
|
||||
TELEPHONY_CORE_SERVICE_ROOT = "$SUBSYSTEM_DIR/core_service"
|
||||
@ -28,6 +30,9 @@ config("tel_core_service_api_config") {
|
||||
"$TELEPHONY_INTERFACES_INNERKITS/ims/include",
|
||||
"$TELEPHONY_INTERFACES_INNERKITS/satellite",
|
||||
]
|
||||
if (core_service_support_esim) {
|
||||
include_dirs += [ "${target_gen_dir}" ]
|
||||
}
|
||||
|
||||
cflags = []
|
||||
if (is_double_framework) {
|
||||
@ -44,6 +49,18 @@ config("tel_core_service_api_config") {
|
||||
}
|
||||
}
|
||||
|
||||
if (core_service_support_esim) {
|
||||
idl_interface_sources = [ "${target_gen_dir}/esim_service_proxy.cpp" ]
|
||||
|
||||
idl_gen_interface("esim_service_api") {
|
||||
src_idl = rebase_path("IEsimService.idl")
|
||||
dst_file = string_join(",", idl_interface_sources)
|
||||
hitrace = "HITRACE_TAG_ABILITY_MANAGER"
|
||||
log_domainid = "0xD001F04"
|
||||
log_tag = "CoreServiceApi"
|
||||
}
|
||||
}
|
||||
|
||||
ohos_shared_library("tel_core_service_api") {
|
||||
sanitize = {
|
||||
cfi = true
|
||||
@ -72,6 +89,21 @@ ohos_shared_library("tel_core_service_api") {
|
||||
"$TELEPHONY_IMS_CORE_SERVICE_ROOT/src/ims_core_service_callback_proxy.cpp",
|
||||
]
|
||||
|
||||
if (core_service_support_esim) {
|
||||
sources += [
|
||||
"$TELEPHONY_FRAMEWORKS_NATIVE_ROOT/src/download_profile_config_info_parcel.cpp",
|
||||
"$TELEPHONY_FRAMEWORKS_NATIVE_ROOT/src/download_profile_result_parcel.cpp",
|
||||
"$TELEPHONY_FRAMEWORKS_NATIVE_ROOT/src/downloadable_profile_parcel.cpp",
|
||||
"$TELEPHONY_FRAMEWORKS_NATIVE_ROOT/src/esim_service_client.cpp",
|
||||
"$TELEPHONY_FRAMEWORKS_NATIVE_ROOT/src/euicc_info_parcel.cpp",
|
||||
"$TELEPHONY_FRAMEWORKS_NATIVE_ROOT/src/get_downloadable_profiles_result_parcel.cpp",
|
||||
"$TELEPHONY_FRAMEWORKS_NATIVE_ROOT/src/profile_info_list_parcel.cpp",
|
||||
"$TELEPHONY_FRAMEWORKS_NATIVE_ROOT/src/profile_metadata_result_parcel.cpp",
|
||||
"$TELEPHONY_FRAMEWORKS_NATIVE_ROOT/src/response_esim_result.cpp",
|
||||
"${target_gen_dir}/esim_service_proxy.cpp",
|
||||
]
|
||||
}
|
||||
|
||||
version_script =
|
||||
"$TELEPHONY_INTERFACES_INNERKITS/libtel_core_service_api.versionscript"
|
||||
|
||||
@ -84,6 +116,10 @@ ohos_shared_library("tel_core_service_api") {
|
||||
|
||||
public_configs += [ ":tel_core_service_api_config" ]
|
||||
|
||||
if (core_service_support_esim) {
|
||||
deps = [ ":esim_service_api" ]
|
||||
}
|
||||
|
||||
external_deps = [
|
||||
"ability_base:want",
|
||||
"bundle_framework:appexecfwk_base",
|
||||
@ -97,6 +133,13 @@ ohos_shared_library("tel_core_service_api") {
|
||||
"samgr:samgr_proxy",
|
||||
]
|
||||
|
||||
if (core_service_support_esim) {
|
||||
external_deps += [
|
||||
"hitrace:hitrace_meter",
|
||||
"ipc:ipc_core",
|
||||
]
|
||||
}
|
||||
|
||||
cflags_cc = [
|
||||
"-O2",
|
||||
"-D_FORTIFY_SOURCE=2",
|
||||
|
68
interfaces/innerkits/IEsimService.idl
Normal file
68
interfaces/innerkits/IEsimService.idl
Normal file
@ -0,0 +1,68 @@
|
||||
/*
|
||||
* Copyright (c) 2024 Huawei Device Co., Ltd.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
sequenceable download_profile_config_info_parcel..OHOS.Telephony.DownloadProfileConfigInfo;
|
||||
sequenceable download_profile_result_parcel..OHOS.Telephony.DownloadableProfile;
|
||||
sequenceable downloadable_profile_parcel..OHOS.Telephony.DownloadProfileResult;
|
||||
sequenceable euicc_info_parcel..OHOS.Telephony.EuiccInfo;
|
||||
sequenceable get_downloadable_profiles_result_parcel..OHOS.Telephony.GetDownloadableProfileMetadataResult;
|
||||
sequenceable profile_info_list_parcel..OHOS.Telephony.GetDownloadableProfilesResult;
|
||||
sequenceable profile_metadata_result_parcel..OHOS.Telephony.GetEuiccProfileInfoListResult;
|
||||
sequenceable response_esim_result..OHOS.Telephony.ResponseEsimResult;
|
||||
|
||||
interface OHOS.Telephony.IEsimService {
|
||||
void GetEid([in] int slotId, [out] String eId);
|
||||
void GetOsuStatus([in] int slotId, [out] int osuStatus);
|
||||
void StartOsu([in] int slotId, [out] int startOsuResult);
|
||||
void GetDownloadableProfileMetadata(
|
||||
[in] int slotId,
|
||||
[in] int portIndex,
|
||||
[in] DownloadableProfile profile,
|
||||
[in] boolean forceDeactivateSim,
|
||||
[out] GetDownloadableProfileMetadataResult profileMetadataResult);
|
||||
void GetDownloadableProfiles(
|
||||
[in] int slotId,
|
||||
[in] int portIndex,
|
||||
[in] boolean forceDeactivateSim,
|
||||
[out] GetDownloadableProfilesResult profileListResult);
|
||||
void DownloadProfile(
|
||||
[in] int slotId,
|
||||
[in] DownloadProfileConfigInfo configInfo,
|
||||
[in] DownloadableProfile profile,
|
||||
[out] DownloadProfileResult downloadProfileResult);
|
||||
void GetEuiccProfileInfoList([in] int slotId, [out] GetEuiccProfileInfoListResult euiccProfileInfoList);
|
||||
void GetEuiccInfo([in] int slotId, [out] EuiccInfo eUiccInfo);
|
||||
void DeleteProfile([in] int slotId, [in] String iccId, [out] int deleteProfileResult);
|
||||
void SwitchToProfile(
|
||||
[in] int slotId,
|
||||
[in] int portIndex,
|
||||
[in] String iccId,
|
||||
[in] boolean forceDeactivateSim,
|
||||
[out] int switchToProfileResult);
|
||||
void SetProfileNickname(
|
||||
[in] int slotId,
|
||||
[in] String iccId,
|
||||
[in] String nickname,
|
||||
[out] int setProfileNicknameResult);
|
||||
void ResetMemory([in] int slotId, [in] int resetOption, [out] int resetMemoryResult);
|
||||
void ReserveProfilesForFactoryRestore([in] int slotId, [out] int restoreResult);
|
||||
void SetDefaultSmdpAddress(
|
||||
[in] int slotId,
|
||||
[in] String defaultSmdpAddress,
|
||||
[out] int setDefaultSmdpAddressResult);
|
||||
void GetDefaultSmdpAddress([in] int slotId, [out] String defaultSmdpAddress);
|
||||
void CancelSession([in] int slotId, [in] String transactionId, [in] int cancelReason,
|
||||
[out] ResponseEsimResult responseResult);
|
||||
void IsEsimSupported([in] int slotId);
|
||||
}
|
@ -919,6 +919,148 @@ public:
|
||||
const std::string &dataStr, const std::string &path, SimAuthenticationResponse &response);
|
||||
|
||||
#ifdef CORE_SERVICE_SUPPORT_ESIM
|
||||
/**
|
||||
* @brief Get the EID identifying the eUICC hardware.
|
||||
*
|
||||
* @param slotId[in], ndicates the card slot index number
|
||||
* @param eId[out], the EID identifying the eUICC hardware
|
||||
* @return int32_t TELEPHONY_SUCCESS on success, others on failure.
|
||||
*/
|
||||
int32_t GetEid(int32_t slotId, std::u16string &eId);
|
||||
|
||||
/**
|
||||
* @brief Obtain the list of all EuiccProfileInfos
|
||||
*
|
||||
* @param slotId[in], sim slot id
|
||||
* @param euiccProfileInfoList[out], the list of all EuiccProfileInfos
|
||||
* @return int32_t TELEPHONY_SUCCESS on success, others on failure.
|
||||
*/
|
||||
int32_t GetEuiccProfileInfoList(int32_t slotId, GetEuiccProfileInfoListResult &euiccProfileInfoList);
|
||||
|
||||
/**
|
||||
* @brief Obtain the info about the eUICC chip/device
|
||||
*
|
||||
* @param slotId[in], sim slot id
|
||||
* @param eUiccInfo[out], the info about the eUICC chip/device
|
||||
* @return int32_t TELEPHONY_SUCCESS on success, others on failure.
|
||||
*/
|
||||
int32_t GetEuiccInfo(int32_t slotId, EuiccInfo &eUiccInfo);
|
||||
|
||||
/**
|
||||
* @brief Disables the profile of the given iccid.
|
||||
*
|
||||
* @param slotId[in], sim slot id
|
||||
* @param portIndex[in], the Id of the eUICC
|
||||
* @param iccId[in], the iccId of the profile
|
||||
* @param refresh[in], whether sending the REFRESH command to modem
|
||||
* @param enumResult[out], the response to obtain
|
||||
* @return int32_t TELEPHONY_SUCCESS on success, others on failure.
|
||||
*/
|
||||
int32_t DisableProfile(
|
||||
int32_t slotId, int32_t portIndex, const std::u16string &iccId, bool refresh, ResultState &enumResult);
|
||||
|
||||
/**
|
||||
* @brief Requests the SM-DS address from eUICC.
|
||||
*
|
||||
* @param slotId[in], sim slot id
|
||||
* @param portIndex[in], the Id of the eUICC
|
||||
* @param smdsAddress[out], the result code and the SM-DS address
|
||||
* @return int32_t TELEPHONY_SUCCESS on success, others on failure.
|
||||
*/
|
||||
int32_t GetSmdsAddress(int32_t slotId, int32_t portIndex, std::u16string &smdsAddress);
|
||||
|
||||
/**
|
||||
* @brief Requests Rules Authorisation Table.
|
||||
*
|
||||
* @param slotId[in], sim slot id
|
||||
* @param portIndex[in], the Id of the eUICC
|
||||
* @param eUiccRulesAuthTable[out], get the rule authorisation table
|
||||
* @return int32_t TELEPHONY_SUCCESS on success, others on failure.
|
||||
*/
|
||||
int32_t GetRulesAuthTable(int32_t slotId, int32_t portIndex, EuiccRulesAuthTable &eUiccRulesAuthTable);
|
||||
|
||||
/**
|
||||
* @brief Requests the eUICC challenge for new profile downloading.
|
||||
*
|
||||
* @param slotId[in], sim slot id
|
||||
* @param portIndex[in], the Id of the eUICC
|
||||
* @param responseResult[out], get the result code and the challenge
|
||||
* @return int32_t TELEPHONY_SUCCESS on success, others on failure.
|
||||
*/
|
||||
int32_t GetEuiccChallenge(int32_t slotId, int32_t portIndex, ResponseEsimResult &responseResult);
|
||||
|
||||
/**
|
||||
* @brief Obtain the international mobile subscriber identity
|
||||
*
|
||||
* @param slotId[in], sim slot id
|
||||
* @param defaultSmdpAddress[out], the international mobile subscriber identity of the SIM card
|
||||
* @return int32_t TELEPHONY_SUCCESS on success, others on failure.
|
||||
*/
|
||||
int32_t GetDefaultSmdpAddress(int32_t slotId, std::u16string &defaultSmdpAddress);
|
||||
|
||||
/**
|
||||
* @brief cancel session.
|
||||
*
|
||||
* @param slotId[in], sim slot id
|
||||
* @param transactionId[in], the Id of the transaction
|
||||
* @param cancelReason[in], reason for canceling a profile download session
|
||||
* @param responseResult[out], the result of the session
|
||||
* @return int32_t TELEPHONY_SUCCESS on success, others on failure.
|
||||
*/
|
||||
int32_t CancelSession(int32_t slotId, const std::u16string &transactionId, CancelReason cancelReason,
|
||||
ResponseEsimResult &responseResult);
|
||||
|
||||
/**
|
||||
* @brief Requests the profile of the given iccid.
|
||||
*
|
||||
* @param slotId[in], sim slot id
|
||||
* @param portIndex[in], the Id of the eUICC
|
||||
* @param iccId[in], the iccId of the profile
|
||||
* @param eUiccProfile[out], the profile of the given iccid
|
||||
* @return int32_t TELEPHONY_SUCCESS on success, others on failure.
|
||||
*/
|
||||
int32_t GetProfile(int32_t slotId, int32_t portIndex, const std::u16string &iccId, EuiccProfile &eUiccProfile);
|
||||
|
||||
/**
|
||||
* @brief Reset memory
|
||||
*
|
||||
* @param slotId[in], sim slot id
|
||||
* @param resetOption[in], options for resetting eUICC memory
|
||||
* @param enumResult[out], the response to obtain
|
||||
* @return int32_t TELEPHONY_SUCCESS on success, others on failure.
|
||||
*/
|
||||
int32_t ResetMemory(int32_t slotId, ResetOption resetOption, ResultState &enumResult);
|
||||
|
||||
/**
|
||||
* @brief This procedure is used to set or update the Default SM-DP+ address stored in an eUICC.
|
||||
*
|
||||
* @param slotId[in], sim slot id
|
||||
* @param defaultSmdpAddress[in], the default SM-DP+ address to set
|
||||
* @param enumResult[out], the response to obtain
|
||||
* @return int32_t TELEPHONY_SUCCESS on success, others on failure.
|
||||
*/
|
||||
int32_t SetDefaultSmdpAddress(int32_t slotId, const std::u16string &defaultSmdpAddress, ResultState &enumResult);
|
||||
|
||||
/**
|
||||
* @brief Whether support for esim
|
||||
*
|
||||
* @param slotId[in], sim slot id
|
||||
* @return returns true if the device support; returns false otherwise.
|
||||
*/
|
||||
bool IsEsimSupported(int32_t slotId);
|
||||
|
||||
/**
|
||||
* @brief Provide sending upgrade or card binding data to the ESIM channel.
|
||||
*
|
||||
* @param slotId[in], sim slot id
|
||||
* @param aid[in], apud sender
|
||||
* @param apduData[in], apud data
|
||||
* @param responseResult[out], return the result of execute one apdu
|
||||
* @return int32_t TELEPHONY_SUCCESS on success, others on failure.
|
||||
*/
|
||||
int32_t SendApduData(
|
||||
int32_t slotId, const std::u16string &aid, const std::u16string &apduData, ResponseEsimResult &responseResult);
|
||||
|
||||
/**
|
||||
* @brief Prepares the profile download request sent to SM-DP+.
|
||||
*
|
||||
@ -969,7 +1111,7 @@ private:
|
||||
public:
|
||||
explicit CoreServiceDeathRecipient(CoreServiceClient &client) : client_(client) {}
|
||||
~CoreServiceDeathRecipient() override = default;
|
||||
void OnRemoteDied(const wptr<IRemoteObject> &remote) override
|
||||
__attribute__((no_sanitize("cfi"))) void OnRemoteDied(const wptr<IRemoteObject> &remote) override
|
||||
{
|
||||
client_.OnRemoteDied(remote);
|
||||
}
|
||||
|
@ -120,6 +120,34 @@ enum class CoreServiceInterfaceCode {
|
||||
GET_OPKEY_VERSION,
|
||||
GET_RESIDENT_NETWORK_NUMERIC,
|
||||
GET_SIM_IO_DONE,
|
||||
|
||||
#ifdef CORE_SERVICE_SUPPORT_ESIM
|
||||
GET_EID,
|
||||
GET_EUICC_PROFILE_INFO_LIST,
|
||||
GET_EUICC_INFO,
|
||||
DELETE_PROFILE,
|
||||
SWITCH_TO_PROFILE,
|
||||
UPDATE_PROFILE_NICKNAME,
|
||||
RESET_MEMORY,
|
||||
SET_DEFAULT_SMDP_ADDRESS,
|
||||
REQUEST_DEFAULT_SMDP_ADDRESS,
|
||||
CANCEL_SESSION,
|
||||
GET_PROFILE,
|
||||
DISABLE_PROFILE,
|
||||
GET_SMDSADDRESS,
|
||||
GET_RULES_AUTH_TABLE,
|
||||
GET_EUICC_CHALLENGE,
|
||||
GET_EUICC_INFO2,
|
||||
AUTHENTICATE_SERVER,
|
||||
PREPARE_DOWNLOAD,
|
||||
LOAD_BOUND_PROFILE_PACKAGE,
|
||||
LIST_NOTIFICATIONS,
|
||||
RETRIEVE_NOTIFICATION_LIST,
|
||||
RETRIEVE_NOTIFICATION,
|
||||
REMOVE_NOTIFICATION,
|
||||
IS_ESIM_SUPPORTED,
|
||||
SEND_APDU_DATA,
|
||||
#endif
|
||||
};
|
||||
} // namespace Telephony
|
||||
} // namespace OHOS
|
||||
|
@ -147,6 +147,27 @@ public:
|
||||
int32_t GetSimIO(int32_t slotId, int32_t command, int32_t fileId,
|
||||
const std::string &data, const std::string &path, SimAuthenticationResponse &response) override;
|
||||
#ifdef CORE_SERVICE_SUPPORT_ESIM
|
||||
int32_t GetEid(int32_t slotId, std::u16string &eId) override;
|
||||
int32_t GetEuiccProfileInfoList(int32_t slotId, GetEuiccProfileInfoListResult &euiccProfileInfoList) override;
|
||||
int32_t GetEuiccInfo(int32_t slotId, EuiccInfo &eUiccInfo) override;
|
||||
int32_t DisableProfile(int32_t slotId, int32_t portIndex, const std::u16string &iccId, bool refresh,
|
||||
ResultState &enumResult) override;
|
||||
int32_t GetSmdsAddress(int32_t slotId, int32_t portIndex, std::u16string &smdsAddress) override;
|
||||
int32_t ParseRulesAuthTableReply(MessageParcel &reply, EuiccRulesAuthTable &eUiccRulesAuthTable);
|
||||
int32_t GetRulesAuthTable(
|
||||
int32_t slotId, int32_t portIndex, EuiccRulesAuthTable &eUiccRulesAuthTable) override;
|
||||
int32_t GetEuiccChallenge(int32_t slotId, int32_t portIndex, ResponseEsimResult &responseResult) override;
|
||||
int32_t GetDefaultSmdpAddress(int32_t slotId, std::u16string &defaultSmdpAddress) override;
|
||||
int32_t CancelSession(int32_t slotId, const std::u16string &transactionId,
|
||||
CancelReason cancelReason, ResponseEsimResult &responseResult) override;
|
||||
int32_t GetProfile(int32_t slotId, int32_t portIndex, const std::u16string &iccId,
|
||||
EuiccProfile &eUiccProfile) override;
|
||||
int32_t ResetMemory(int32_t slotId, ResetOption resetOption, ResultState &enumResult) override;
|
||||
int32_t SetDefaultSmdpAddress(
|
||||
int32_t slotId, const std::u16string &defaultSmdpAddress, ResultState &enumResult) override;
|
||||
bool IsEsimSupported(int32_t slotId) override;
|
||||
int32_t SendApduData(int32_t slotId, const std::u16string &aid, const std::u16string &apduData,
|
||||
ResponseEsimResult &responseResult) override;
|
||||
int32_t PrepareDownload(int32_t slotId, const DownLoadConfigInfo &downLoadConfigInfo,
|
||||
ResponseEsimResult &responseResult) override;
|
||||
int32_t LoadBoundProfilePackage(int32_t slotId, int32_t portIndex, const std::u16string &boundProfilePackage,
|
||||
@ -169,6 +190,9 @@ private:
|
||||
void ProcessSignalInfo(MessageParcel &reply, std::vector<sptr<SignalInformation>> &result);
|
||||
void ProcessCellInfo(MessageParcel &reply, std::vector<sptr<CellInformation>> &cells);
|
||||
int32_t SerializeImsRegInfoData(int32_t slotId, ImsServiceType imsSrvType, MessageParcel &data);
|
||||
#ifdef CORE_SERVICE_SUPPORT_ESIM
|
||||
void ReadEuiccProfileFromReply(MessageParcel &reply, EuiccProfile &euiccProfile);
|
||||
#endif
|
||||
|
||||
private:
|
||||
static inline BrokerDelegator<CoreServiceProxy> delegator_;
|
||||
|
@ -13,31 +13,22 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#ifndef ESIM_SERVICE_INTERFACE_CODE_H
|
||||
#define ESIM_SERVICE_INTERFACE_CODE_H
|
||||
#ifndef OHOS_DOWNLOAD_PROFILE_CONFIG_INFO_PARCEL_H
|
||||
#define OHOS_DOWNLOAD_PROFILE_CONFIG_INFO_PARCEL_H
|
||||
|
||||
#include <parcel.h>
|
||||
|
||||
/* SAID:4018 */
|
||||
namespace OHOS {
|
||||
namespace Telephony {
|
||||
enum class EsimServiceInterfaceCode {
|
||||
GET_EID = 0,
|
||||
GET_OSU_STATUS,
|
||||
START_OSU,
|
||||
GET_DOWNLOAD_ABLE_PROFILE_METADATA,
|
||||
GET_AVAILABLE_DOWNLOADABLE_PROFILE_LIST,
|
||||
DOWNLOAD_PROFILE,
|
||||
GET_EUICC_PROFILE_INFO_LIST,
|
||||
GET_EUICC_INFO,
|
||||
DELETE_PROFILE,
|
||||
SWITCH_TO_PROFILE,
|
||||
SET_PROFILE_NICKNAME,
|
||||
RESET_MEMORY,
|
||||
RESERVE_PROFILES_FOR_FACTORY_RESTORE,
|
||||
SET_DEFAULT_SMDP_ADDRESS,
|
||||
GET_DEFAULT_SMDP_ADDRESS,
|
||||
CANCEL_SESSION,
|
||||
IS_ESIM_SUPPORTED,
|
||||
struct DownloadProfileConfigInfo : public Parcelable {
|
||||
int32_t portIndex_ = 0;
|
||||
bool isSwitchAfterDownload_ = false;
|
||||
bool isForceDeactivateSim_ = false;
|
||||
|
||||
bool ReadFromParcel(Parcel &parcel);
|
||||
virtual bool Marshalling(Parcel &parcel) const override;
|
||||
static DownloadProfileConfigInfo *Unmarshalling(Parcel &parcel);
|
||||
};
|
||||
} // namespace Telephony
|
||||
} // namespace OHOS
|
||||
#endif // ESIM_SERVICE_INTERFACE_CODE_H
|
||||
#endif // OHOS_DOWNLOAD_PROFILE_CONFIG_INFO_PARCEL_H
|
@ -0,0 +1,39 @@
|
||||
/*
|
||||
* Copyright (C) 2024 Huawei Device Co., Ltd.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#ifndef OHOS_DOWNLOAD_PROFILE_RESULT_PARCEL_H
|
||||
#define OHOS_DOWNLOAD_PROFILE_RESULT_PARCEL_H
|
||||
|
||||
#include <parcel.h>
|
||||
|
||||
#include "esim_state_type.h"
|
||||
|
||||
namespace OHOS {
|
||||
namespace Telephony {
|
||||
/**
|
||||
* @brief Result set for downloading configuration files.
|
||||
*/
|
||||
struct DownloadProfileResult : public Parcelable {
|
||||
ResultState result_;
|
||||
ResolvableErrors resolvableErrors_;
|
||||
uint32_t cardId_ = 0;
|
||||
|
||||
bool ReadFromParcel(Parcel &parcel);
|
||||
virtual bool Marshalling(Parcel &parcel) const override;
|
||||
static DownloadProfileResult *Unmarshalling(Parcel &parcel);
|
||||
};
|
||||
} // namespace Telephony
|
||||
} // namespace OHOS
|
||||
#endif // OHOS_DOWNLOAD_PROFILE_RESULT_PARCEL_H
|
42
interfaces/innerkits/include/downloadable_profile_parcel.h
Normal file
42
interfaces/innerkits/include/downloadable_profile_parcel.h
Normal file
@ -0,0 +1,42 @@
|
||||
/*
|
||||
* Copyright (C) 2024 Huawei Device Co., Ltd.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#ifndef OHOS_DOWNLOADABLE_PROFILE_PARCEL_H
|
||||
#define OHOS_DOWNLOADABLE_PROFILE_PARCEL_H
|
||||
|
||||
#include <parcel.h>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
#include "esim_state_type.h"
|
||||
|
||||
namespace OHOS {
|
||||
namespace Telephony {
|
||||
/**
|
||||
* @brief Information about a subscription which is downloadable to an eUICC using.
|
||||
*/
|
||||
struct DownloadableProfile : public Parcelable {
|
||||
std::u16string encodedActivationCode_ = u"";
|
||||
std::u16string confirmationCode_ = u"";
|
||||
std::u16string carrierName_ = u"";
|
||||
std::vector<AccessRule> accessRules_{};
|
||||
|
||||
bool ReadFromParcel(Parcel &parcel);
|
||||
virtual bool Marshalling(Parcel &parcel) const override;
|
||||
static DownloadableProfile *Unmarshalling(Parcel &parcel);
|
||||
};
|
||||
} // namespace Telephony
|
||||
} // namespace OHOS
|
||||
#endif // OHOS_DOWNLOADABLE_PROFILE_PARCEL_H
|
248
interfaces/innerkits/include/esim_service_client.h
Normal file
248
interfaces/innerkits/include/esim_service_client.h
Normal file
@ -0,0 +1,248 @@
|
||||
/*
|
||||
* Copyright (C) 2024 Huawei Device Co., Ltd.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#ifndef ESIM_SERVICE_CLIENT_H
|
||||
#define ESIM_SERVICE_CLIENT_H
|
||||
|
||||
#include <cstdint>
|
||||
#include <iremote_object.h>
|
||||
#include <singleton.h>
|
||||
#include <string_ex.h>
|
||||
|
||||
#include "iesim_service.h"
|
||||
#include "system_ability_load_callback_stub.h"
|
||||
|
||||
namespace OHOS {
|
||||
namespace Telephony {
|
||||
class EsimServiceClientCallback : public SystemAbilityLoadCallbackStub {
|
||||
public:
|
||||
void OnLoadSystemAbilitySuccess(int32_t systemAbilityId, const sptr<IRemoteObject> &remoteObject) override;
|
||||
void OnLoadSystemAbilityFail(int32_t systemAbilityId) override;
|
||||
bool IsFailed();
|
||||
const sptr<IRemoteObject> &GetRemoteObject() const;
|
||||
|
||||
private:
|
||||
bool isLoadSAFailed_ = false;
|
||||
sptr<IRemoteObject> remoteObject_ = nullptr;
|
||||
};
|
||||
|
||||
class EsimServiceClient : public DelayedRefSingleton<EsimServiceClient> {
|
||||
DECLARE_DELAYED_REF_SINGLETON(EsimServiceClient);
|
||||
|
||||
public:
|
||||
/**
|
||||
* @brief Get the EID identifying for the eUICC hardware.
|
||||
*
|
||||
* @param slotId[in], indicates the card slot index number.
|
||||
* @param eId[out], the EID identifying the eUICC hardware.
|
||||
* @return int32_t TELEPHONY_SUCCESS on success, others on failure.
|
||||
*/
|
||||
int32_t GetEid(int32_t slotId, std::string &eId);
|
||||
|
||||
/**
|
||||
* @brief Get the current status of eUICC OSU.
|
||||
*
|
||||
* @param slotId[in], indicates the card slot index number.
|
||||
* @param osuStatus[out], the status of eUICC OSU update.
|
||||
* @return int32_t TELEPHONY_SUCCESS on success, others on failure.
|
||||
*/
|
||||
int32_t GetOsuStatus(int32_t slotId, int32_t &osuStatus);
|
||||
|
||||
/**
|
||||
* @brief Execute OSU if current OSU is not the latest one.
|
||||
*
|
||||
* @param slotId[in], indicates the card slot index number.
|
||||
* @param startOsuResult[out], the status of OSU update when OSU status changed.
|
||||
* @return int32_t TELEPHONY_SUCCESS on success, others on failure.
|
||||
*/
|
||||
int32_t StartOsu(int32_t slotId, int32_t &startOsuResult);
|
||||
|
||||
/**
|
||||
* @brief Fills in the metadata for a downloadable profile.
|
||||
*
|
||||
* @param slotId[in], indicates the card slot index number.
|
||||
* @param portIndex[in], index of the port from the slot.
|
||||
* @param profile[in], the Bound Profile Package data returned by SM-DP+ server.
|
||||
* @param forceDeactivateSim[in], if true, and if an active SIM must be deactivated to access the eUICC,
|
||||
* perform this action automatically.
|
||||
* @param profileMetadataResult[out], the metadata for profile.
|
||||
* @return int32_t TELEPHONY_SUCCESS on success, others on failure.
|
||||
*/
|
||||
int32_t GetDownloadableProfileMetadata(int32_t slotId, int32_t portIndex, const DownloadableProfile &profile,
|
||||
bool forceDeactivateSim, GetDownloadableProfileMetadataResult &profileMetadataResult);
|
||||
|
||||
/**
|
||||
* @brief Gets downloadable profile List which are available for download on this device.
|
||||
*
|
||||
* @param slotId[in], indicates the card slot index number.
|
||||
* @param forceDeactivateSim[in], if true, and if an active SIM must be deactivated to access the eUICC,
|
||||
* perform this action automatically.
|
||||
* @param profileListResult[out], the metadata for downloadableProfile which are
|
||||
* available for download on this device.
|
||||
* @return int32_t TELEPHONY_SUCCESS on success, others on failure.
|
||||
*/
|
||||
int32_t GetDownloadableProfiles(
|
||||
int32_t slotId, int32_t portIndex, bool forceDeactivateSim, GetDownloadableProfilesResult &profileListResult);
|
||||
|
||||
/**
|
||||
* @brief Attempt to download the given downloadable Profile.
|
||||
*
|
||||
* @param slotId[in], indicates the card slot index number.
|
||||
* @param configInfo[in], downloadprofile config info.
|
||||
* @param profile[in], the Bound Profile Package data returned by SM-DP+ server.
|
||||
* @param downloadProfileResult[out], the given downloadableProfile.
|
||||
* @return int32_t TELEPHONY_SUCCESS on success, others on failure.
|
||||
*/
|
||||
int32_t DownloadProfile(int32_t slotId, DownloadProfileConfigInfo configInfo, const DownloadableProfile &profile,
|
||||
DownloadProfileResult &downloadProfileResult);
|
||||
|
||||
/**
|
||||
* @brief Get a list of all euiccProfile informations.
|
||||
*
|
||||
* @param slotId[in], indicates the card slot index number.
|
||||
* @param euiccProfileInfoList[out], a list of eUICC profile information.
|
||||
* @return int32_t TELEPHONY_SUCCESS on success, others on failure.
|
||||
*/
|
||||
int32_t GetEuiccProfileInfoList(int32_t slotId, GetEuiccProfileInfoListResult &euiccProfileInfoList);
|
||||
|
||||
/**
|
||||
* @brief Get information about the eUICC chip/device.
|
||||
*
|
||||
* @param slotId[in], indicates the card slot index number.
|
||||
* @param eUiccInfo[out], the eUICC information to obtain.
|
||||
* @return int32_t TELEPHONY_SUCCESS on success, others on failure.
|
||||
*/
|
||||
int32_t GetEuiccInfo(int32_t slotId, EuiccInfo &eUiccInfo);
|
||||
|
||||
/**
|
||||
* @brief Delete the given profile.
|
||||
*
|
||||
* @param slotId[in], indicates the card slot index number.
|
||||
* @param iccId[in], the iccId of the profile.
|
||||
* @param deleteProfileResult[out], the response to deletes the given profile.
|
||||
* @return int32_t TELEPHONY_SUCCESS on success, others on failure.
|
||||
*/
|
||||
int32_t DeleteProfile(int32_t slotId, const std::string &iccId, int32_t &deleteProfileResult);
|
||||
|
||||
/**
|
||||
* @brief Switch to (enable) the given profile.
|
||||
*
|
||||
* @param slotId[in], indicates the card slot index number.
|
||||
* @param portIndex[in], index of the port from the slot.
|
||||
* @param iccId[in], the iccId of the profile.
|
||||
* @param forceDeactivateSim[in], if true, and if an active SIM must be deactivated to access the eUICC,
|
||||
* perform this action automatically.
|
||||
* @param switchToProfileResult[out], the response to switch profile.
|
||||
* @return int32_t TELEPHONY_SUCCESS on success, others on failure.
|
||||
*/
|
||||
int32_t SwitchToProfile(int32_t slotId, int32_t portIndex,
|
||||
const std::string &iccId, bool forceDeactivateSim, int32_t &switchToProfileResult);
|
||||
|
||||
/**
|
||||
* @brief Set the nickname for the given profile.
|
||||
*
|
||||
* @param slotId[in], indicates the card slot index number.
|
||||
* @param iccId[in], the iccId of the profile.
|
||||
* @param nickname[in], the nickname of the profile.
|
||||
* @param setProfileNicknameResult[out], the result of the set nickname operation.
|
||||
* @return int32_t TELEPHONY_SUCCESS on success, others on failure.
|
||||
*/
|
||||
int32_t SetProfileNickname(
|
||||
int32_t slotId, const std::string &iccId, const std::string &nickname, int32_t &setProfileNicknameResult);
|
||||
|
||||
/**
|
||||
* @brief Erase all specific profiles and reset the eUICC.
|
||||
*
|
||||
* @param slotId[in], indicates the card slot index number.
|
||||
* @param resetOption[in], options for resetting eUICC memory.
|
||||
* @param resetMemoryResult[out], the result of the reset operation.
|
||||
* @return int32_t TELEPHONY_SUCCESS on success, others on failure.
|
||||
*/
|
||||
int32_t ResetMemory(int32_t slotId, int32_t resetOption, int32_t &resetMemoryResult);
|
||||
|
||||
/**
|
||||
* @brief Ensure that profiles will be retained on the next factory reset.
|
||||
*
|
||||
* @param slotId[in], indicates the card slot index number.
|
||||
* @param restoreResult[out], the result code.
|
||||
* @return int32_t TELEPHONY_SUCCESS on success, others on failure.
|
||||
*/
|
||||
int32_t ReserveProfilesForFactoryRestore(int32_t slotId, int32_t &restoreResult);
|
||||
|
||||
/**
|
||||
* @brief Set or update the default SM-DP+ address stored in an eUICC.
|
||||
*
|
||||
* @param slotId[in], indicates the card slot index number.
|
||||
* @param defaultSmdpAddress[in], the default SM-DP+ address to set.
|
||||
* @param setDefaultSmdpAddressResult[out], the result code.
|
||||
* @return int32_t TELEPHONY_SUCCESS on success, others on failure.
|
||||
*/
|
||||
int32_t SetDefaultSmdpAddress(
|
||||
int32_t slotId, const std::string &defaultSmdpAddress, int32_t &setDefaultSmdpAddressResult);
|
||||
|
||||
/**
|
||||
* @brief Gets the default SM-DP+ address stored in an eUICC.
|
||||
*
|
||||
* @param slotId[in], indicates the card slot index number.
|
||||
* @param defaultSmdpAddress[out], the default SM-DP+ address.
|
||||
* @return int32_t TELEPHONY_SUCCESS on success, others on failure.
|
||||
*/
|
||||
int32_t GetDefaultSmdpAddress(int32_t slotId, std::string &defaultSmdpAddress);
|
||||
|
||||
/**
|
||||
* @brief Cancel session.
|
||||
*
|
||||
* @param slotId[in], indicates the card slot index number.
|
||||
* @param transactionId[in], the transaction ID returned by SM-DP+ server.
|
||||
* @param cancelReason[in], the cancel reason.
|
||||
* @param responseResult[out], the result code and cancel session response string.
|
||||
* @return int32_t TELEPHONY_SUCCESS on success, others on failure.
|
||||
*/
|
||||
int32_t CancelSession(int32_t slotId, const std::string &transactionId,
|
||||
int32_t cancelReason, ResponseEsimResult &responseResult);
|
||||
|
||||
/**
|
||||
* @brief Check whether embedded subscriptions are currently supported.
|
||||
*
|
||||
* @param slotId[in], indicates the card slot index number.
|
||||
* @return Return true if the eSIM capability is supported; return false otherwise.
|
||||
*/
|
||||
bool IsEsimSupported(int32_t slotId);
|
||||
|
||||
private:
|
||||
void RemoveDeathRecipient(const wptr<IRemoteObject> &remote, bool isRemoteDied);
|
||||
class EsimServiceDeathRecipient : public IRemoteObject::DeathRecipient {
|
||||
public:
|
||||
explicit EsimServiceDeathRecipient(EsimServiceClient &client) : client_(client) {}
|
||||
~EsimServiceDeathRecipient() override = default;
|
||||
void OnRemoteDied(const wptr<IRemoteObject> &remote) override
|
||||
{
|
||||
client_.OnRemoteDied(remote);
|
||||
}
|
||||
|
||||
private:
|
||||
EsimServiceClient &client_;
|
||||
};
|
||||
|
||||
private:
|
||||
std::mutex mutexProxy_;
|
||||
sptr<IEsimService> proxy_ { nullptr };
|
||||
sptr<IRemoteObject::DeathRecipient> deathRecipient_ { nullptr };
|
||||
sptr<IEsimService> GetProxy();
|
||||
void OnRemoteDied(const wptr<IRemoteObject> &remote);
|
||||
};
|
||||
} // namespace Telephony
|
||||
} // namespace OHOS
|
||||
#endif // ESIM_SERVICE_CLIENT_H
|
@ -26,7 +26,7 @@ namespace Telephony {
|
||||
/**
|
||||
* @brief Result state.
|
||||
*/
|
||||
enum class Result {
|
||||
enum class ResultState {
|
||||
RESULT_RESOLVABLE_ERRORS = -2,
|
||||
RESULT_MUST_DEACTIVATE_SIM = -1,
|
||||
RESULT_OK = 0,
|
||||
@ -42,7 +42,7 @@ enum class OsuStatus {
|
||||
EUICC_OSU_FAILED = 2,
|
||||
EUICC_OSU_SUCCEEDED = 3,
|
||||
EUICC_OSU_NOT_NEEDED = 4,
|
||||
EUICC_OSU_STATUS_UNAVAILABLE = 5,
|
||||
EUICC_OSU_UNAVAILABLE = 5,
|
||||
};
|
||||
|
||||
/**
|
||||
@ -59,121 +59,103 @@ enum class CancelReason {
|
||||
* @brief Options for resetting eUICC memory.
|
||||
*/
|
||||
enum class ResetOption {
|
||||
RESET_OPTION_DELETE_OPERATIONAL_PROFILES = 1,
|
||||
RESET_OPTION_DELETE_FIELD_LOADED_TEST_PROFILES = 1 << 1,
|
||||
RESET_OPTION_RESET_DEFAULT_SMDP_ADDRESS = 1 << 2,
|
||||
DELETE_OPERATIONAL_PROFILES = 1,
|
||||
DELETE_FIELD_LOADED_TEST_PROFILES = 1 << 1,
|
||||
RESET_DEFAULT_SMDP_ADDRESS = 1 << 2,
|
||||
};
|
||||
|
||||
/**
|
||||
* @brief Euicc Information.
|
||||
* @brief The profile state.
|
||||
*/
|
||||
struct EuiccInfo {
|
||||
std::u16string osVersion = u"";
|
||||
enum class ProfileState {
|
||||
PROFILE_STATE_UNSPECIFIED = -1,
|
||||
PROFILE_STATE_DISABLED = 0,
|
||||
PROFILE_STATE_ENABLED = 1,
|
||||
};
|
||||
|
||||
/**
|
||||
* @brief Result set for downloading configuration files.
|
||||
* @brief Profile class for the profile.
|
||||
*/
|
||||
struct DownloadProfileResult {
|
||||
int32_t result = 0;
|
||||
int32_t resolvableErrors = 0;
|
||||
int32_t cardId = 0;
|
||||
enum class ProfileClass {
|
||||
PROFILE_CLASS_UNSPECIFIED = -1,
|
||||
PROFILE_CLASS_TESTING = 0,
|
||||
PROFILE_CLASS_PROVISIONING = 1,
|
||||
PROFILE_CLASS_OPERATIONAL = 2,
|
||||
};
|
||||
|
||||
/**
|
||||
* @brief The policy rules of the profile.
|
||||
*/
|
||||
enum class PolicyRules {
|
||||
POLICY_RULE_DO_NOT_DISABLE = 1,
|
||||
POLICY_RULE_DO_NOT_DELETE = 1 << 1,
|
||||
POLICY_RULE_DELETE_AFTER_DISABLING = 1 << 2,
|
||||
};
|
||||
|
||||
/**
|
||||
* @brief The bit map of resolvable errors.
|
||||
*/
|
||||
enum class ResolvableErrors {
|
||||
RESOLVABLE_ERROR_CONFIRMATION_CODE = 1 << 0,
|
||||
RESOLVABLE_ERROR_POLICY_RULES = 1 << 1,
|
||||
};
|
||||
|
||||
/**
|
||||
* @brief Describes the UICC access rule according to the GlobalPlatform Secure Element Access Control specification.
|
||||
*/
|
||||
struct AccessRule {
|
||||
std::u16string certificateHashHexStr = u"";
|
||||
std::u16string packageName = u"";
|
||||
int32_t accessType = 0;
|
||||
};
|
||||
|
||||
/**
|
||||
* @brief Information about a subscription which is downloadable to an eUICC using.
|
||||
*/
|
||||
struct DownloadableProfile {
|
||||
std::u16string encodedActivationCode = u"";
|
||||
std::u16string confirmationCode = u"";
|
||||
std::u16string carrierName = u"";
|
||||
std::vector<AccessRule> accessRules {};
|
||||
};
|
||||
|
||||
/**
|
||||
* @brief List of metadata for downloaded configuration files.
|
||||
*/
|
||||
struct GetDownloadableProfileMetadataResult {
|
||||
DownloadableProfile downloadableProfiles;
|
||||
int32_t pprType = 0;
|
||||
bool pprFlag = false;
|
||||
int32_t resolvableErrors = 0;
|
||||
int32_t result = 0;
|
||||
};
|
||||
|
||||
/**
|
||||
* @brief Series data of downloadable configuration files.
|
||||
*/
|
||||
struct GetAvailableDownloadableProfileListResult {
|
||||
int32_t result = 0;
|
||||
std::vector<DownloadableProfile> downloadableProfiles {};
|
||||
std::u16string certificateHashHexStr_ = u"";
|
||||
std::u16string packageName_ = u"";
|
||||
int32_t accessType_ = 0;
|
||||
};
|
||||
|
||||
/**
|
||||
* @brief Information about the eUICC chip/device.
|
||||
*/
|
||||
struct OperatorId {
|
||||
std::u16string mcc = u"";
|
||||
std::u16string mnc = u"";
|
||||
std::u16string gid1 = u"";
|
||||
std::u16string gid2 = u"";
|
||||
std::u16string mcc_ = u"";
|
||||
std::u16string mnc_ = u"";
|
||||
std::u16string gid1_ = u"";
|
||||
std::u16string gid2_ = u"";
|
||||
};
|
||||
|
||||
/**
|
||||
* @brief Information about an embedded profile (subscription) on an eUICC.
|
||||
*/
|
||||
struct EuiccProfile {
|
||||
std::u16string iccId = u"";
|
||||
std::u16string nickName = u"";
|
||||
std::u16string serviceProviderName = u"";
|
||||
std::u16string profileName = u"";
|
||||
int32_t state = 0;
|
||||
int32_t profileClass = 0;
|
||||
OperatorId carrierId;
|
||||
int32_t policyRules = 0;
|
||||
std::vector<AccessRule> accessRules {};
|
||||
};
|
||||
|
||||
/**
|
||||
* @brief Result of a operation.
|
||||
*/
|
||||
struct GetEuiccProfileInfoListResult {
|
||||
int32_t result = 0;
|
||||
std::vector<EuiccProfile> profiles {};
|
||||
bool isRemovable = false;
|
||||
std::u16string iccId_ = u"";
|
||||
std::u16string nickName_ = u"";
|
||||
std::u16string serviceProviderName_ = u"";
|
||||
std::u16string profileName_ = u"";
|
||||
ProfileState state_;
|
||||
ProfileClass profileClass_;
|
||||
OperatorId carrierId_;
|
||||
PolicyRules policyRules_;
|
||||
std::vector<AccessRule> accessRules_{};
|
||||
};
|
||||
|
||||
/**
|
||||
* @brief Information about the eUICC chip/device.
|
||||
*/
|
||||
struct CarrierIdentifier {
|
||||
std::u16string mcc = u"";
|
||||
std::u16string mnc = u"";
|
||||
std::u16string spn = u"";
|
||||
std::u16string imsi = u"";
|
||||
std::u16string gid1 = u"";
|
||||
std::u16string gid2 = u"";
|
||||
int32_t carrierId = 0;
|
||||
int32_t specificCarrierId = 0;
|
||||
std::u16string mcc_ = u"";
|
||||
std::u16string mnc_ = u"";
|
||||
std::u16string spn_ = u"";
|
||||
std::u16string imsi_ = u"";
|
||||
std::u16string gid1_ = u"";
|
||||
std::u16string gid2_ = u"";
|
||||
int32_t carrierId_ = 0;
|
||||
int32_t specificCarrierId_ = 0;
|
||||
};
|
||||
|
||||
/**
|
||||
* @brief the rules authorisation table stored on eUICC.
|
||||
*/
|
||||
struct EuiccRulesAuthTable {
|
||||
std::vector<int32_t> policyRules;
|
||||
std::vector<CarrierIdentifier> carrierIds {};
|
||||
std::vector<int32_t> policyRuleFlags;
|
||||
int32_t position = 0;
|
||||
std::vector<int32_t> policyRules_;
|
||||
std::vector<CarrierIdentifier> carrierIds_{};
|
||||
std::vector<int32_t> policyRuleFlags_;
|
||||
int32_t position_ = 0;
|
||||
};
|
||||
|
||||
/**
|
||||
@ -189,10 +171,15 @@ struct DownLoadConfigInfo {
|
||||
|
||||
/**
|
||||
* @brief Result of a operation.
|
||||
* @brief Result of a bpp operation.
|
||||
*/
|
||||
struct ResponseEsimResult {
|
||||
int32_t resultCode = 0;
|
||||
std::u16string response = u"";
|
||||
struct ResponseEsimBppResult {
|
||||
int32_t resultCode_ = 0;
|
||||
std::u16string response_ = u"";
|
||||
int32_t seqNumber_ = 0;
|
||||
int32_t profileManagementOperation_ = 0;
|
||||
std::u16string notificationAddress_ = u"";
|
||||
std::u16string iccId_ = u"";
|
||||
};
|
||||
|
||||
/**
|
||||
@ -210,17 +197,17 @@ enum class Event {
|
||||
* @brief A signed notification which is defined in SGP.22.
|
||||
*/
|
||||
struct EuiccNotification {
|
||||
int32_t seq;
|
||||
std::u16string targetAddr;
|
||||
int32_t event;
|
||||
std::u16string data = u"";
|
||||
int32_t seq_;
|
||||
std::u16string targetAddr_ = u"";
|
||||
int32_t event_;
|
||||
std::u16string data_ = u"";
|
||||
};
|
||||
|
||||
/**
|
||||
* @brief List of notifications.
|
||||
*/
|
||||
struct EuiccNotificationList {
|
||||
std::vector<EuiccNotification> euiccNotification {};
|
||||
std::vector<EuiccNotification> euiccNotification_{};
|
||||
};
|
||||
} // namespace Telephony
|
||||
} // namespace OHOS
|
||||
|
37
interfaces/innerkits/include/euicc_info_parcel.h
Normal file
37
interfaces/innerkits/include/euicc_info_parcel.h
Normal file
@ -0,0 +1,37 @@
|
||||
/*
|
||||
* Copyright (C) 2024 Huawei Device Co., Ltd.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#ifndef OHOS_EUICC_INFO_PARCEL_H
|
||||
#define OHOS_EUICC_INFO_PARCEL_H
|
||||
|
||||
#include <parcel.h>
|
||||
#include <string>
|
||||
|
||||
namespace OHOS {
|
||||
namespace Telephony {
|
||||
/**
|
||||
* @brief Euicc Information.
|
||||
*/
|
||||
struct EuiccInfo : public Parcelable {
|
||||
std::u16string osVersion_ = u"";
|
||||
std::u16string response_ = u"";
|
||||
|
||||
bool ReadFromParcel(Parcel &parcel);
|
||||
virtual bool Marshalling(Parcel &parcel) const override;
|
||||
static EuiccInfo *Unmarshalling(Parcel &parcel);
|
||||
};
|
||||
} // namespace Telephony
|
||||
} // namespace OHOS
|
||||
#endif // OHOS_EUICC_INFO_PARCEL_H
|
@ -0,0 +1,40 @@
|
||||
/*
|
||||
* Copyright (C) 2024 Huawei Device Co., Ltd.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#ifndef OHOS_GET_DOWNLOADABLE_PROFILES_RESULT_PARCEL_H
|
||||
#define OHOS_GET_DOWNLOADABLE_PROFILES_RESULT_PARCEL_H
|
||||
|
||||
#include <parcel.h>
|
||||
#include <vector>
|
||||
|
||||
#include "downloadable_profile_parcel.h"
|
||||
#include "esim_state_type.h"
|
||||
|
||||
namespace OHOS {
|
||||
namespace Telephony {
|
||||
/**
|
||||
* @brief Series data of downloadable configuration files.
|
||||
*/
|
||||
struct GetDownloadableProfilesResult : public Parcelable {
|
||||
ResultState result_;
|
||||
std::vector<DownloadableProfile> downloadableProfiles_{};
|
||||
|
||||
bool ReadFromParcel(Parcel &parcel);
|
||||
virtual bool Marshalling(Parcel &parcel) const override;
|
||||
static GetDownloadableProfilesResult *Unmarshalling(Parcel &parcel);
|
||||
};
|
||||
} // namespace Telephony
|
||||
} // namespace OHOS
|
||||
#endif // OHOS_GET_DOWNLOADABLE_PROFILES_RESULT_PARCEL_H
|
@ -18,6 +18,9 @@
|
||||
|
||||
#include "cell_information.h"
|
||||
#include "dialling_numbers_info.h"
|
||||
#ifdef CORE_SERVICE_SUPPORT_ESIM
|
||||
#include "esim_state_type.h"
|
||||
#endif
|
||||
#include "i_network_search_callback.h"
|
||||
#include "ims_reg_info_callback.h"
|
||||
#include "network_search_result.h"
|
||||
@ -150,6 +153,27 @@ public:
|
||||
virtual int32_t GetSimIO(int32_t slotId, int32_t command,
|
||||
int32_t fileId, const std::string &data, const std::string &path, SimAuthenticationResponse &response) = 0;
|
||||
#ifdef CORE_SERVICE_SUPPORT_ESIM
|
||||
virtual int32_t GetEid(int32_t slotId, std::u16string &eId) = 0;
|
||||
virtual int32_t GetEuiccProfileInfoList(int32_t slotId, GetEuiccProfileInfoListResult &euiccProfileInfoList) = 0;
|
||||
virtual int32_t GetEuiccInfo(int32_t slotId, EuiccInfo &eUiccInfo) = 0;
|
||||
virtual int32_t DisableProfile(
|
||||
int32_t slotId, int32_t portIndex, const std::u16string &iccId, bool refresh, ResultState &enumResult) = 0;
|
||||
virtual int32_t GetSmdsAddress(int32_t slotId, int32_t portIndex, std::u16string &smdsAddress) = 0;
|
||||
virtual int32_t GetRulesAuthTable(
|
||||
int32_t slotId, int32_t portIndex, EuiccRulesAuthTable &eUiccRulesAuthTable) = 0;
|
||||
virtual int32_t GetEuiccChallenge(
|
||||
int32_t slotId, int32_t portIndex, ResponseEsimResult &responseResult) = 0;
|
||||
virtual int32_t GetDefaultSmdpAddress(int32_t slotId, std::u16string &defaultSmdpAddress) = 0;
|
||||
virtual int32_t CancelSession(int32_t slotId, const std::u16string &transactionId, CancelReason cancelReason,
|
||||
ResponseEsimResult &responseResult) = 0;
|
||||
virtual int32_t GetProfile(
|
||||
int32_t slotId, int32_t portIndex, const std::u16string &iccId, EuiccProfile &eUiccProfile) = 0;
|
||||
virtual int32_t ResetMemory(int32_t slotId, ResetOption resetOption, ResultState &enumResult) = 0;
|
||||
virtual int32_t SetDefaultSmdpAddress(
|
||||
int32_t slotId, const std::u16string &defaultSmdpAddress, ResultState &enumResult) = 0;
|
||||
virtual bool IsEsimSupported(int32_t slotId) = 0;
|
||||
virtual int32_t SendApduData(int32_t slotId, const std::u16string &aid,
|
||||
const std::u16string &apduData, ResponseEsimResult &responseResult) = 0;
|
||||
virtual int32_t PrepareDownload(int32_t slotId, const DownLoadConfigInfo &downLoadConfigInfo,
|
||||
ResponseEsimResult &responseResult) = 0;
|
||||
virtual int32_t LoadBoundProfilePackage(int32_t slotId, int32_t portIndex,
|
||||
|
@ -1,60 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 2024 Huawei Device Co., Ltd.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#ifndef I_BASE_ESIM_SERVICE_H
|
||||
#define I_BASE_ESIM_SERVICE_H
|
||||
|
||||
#include "esim_state_type.h"
|
||||
#include "iremote_object.h"
|
||||
#include "iremote_broker.h"
|
||||
#include "iremote_proxy.h"
|
||||
|
||||
namespace OHOS {
|
||||
namespace Telephony {
|
||||
class IEsimService : public IRemoteBroker {
|
||||
public:
|
||||
DECLARE_INTERFACE_DESCRIPTOR(u"ohos.telephony.IEsimService");
|
||||
|
||||
public:
|
||||
virtual ~IEsimService() = default;
|
||||
virtual int32_t GetEid(int32_t slotId, std::u16string &eId) = 0;
|
||||
virtual int32_t GetOsuStatus(int32_t slotId, OsuStatus &osuStatus) = 0;
|
||||
virtual int32_t StartOsu(int32_t slotId, Result &enumResult) = 0;
|
||||
virtual int32_t GetDownloadableProfileMetadata(
|
||||
int32_t slotId, int32_t portIndex, const DownloadableProfile &profile,
|
||||
bool forceDeactivateSim, GetDownloadableProfileMetadataResult &profileMetadataResult) = 0;
|
||||
virtual int32_t GetAvailableDownloadableProfileList(
|
||||
int32_t slotId, bool forceDeactivateSim, GetAvailableDownloadableProfileListResult &profileListResult) = 0;
|
||||
virtual int32_t DownloadProfile(int32_t slotId, int32_t portIndex, const DownloadableProfile &profile,
|
||||
bool switchAfterDownload, bool forceDeactivateSim, DownloadProfileResult &downloadProfileResult) = 0;
|
||||
virtual int32_t GetEuiccProfileInfoList(int32_t slotId, GetEuiccProfileInfoListResult &euiccProfileInfoList) = 0;
|
||||
virtual int32_t GetEuiccInfo(int32_t slotId, EuiccInfo &eUiccInfo) = 0;
|
||||
virtual int32_t DeleteProfile(int32_t slotId, const std::u16string &iccId, Result &enumResult) = 0;
|
||||
virtual int32_t SwitchToProfile(int32_t slotId,
|
||||
int32_t portIndex, const std::u16string &iccId, bool forceDeactivateSim, Result &enumResult) = 0;
|
||||
virtual int32_t SetProfileNickname(
|
||||
int32_t slotId, const std::u16string &iccId, const std::u16string &nickname, Result &enumResult) = 0;
|
||||
virtual int32_t ResetMemory(int32_t slotId, ResetOption resetOption, Result &enumResult) = 0;
|
||||
virtual int32_t ReserveProfilesForFactoryRestore(int32_t slotId, Result &enumResult) = 0;
|
||||
virtual int32_t SetDefaultSmdpAddress(
|
||||
int32_t slotId, const std::u16string &defaultSmdpAddress, Result &enumResult) = 0;
|
||||
virtual int32_t GetDefaultSmdpAddress(int32_t slotId, std::u16string &defaultSmdpAddress) = 0;
|
||||
virtual int32_t CancelSession(int32_t slotId, const std::u16string &transactionId,
|
||||
CancelReason cancelReason, ResponseEsimResult &responseResult) = 0;
|
||||
virtual bool IsEsimSupported(int32_t slotId) = 0;
|
||||
};
|
||||
} // namespace Telephony
|
||||
} // namespace OHOS
|
||||
#endif // I_BASE_ESIM_SERVICE_H
|
@ -17,6 +17,9 @@
|
||||
#define OHOS_I_SIM_MANAGER_H
|
||||
|
||||
#include "dialling_numbers_info.h"
|
||||
#ifdef CORE_SERVICE_SUPPORT_ESIM
|
||||
#include "esim_state_type.h"
|
||||
#endif
|
||||
#include "event_handler.h"
|
||||
#include "operator_config_types.h"
|
||||
#include "sim_account_callback.h"
|
||||
@ -142,6 +145,27 @@ public:
|
||||
int32_t fileId, const std::string &data, const std::string &path, SimAuthenticationResponse &response) = 0;
|
||||
virtual int32_t SavePrimarySlotId(int32_t slotId) = 0;
|
||||
#ifdef CORE_SERVICE_SUPPORT_ESIM
|
||||
virtual int32_t GetEid(int32_t slotId, std::u16string &eId) = 0;
|
||||
virtual int32_t GetEuiccProfileInfoList(int32_t slotId, GetEuiccProfileInfoListResult &euiccProfileInfoList) = 0;
|
||||
virtual int32_t GetEuiccInfo(int32_t slotId, EuiccInfo &eUiccInfo) = 0;
|
||||
virtual int32_t DisableProfile(
|
||||
int32_t slotId, int32_t portIndex, const std::u16string &iccId, bool refresh, ResultState &enumResult) = 0;
|
||||
virtual int32_t GetSmdsAddress(int32_t slotId, int32_t portIndex, std::u16string &smdsAddress) = 0;
|
||||
virtual int32_t GetRulesAuthTable(
|
||||
int32_t slotId, int32_t portIndex, EuiccRulesAuthTable &eUiccRulesAuthTable) = 0;
|
||||
virtual int32_t GetEuiccChallenge(
|
||||
int32_t slotId, int32_t portIndex, ResponseEsimResult &responseResult) = 0;
|
||||
virtual int32_t GetDefaultSmdpAddress(int32_t slotId, std::u16string &defaultSmdpAddress) = 0;
|
||||
virtual int32_t CancelSession(int32_t slotId, const std::u16string &transactionId, CancelReason cancelReason,
|
||||
ResponseEsimResult &responseResult) = 0;
|
||||
virtual int32_t GetProfile(
|
||||
int32_t slotId, int32_t portIndex, const std::u16string &iccId, EuiccProfile &eUiccProfile) = 0;
|
||||
virtual int32_t ResetMemory(int32_t slotId, ResetOption resetOption, ResultState &enumResult) = 0;
|
||||
virtual int32_t SetDefaultSmdpAddress(
|
||||
int32_t slotId, const std::u16string &defaultSmdpAddress, ResultState &enumResult) = 0;
|
||||
virtual bool IsEsimSupported(int32_t slotId) = 0;
|
||||
virtual int32_t SendApduData(int32_t slotId, const std::u16string &aid,
|
||||
const std::u16string &apduData, ResponseEsimResult &responseResult) = 0;
|
||||
virtual int32_t PrepareDownload(int32_t slotId, const DownLoadConfigInfo &downLoadConfigInfo,
|
||||
ResponseEsimResult &responseResult) = 0;
|
||||
virtual int32_t LoadBoundProfilePackage(int32_t slotId, int32_t portIndex,
|
||||
|
42
interfaces/innerkits/include/profile_info_list_parcel.h
Normal file
42
interfaces/innerkits/include/profile_info_list_parcel.h
Normal file
@ -0,0 +1,42 @@
|
||||
/*
|
||||
* Copyright (C) 2024 Huawei Device Co., Ltd.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#ifndef OHOS_PROFILE_INFO_LIST_PARCEL_H
|
||||
#define OHOS_PROFILE_INFO_LIST_PARCEL_H
|
||||
|
||||
#include <parcel.h>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
#include "esim_state_type.h"
|
||||
|
||||
namespace OHOS {
|
||||
namespace Telephony {
|
||||
/**
|
||||
* @brief Result of a operation.
|
||||
*/
|
||||
struct GetEuiccProfileInfoListResult : public Parcelable {
|
||||
ResultState result_;
|
||||
std::vector<EuiccProfile> profiles_{};
|
||||
bool isRemovable_ = false;
|
||||
|
||||
bool ReadProfileFromParcel(Parcel &parcel, EuiccProfile &profile);
|
||||
bool ReadFromParcel(Parcel &parcel);
|
||||
virtual bool Marshalling(Parcel &parcel) const override;
|
||||
static GetEuiccProfileInfoListResult *Unmarshalling(Parcel &parcel);
|
||||
};
|
||||
} // namespace Telephony
|
||||
} // namespace OHOS
|
||||
#endif // OHOS_PROFILE_INFO_LIST_PARCEL_H
|
@ -0,0 +1,44 @@
|
||||
/*
|
||||
* Copyright (C) 2024 Huawei Device Co., Ltd.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#ifndef OHOS_PROFILE_METADATA_RESULT_PARCEL_H
|
||||
#define OHOS_PROFILE_METADATA_RESULT_PARCEL_H
|
||||
|
||||
#include <parcel.h>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
#include "downloadable_profile_parcel.h"
|
||||
#include "esim_state_type.h"
|
||||
|
||||
namespace OHOS {
|
||||
namespace Telephony {
|
||||
/**
|
||||
* @brief List of metadata for downloaded configuration files.
|
||||
*/
|
||||
struct GetDownloadableProfileMetadataResult : public Parcelable {
|
||||
DownloadableProfile downloadableProfiles_;
|
||||
int32_t pprType_ = 0;
|
||||
bool pprFlag_ = false;
|
||||
ResolvableErrors resolvableErrors_;
|
||||
ResultState result_;
|
||||
|
||||
bool ReadFromParcel(Parcel &parcel);
|
||||
virtual bool Marshalling(Parcel &parcel) const override;
|
||||
static GetDownloadableProfileMetadataResult *Unmarshalling(Parcel &parcel);
|
||||
};
|
||||
} // namespace Telephony
|
||||
} // namespace OHOS
|
||||
#endif // OHOS_PROFILE_METADATA_RESULT_PARCEL_H
|
39
interfaces/innerkits/include/response_esim_result.h
Normal file
39
interfaces/innerkits/include/response_esim_result.h
Normal file
@ -0,0 +1,39 @@
|
||||
/*
|
||||
* Copyright (C) 2024 Huawei Device Co., Ltd.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#ifndef OHOS_RESPONSE_ESIM_RESULT_H
|
||||
#define OHOS_RESPONSE_ESIM_RESULT_H
|
||||
|
||||
#include <parcel.h>
|
||||
#include <string>
|
||||
|
||||
#include "esim_state_type.h"
|
||||
|
||||
namespace OHOS {
|
||||
namespace Telephony {
|
||||
/**
|
||||
* @brief Result of a operation.
|
||||
*/
|
||||
struct ResponseEsimResult : public Parcelable {
|
||||
ResultState resultCode_;
|
||||
std::u16string response_ = u"";
|
||||
|
||||
bool ReadFromParcel(Parcel &parcel);
|
||||
virtual bool Marshalling(Parcel &parcel) const override;
|
||||
static ResponseEsimResult *Unmarshalling(Parcel &parcel);
|
||||
};
|
||||
} // namespace Telephony
|
||||
} // namespace OHOS
|
||||
#endif // OHOS_RESPONSE_ESIM_RESULT_H
|
@ -119,6 +119,11 @@ struct SetupDataCallResultInfo {
|
||||
* integer type; identifies the PDU session, see 3GPP TS 24.501 [161].
|
||||
*/
|
||||
int32_t pduSessionId = 0;
|
||||
|
||||
/** retry scene,
|
||||
* 0 - setup datacall fail, 1 - modem deactivate, 2 - others
|
||||
*/
|
||||
int32_t retryScene = 2;
|
||||
};
|
||||
|
||||
/**
|
||||
|
@ -145,6 +145,7 @@ enum PdpErrorReason {
|
||||
PDP_ERR_APN_RESTRICTION_VALUE_INCOMPATIBLE = 112, /* APN restriction value incompatible
|
||||
* with active PDP context */
|
||||
PDP_ERR_MULT_ACCESSES_PDN_NOT_ALLOWED = 113, /* Multiple accesses to a PDN connection not allowed */
|
||||
PDP_ERR_UNKNOWN_TO_CLEAR_CONNECTION = 0xFFFE, /* unspecific errors, do not retry, just clear connection */
|
||||
};
|
||||
|
||||
enum NotificationFilter {
|
||||
|
@ -30,6 +30,7 @@ namespace Telephony {
|
||||
#define PREFERRED_NETWORK_TYPE GetPreferredNetworkType<int32_t>()
|
||||
#define VSIM_MODEM_COUNT GetVSimModemCount<int32_t>()
|
||||
#define IS_SUPPORT_VSIM (VSIM_MODEM_COUNT > 0)
|
||||
#define DEFAULT_ESIM_ID GetDefaultEsimSlotId<int32_t>()
|
||||
inline const int32_t SYSPARA_SIZE = 128;
|
||||
inline constexpr size_t ARRAY_SIZE = 1024;
|
||||
inline const int32_t DEFAULT_SIM_SLOT_ID = 0;
|
||||
@ -42,11 +43,14 @@ inline const size_t MAX_PARAMETER_LENGTH = 100;
|
||||
inline const int32_t DUAL_SLOT_COUNT = 2;
|
||||
inline const int32_t MAX_SLOT_COUNT = 3;
|
||||
inline const int32_t VSIM_DEFAULT_VALUE = -1;
|
||||
inline const int32_t ESIM_DEFAULT_SLOTID = -1;
|
||||
inline std::atomic<int32_t> maxRealSlotCount_ = 0;
|
||||
inline int32_t maxSlotCount_ = 0;
|
||||
inline int32_t esimDefaultSlotId_ = ESIM_DEFAULT_SLOTID;
|
||||
inline int32_t vSimModemCount_ = VSIM_DEFAULT_VALUE;
|
||||
inline constexpr const char *SATELLITE_DEFAULT_VALUE = "0";
|
||||
inline constexpr const char *DEFAULT_SLOT_COUNT = "1";
|
||||
inline constexpr const char *DEFAULT_ESIM_SLOT_ID = "0";
|
||||
inline constexpr const char *TEL_SIM_SLOT_COUNT = "const.telephony.slotCount";
|
||||
inline constexpr const char *VIRTUAL_MODEM_SWITCH = "const.booster.virtual_modem_switch";
|
||||
inline constexpr const char *VIRTUAL_MODEM_DEFAULT_SWITCH = "false";
|
||||
@ -60,6 +64,8 @@ inline constexpr const char *COUNTRY_CODE_KEY = "telephony.sim.countryCode";
|
||||
inline constexpr const char *TEL_SATELLITE_SUPPORTED = "const.telephony.satellite.supported";
|
||||
inline constexpr const char *DEFAULT_VSIM_MODEM_COUNT = "0";
|
||||
inline constexpr const char *VSIM_MODEM_COUNT_STR = "const.telephony.vsimModemCount";
|
||||
inline constexpr const char *TEL_ESIM_SUPPORT = "persist.telephony.esim.supported";
|
||||
inline constexpr const char *TEL_DEFAULT_ESIM_SLOT_ID = "const.telephony.esim.slotID";
|
||||
|
||||
template<typename T>
|
||||
inline T GetVirtualModemSwitch()
|
||||
@ -97,6 +103,17 @@ inline T GetRealMaxSlotCount()
|
||||
return maxRealSlotCount_;
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
inline T GetDefaultEsimSlotId()
|
||||
{
|
||||
if (esimDefaultSlotId_ == ESIM_DEFAULT_SLOTID) {
|
||||
char esimDefaultSlotId[SYSPARA_SIZE] = { 0 };
|
||||
GetParameter(TEL_DEFAULT_ESIM_SLOT_ID, DEFAULT_ESIM_SLOT_ID, esimDefaultSlotId, SYSPARA_SIZE);
|
||||
esimDefaultSlotId_ = std::stoi(esimDefaultSlotId);
|
||||
}
|
||||
return esimDefaultSlotId_;
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
inline T GetVSimModemCount()
|
||||
{
|
||||
|
@ -22,6 +22,14 @@
|
||||
*CoreManagerInner*;
|
||||
*CoreServiceClient*;
|
||||
*CoreServiceProxy*;
|
||||
*DownloadProfileResult*;
|
||||
*DownloadableProfile*;
|
||||
*EsimServiceClient*;
|
||||
*EsimServiceProxy*;
|
||||
*EuiccInfo*;
|
||||
*GetDownloadableProfilesResult*;
|
||||
*GetEuiccProfileInfoListResult*;
|
||||
*GetDownloadableProfileMetadataResult*;
|
||||
*GsmCellInformation*;
|
||||
*GsmCellLocation*;
|
||||
*GsmSignalInformation*;
|
||||
@ -46,6 +54,7 @@
|
||||
*WcdmaCellInformation*;
|
||||
*WcdmaSignalInformation*;
|
||||
*SatelliteServiceClient*;
|
||||
*ResponseEsimResult*;
|
||||
OHOS::Telephony::TelRilBaseParcel*;
|
||||
OHOS::Telephony::BaseParcel::Read*;
|
||||
OHOS::Telephony::BaseParcel::Write*;
|
||||
|
@ -259,6 +259,39 @@ public:
|
||||
int32_t GetSimIO(int32_t slotId, int32_t command, int32_t fileId,
|
||||
const std::string &data, const std::string &path, SimAuthenticationResponse &response) override;
|
||||
#ifdef CORE_SERVICE_SUPPORT_ESIM
|
||||
int32_t GetEid(int32_t slotId, std::u16string &eId) override;
|
||||
|
||||
int32_t GetEuiccProfileInfoList(int32_t slotId, GetEuiccProfileInfoListResult &euiccProfileInfoList) override;
|
||||
|
||||
int32_t GetEuiccInfo(int32_t slotId, EuiccInfo &eUiccInfo) override;
|
||||
|
||||
int32_t DisableProfile(
|
||||
int32_t slotId, int32_t portIndex, const std::u16string &iccId, bool refresh, ResultState &enumResult) override;
|
||||
|
||||
int32_t GetSmdsAddress(int32_t slotId, int32_t portIndex, std::u16string &smdsAddress) override;
|
||||
|
||||
int32_t GetRulesAuthTable(int32_t slotId, int32_t portIndex, EuiccRulesAuthTable &eUiccRulesAuthTable) override;
|
||||
|
||||
int32_t GetEuiccChallenge(int32_t slotId, int32_t portIndex, ResponseEsimResult &responseResult) override;
|
||||
|
||||
int32_t GetDefaultSmdpAddress(int32_t slotId, std::u16string &defaultSmdpAddress) override;
|
||||
|
||||
int32_t CancelSession(int32_t slotId, const std::u16string &transactionId, CancelReason cancelReason,
|
||||
ResponseEsimResult &responseResult) override;
|
||||
|
||||
int32_t GetProfile(
|
||||
int32_t slotId, int32_t portIndex, const std::u16string &iccId, EuiccProfile &eUiccProfile) override;
|
||||
|
||||
int32_t ResetMemory(int32_t slotId, ResetOption resetOption, ResultState &enumResult) override;
|
||||
|
||||
int32_t SetDefaultSmdpAddress(
|
||||
int32_t slotId, const std::u16string &defaultSmdpAddress, ResultState &enumResult) override;
|
||||
|
||||
bool IsEsimSupported(int32_t slotId) override;
|
||||
|
||||
int32_t SendApduData(int32_t slotId, const std::u16string &aid, const std::u16string &apduData,
|
||||
ResponseEsimResult &responseResult) override;
|
||||
|
||||
int32_t PrepareDownload(int32_t slotId, const DownLoadConfigInfo &downLoadConfigInfo,
|
||||
ResponseEsimResult &responseResult) override;
|
||||
|
||||
@ -268,6 +301,7 @@ public:
|
||||
int32_t ListNotifications(int32_t slotId, int32_t portIndex, Event events,
|
||||
EuiccNotificationList ¬ificationList) override;
|
||||
#endif
|
||||
|
||||
private:
|
||||
bool Init();
|
||||
|
||||
|
@ -36,6 +36,7 @@ class CoreServiceHiSysEvent : public TelephonyHiSysEvent {
|
||||
public:
|
||||
static void WriteSignalLevelBehaviorEvent(int32_t slotId, int32_t level);
|
||||
static void WriteNetworkStateBehaviorEvent(int32_t slotId, int32_t domain, int32_t tech, int32_t state);
|
||||
static void WriteRadioStateBehaviorEvent(int32_t slotId, int32_t state);
|
||||
static void WriteDefaultDataSlotIdBehaviorEvent(int32_t slotId);
|
||||
static void WriteSimStateBehaviorEvent(int32_t slotId, int32_t state);
|
||||
static void WriteDialCallFaultEvent(int32_t slotId, int32_t errCode, const std::string &desc);
|
||||
|
@ -38,6 +38,9 @@ private:
|
||||
void AddHandlerVoiceMailToMap();
|
||||
void AddHandlerPdpProfileToMap();
|
||||
void AddHandlerOpkeyVersionToMap();
|
||||
#ifdef CORE_SERVICE_SUPPORT_ESIM
|
||||
void AddHandlerEsimToMap();
|
||||
#endif
|
||||
int32_t SetTimer(uint32_t code);
|
||||
void CancelTimer(int32_t id);
|
||||
|
||||
@ -142,10 +145,25 @@ private:
|
||||
int32_t OnGetOpkeyVersion(MessageParcel &data, MessageParcel &reply);
|
||||
int32_t OnGetSimIO(MessageParcel &data, MessageParcel &reply);
|
||||
#ifdef CORE_SERVICE_SUPPORT_ESIM
|
||||
int32_t OnGetEid(MessageParcel &data, MessageParcel &reply);
|
||||
int32_t OnGetEuiccProfileInfoList(MessageParcel &data, MessageParcel &reply);
|
||||
int32_t OnGetEuiccInfo(MessageParcel &data, MessageParcel &reply);
|
||||
int32_t OnDisableProfile(MessageParcel &data, MessageParcel &reply);
|
||||
int32_t OnGetSmdsAddress(MessageParcel &data, MessageParcel &reply);
|
||||
int32_t OnGetRulesAuthTable(MessageParcel &data, MessageParcel &reply);
|
||||
int32_t OnGetEuiccChallenge(MessageParcel &data, MessageParcel &reply);
|
||||
int32_t OnRequestDefaultSmdpAddress(MessageParcel &data, MessageParcel &reply);
|
||||
int32_t OnCancelSession(MessageParcel &data, MessageParcel &reply);
|
||||
int32_t OnGetProfile(MessageParcel &data, MessageParcel &reply);
|
||||
int32_t OnResetMemory(MessageParcel &data, MessageParcel &reply);
|
||||
int32_t OnSetDefaultSmdpAddress(MessageParcel &data, MessageParcel &reply);
|
||||
int32_t OnIsEsimSupported(MessageParcel &data, MessageParcel &reply);
|
||||
int32_t OnSendApduData(MessageParcel &data, MessageParcel &reply);
|
||||
int32_t OnPrepareDownload(MessageParcel &data, MessageParcel &reply);
|
||||
int32_t OnLoadBoundProfilePackage(MessageParcel &data, MessageParcel &reply);
|
||||
int32_t OnListNotifications(MessageParcel &data, MessageParcel &reply);
|
||||
#endif
|
||||
|
||||
private:
|
||||
std::map<uint32_t, CoreServiceFunc> memberFuncMap_;
|
||||
std::map<uint32_t, std::string> collieCodeStringMap_ = {
|
||||
|
@ -1685,6 +1685,278 @@ int32_t CoreService::LoadBoundProfilePackage(int32_t slotId, int32_t portIndex,
|
||||
return simManager_->LoadBoundProfilePackage(slotId, portIndex, boundProfilePackage, responseResult);
|
||||
}
|
||||
|
||||
#ifdef CORE_SERVICE_SUPPORT_ESIM
|
||||
int32_t CoreService::GetEid(int32_t slotId, std::u16string &eId)
|
||||
{
|
||||
if (!TelephonyPermission::CheckCallerIsSystemApp()) {
|
||||
TELEPHONY_LOGE("Non-system applications use system APIs!");
|
||||
return TELEPHONY_ERR_ILLEGAL_USE_OF_SYSTEM_API;
|
||||
}
|
||||
if (!TelephonyPermission::CheckPermission(Permission::GET_TELEPHONY_ESIM_STATE)) {
|
||||
TELEPHONY_LOGE("permission denied!");
|
||||
return TELEPHONY_ERR_PERMISSION_ERR;
|
||||
}
|
||||
if (simManager_ == nullptr) {
|
||||
TELEPHONY_LOGE("simManager_ is null");
|
||||
return TELEPHONY_ERR_LOCAL_PTR_NULL;
|
||||
}
|
||||
return simManager_->GetEid(slotId, eId);
|
||||
}
|
||||
|
||||
int32_t CoreService::GetEuiccProfileInfoList(int32_t slotId, GetEuiccProfileInfoListResult &euiccProfileInfoList)
|
||||
{
|
||||
if (!TelephonyPermission::CheckCallerIsSystemApp()) {
|
||||
TELEPHONY_LOGE("Non-system applications use system APIs!");
|
||||
return TELEPHONY_ERR_ILLEGAL_USE_OF_SYSTEM_API;
|
||||
}
|
||||
if (!TelephonyPermission::CheckPermission(Permission::GET_TELEPHONY_ESIM_STATE)) {
|
||||
TELEPHONY_LOGE("permission denied!");
|
||||
return TELEPHONY_ERR_PERMISSION_ERR;
|
||||
}
|
||||
if (simManager_ == nullptr) {
|
||||
TELEPHONY_LOGE("simManager_ is null");
|
||||
return TELEPHONY_ERR_LOCAL_PTR_NULL;
|
||||
}
|
||||
return simManager_->GetEuiccProfileInfoList(slotId, euiccProfileInfoList);
|
||||
}
|
||||
|
||||
int32_t CoreService::GetEuiccInfo(int32_t slotId, EuiccInfo &eUiccInfo)
|
||||
{
|
||||
if (!TelephonyPermission::CheckCallerIsSystemApp()) {
|
||||
TELEPHONY_LOGE("Non-system applications use system APIs!");
|
||||
return TELEPHONY_ERR_ILLEGAL_USE_OF_SYSTEM_API;
|
||||
}
|
||||
if (!TelephonyPermission::CheckPermission(Permission::GET_TELEPHONY_ESIM_STATE)) {
|
||||
TELEPHONY_LOGE("permission denied!");
|
||||
return TELEPHONY_ERR_PERMISSION_ERR;
|
||||
}
|
||||
if (simManager_ == nullptr) {
|
||||
TELEPHONY_LOGE("simManager_ is null");
|
||||
return TELEPHONY_ERR_LOCAL_PTR_NULL;
|
||||
}
|
||||
return simManager_->GetEuiccInfo(slotId, eUiccInfo);
|
||||
}
|
||||
|
||||
int32_t CoreService::DisableProfile(
|
||||
int32_t slotId, int32_t portIndex, const std::u16string &iccId, bool refresh, ResultState &enumResult)
|
||||
{
|
||||
if (!TelephonyPermission::CheckCallerIsSystemApp()) {
|
||||
TELEPHONY_LOGE("Non-system applications use system APIs!");
|
||||
return TELEPHONY_ERR_ILLEGAL_USE_OF_SYSTEM_API;
|
||||
}
|
||||
if (!TelephonyPermission::CheckPermission(Permission::SET_TELEPHONY_ESIM_STATE)) {
|
||||
TELEPHONY_LOGE("permission denied!");
|
||||
return TELEPHONY_ERR_PERMISSION_ERR;
|
||||
}
|
||||
if (simManager_ == nullptr) {
|
||||
TELEPHONY_LOGE("simManager_ is null");
|
||||
return TELEPHONY_ERR_LOCAL_PTR_NULL;
|
||||
}
|
||||
return simManager_->DisableProfile(slotId, portIndex, iccId, refresh, enumResult);
|
||||
}
|
||||
|
||||
int32_t CoreService::GetSmdsAddress(int32_t slotId, int32_t portIndex, std::u16string &smdsAddress)
|
||||
{
|
||||
if (!TelephonyPermission::CheckCallerIsSystemApp()) {
|
||||
TELEPHONY_LOGE("Non-system applications use system APIs!");
|
||||
return TELEPHONY_ERR_ILLEGAL_USE_OF_SYSTEM_API;
|
||||
}
|
||||
if (!TelephonyPermission::CheckPermission(Permission::GET_TELEPHONY_ESIM_STATE)) {
|
||||
TELEPHONY_LOGE("permission denied!");
|
||||
return TELEPHONY_ERR_PERMISSION_ERR;
|
||||
}
|
||||
if (simManager_ == nullptr) {
|
||||
TELEPHONY_LOGE("simManager_ is null");
|
||||
return TELEPHONY_ERR_LOCAL_PTR_NULL;
|
||||
}
|
||||
return simManager_->GetSmdsAddress(slotId, portIndex, smdsAddress);
|
||||
}
|
||||
|
||||
int32_t CoreService::GetRulesAuthTable(int32_t slotId, int32_t portIndex, EuiccRulesAuthTable &eUiccRulesAuthTable)
|
||||
{
|
||||
if (!TelephonyPermission::CheckCallerIsSystemApp()) {
|
||||
TELEPHONY_LOGE("Non-system applications use system APIs!");
|
||||
return TELEPHONY_ERR_ILLEGAL_USE_OF_SYSTEM_API;
|
||||
}
|
||||
if (!TelephonyPermission::CheckPermission(Permission::GET_TELEPHONY_ESIM_STATE)) {
|
||||
TELEPHONY_LOGE("permission denied!");
|
||||
return TELEPHONY_ERR_PERMISSION_ERR;
|
||||
}
|
||||
if (simManager_ == nullptr) {
|
||||
TELEPHONY_LOGE("simManager_ is null");
|
||||
return TELEPHONY_ERR_LOCAL_PTR_NULL;
|
||||
}
|
||||
return simManager_->GetRulesAuthTable(slotId, portIndex, eUiccRulesAuthTable);
|
||||
}
|
||||
|
||||
int32_t CoreService::GetEuiccChallenge(int32_t slotId, int32_t portIndex, ResponseEsimResult &responseResult)
|
||||
{
|
||||
if (!TelephonyPermission::CheckCallerIsSystemApp()) {
|
||||
TELEPHONY_LOGE("Non-system applications use system APIs!");
|
||||
return TELEPHONY_ERR_ILLEGAL_USE_OF_SYSTEM_API;
|
||||
}
|
||||
if (!TelephonyPermission::CheckPermission(Permission::GET_TELEPHONY_ESIM_STATE)) {
|
||||
TELEPHONY_LOGE("permission denied!");
|
||||
return TELEPHONY_ERR_PERMISSION_ERR;
|
||||
}
|
||||
if (simManager_ == nullptr) {
|
||||
TELEPHONY_LOGE("simManager_ is null");
|
||||
return TELEPHONY_ERR_LOCAL_PTR_NULL;
|
||||
}
|
||||
return simManager_->GetEuiccChallenge(slotId, portIndex, responseResult);
|
||||
}
|
||||
|
||||
int32_t CoreService::GetDefaultSmdpAddress(int32_t slotId, std::u16string &defaultSmdpAddress)
|
||||
{
|
||||
if (!TelephonyPermission::CheckCallerIsSystemApp()) {
|
||||
TELEPHONY_LOGE("Non-system applications use system APIs!");
|
||||
return TELEPHONY_ERR_ILLEGAL_USE_OF_SYSTEM_API;
|
||||
}
|
||||
if (!TelephonyPermission::CheckPermission(Permission::GET_TELEPHONY_ESIM_STATE)) {
|
||||
TELEPHONY_LOGE("Failed because no permission:GET_TELEPHONY_ESIM_STATE");
|
||||
return TELEPHONY_ERR_PERMISSION_ERR;
|
||||
}
|
||||
if (simManager_ == nullptr) {
|
||||
TELEPHONY_LOGE("simManager_ is null");
|
||||
return TELEPHONY_ERR_LOCAL_PTR_NULL;
|
||||
}
|
||||
return simManager_->GetDefaultSmdpAddress(slotId, defaultSmdpAddress);
|
||||
}
|
||||
|
||||
int32_t CoreService::CancelSession(
|
||||
int32_t slotId, const std::u16string &transactionId, CancelReason cancelReason, ResponseEsimResult &responseResult)
|
||||
{
|
||||
if (!TelephonyPermission::CheckCallerIsSystemApp()) {
|
||||
TELEPHONY_LOGE("Non-system applications use system APIs!");
|
||||
return TELEPHONY_ERR_ILLEGAL_USE_OF_SYSTEM_API;
|
||||
}
|
||||
if (!TelephonyPermission::CheckPermission(Permission::SET_TELEPHONY_ESIM_STATE)) {
|
||||
TELEPHONY_LOGE("Failed because no permission:SET_TELEPHONY_ESIM_STATE");
|
||||
return TELEPHONY_ERR_PERMISSION_ERR;
|
||||
}
|
||||
if (simManager_ == nullptr) {
|
||||
TELEPHONY_LOGE("simManager_ is null");
|
||||
return TELEPHONY_ERR_LOCAL_PTR_NULL;
|
||||
}
|
||||
return simManager_->CancelSession(slotId, transactionId, cancelReason, responseResult);
|
||||
}
|
||||
|
||||
int32_t CoreService::GetProfile(
|
||||
int32_t slotId, int32_t portIndex, const std::u16string &iccId, EuiccProfile &eUiccProfile)
|
||||
{
|
||||
if (!TelephonyPermission::CheckCallerIsSystemApp()) {
|
||||
TELEPHONY_LOGE("Non-system applications use system APIs!");
|
||||
return TELEPHONY_ERR_ILLEGAL_USE_OF_SYSTEM_API;
|
||||
}
|
||||
if (!TelephonyPermission::CheckPermission(Permission::GET_TELEPHONY_ESIM_STATE)) {
|
||||
TELEPHONY_LOGE("Failed because no permission:GET_TELEPHONY_ESIM_STATE");
|
||||
return TELEPHONY_ERR_PERMISSION_ERR;
|
||||
}
|
||||
if (simManager_ == nullptr) {
|
||||
TELEPHONY_LOGE("simManager_ is null");
|
||||
return TELEPHONY_ERR_LOCAL_PTR_NULL;
|
||||
}
|
||||
return simManager_->GetProfile(slotId, portIndex, iccId, eUiccProfile);
|
||||
}
|
||||
|
||||
int32_t CoreService::ResetMemory(int32_t slotId, ResetOption resetOption, ResultState &enumResult)
|
||||
{
|
||||
if (!TelephonyPermission::CheckCallerIsSystemApp()) {
|
||||
TELEPHONY_LOGE("Non-system applications use system APIs!");
|
||||
return TELEPHONY_ERR_ILLEGAL_USE_OF_SYSTEM_API;
|
||||
}
|
||||
if (!TelephonyPermission::CheckPermission(Permission::SET_TELEPHONY_ESIM_STATE)) {
|
||||
TELEPHONY_LOGE("Failed because no permission:SET_TELEPHONY_ESIM_STATE");
|
||||
return TELEPHONY_ERR_PERMISSION_ERR;
|
||||
}
|
||||
if (simManager_ == nullptr) {
|
||||
TELEPHONY_LOGE("simManager_ is null");
|
||||
return TELEPHONY_ERR_LOCAL_PTR_NULL;
|
||||
}
|
||||
return simManager_->ResetMemory(slotId, resetOption, enumResult);
|
||||
}
|
||||
|
||||
int32_t CoreService::SetDefaultSmdpAddress(
|
||||
int32_t slotId, const std::u16string &defaultSmdpAddress, ResultState &enumResult)
|
||||
{
|
||||
if (!TelephonyPermission::CheckCallerIsSystemApp()) {
|
||||
TELEPHONY_LOGE("Non-system applications use system APIs!");
|
||||
return TELEPHONY_ERR_ILLEGAL_USE_OF_SYSTEM_API;
|
||||
}
|
||||
if (!TelephonyPermission::CheckPermission(Permission::SET_TELEPHONY_ESIM_STATE)) {
|
||||
TELEPHONY_LOGE("Failed because no permission:SET_TELEPHONY_ESIM_STATE");
|
||||
return TELEPHONY_ERR_PERMISSION_ERR;
|
||||
}
|
||||
if (simManager_ == nullptr) {
|
||||
TELEPHONY_LOGE("simManager_ is null");
|
||||
return TELEPHONY_ERR_LOCAL_PTR_NULL;
|
||||
}
|
||||
return simManager_->SetDefaultSmdpAddress(slotId, defaultSmdpAddress, enumResult);
|
||||
}
|
||||
|
||||
bool CoreService::IsEsimSupported(int32_t slotId)
|
||||
{
|
||||
if (simManager_ == nullptr) {
|
||||
TELEPHONY_LOGE("simManager_ is null");
|
||||
return false;
|
||||
}
|
||||
return simManager_->IsEsimSupported(slotId);
|
||||
}
|
||||
|
||||
int32_t CoreService::SendApduData(
|
||||
int32_t slotId, const std::u16string &aid, const std::u16string &apduData, ResponseEsimResult &responseResult)
|
||||
{
|
||||
if (!TelephonyPermission::CheckCallerIsSystemApp()) {
|
||||
TELEPHONY_LOGE("Non-system applications use system APIs!");
|
||||
return TELEPHONY_ERR_ILLEGAL_USE_OF_SYSTEM_API;
|
||||
}
|
||||
if (!TelephonyPermission::CheckPermission(Permission::SET_TELEPHONY_ESIM_STATE)) {
|
||||
TELEPHONY_LOGE("Failed because no permission:SET_TELEPHONY_ESIM_STATE");
|
||||
return TELEPHONY_ERR_PERMISSION_ERR;
|
||||
}
|
||||
if (simManager_ == nullptr) {
|
||||
TELEPHONY_LOGE("simManager_ is null");
|
||||
return TELEPHONY_ERR_LOCAL_PTR_NULL;
|
||||
}
|
||||
return simManager_->SendApduData(slotId, aid, apduData, responseResult);
|
||||
}
|
||||
|
||||
int32_t CoreService::PrepareDownload(int32_t slotId, const DownLoadConfigInfo &downLoadConfigInfo,
|
||||
ResponseEsimResult &responseResult)
|
||||
{
|
||||
if (!TelephonyPermission::CheckCallerIsSystemApp()) {
|
||||
TELEPHONY_LOGE("Non-system applications use system APIs!");
|
||||
return TELEPHONY_ERR_ILLEGAL_USE_OF_SYSTEM_API;
|
||||
}
|
||||
if (!TelephonyPermission::CheckPermission(Permission::SET_TELEPHONY_ESIM_STATE)) {
|
||||
TELEPHONY_LOGE("Failed because no permission:SET_TELEPHONY_ESIM_STATE");
|
||||
return TELEPHONY_ERR_PERMISSION_ERR;
|
||||
}
|
||||
if (simManager_ == nullptr) {
|
||||
TELEPHONY_LOGE("simManager_ is null");
|
||||
return TELEPHONY_ERR_LOCAL_PTR_NULL;
|
||||
}
|
||||
return simManager_->PrepareDownload(slotId, downLoadConfigInfo, responseResult);
|
||||
}
|
||||
|
||||
int32_t CoreService::LoadBoundProfilePackage(int32_t slotId, int32_t portIndex,
|
||||
const std::u16string &boundProfilePackage, ResponseEsimBppResult &responseResult)
|
||||
{
|
||||
if (!TelephonyPermission::CheckCallerIsSystemApp()) {
|
||||
TELEPHONY_LOGE("Non-system applications use system APIs!");
|
||||
return TELEPHONY_ERR_ILLEGAL_USE_OF_SYSTEM_API;
|
||||
}
|
||||
if (!TelephonyPermission::CheckPermission(Permission::SET_TELEPHONY_ESIM_STATE)) {
|
||||
TELEPHONY_LOGE("Failed because no permission:SET_TELEPHONY_ESIM_STATE");
|
||||
return TELEPHONY_ERR_PERMISSION_ERR;
|
||||
}
|
||||
if (simManager_ == nullptr) {
|
||||
TELEPHONY_LOGE("simManager_ is null");
|
||||
return TELEPHONY_ERR_LOCAL_PTR_NULL;
|
||||
}
|
||||
return simManager_->LoadBoundProfilePackage(slotId, portIndex, boundProfilePackage, responseResult);
|
||||
}
|
||||
|
||||
int32_t CoreService::ListNotifications(
|
||||
int32_t slotId, int32_t portIndex, Event events, EuiccNotificationList ¬ificationList)
|
||||
{
|
||||
|
@ -22,6 +22,7 @@ namespace Telephony {
|
||||
// EVENT
|
||||
static constexpr const char *SIGNAL_LEVEL_EVENT = "SIGNAL_LEVEL";
|
||||
static constexpr const char *NETWORK_REGISTER_EVENT = "NETWORK_REGISTER";
|
||||
static constexpr const char *RADIO_STATE_CHANGE_EVENT = "RADIO_STATE_CHANGE";
|
||||
static constexpr const char *SET_DEFAULT_CELLULAR_DATA_EVENT = "SET_DEFAULT_CELLULAR_DATA";
|
||||
static constexpr const char *SIM_STATE_CHANGE_EVENT = "SIM_STATE_CHANGE";
|
||||
static constexpr const char *CALL_DIAL_FAILED_EVENT = "CALL_DIAL_FAILED";
|
||||
@ -67,6 +68,11 @@ void CoreServiceHiSysEvent::WriteNetworkStateBehaviorEvent(int32_t slotId, int32
|
||||
tech, NETWORK_STATE_KEY, state);
|
||||
}
|
||||
|
||||
void CoreServiceHiSysEvent::WriteRadioStateBehaviorEvent(int32_t slotId, int32_t state)
|
||||
{
|
||||
HiWriteBehaviorEvent(RADIO_STATE_CHANGE_EVENT, SLOT_ID_KEY, slotId, STATE_KEY, state);
|
||||
}
|
||||
|
||||
void CoreServiceHiSysEvent::WriteDefaultDataSlotIdBehaviorEvent(int32_t slotId)
|
||||
{
|
||||
HiWriteBehaviorEvent(SET_DEFAULT_CELLULAR_DATA_EVENT, SLOT_ID_KEY, slotId);
|
||||
|
@ -40,6 +40,9 @@ CoreServiceStub::CoreServiceStub()
|
||||
AddHandlerVoiceMailToMap();
|
||||
AddHandlerPdpProfileToMap();
|
||||
AddHandlerOpkeyVersionToMap();
|
||||
#ifdef CORE_SERVICE_SUPPORT_ESIM
|
||||
AddHandlerEsimToMap();
|
||||
#endif
|
||||
}
|
||||
|
||||
void CoreServiceStub::AddHandlerNetWorkToMap()
|
||||
@ -281,6 +284,34 @@ void CoreServiceStub::AddHandlerEsimToMap()
|
||||
[this](MessageParcel &data, MessageParcel &reply) { return OnLoadBoundProfilePackage(data, reply); };
|
||||
memberFuncMap_[uint32_t(CoreServiceInterfaceCode::LIST_NOTIFICATIONS)] =
|
||||
[this](MessageParcel &data, MessageParcel &reply) { return OnListNotifications(data, reply); };
|
||||
memberFuncMap_[uint32_t(CoreServiceInterfaceCode::GET_EID)] =
|
||||
[this](MessageParcel &data, MessageParcel &reply) { return OnGetEid(data, reply); };
|
||||
memberFuncMap_[uint32_t(CoreServiceInterfaceCode::GET_EUICC_PROFILE_INFO_LIST)] =
|
||||
[this](MessageParcel &data, MessageParcel &reply) { return OnGetEuiccProfileInfoList(data, reply); };
|
||||
memberFuncMap_[uint32_t(CoreServiceInterfaceCode::GET_EUICC_INFO)] =
|
||||
[this](MessageParcel &data, MessageParcel &reply) { return OnGetEuiccInfo(data, reply); };
|
||||
memberFuncMap_[uint32_t(CoreServiceInterfaceCode::DISABLE_PROFILE)] =
|
||||
[this](MessageParcel &data, MessageParcel &reply) { return OnDisableProfile(data, reply); };
|
||||
memberFuncMap_[uint32_t(CoreServiceInterfaceCode::GET_SMDSADDRESS)] =
|
||||
[this](MessageParcel &data, MessageParcel &reply) { return OnGetSmdsAddress(data, reply); };
|
||||
memberFuncMap_[uint32_t(CoreServiceInterfaceCode::GET_RULES_AUTH_TABLE)] =
|
||||
[this](MessageParcel &data, MessageParcel &reply) { return OnGetRulesAuthTable(data, reply); };
|
||||
memberFuncMap_[uint32_t(CoreServiceInterfaceCode::GET_EUICC_CHALLENGE)] =
|
||||
[this](MessageParcel &data, MessageParcel &reply) { return OnGetEuiccChallenge(data, reply); };
|
||||
memberFuncMap_[uint32_t(CoreServiceInterfaceCode::REQUEST_DEFAULT_SMDP_ADDRESS)] =
|
||||
[this](MessageParcel &data, MessageParcel &reply) { return OnRequestDefaultSmdpAddress(data, reply); };
|
||||
memberFuncMap_[uint32_t(CoreServiceInterfaceCode::CANCEL_SESSION)] =
|
||||
[this](MessageParcel &data, MessageParcel &reply) { return OnCancelSession(data, reply); };
|
||||
memberFuncMap_[uint32_t(CoreServiceInterfaceCode::GET_PROFILE)] =
|
||||
[this](MessageParcel &data, MessageParcel &reply) { return OnGetProfile(data, reply); };
|
||||
memberFuncMap_[uint32_t(CoreServiceInterfaceCode::RESET_MEMORY)] =
|
||||
[this](MessageParcel &data, MessageParcel &reply) { return OnResetMemory(data, reply); };
|
||||
memberFuncMap_[uint32_t(CoreServiceInterfaceCode::SET_DEFAULT_SMDP_ADDRESS)] =
|
||||
[this](MessageParcel &data, MessageParcel &reply) { return OnSetDefaultSmdpAddress(data, reply); };
|
||||
memberFuncMap_[uint32_t(CoreServiceInterfaceCode::IS_ESIM_SUPPORTED)] =
|
||||
[this](MessageParcel &data, MessageParcel &reply) { return OnIsEsimSupported(data, reply); };
|
||||
memberFuncMap_[uint32_t(CoreServiceInterfaceCode::SEND_APDU_DATA)] =
|
||||
[this](MessageParcel &data, MessageParcel &reply) { return OnSendApduData(data, reply); };
|
||||
}
|
||||
#endif
|
||||
|
||||
@ -1952,6 +1983,302 @@ int32_t CoreServiceStub::OnGetSimIO(MessageParcel &data, MessageParcel &reply)
|
||||
}
|
||||
|
||||
#ifdef CORE_SERVICE_SUPPORT_ESIM
|
||||
int32_t CoreServiceStub::OnGetEid(MessageParcel &data, MessageParcel &reply)
|
||||
{
|
||||
int32_t slotId = data.ReadInt32();
|
||||
std::u16string eId;
|
||||
int32_t result = GetEid(slotId, eId);
|
||||
bool ret = reply.WriteInt32(result);
|
||||
if (result == TELEPHONY_ERR_SUCCESS) {
|
||||
ret = (ret && reply.WriteString16(eId));
|
||||
}
|
||||
if (!ret) {
|
||||
TELEPHONY_LOGE("write reply failed.");
|
||||
return TELEPHONY_ERR_WRITE_REPLY_FAIL;
|
||||
}
|
||||
return NO_ERROR;
|
||||
}
|
||||
|
||||
int32_t CoreServiceStub::OnGetEuiccProfileInfoList(MessageParcel &data, MessageParcel &reply)
|
||||
{
|
||||
int32_t slotId = data.ReadInt32();
|
||||
GetEuiccProfileInfoListResult euiccProfileInfoList;
|
||||
int32_t result = GetEuiccProfileInfoList(slotId, euiccProfileInfoList);
|
||||
bool ret = reply.WriteInt32(result);
|
||||
if (result == TELEPHONY_ERR_SUCCESS) {
|
||||
if (!reply.WriteUint32(euiccProfileInfoList.profiles.size())) {
|
||||
TELEPHONY_LOGE("write reply failed.");
|
||||
return TELEPHONY_ERR_WRITE_REPLY_FAIL;
|
||||
}
|
||||
for (const auto &profile : euiccProfileInfoList.profiles) {
|
||||
ret = (ret && reply.WriteString16(profile.iccId));
|
||||
ret = (ret && reply.WriteString16(profile.nickName));
|
||||
ret = (ret && reply.WriteString16(profile.serviceProviderName));
|
||||
ret = (ret && reply.WriteString16(profile.profileName));
|
||||
ret = (ret && reply.WriteInt32(static_cast<int32_t>(profile.state)));
|
||||
ret = (ret && reply.WriteInt32(static_cast<int32_t>(profile.profileClass)));
|
||||
ret = (ret && reply.WriteString16(profile.carrierId.mcc));
|
||||
ret = (ret && reply.WriteString16(profile.carrierId.mnc));
|
||||
ret = (ret && reply.WriteString16(profile.carrierId.gid1));
|
||||
ret = (ret && reply.WriteString16(profile.carrierId.gid2));
|
||||
ret = (ret && reply.WriteInt32(static_cast<int32_t>(profile.policyRules)));
|
||||
ret = (ret && reply.WriteUint32(profile.accessRules.size()));
|
||||
for (const auto &rule : profile.accessRules) {
|
||||
ret = (ret && reply.WriteString16(rule.certificateHashHexStr));
|
||||
ret = (ret && reply.WriteString16(rule.packageName));
|
||||
ret = (ret && reply.WriteInt32(rule.accessType));
|
||||
}
|
||||
}
|
||||
ret = (ret && reply.WriteBool(euiccProfileInfoList.isRemovable));
|
||||
ret = (ret && reply.WriteInt32(static_cast<int32_t>(euiccProfileInfoList.result)));
|
||||
if (!ret) {
|
||||
TELEPHONY_LOGE("write reply failed.");
|
||||
return TELEPHONY_ERR_WRITE_REPLY_FAIL;
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
int32_t CoreServiceStub::OnGetEuiccInfo(MessageParcel &data, MessageParcel &reply)
|
||||
{
|
||||
int32_t slotId = data.ReadInt32();
|
||||
EuiccInfo eUiccInfo;
|
||||
int32_t result = GetEuiccInfo(slotId, eUiccInfo);
|
||||
bool ret = reply.WriteInt32(result);
|
||||
if (result == TELEPHONY_ERR_SUCCESS) {
|
||||
ret = (ret && reply.WriteString16(eUiccInfo.osVersion) && reply.WriteString16(eUiccInfo.response));
|
||||
}
|
||||
if (!ret) {
|
||||
TELEPHONY_LOGE("write reply failed.");
|
||||
return TELEPHONY_ERR_WRITE_REPLY_FAIL;
|
||||
}
|
||||
return NO_ERROR;
|
||||
}
|
||||
|
||||
int32_t CoreServiceStub::OnDisableProfile(MessageParcel &data, MessageParcel &reply)
|
||||
{
|
||||
int32_t slotId = data.ReadInt32();
|
||||
int32_t portIndex = data.ReadInt32();
|
||||
std::u16string iccId = data.ReadString16();
|
||||
bool refresh = data.ReadBool();
|
||||
ResultState enumResult;
|
||||
int32_t result = DisableProfile(slotId, portIndex, iccId, refresh, enumResult);
|
||||
bool ret = reply.WriteInt32(result);
|
||||
if (result == TELEPHONY_ERR_SUCCESS) {
|
||||
ret = (ret && reply.WriteInt32(static_cast<int32_t>(enumResult)));
|
||||
}
|
||||
if (!ret) {
|
||||
TELEPHONY_LOGE("write reply failed.");
|
||||
return TELEPHONY_ERR_WRITE_REPLY_FAIL;
|
||||
}
|
||||
return NO_ERROR;
|
||||
}
|
||||
|
||||
int32_t CoreServiceStub::OnGetSmdsAddress(MessageParcel &data, MessageParcel &reply)
|
||||
{
|
||||
int32_t slotId = data.ReadInt32();
|
||||
int32_t portIndex = data.ReadInt32();
|
||||
std::u16string smdsAddress;
|
||||
int32_t result = GetSmdsAddress(slotId, portIndex, smdsAddress);
|
||||
bool ret = reply.WriteInt32(result);
|
||||
if (result == TELEPHONY_ERR_SUCCESS) {
|
||||
ret = (ret && reply.WriteString16(smdsAddress));
|
||||
}
|
||||
if (!ret) {
|
||||
TELEPHONY_LOGE("write reply failed.");
|
||||
return TELEPHONY_ERR_WRITE_REPLY_FAIL;
|
||||
}
|
||||
return NO_ERROR;
|
||||
}
|
||||
|
||||
int32_t CoreServiceStub::OnGetRulesAuthTable(MessageParcel &data, MessageParcel &reply)
|
||||
{
|
||||
int32_t slotId = data.ReadInt32();
|
||||
int32_t portIndex = data.ReadInt32();
|
||||
EuiccRulesAuthTable eUiccRulesAuthTable;
|
||||
int32_t result = GetRulesAuthTable(slotId, portIndex, eUiccRulesAuthTable);
|
||||
bool ret = reply.WriteInt32(result);
|
||||
if (result == TELEPHONY_ERR_SUCCESS) {
|
||||
ret = (ret && reply.WriteUint32(eUiccRulesAuthTable.policyRules.size()));
|
||||
for (const auto &rules : eUiccRulesAuthTable.policyRules) {
|
||||
ret = (ret && reply.WriteInt32(rules));
|
||||
}
|
||||
ret = (ret && reply.WriteUint32(eUiccRulesAuthTable.carrierIds.size()));
|
||||
for (const auto &carrier : eUiccRulesAuthTable.carrierIds) {
|
||||
ret = (ret && reply.WriteString16(carrier.mcc));
|
||||
ret = (ret && reply.WriteString16(carrier.mnc));
|
||||
ret = (ret && reply.WriteString16(carrier.spn));
|
||||
ret = (ret && reply.WriteString16(carrier.imsi));
|
||||
ret = (ret && reply.WriteString16(carrier.gid1));
|
||||
ret = (ret && reply.WriteString16(carrier.gid2));
|
||||
ret = (ret && reply.WriteInt32(carrier.carrierId));
|
||||
ret = (ret && reply.WriteInt32(carrier.specificCarrierId));
|
||||
}
|
||||
ret = (ret && reply.WriteUint32(eUiccRulesAuthTable.policyRuleFlags.size()));
|
||||
for (const auto &ruleFlags : eUiccRulesAuthTable.policyRuleFlags) {
|
||||
ret = (ret && reply.WriteInt32(ruleFlags));
|
||||
}
|
||||
ret = (ret && reply.WriteInt32(eUiccRulesAuthTable.position));
|
||||
}
|
||||
if (!ret) {
|
||||
TELEPHONY_LOGE("write reply failed.");
|
||||
return TELEPHONY_ERR_WRITE_REPLY_FAIL;
|
||||
}
|
||||
return NO_ERROR;
|
||||
}
|
||||
|
||||
int32_t CoreServiceStub::OnGetEuiccChallenge(MessageParcel &data, MessageParcel &reply)
|
||||
{
|
||||
int32_t slotId = data.ReadInt32();
|
||||
int32_t portIndex = data.ReadInt32();
|
||||
ResponseEsimResult responseResult;
|
||||
int32_t result = GetEuiccChallenge(slotId, portIndex, responseResult);
|
||||
bool ret = reply.WriteInt32(result);
|
||||
if (result == TELEPHONY_ERR_SUCCESS) {
|
||||
ret = (ret && reply.WriteInt32(static_cast<int32_t>(responseResult.resultCode)));
|
||||
ret = (ret && reply.WriteString16(responseResult.response));
|
||||
}
|
||||
if (!ret) {
|
||||
TELEPHONY_LOGE("write reply failed.");
|
||||
return TELEPHONY_ERR_WRITE_REPLY_FAIL;
|
||||
}
|
||||
return NO_ERROR;
|
||||
}
|
||||
|
||||
int32_t CoreServiceStub::OnRequestDefaultSmdpAddress(MessageParcel &data, MessageParcel &reply)
|
||||
{
|
||||
int32_t slotId = data.ReadInt32();
|
||||
std::u16string defaultSmdpAddress;
|
||||
int32_t result = GetDefaultSmdpAddress(slotId, defaultSmdpAddress);
|
||||
bool ret = reply.WriteInt32(result);
|
||||
if (result == TELEPHONY_ERR_SUCCESS) {
|
||||
ret = (ret && reply.WriteString16(defaultSmdpAddress));
|
||||
}
|
||||
if (!ret) {
|
||||
TELEPHONY_LOGE("write reply failed");
|
||||
return TELEPHONY_ERR_WRITE_REPLY_FAIL;
|
||||
}
|
||||
return NO_ERROR;
|
||||
}
|
||||
|
||||
int32_t CoreServiceStub::OnCancelSession(MessageParcel &data, MessageParcel &reply)
|
||||
{
|
||||
int32_t slotId = data.ReadInt32();
|
||||
std::u16string transactionId = data.ReadString16();
|
||||
CancelReason cancelReason = static_cast<CancelReason>(data.ReadInt32());
|
||||
ResponseEsimResult responseResult;
|
||||
int32_t result = CancelSession(slotId, transactionId, cancelReason, responseResult);
|
||||
bool ret = reply.WriteInt32(result);
|
||||
if (result == TELEPHONY_ERR_SUCCESS) {
|
||||
ret = (ret && reply.WriteInt32(static_cast<int32_t>(responseResult.resultCode)));
|
||||
ret = (ret && reply.WriteString16(responseResult.response));
|
||||
}
|
||||
if (!ret) {
|
||||
TELEPHONY_LOGE("write reply failed");
|
||||
return TELEPHONY_ERR_WRITE_REPLY_FAIL;
|
||||
}
|
||||
return NO_ERROR;
|
||||
}
|
||||
|
||||
int32_t CoreServiceStub::OnGetProfile(MessageParcel &data, MessageParcel &reply)
|
||||
{
|
||||
int32_t slotId = data.ReadInt32();
|
||||
int32_t portIndex = data.ReadInt32();
|
||||
std::u16string iccId = data.ReadString16();
|
||||
EuiccProfile eUiccProfile;
|
||||
int32_t result = GetProfile(slotId, portIndex, iccId, eUiccProfile);
|
||||
bool ret = reply.WriteInt32(result);
|
||||
if (result == TELEPHONY_ERR_SUCCESS) {
|
||||
ret = (ret && reply.WriteString16(eUiccProfile.iccId));
|
||||
ret = (ret && reply.WriteString16(eUiccProfile.nickName));
|
||||
ret = (ret && reply.WriteString16(eUiccProfile.serviceProviderName));
|
||||
ret = (ret && reply.WriteString16(eUiccProfile.profileName));
|
||||
ret = (ret && reply.WriteInt32(static_cast<int32_t>(eUiccProfile.state)));
|
||||
ret = (ret && reply.WriteInt32(static_cast<int32_t>(eUiccProfile.profileClass)));
|
||||
ret = (ret && reply.WriteString16(eUiccProfile.carrierId.mcc));
|
||||
ret = (ret && reply.WriteString16(eUiccProfile.carrierId.mnc));
|
||||
ret = (ret && reply.WriteString16(eUiccProfile.carrierId.gid1));
|
||||
ret = (ret && reply.WriteString16(eUiccProfile.carrierId.gid2));
|
||||
ret = (ret && reply.WriteInt32(static_cast<int32_t>(eUiccProfile.policyRules)));
|
||||
ret = (ret && reply.WriteInt32(eUiccProfile.accessRules.size()));
|
||||
for (const auto &rule : eUiccProfile.accessRules) {
|
||||
ret = (ret && reply.WriteString16(rule.certificateHashHexStr));
|
||||
ret = (ret && reply.WriteString16(rule.packageName));
|
||||
ret = (ret && reply.WriteInt32(rule.accessType));
|
||||
}
|
||||
}
|
||||
if (!ret) {
|
||||
TELEPHONY_LOGE("OnRequestDefaultSmdpAddress OnRemoteRequest::REQUEST_DEFAULT_SMDP_ADDRESS write reply failed");
|
||||
return TELEPHONY_ERR_WRITE_REPLY_FAIL;
|
||||
}
|
||||
return NO_ERROR;
|
||||
}
|
||||
|
||||
int32_t CoreServiceStub::OnResetMemory(MessageParcel &data, MessageParcel &reply)
|
||||
{
|
||||
int32_t slotId = data.ReadInt32();
|
||||
ResetOption resetOption = static_cast<ResetOption>(data.ReadInt32());
|
||||
ResultState enumResult;
|
||||
int32_t result = ResetMemory(slotId, resetOption, enumResult);
|
||||
bool ret = reply.WriteInt32(result);
|
||||
if (result == TELEPHONY_ERR_SUCCESS) {
|
||||
ret = (ret && reply.WriteInt32(static_cast<int32_t>(enumResult)));
|
||||
}
|
||||
if (!ret) {
|
||||
TELEPHONY_LOGE("write reply failed.");
|
||||
return TELEPHONY_ERR_WRITE_REPLY_FAIL;
|
||||
}
|
||||
return NO_ERROR;
|
||||
}
|
||||
|
||||
int32_t CoreServiceStub::OnSetDefaultSmdpAddress(MessageParcel &data, MessageParcel &reply)
|
||||
{
|
||||
int32_t slotId = data.ReadInt32();
|
||||
std::u16string defaultSmdpAddress = data.ReadString16();
|
||||
ResultState enumResult;
|
||||
int32_t result = SetDefaultSmdpAddress(slotId, defaultSmdpAddress, enumResult);
|
||||
bool ret = reply.WriteInt32(result);
|
||||
if (result == TELEPHONY_ERR_SUCCESS) {
|
||||
ret = (ret && reply.WriteInt32(static_cast<int32_t>(enumResult)));
|
||||
}
|
||||
if (!ret) {
|
||||
TELEPHONY_LOGE("write reply failed.");
|
||||
return TELEPHONY_ERR_WRITE_REPLY_FAIL;
|
||||
}
|
||||
return NO_ERROR;
|
||||
}
|
||||
|
||||
int32_t CoreServiceStub::OnIsEsimSupported(MessageParcel &data, MessageParcel &reply)
|
||||
{
|
||||
int32_t slotId = data.ReadInt32();
|
||||
bool result = IsEsimSupported(slotId);
|
||||
bool ret = reply.WriteBool(result);
|
||||
if (!ret) {
|
||||
TELEPHONY_LOGE("write reply failed.");
|
||||
return ERR_FLATTEN_OBJECT;
|
||||
}
|
||||
return NO_ERROR;
|
||||
}
|
||||
|
||||
int32_t CoreServiceStub::OnSendApduData(MessageParcel &data, MessageParcel &reply)
|
||||
{
|
||||
int32_t slotId = data.ReadInt32();
|
||||
std::u16string aid = data.ReadString16();
|
||||
std::u16string apduData = data.ReadString16();
|
||||
ResponseEsimResult responseResult;
|
||||
int32_t result = SendApduData(slotId, aid, apduData, responseResult);
|
||||
bool ret = reply.WriteInt32(result);
|
||||
if (result == TELEPHONY_ERR_SUCCESS) {
|
||||
ret = (ret && reply.WriteInt32(static_cast<int32_t>(responseResult.resultCode)));
|
||||
ret = (ret && reply.WriteString16(responseResult.response));
|
||||
}
|
||||
if (!ret) {
|
||||
TELEPHONY_LOGE("write reply failed.");
|
||||
return TELEPHONY_ERR_WRITE_REPLY_FAIL;
|
||||
}
|
||||
return NO_ERROR;
|
||||
}
|
||||
|
||||
int32_t CoreServiceStub::OnPrepareDownload(MessageParcel &data, MessageParcel &reply)
|
||||
{
|
||||
DownLoadConfigInfo downLoadConfigInfo;
|
||||
|
@ -66,7 +66,9 @@
|
||||
"ohos.permission.ACCESS_DISTRIBUTED_MODEM",
|
||||
"ohos.permission.MANAGE_CAMERA_CONFIG",
|
||||
"ohos.permission.PERCEIVE_SMART_POWER_SCENARIO",
|
||||
"ohos.permission.MANAGE_WIFI_CONNECTION"
|
||||
"ohos.permission.MANAGE_WIFI_CONNECTION",
|
||||
"ohos.permission.INTERNET",
|
||||
"ohos.permission.READ_WRITE_DOCUMENTS_DIRECTORY"
|
||||
],
|
||||
"permission_acls" : [
|
||||
"ohos.permission.MANAGE_WIFI_CONNECTION"
|
||||
|
@ -8,6 +8,7 @@
|
||||
4011,
|
||||
4014,
|
||||
4016,
|
||||
4017
|
||||
4017,
|
||||
66250
|
||||
]
|
||||
}
|
@ -16,3 +16,4 @@ telephony.sim.opkey0=-1
|
||||
telephony.sim.opkey1=-1
|
||||
const.telephony.sms.expire.days=7
|
||||
const.telephony.satellite.supported=0
|
||||
persist.telephony.retrystrategy.allow=true
|
@ -239,6 +239,19 @@ public:
|
||||
bool SendCallback(int32_t slotId, RadioEvent radioEvent, const sptr<INetworkSearchCallback> *callback,
|
||||
int32_t firstParam, std::string secondParam);
|
||||
|
||||
/**
|
||||
* @brief send event to RilBaseManager with callback
|
||||
*
|
||||
* @param slotId sim card id
|
||||
* @param radioEvent see RadioEvent
|
||||
* @param callback pointer to callback interface
|
||||
* @param isChipsetNetworkExtSupported indicates whether the chipset supports networkExt
|
||||
* @return true success
|
||||
* @return false fail
|
||||
*/
|
||||
bool SendCallbackNetworkExt(int32_t slotId, RadioEvent radioEvent, const sptr<INetworkSearchCallback> *callback,
|
||||
bool isChipsetNetworkExtSupported);
|
||||
|
||||
private:
|
||||
/**
|
||||
* @brief Get the Ril Function Pointer From Map
|
||||
|
@ -21,6 +21,7 @@
|
||||
#include <string_ex.h>
|
||||
|
||||
#include "core_service_errors.h"
|
||||
#include "core_service_hisysevent.h"
|
||||
#include "enum_convert.h"
|
||||
#include "mcc_pool.h"
|
||||
#include "network_search_types.h"
|
||||
@ -44,6 +45,9 @@ const int32_t SERVICE_ABILITY_OFF = 0;
|
||||
const int32_t SERVICE_ABILITY_ON = 1;
|
||||
const int32_t SYS_PARAMETER_SIZE = 256;
|
||||
const int32_t INVALID_DELAY_TIME = 0;
|
||||
const int32_t SLOT_0 = 0;
|
||||
const int32_t SLOT_1 = 1;
|
||||
|
||||
constexpr const char *NO_DELAY_TIME__CONFIG = "0";
|
||||
constexpr const char *CFG_TECH_UPDATE_TIME = "persist.radio.cfg.update.time";
|
||||
constexpr static const int32_t GET_SSB_WAIT_TIME_SECOND = 5;
|
||||
@ -560,7 +564,11 @@ void NetworkSearchManager::SetRadioStateValue(int32_t slotId, ModemPowerState ra
|
||||
{
|
||||
auto inner = FindManagerInner(slotId);
|
||||
if (inner != nullptr) {
|
||||
ModemPowerState radioStateOld = inner->radioState_;
|
||||
inner->radioState_ = radioState;
|
||||
if (radioStateOld != radioState) {
|
||||
CoreServiceHiSysEvent::WriteRadioStateBehaviorEvent(slotId, static_cast<int32_t>(radioState));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -775,7 +783,12 @@ int32_t NetworkSearchManager::GetPreferredNetwork(int32_t slotId, NSCALLBACK &ca
|
||||
TELEPHONY_LOGE("slotId:%{public}d eventSender_ is null", slotId);
|
||||
return TELEPHONY_ERR_LOCAL_PTR_NULL;
|
||||
}
|
||||
if (!eventSender_->SendCallback(slotId, RadioEvent::RADIO_GET_PREFERRED_NETWORK_MODE, &callback)) {
|
||||
bool isChipsetNetworkExtSupported = true;
|
||||
if (TELEPHONY_EXT_WRAPPER.isChipsetNetworkExtSupported_ != nullptr) {
|
||||
isChipsetNetworkExtSupported = TELEPHONY_EXT_WRAPPER.isChipsetNetworkExtSupported_();
|
||||
}
|
||||
if (!eventSender_->SendCallbackNetworkExt(slotId, RadioEvent::RADIO_GET_PREFERRED_NETWORK_MODE, &callback,
|
||||
isChipsetNetworkExtSupported)) {
|
||||
TELEPHONY_LOGE("slotId:%{public}d GetPreferredNetwork SendCallback failed.", slotId);
|
||||
return CORE_SERVICE_SEND_CALLBACK_FAILED;
|
||||
}
|
||||
@ -1009,6 +1022,24 @@ int32_t NetworkSearchManager::GetImei(int32_t slotId, std::u16string &imei)
|
||||
return TELEPHONY_ERR_LOCAL_PTR_NULL;
|
||||
}
|
||||
imei = inner->imei_;
|
||||
if (imei.empty()) {
|
||||
TELEPHONY_LOGI("imei is empty");
|
||||
return TELEPHONY_ERR_SUCCESS;
|
||||
}
|
||||
int32_t otherSlotId = slotId == SLOT_0 ? SLOT_1 : SLOT_0;
|
||||
if (otherSlotId < static_cast<int32_t>(mapManagerInner_.size())) {
|
||||
auto otherInner = FindManagerInner(otherSlotId);
|
||||
if (otherInner != nullptr) {
|
||||
std::u16string otherImei = otherInner->imei_;
|
||||
if (otherImei.empty()) {
|
||||
TELEPHONY_LOGI("otherImei is empty");
|
||||
} else if (otherImei == imei) {
|
||||
TELEPHONY_LOGI("slotId:%{public}d, otherSlotId:%{public}d, imei is same", slotId, otherSlotId);
|
||||
} else {
|
||||
TELEPHONY_LOGI("slotId:%{public}d, otherSlotId:%{public}d, imei is different", slotId, otherSlotId);
|
||||
}
|
||||
}
|
||||
}
|
||||
return TELEPHONY_ERR_SUCCESS;
|
||||
}
|
||||
|
||||
|
@ -40,9 +40,6 @@ void NetworkType::ProcessGetPreferredNetwork(const AppExecFwk::InnerEvent::Point
|
||||
return;
|
||||
}
|
||||
std::shared_ptr<NetworkSearchManager> networkSearchManager = networkSearchManager_.lock();
|
||||
if (networkSearchManager != nullptr && preferredNetworkInfo != nullptr) {
|
||||
networkSearchManager->SetCachePreferredNetworkValue(slotId_, preferredNetworkInfo->preferredNetworkType);
|
||||
}
|
||||
if (TELEPHONY_EXT_WRAPPER.getPreferredNetworkExt_ != nullptr && preferredNetworkInfo != nullptr) {
|
||||
TELEPHONY_EXT_WRAPPER.getPreferredNetworkExt_(preferredNetworkInfo->preferredNetworkType);
|
||||
}
|
||||
@ -134,6 +131,13 @@ bool NetworkType::WriteGetPreferredNetworkInfo(std::shared_ptr<PreferredNetworkT
|
||||
networkMode = preferredNetworkInfo->preferredNetworkType;
|
||||
index = preferredNetworkInfo->flag;
|
||||
networkSearchManager->SavePreferredNetworkValue(slotId_, networkMode);
|
||||
std::shared_ptr<NetworkSearchCallbackInfo> callbackInfo = NetworkUtils::FindNetworkSearchCallback(index);
|
||||
if (callbackInfo != nullptr) {
|
||||
bool isChipsetNetworkExtSupported = static_cast<bool>(callbackInfo->param_);
|
||||
if (!isChipsetNetworkExtSupported && TELEPHONY_EXT_WRAPPER.getPreferredNetworkExt_ != nullptr) {
|
||||
TELEPHONY_EXT_WRAPPER.getPreferredNetworkExt_(networkMode);
|
||||
}
|
||||
}
|
||||
if (!data.WriteInt32(networkMode) || !data.WriteInt32(TELEPHONY_SUCCESS)) {
|
||||
TELEPHONY_LOGE("NetworkType::ProcessGetPreferredNetwork WriteInt32 networkMode is false");
|
||||
return false;
|
||||
|
@ -448,5 +448,14 @@ bool EventSender::SendCallback(int32_t slotId, RadioEvent radioEvent, const sptr
|
||||
return Send<EventGetMode::GET_EVENT_BY_INDEX, RilFunc_Int_String_Event, int32_t, std::string>(
|
||||
parameters, firstParam, secondParam);
|
||||
}
|
||||
|
||||
bool EventSender::SendCallbackNetworkExt(int32_t slotId, RadioEvent radioEvent,
|
||||
const sptr<INetworkSearchCallback> *callback, bool isChipsetNetworkExtSupported)
|
||||
{
|
||||
auto fun = GetFunctionOfEvent<RilFunc_Event>(mapFunctions_, radioEvent);
|
||||
std::tuple<int32_t, RadioEvent, int32_t, const sptr<INetworkSearchCallback> *, RilFunc_Event> parameters(
|
||||
slotId, radioEvent, static_cast<int32_t>(isChipsetNetworkExtSupported), callback, fun);
|
||||
return Send<EventGetMode::GET_EVENT_BY_INDEX, RilFunc_Event>(parameters);
|
||||
}
|
||||
} // namespace Telephony
|
||||
} // namespace OHOS
|
||||
|
@ -131,7 +131,6 @@ void RadioInfo::RadioFirstPowerOn(std::shared_ptr<NetworkSearchManager> &nsm, Mo
|
||||
void RadioInfo::ProcessGetImei(const AppExecFwk::InnerEvent::Pointer &event) const
|
||||
{
|
||||
std::shared_ptr<NetworkSearchManager> nsm = networkSearchManager_.lock();
|
||||
TELEPHONY_LOGI("RadioInfo::ProcessGetImei slotId:%{public}d", slotId_);
|
||||
if (event == nullptr) {
|
||||
TELEPHONY_LOGE("RadioInfo::ProcessGetImei event is nullptr slotId:%{public}d", slotId_);
|
||||
return;
|
||||
@ -147,14 +146,13 @@ void RadioInfo::ProcessGetImei(const AppExecFwk::InnerEvent::Pointer &event) con
|
||||
nsm->SetImei(slotId_, u"");
|
||||
return;
|
||||
}
|
||||
TELEPHONY_LOGI("RadioInfo::ProcessGetImei get imei success");
|
||||
TELEPHONY_LOGI("RadioInfo::ProcessGetImei get imei success slotId:%{public}d", slotId_);
|
||||
nsm->SetImei(slotId_, Str8ToStr16(imeiID->data));
|
||||
}
|
||||
|
||||
void RadioInfo::ProcessGetImeiSv(const AppExecFwk::InnerEvent::Pointer &event) const
|
||||
{
|
||||
std::shared_ptr<NetworkSearchManager> nsm = networkSearchManager_.lock();
|
||||
TELEPHONY_LOGI("RadioInfo::ProcessGetImeiSv slotId:%{public}d", slotId_);
|
||||
if (event == nullptr) {
|
||||
TELEPHONY_LOGE("RadioInfo::ProcessGetImeiSv event is nullptr slotId:%{public}d", slotId_);
|
||||
return;
|
||||
@ -170,14 +168,13 @@ void RadioInfo::ProcessGetImeiSv(const AppExecFwk::InnerEvent::Pointer &event) c
|
||||
nsm->SetImeiSv(slotId_, u"");
|
||||
return;
|
||||
}
|
||||
TELEPHONY_LOGI("RadioInfo::ProcessGetImeiSv get imeiSv success");
|
||||
TELEPHONY_LOGI("RadioInfo::ProcessGetImeiSv get imeiSv success slotId:%{public}d", slotId_);
|
||||
nsm->SetImeiSv(slotId_, Str8ToStr16(imeiSvID->data));
|
||||
}
|
||||
|
||||
void RadioInfo::ProcessGetMeid(const AppExecFwk::InnerEvent::Pointer &event) const
|
||||
{
|
||||
std::shared_ptr<NetworkSearchManager> nsm = networkSearchManager_.lock();
|
||||
TELEPHONY_LOGI("RadioInfo::ProcessGetMeid slotId:%{public}d", slotId_);
|
||||
if (event == nullptr) {
|
||||
TELEPHONY_LOGE("RadioInfo::ProcessGetMeid event is nullptr slotId:%{public}d", slotId_);
|
||||
return;
|
||||
@ -193,7 +190,7 @@ void RadioInfo::ProcessGetMeid(const AppExecFwk::InnerEvent::Pointer &event) con
|
||||
nsm->SetMeid(slotId_, u"");
|
||||
return;
|
||||
}
|
||||
TELEPHONY_LOGI("RadioInfo::ProcessGetMeid success");
|
||||
TELEPHONY_LOGI("RadioInfo::ProcessGetMeid success slotId:%{public}d", slotId_);
|
||||
nsm->SetMeid(slotId_, Str8ToStr16(meid->data));
|
||||
}
|
||||
|
||||
|
@ -21,8 +21,8 @@
|
||||
#include "asn1_decoder.h"
|
||||
#include "asn1_node.h"
|
||||
#include "asn1_utils.h"
|
||||
#include "esim_state_type.h"
|
||||
#include "esim_service.h"
|
||||
#include "esim_state_type.h"
|
||||
#include "icc_file.h"
|
||||
#include "request_apdu_build.h"
|
||||
#include "reset_response.h"
|
||||
@ -30,14 +30,110 @@
|
||||
|
||||
namespace OHOS {
|
||||
namespace Telephony {
|
||||
constexpr static const int32_t NUMBER_ZERO = 0;
|
||||
constexpr static const int32_t NUMBER_ONE = 1;
|
||||
constexpr static const int32_t NUMBER_TWO = 2;
|
||||
constexpr static const int32_t NUMBER_THREE = 3;
|
||||
constexpr static const int32_t NUMBER_FOUR = 4;
|
||||
constexpr static const int32_t NUMBER_FIVE = 5;
|
||||
constexpr static const int32_t NUMBER_ELEVEN = 11;
|
||||
constexpr static const int32_t PARAMETER_TWO = -1;
|
||||
constexpr static const int32_t PROFILE_DEFAULT_NUMBER = 256;
|
||||
constexpr static const int32_t WAIT_TIME_LONG_SECOND_FOR_ESIM = 20;
|
||||
constexpr static const int32_t SW1_MORE_RESPONSE = 0x61;
|
||||
constexpr static const int32_t INS_GET_MORE_RESPONSE = 0xC0;
|
||||
constexpr static const int32_t SW1_VALUE_90 = 0x90;
|
||||
constexpr static const int32_t SW2_VALUE_00 = 0x00;
|
||||
static std::string ISDR_AID = "A0000005591010FFFFFFFF8900000100";
|
||||
constexpr static const int32_t ATR_LENGTH = 47;
|
||||
class EsimFile : public IccFile {
|
||||
public:
|
||||
explicit EsimFile(std::shared_ptr<SimStateManager> simStateManager);
|
||||
int32_t ObtainSpnCondition(bool roaming, const std::string &operatorNum);
|
||||
bool ProcessIccReady(const AppExecFwk::InnerEvent::Pointer &event);
|
||||
bool UpdateVoiceMail(const std::string &mailName, const std::string &mailNumber);
|
||||
bool SetVoiceMailCount(int32_t voiceMailCount);
|
||||
bool SetVoiceCallForwarding(bool enable, const std::string &number);
|
||||
std::string GetVoiceMailNumber();
|
||||
void SetVoiceMailNumber(const std::string mailNumber);
|
||||
void ProcessIccRefresh(int msgId);
|
||||
void ProcessFileLoaded(bool response);
|
||||
void OnAllFilesFetched();
|
||||
void StartLoad();
|
||||
~EsimFile() = default;
|
||||
std::string ObtainEid();
|
||||
GetEuiccProfileInfoListResult GetEuiccProfileInfoList();
|
||||
EuiccInfo GetEuiccInfo();
|
||||
ResultState DisableProfile(int32_t portIndex, const std::u16string &iccId);
|
||||
std::string ObtainSmdsAddress(int32_t portIndex);
|
||||
EuiccRulesAuthTable ObtainRulesAuthTable(int32_t portIndex);
|
||||
ResponseEsimResult ObtainEuiccChallenge(int32_t portIndex);
|
||||
bool ProcessObtainEuiccChallenge(int32_t slotId, const AppExecFwk::InnerEvent::Pointer &responseEvent);
|
||||
bool ProcessObtainEuiccChallengeDone(const AppExecFwk::InnerEvent::Pointer &event);
|
||||
bool ProcessDisableProfile(int32_t slotId, const AppExecFwk::InnerEvent::Pointer &responseEvent);
|
||||
bool ProcessDisableProfileDone(const AppExecFwk::InnerEvent::Pointer &event);
|
||||
bool ProcessObtainSmdsAddress(int32_t slotId, const AppExecFwk::InnerEvent::Pointer &responseEvent);
|
||||
bool ProcessObtainSmdsAddressDone(const AppExecFwk::InnerEvent::Pointer &event);
|
||||
bool ProcessRequestRulesAuthTable(int32_t slotId, const AppExecFwk::InnerEvent::Pointer &responseEvent);
|
||||
bool ProcessRequestRulesAuthTableDone(const AppExecFwk::InnerEvent::Pointer &event);
|
||||
bool RequestRulesAuthTableParseTagCtxComp0(std::shared_ptr<Asn1Node> &root);
|
||||
std::string ObtainDefaultSmdpAddress();
|
||||
ResponseEsimResult CancelSession(const std::u16string &transactionId, CancelReason cancelReason);
|
||||
EuiccProfile ObtainProfile(int32_t portIndex, const std::u16string &iccId);
|
||||
ResultState ResetMemory(ResetOption resetOption);
|
||||
ResultState SetDefaultSmdpAddress(const std::u16string &defaultSmdpAddress);
|
||||
bool IsEsimSupported();
|
||||
ResponseEsimResult SendApduData(const std::u16string &aid, const std::u16string &apduData);
|
||||
ResponseEsimResult ObtainPrepareDownload(const DownLoadConfigInfo &downLoadConfigInfo);
|
||||
ResponseEsimBppResult ObtainLoadBoundProfilePackage(int32_t portIndex, const std::u16string boundProfilePackage);
|
||||
EuiccNotificationList ListNotifications(int32_t portIndex, Event events);
|
||||
|
||||
private:
|
||||
using FileProcessFunc = std::function<bool(const AppExecFwk::InnerEvent::Pointer &event)>;
|
||||
void InitMemberFunc();
|
||||
void SyncCloseChannel();
|
||||
bool IsLogicChannelOpen();
|
||||
void ProcessEsimOpenChannel(const std::u16string &aid);
|
||||
bool ProcessEsimOpenChannelDone(const AppExecFwk::InnerEvent::Pointer &event);
|
||||
void ProcessEsimCloseChannel();
|
||||
bool ProcessEsimCloseChannelDone(const AppExecFwk::InnerEvent::Pointer &event);
|
||||
void SyncOpenChannel();
|
||||
void ProcessEvent(const AppExecFwk::InnerEvent::Pointer &event);
|
||||
void SyncOpenChannel(const std::u16string &aid);
|
||||
void CopyApdCmdToReqInfo(ApduSimIORequestInfo *pReqInfo, ApduCommand *apdCmd);
|
||||
void CommBuildOneApduReqInfo(ApduSimIORequestInfo &reqInfo, std::shared_ptr<Asn1Builder> &builder);
|
||||
bool ProcessObtainEid(int32_t slotId, const AppExecFwk::InnerEvent::Pointer &responseEvent);
|
||||
bool ProcessObtainEidDone(const AppExecFwk::InnerEvent::Pointer &event);
|
||||
bool ProcessObtainEuiccInfo1(int32_t slotId, const AppExecFwk::InnerEvent::Pointer &responseEvent);
|
||||
bool ProcessObtainEuiccInfo1Done(const AppExecFwk::InnerEvent::Pointer &event);
|
||||
bool ObtainEuiccInfo1ParseTagCtx2(std::shared_ptr<Asn1Node> &root);
|
||||
bool ProcessRequestAllProfiles(int32_t slotId, const AppExecFwk::InnerEvent::Pointer &responseEvent);
|
||||
bool ProcessRequestAllProfilesDone(const AppExecFwk::InnerEvent::Pointer &event);
|
||||
bool RequestAllProfilesParseProfileInfo(std::shared_ptr<Asn1Node> &root);
|
||||
bool SplitMccAndMnc(const std::string mccMnc, std::string &mcc, std::string &mnc);
|
||||
void BuildBasicProfileInfo(EuiccProfileInfo *eProfileInfo, std::shared_ptr<Asn1Node> &profileNode);
|
||||
void BuildAdvancedProfileInfo(EuiccProfileInfo *eProfileInfo, std::shared_ptr<Asn1Node> &profileNode);
|
||||
void BuildOperatorId(EuiccProfileInfo *eProfileInfo, std::shared_ptr<Asn1Node> &operatorIdNode);
|
||||
void ConvertProfileInfoToApiStruct(EuiccProfile &dst, EuiccProfileInfo &src);
|
||||
std::shared_ptr<Asn1Node> ParseEvent(const AppExecFwk::InnerEvent::Pointer &event);
|
||||
std::string MakeVersionString(std::vector<uint8_t> &versionRaw);
|
||||
std::shared_ptr<Asn1Node> Asn1ParseResponse(const std::vector<uint8_t> &response, uint32_t respLength);
|
||||
bool ProcessObtainDefaultSmdpAddress(int32_t slotId, const AppExecFwk::InnerEvent::Pointer &responseEvent);
|
||||
bool ProcessObtainDefaultSmdpAddressDone(const AppExecFwk::InnerEvent::Pointer &event);
|
||||
bool ProcessCancelSession(int32_t slotId, const AppExecFwk::InnerEvent::Pointer &responseEvent);
|
||||
bool ProcessCancelSessionDone(const AppExecFwk::InnerEvent::Pointer &event);
|
||||
bool ProcessGetProfile(int32_t slotId, const AppExecFwk::InnerEvent::Pointer &responseEvent);
|
||||
std::vector<uint8_t> GetProfileTagList();
|
||||
bool ProcessGetProfileDone(const AppExecFwk::InnerEvent::Pointer &event);
|
||||
bool GetProfileDoneParseProfileInfo(std::shared_ptr<Asn1Node> &root);
|
||||
bool ProcessResetMemory(int32_t slotId, const AppExecFwk::InnerEvent::Pointer &responseEvent);
|
||||
bool ProcessResetMemoryDone(const AppExecFwk::InnerEvent::Pointer &event);
|
||||
bool setDefaultSmdpAddress(int32_t slotId, const AppExecFwk::InnerEvent::Pointer &responseEvent);
|
||||
bool setDefaultSmdpAddressDone(const AppExecFwk::InnerEvent::Pointer &event);
|
||||
bool ProcessSendApduData(int32_t slotId, const AppExecFwk::InnerEvent::Pointer &responseEvent);
|
||||
bool ProcessSendApduDataDone(const AppExecFwk::InnerEvent::Pointer &event);
|
||||
bool ProcessEstablishDefaultSmdpAddress(int32_t slotId, const AppExecFwk::InnerEvent::Pointer &responseEvent);
|
||||
bool ProcessEstablishDefaultSmdpAddressDone(const AppExecFwk::InnerEvent::Pointer &event);
|
||||
void Asn1AddChildAsBase64(std::shared_ptr<Asn1Builder> &builder, std::string &base64Src);
|
||||
bool ProcessPrepareDownload(int32_t slotId);
|
||||
bool ProcessPrepareDownloadDone(const AppExecFwk::InnerEvent::Pointer &event);
|
||||
@ -64,12 +160,97 @@ private:
|
||||
bool CombineResponseDataFinish(IccFileData &fileData);
|
||||
bool ProcessIfNeedMoreResponse(IccFileData &fileData, int32_t eventId);
|
||||
|
||||
protected:
|
||||
private:
|
||||
std::map<int32_t, FileProcessFunc> memberFuncMap_;
|
||||
int32_t nextSerialId_ = 0;
|
||||
int32_t currentChannelId_ = -1;
|
||||
int32_t slotId_ = 0;
|
||||
EsimProfile esimProfile_;
|
||||
std::string eid_ = "";
|
||||
std::string defaultDpAddress_ = "";
|
||||
ResultState delProfile_ = ResultState::RESULT_UNDEFINED_ERROR;
|
||||
ResultState setDpAddressResult_ = ResultState::RESULT_UNDEFINED_ERROR;
|
||||
ResultState switchResult_ = ResultState::RESULT_UNDEFINED_ERROR;
|
||||
ResultState updateNicknameResult_ = ResultState::RESULT_UNDEFINED_ERROR;
|
||||
ResultState resetResult_ = ResultState::RESULT_UNDEFINED_ERROR;
|
||||
ResultState disableProfileResult_ = ResultState::RESULT_UNDEFINED_ERROR;
|
||||
ResultState factoryResetResult_ = ResultState::RESULT_UNDEFINED_ERROR;
|
||||
ResultState removeNotifResult_ = ResultState::RESULT_UNDEFINED_ERROR;
|
||||
GetEuiccProfileInfoListResult euiccProfileInfoList_;
|
||||
EuiccInfo eUiccInfo_;
|
||||
EuiccProfile eUiccProfile_;
|
||||
std::string smdsAddress_ = "";
|
||||
EuiccRulesAuthTable eUiccRulesAuthTable_;
|
||||
ResponseEsimResult responseChallengeResult_;
|
||||
ResponseEsimResult responseInfo2Result_;
|
||||
ResponseEsimResult responseAuthenticateResult_;
|
||||
ResponseEsimResult preDownloadResult_;
|
||||
ResponseEsimBppResult loadBPPResult_;
|
||||
ResponseEsimResult cancelSessionResult_;
|
||||
EuiccNotification notification_;
|
||||
EuiccNotificationList eUiccNotificationList_;
|
||||
EuiccNotificationList retrieveNotificationList_;
|
||||
ResponseEsimResult transApduDataResponse_;
|
||||
bool isSupported_ = false;
|
||||
|
||||
std::mutex closeChannelMutex_;
|
||||
std::condition_variable closeChannelCv_;
|
||||
|
||||
std::mutex openChannelMutex_;
|
||||
std::condition_variable openChannelCv_;
|
||||
|
||||
std::mutex getEidMutex_;
|
||||
std::condition_variable getEidCv_;
|
||||
bool isEidReady_ = false;
|
||||
|
||||
std::mutex allProfileInfoMutex_;
|
||||
std::condition_variable allProfileInfoCv_;
|
||||
bool isAllProfileInfoReady_ = false;
|
||||
|
||||
std::mutex euiccInfo1Mutex_;
|
||||
std::condition_variable euiccInfo1Cv_;
|
||||
bool isEuiccInfo1Ready_ = false;
|
||||
|
||||
std::mutex disableProfileMutex_;
|
||||
std::condition_variable disableProfileCv_;
|
||||
bool isDisableProfileReady_ = false;
|
||||
|
||||
std::mutex smdsAddressMutex_;
|
||||
std::condition_variable smdsAddressCv_;
|
||||
bool isSmdsAddressReady_ = false;
|
||||
|
||||
std::mutex rulesAuthTableMutex_;
|
||||
std::condition_variable rulesAuthTableCv_;
|
||||
bool isRulesAuthTableReady_ = false;
|
||||
|
||||
std::mutex euiccChallengeMutex_;
|
||||
std::condition_variable euiccChallengeCv_;
|
||||
bool isEuiccChallengeReady_ = false;
|
||||
|
||||
std::mutex obtainDefaultSmdpAddressMutex_;
|
||||
std::condition_variable obtainDefaultSmdpAddressCv_;
|
||||
bool isObtainDefaultSmdpAddressReady_ = false;
|
||||
|
||||
std::mutex cancelSessionMutex_;
|
||||
std::condition_variable cancelSessionCv_;
|
||||
bool isCancelSessionReady_ = false;
|
||||
|
||||
std::mutex obtainProfileMutex_;
|
||||
std::condition_variable obtainProfileCv_;
|
||||
bool isObtainProfileReady_ = false;
|
||||
|
||||
std::mutex resetMemoryMutex_;
|
||||
std::condition_variable resetMemoryCv_;
|
||||
bool isResetMemoryReady_ = false;
|
||||
|
||||
std::mutex setDefaultSmdpAddressMutex_;
|
||||
std::condition_variable setDefaultSmdpAddressCv_;
|
||||
bool isSetDefaultSmdpAddressReady_ = false;
|
||||
|
||||
std::mutex sendApduDataMutex_;
|
||||
std::condition_variable sendApduDataCv_;
|
||||
bool isSendApduDataReady_ = false;
|
||||
|
||||
private:
|
||||
std::mutex prepareDownloadMutex_;
|
||||
std::condition_variable prepareDownloadCv_;
|
||||
bool isPrepareDownloadReady_ = false;
|
||||
@ -85,4 +266,4 @@ private:
|
||||
} // namespace Telephony
|
||||
} // namespace OHOS
|
||||
|
||||
#endif // OHOS_ESIM_FILE_H
|
||||
#endif // OHOS_ESIM_FILE_H
|
||||
|
@ -92,6 +92,34 @@ enum SimMessage {
|
||||
MSG_SIM_OBTAIN_IMPI_DONE,
|
||||
MSG_SIM_OBTAIN_CSIM_SPN_DONE,
|
||||
MSG_SIM_OBTAIN_IST_DONE,
|
||||
#ifdef CORE_SERVICE_SUPPORT_ESIM
|
||||
MSG_ESIM_OPEN_CHANNEL_DONE,
|
||||
MSG_ESIM_CLOSE_CHANNEL_DONE,
|
||||
MSG_ESIM_OBTAIN_EID_DONE,
|
||||
MSG_ESIM_OBTAIN_EUICC_CHALLENGE_DONE,
|
||||
MSG_ESIM_OBTAIN_EUICC_INFO2_DONE,
|
||||
MSG_ESIM_OBTAIN_EUICC_INFO_1_DONE,
|
||||
MSG_ESIM_OBTAIN_DEFAULT_SMDP_ADDRESS_DONE,
|
||||
MSG_ESIM_ESTABLISH_DEFAULT_SMDP_ADDRESS_DONE,
|
||||
MSG_ESIM_DELETE_PROFILE,
|
||||
MSG_ESIM_SWITCH_PROFILE,
|
||||
MSG_ESIM_DISABLE_PROFILE,
|
||||
MSG_ESIM_RESET_MEMORY,
|
||||
MSG_ESIM_REMOVE_NOTIFICATION,
|
||||
MSG_ESIM_REQUEST_ALL_PROFILES,
|
||||
MSG_ESIM_LIST_NOTIFICATION,
|
||||
MSG_ESIM_SET_NICK_NAME,
|
||||
MSG_ESIM_CANCEL_SESSION,
|
||||
MSG_ESIM_OBTAIN_SMDS_ADDRESS,
|
||||
MSG_ESIM_GET_PROFILE,
|
||||
MSG_ESIM_RETRIEVE_NOTIFICATION_DONE,
|
||||
MSG_ESIM_RETRIEVE_NOTIFICATION_LIST,
|
||||
MSG_ESIM_AUTHENTICATE_SERVER,
|
||||
MSG_ESIM_PREPARE_DOWNLOAD_DONE,
|
||||
MSG_ESIM_SEND_APUD_DATA,
|
||||
MSG_ESIM_LOAD_BOUND_PROFILE_PACKAGE,
|
||||
MSG_ESIM_REQUEST_RULES_AUTH_TABLE,
|
||||
#endif
|
||||
};
|
||||
|
||||
enum ElementaryFile {
|
||||
|
@ -17,9 +17,12 @@
|
||||
#define OHOS_SIM_FILE_MANAGER_H
|
||||
|
||||
#include "common_event_subscriber.h"
|
||||
#include "csim_file_controller.h"
|
||||
#include "event_handler.h"
|
||||
#include "event_runner.h"
|
||||
#include "tel_ril_modem_parcel.h"
|
||||
#ifdef CORE_SERVICE_SUPPORT_ESIM
|
||||
#include "esim_file.h"
|
||||
#endif
|
||||
#include "i_tel_ril_manager.h"
|
||||
#include "isim_file.h"
|
||||
#include "isim_file_controller.h"
|
||||
@ -28,9 +31,7 @@
|
||||
#include "sim_file.h"
|
||||
#include "sim_file_controller.h"
|
||||
#include "system_ability_status_change_stub.h"
|
||||
#include "isim_file.h"
|
||||
#include "isim_file_controller.h"
|
||||
#include "csim_file_controller.h"
|
||||
#include "tel_ril_modem_parcel.h"
|
||||
#include "telephony_log_wrapper.h"
|
||||
#include "usim_file_controller.h"
|
||||
|
||||
@ -91,19 +92,38 @@ public:
|
||||
enum class HandleRunningState { STATE_NOT_START, STATE_RUNNING };
|
||||
enum class IccType { ICC_TYPE_CDMA, ICC_TYPE_GSM, ICC_TYPE_IMS, ICC_TYPE_USIM };
|
||||
#ifdef CORE_SERVICE_SUPPORT_ESIM
|
||||
std::shared_ptr<EsimFile> GetEsimfile();
|
||||
std::u16string GetEid();
|
||||
GetEuiccProfileInfoListResult GetEuiccProfileInfoList();
|
||||
EuiccInfo GetEuiccInfo();
|
||||
ResultState DisableProfile(int32_t portIndex, const std::u16string &iccId);
|
||||
std::u16string GetSmdsAddress(int32_t portIndex);
|
||||
EuiccRulesAuthTable GetRulesAuthTable(int32_t portIndex);
|
||||
ResponseEsimResult GetEuiccChallenge(int32_t portIndex);
|
||||
std::u16string GetDefaultSmdpAddress();
|
||||
ResponseEsimResult CancelSession(const std::u16string &transactionId, CancelReason cancelReason);
|
||||
EuiccProfile GetProfile(int32_t portIndex, const std::u16string &iccId);
|
||||
ResultState ResetMemory(ResetOption resetOption);
|
||||
ResultState SetDefaultSmdpAddress(const std::u16string &defaultSmdpAddress);
|
||||
bool IsEsimSupported();
|
||||
ResponseEsimResult SendApduData(const std::u16string &aid, const std::u16string &apduData);
|
||||
ResponseEsimResult PrepareDownload(const DownLoadConfigInfo &downLoadConfigInfo);
|
||||
ResponseEsimBppResult LoadBoundProfilePackage(int32_t portIndex, const std::u16string &boundProfilePackage);
|
||||
EuiccNotificationList ListNotifications(int32_t portIndex, Event events);
|
||||
#endif
|
||||
|
||||
protected:
|
||||
std::weak_ptr<Telephony::ITelRilManager> telRilManager_;
|
||||
std::shared_ptr<IccFileController> fileController_ = nullptr;
|
||||
std::shared_ptr<IccFile> simFile_ = nullptr;
|
||||
#ifdef CORE_SERVICE_SUPPORT_ESIM
|
||||
std::shared_ptr<EsimFile> eSimFile_ = nullptr;
|
||||
#endif
|
||||
std::shared_ptr<IccDiallingNumbersHandler> diallingNumberHandler_ = nullptr;
|
||||
HandleRunningState stateRecord_ = HandleRunningState::STATE_NOT_START;
|
||||
HandleRunningState stateHandler_ = HandleRunningState::STATE_NOT_START;
|
||||
std::weak_ptr<Telephony::SimStateManager> simStateManager_;
|
||||
int slotId_ = 0;
|
||||
int32_t slotId_ = 0;
|
||||
IccType iccType_ = IccType::ICC_TYPE_USIM;
|
||||
std::map<IccType, std::shared_ptr<IccFile>> iccFileCache_;
|
||||
std::map<IccType, std::shared_ptr<IccFileController>> iccFileControllerCache_;
|
||||
|
@ -156,6 +156,25 @@ public:
|
||||
const std::string &data, const std::string &path, SimAuthenticationResponse &response) override;
|
||||
int32_t SavePrimarySlotId(int32_t slotId) override;
|
||||
#ifdef CORE_SERVICE_SUPPORT_ESIM
|
||||
int32_t GetEid(int32_t slotId, std::u16string &eId) override;
|
||||
int32_t GetEuiccProfileInfoList(int32_t slotId, GetEuiccProfileInfoListResult &euiccProfileInfoList) override;
|
||||
int32_t GetEuiccInfo(int32_t slotId, EuiccInfo &eUiccInfo) override;
|
||||
int32_t DisableProfile(
|
||||
int32_t slotId, int32_t portIndex, const std::u16string &iccId, bool refresh, ResultState &enumResult) override;
|
||||
int32_t GetSmdsAddress(int32_t slotId, int32_t portIndex, std::u16string &smdsAddress) override;
|
||||
int32_t GetRulesAuthTable(int32_t slotId, int32_t portIndex, EuiccRulesAuthTable &eUiccRulesAuthTable) override;
|
||||
int32_t GetEuiccChallenge(int32_t slotId, int32_t portIndex, ResponseEsimResult &responseResult) override;
|
||||
int32_t GetDefaultSmdpAddress(int32_t slotId, std::u16string &defaultSmdpAddress) override;
|
||||
int32_t CancelSession(int32_t slotId, const std::u16string &transactionId, CancelReason cancelReason,
|
||||
ResponseEsimResult &responseResult) override;
|
||||
int32_t GetProfile(
|
||||
int32_t slotId, int32_t portIndex, const std::u16string &iccId, EuiccProfile &eUiccProfile) override;
|
||||
int32_t ResetMemory(int32_t slotId, ResetOption resetOption, ResultState &enumResult) override;
|
||||
int32_t SetDefaultSmdpAddress(
|
||||
int32_t slotId, const std::u16string &defaultSmdpAddress, ResultState &enumResult) override;
|
||||
bool IsEsimSupported(int32_t slotId) override;
|
||||
int32_t SendApduData(int32_t slotId, const std::u16string &aid, const std::u16string &apduData,
|
||||
ResponseEsimResult &responseResult) override;
|
||||
int32_t PrepareDownload(int32_t slotId, const DownLoadConfigInfo &downLoadConfigInfo,
|
||||
ResponseEsimResult &responseResult) override;
|
||||
int32_t LoadBoundProfilePackage(int32_t slotId, int32_t portIndex, const std::u16string &boundProfilePackage,
|
||||
@ -163,6 +182,7 @@ public:
|
||||
int32_t ListNotifications(int32_t slotId, int32_t portIndex, Event events,
|
||||
EuiccNotificationList ¬ificationList) override;
|
||||
#endif
|
||||
|
||||
private:
|
||||
bool IsValidSlotId(int32_t slotId);
|
||||
template<class N>
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -246,6 +246,10 @@ bool RuimFile::ProcessGetImsiDone(const AppExecFwk::InnerEvent::Pointer &event)
|
||||
if ((lengthOfMnc_ != UNINITIALIZED_MNC) && (lengthOfMnc_ != UNKNOWN_MNC) && isSizeEnough) {
|
||||
mnc = imsi_.substr(MCC_LEN, lengthOfMnc_);
|
||||
}
|
||||
if (!IsValidDecValue(mcc)) {
|
||||
TELEPHONY_LOGE("mcc is invalid decimal value");
|
||||
return false;
|
||||
}
|
||||
int mncLength = MccPool::ShortestMncLengthFromMcc(std::stoi(mcc));
|
||||
isSizeEnough = imsiSize >= MCC_LEN + mncLength;
|
||||
if (mnc.empty() && IsValidDecValue(mcc) && isSizeEnough) {
|
||||
|
@ -38,6 +38,9 @@ std::string SimFileController::ObtainElementFilePath(int efId)
|
||||
case ELEMENTARY_FILE_SPN:
|
||||
case ELEMENTARY_FILE_AD:
|
||||
case ELEMENTARY_FILE_PNN:
|
||||
case ELEMENTARY_FILE_OPL:
|
||||
mf.append(DEDICATED_FILE_GSM);
|
||||
return mf;
|
||||
case ELEMENTARY_FILE_MBDN:
|
||||
case ELEMENTARY_FILE_EXT6:
|
||||
case ELEMENTARY_FILE_MBI:
|
||||
|
@ -143,6 +143,9 @@ bool SimFileManager::InitSimFile(SimFileManager::IccType type)
|
||||
iccFileCache_.insert(std::make_pair(SimFileManager::IccType::ICC_TYPE_GSM, simFile_));
|
||||
}
|
||||
if (simFile_ != nullptr) {
|
||||
#ifdef CORE_SERVICE_SUPPORT_ESIM
|
||||
eSimFile_ = std::make_shared<EsimFile>(simStateManager_.lock());
|
||||
#endif
|
||||
simFile_->RegisterCoreNotify(shared_from_this(), RadioEvent::RADIO_SIM_RECORDS_LOADED);
|
||||
}
|
||||
} else {
|
||||
@ -153,6 +156,10 @@ bool SimFileManager::InitSimFile(SimFileManager::IccType type)
|
||||
TELEPHONY_LOGE("SimFileManager::Init simFile create nullptr.");
|
||||
return false;
|
||||
}
|
||||
|
||||
#ifdef CORE_SERVICE_SUPPORT_ESIM
|
||||
eSimFile_->SetRilAndFileController(telRilManager_.lock(), fileController_, diallingNumberHandler_);
|
||||
#endif
|
||||
simFile_->SetRilAndFileController(telRilManager_.lock(), fileController_, diallingNumberHandler_);
|
||||
simFile_->SetId(slotId_);
|
||||
simFile_->Init();
|
||||
@ -984,6 +991,149 @@ void SimFileManager::ClearData()
|
||||
}
|
||||
|
||||
#ifdef CORE_SERVICE_SUPPORT_ESIM
|
||||
std::shared_ptr<EsimFile> SimFileManager::GetEsimfile()
|
||||
{
|
||||
return eSimFile_;
|
||||
}
|
||||
|
||||
std::u16string SimFileManager::GetEid()
|
||||
{
|
||||
if (eSimFile_ == nullptr) {
|
||||
TELEPHONY_LOGE("esimFile is nullptr");
|
||||
return Str8ToStr16("");
|
||||
}
|
||||
std::string result = eSimFile_->ObtainEid();
|
||||
return Str8ToStr16(result);
|
||||
}
|
||||
|
||||
GetEuiccProfileInfoListResult SimFileManager::GetEuiccProfileInfoList()
|
||||
{
|
||||
if (eSimFile_ == nullptr) {
|
||||
TELEPHONY_LOGE("esimFile is nullptr");
|
||||
return GetEuiccProfileInfoListResult();
|
||||
}
|
||||
return eSimFile_->GetEuiccProfileInfoList();
|
||||
}
|
||||
|
||||
EuiccInfo SimFileManager::GetEuiccInfo()
|
||||
{
|
||||
if (eSimFile_ == nullptr) {
|
||||
TELEPHONY_LOGE("simFile is nullptr");
|
||||
return EuiccInfo();
|
||||
}
|
||||
return eSimFile_->GetEuiccInfo();
|
||||
}
|
||||
|
||||
ResultState SimFileManager::DisableProfile(int32_t portIndex, const std::u16string &iccId)
|
||||
{
|
||||
if (eSimFile_ == nullptr) {
|
||||
TELEPHONY_LOGE("esimFile is nullptr");
|
||||
return ResultState::RESULT_UNDEFINED_ERROR;
|
||||
}
|
||||
ResultState enumResult = eSimFile_->DisableProfile(portIndex, iccId);
|
||||
return enumResult;
|
||||
}
|
||||
|
||||
std::u16string SimFileManager::GetSmdsAddress(int32_t portIndex)
|
||||
{
|
||||
if (eSimFile_ == nullptr) {
|
||||
TELEPHONY_LOGE("esimFile is nullptr");
|
||||
return Str8ToStr16("");
|
||||
}
|
||||
std::string result = eSimFile_->ObtainSmdsAddress(portIndex);
|
||||
return Str8ToStr16(result);
|
||||
}
|
||||
|
||||
EuiccRulesAuthTable SimFileManager::GetRulesAuthTable(int32_t portIndex)
|
||||
{
|
||||
if (eSimFile_ == nullptr) {
|
||||
TELEPHONY_LOGE("esimFile is nullptr");
|
||||
return EuiccRulesAuthTable();
|
||||
}
|
||||
EuiccRulesAuthTable result = eSimFile_->ObtainRulesAuthTable(portIndex);
|
||||
return result;
|
||||
}
|
||||
|
||||
ResponseEsimResult SimFileManager::GetEuiccChallenge(int32_t portIndex)
|
||||
{
|
||||
if (eSimFile_ == nullptr) {
|
||||
TELEPHONY_LOGE("esimFile is nullptr");
|
||||
return ResponseEsimResult();
|
||||
}
|
||||
ResponseEsimResult result = eSimFile_->ObtainEuiccChallenge(portIndex);
|
||||
return result;
|
||||
}
|
||||
|
||||
std::u16string SimFileManager::GetDefaultSmdpAddress()
|
||||
{
|
||||
if (eSimFile_ == nullptr) {
|
||||
TELEPHONY_LOGE("esimFile is nullptr");
|
||||
return Str8ToStr16("");
|
||||
}
|
||||
std::string result = eSimFile_->ObtainDefaultSmdpAddress();
|
||||
return Str8ToStr16(result);
|
||||
}
|
||||
|
||||
ResponseEsimResult SimFileManager::CancelSession(const std::u16string &transactionId, CancelReason cancelReason)
|
||||
{
|
||||
if (eSimFile_ == nullptr) {
|
||||
TELEPHONY_LOGE("esimFile is nullptr");
|
||||
return ResponseEsimResult();
|
||||
}
|
||||
ResponseEsimResult result = eSimFile_->CancelSession(transactionId, cancelReason);
|
||||
return result;
|
||||
}
|
||||
|
||||
EuiccProfile SimFileManager::GetProfile(int32_t portIndex, const std::u16string &iccId)
|
||||
{
|
||||
if (eSimFile_ == nullptr) {
|
||||
TELEPHONY_LOGE("esimFile is nullptr");
|
||||
return EuiccProfile();
|
||||
}
|
||||
EuiccProfile result = eSimFile_->ObtainProfile(portIndex, iccId);
|
||||
return result;
|
||||
}
|
||||
|
||||
ResultState SimFileManager::ResetMemory(ResetOption resetOption)
|
||||
{
|
||||
if (eSimFile_ == nullptr) {
|
||||
TELEPHONY_LOGE("esimFile nullptr");
|
||||
return ResultState::RESULT_UNDEFINED_ERROR;
|
||||
}
|
||||
ResultState result = eSimFile_->ResetMemory(resetOption);
|
||||
return result;
|
||||
}
|
||||
|
||||
ResultState SimFileManager::SetDefaultSmdpAddress(const std::u16string &defaultSmdpAddress)
|
||||
{
|
||||
if (eSimFile_ == nullptr) {
|
||||
TELEPHONY_LOGE("esimFile is nullptr");
|
||||
return ResultState::RESULT_UNDEFINED_ERROR;
|
||||
}
|
||||
ResultState result = eSimFile_->SetDefaultSmdpAddress(defaultSmdpAddress);
|
||||
return result;
|
||||
}
|
||||
|
||||
bool SimFileManager::IsEsimSupported()
|
||||
{
|
||||
if (eSimFile_ == nullptr) {
|
||||
TELEPHONY_LOGE("esimFile is nullptr");
|
||||
return false;
|
||||
}
|
||||
bool result = eSimFile_->IsEsimSupported();
|
||||
return result;
|
||||
}
|
||||
|
||||
ResponseEsimResult SimFileManager::SendApduData(const std::u16string &aid, const std::u16string &apduData)
|
||||
{
|
||||
if (eSimFile_ == nullptr) {
|
||||
TELEPHONY_LOGE("esimFile is nullptr");
|
||||
return ResponseEsimResult();
|
||||
}
|
||||
ResponseEsimResult result = eSimFile_->SendApduData(aid, apduData);
|
||||
return result;
|
||||
}
|
||||
|
||||
ResponseEsimResult SimFileManager::PrepareDownload(const DownLoadConfigInfo &downLoadConfigInfo)
|
||||
{
|
||||
if (eSimFile_ == nullptr) {
|
||||
|
@ -17,6 +17,7 @@
|
||||
|
||||
#include "core_service_errors.h"
|
||||
#include "radio_event.h"
|
||||
#include "str_convert.h"
|
||||
#include "telephony_errors.h"
|
||||
#include "telephony_ext_wrapper.h"
|
||||
#include "telephony_permission.h"
|
||||
@ -1257,6 +1258,160 @@ int32_t SimManager::SavePrimarySlotId(int32_t slotId)
|
||||
}
|
||||
|
||||
#ifdef CORE_SERVICE_SUPPORT_ESIM
|
||||
int32_t SimManager::GetEid(int32_t slotId, std::u16string &eId)
|
||||
{
|
||||
if ((!IsValidSlotId(slotId, simFileManager_)) || (simFileManager_[slotId] == nullptr)) {
|
||||
TELEPHONY_LOGE("simFileManager is null!");
|
||||
return TELEPHONY_ERR_LOCAL_PTR_NULL;
|
||||
}
|
||||
eId = simFileManager_[slotId]->GetEid();
|
||||
return TELEPHONY_ERR_SUCCESS;
|
||||
}
|
||||
|
||||
int32_t SimManager::GetEuiccProfileInfoList(int32_t slotId, GetEuiccProfileInfoListResult &euiccProfileInfoList)
|
||||
{
|
||||
if ((!IsValidSlotId(slotId, simFileManager_)) || (simFileManager_[slotId] == nullptr)) {
|
||||
TELEPHONY_LOGE("simFileManager is null!");
|
||||
return TELEPHONY_ERR_LOCAL_PTR_NULL;
|
||||
}
|
||||
euiccProfileInfoList = simFileManager_[slotId]->GetEuiccProfileInfoList();
|
||||
return TELEPHONY_ERR_SUCCESS;
|
||||
}
|
||||
|
||||
int32_t SimManager::GetEuiccInfo(int32_t slotId, EuiccInfo &eUiccInfo)
|
||||
{
|
||||
if ((!IsValidSlotId(slotId, simFileManager_)) || (simFileManager_[slotId] == nullptr)) {
|
||||
TELEPHONY_LOGE("simFileManager is null!");
|
||||
return TELEPHONY_ERR_LOCAL_PTR_NULL;
|
||||
}
|
||||
eUiccInfo = simFileManager_[slotId]->GetEuiccInfo();
|
||||
return TELEPHONY_ERR_SUCCESS;
|
||||
}
|
||||
|
||||
int32_t SimManager::DisableProfile(
|
||||
int32_t slotId, int32_t portIndex, const std::u16string &iccId, bool refresh, ResultState &enumResult)
|
||||
{
|
||||
if ((!IsValidSlotId(slotId, simFileManager_)) || (simFileManager_[slotId] == nullptr)) {
|
||||
TELEPHONY_LOGE("simFileManager is null!");
|
||||
return TELEPHONY_ERR_LOCAL_PTR_NULL;
|
||||
}
|
||||
enumResult = simFileManager_[slotId]->DisableProfile(portIndex, iccId);
|
||||
return TELEPHONY_ERR_SUCCESS;
|
||||
}
|
||||
|
||||
int32_t SimManager::GetSmdsAddress(int32_t slotId, int32_t portIndex, std::u16string &smdsAddress)
|
||||
{
|
||||
if ((!IsValidSlotId(slotId, simFileManager_)) || (simFileManager_[slotId] == nullptr)) {
|
||||
TELEPHONY_LOGE("simFileManager is null!");
|
||||
return TELEPHONY_ERR_LOCAL_PTR_NULL;
|
||||
}
|
||||
smdsAddress = simFileManager_[slotId]->GetSmdsAddress(portIndex);
|
||||
return TELEPHONY_ERR_SUCCESS;
|
||||
}
|
||||
|
||||
int32_t SimManager::GetRulesAuthTable(
|
||||
int32_t slotId, int32_t portIndex, EuiccRulesAuthTable &eUiccRulesAuthTable)
|
||||
{
|
||||
if ((!IsValidSlotId(slotId, simFileManager_)) || (simFileManager_[slotId] == nullptr)) {
|
||||
TELEPHONY_LOGE("simFileManager is null!");
|
||||
return TELEPHONY_ERR_LOCAL_PTR_NULL;
|
||||
}
|
||||
eUiccRulesAuthTable = simFileManager_[slotId]->GetRulesAuthTable(portIndex);
|
||||
return TELEPHONY_ERR_SUCCESS;
|
||||
}
|
||||
|
||||
int32_t SimManager::GetEuiccChallenge(int32_t slotId, int32_t portIndex, ResponseEsimResult &responseResult)
|
||||
{
|
||||
if ((!IsValidSlotId(slotId, simFileManager_)) || (simFileManager_[slotId] == nullptr)) {
|
||||
TELEPHONY_LOGE("simFileManager is null!");
|
||||
return TELEPHONY_ERR_LOCAL_PTR_NULL;
|
||||
}
|
||||
responseResult = simFileManager_[slotId]->GetEuiccChallenge(portIndex);
|
||||
return TELEPHONY_ERR_SUCCESS;
|
||||
}
|
||||
|
||||
int32_t SimManager::GetDefaultSmdpAddress(int32_t slotId, std::u16string &defaultSmdpAddress)
|
||||
{
|
||||
if ((!IsValidSlotId(slotId, simFileManager_)) || (simFileManager_[slotId] == nullptr)) {
|
||||
TELEPHONY_LOGE("simFileManager is null!");
|
||||
return TELEPHONY_ERR_LOCAL_PTR_NULL;
|
||||
}
|
||||
defaultSmdpAddress = simFileManager_[slotId]->GetDefaultSmdpAddress();
|
||||
if (defaultSmdpAddress == Str8ToStr16("")) {
|
||||
return TELEPHONY_ERR_FAIL;
|
||||
}
|
||||
return TELEPHONY_ERR_SUCCESS;
|
||||
}
|
||||
|
||||
int32_t SimManager::CancelSession(
|
||||
int32_t slotId, const std::u16string &transactionId, CancelReason cancelReason, ResponseEsimResult &responseResult)
|
||||
{
|
||||
if ((!IsValidSlotId(slotId, simFileManager_)) || (simFileManager_[slotId] == nullptr)) {
|
||||
TELEPHONY_LOGE("simFileManager is null!");
|
||||
return TELEPHONY_ERR_LOCAL_PTR_NULL;
|
||||
}
|
||||
responseResult = simFileManager_[slotId]->CancelSession(transactionId, cancelReason);
|
||||
if (responseResult.resultCode != ResultState::RESULT_OK) {
|
||||
return TELEPHONY_ERR_FAIL;
|
||||
}
|
||||
return TELEPHONY_ERR_SUCCESS;
|
||||
}
|
||||
|
||||
int32_t SimManager::GetProfile(
|
||||
int32_t slotId, int32_t portIndex, const std::u16string &iccId, EuiccProfile &eUiccProfile)
|
||||
{
|
||||
if ((!IsValidSlotId(slotId, simFileManager_)) || (simFileManager_[slotId] == nullptr)) {
|
||||
TELEPHONY_LOGE("simFileManager is null!");
|
||||
return TELEPHONY_ERR_LOCAL_PTR_NULL;
|
||||
}
|
||||
eUiccProfile = simFileManager_[slotId]->GetProfile(portIndex, iccId);
|
||||
if (eUiccProfile.state != ProfileState::PROFILE_STATE_DISABLED) {
|
||||
return TELEPHONY_ERR_FAIL;
|
||||
}
|
||||
return TELEPHONY_ERR_SUCCESS;
|
||||
}
|
||||
|
||||
int32_t SimManager::ResetMemory(int32_t slotId, ResetOption resetOption, ResultState &enumResult)
|
||||
{
|
||||
if ((!IsValidSlotId(slotId, simFileManager_)) || (simFileManager_[slotId] == nullptr)) {
|
||||
TELEPHONY_LOGE("slotId is invalid or simFileManager_ is null!");
|
||||
return TELEPHONY_ERR_LOCAL_PTR_NULL;
|
||||
}
|
||||
enumResult = simFileManager_[slotId]->ResetMemory(resetOption);
|
||||
return TELEPHONY_ERR_SUCCESS;
|
||||
}
|
||||
|
||||
int32_t SimManager::SetDefaultSmdpAddress(
|
||||
int32_t slotId, const std::u16string &defaultSmdpAddress, ResultState &enumResult)
|
||||
{
|
||||
if ((!IsValidSlotId(slotId, simFileManager_)) || (simFileManager_[slotId] == nullptr)) {
|
||||
TELEPHONY_LOGE("slotId is invalid or simFileManager_ is null!");
|
||||
return TELEPHONY_ERR_LOCAL_PTR_NULL;
|
||||
}
|
||||
enumResult = simFileManager_[slotId]->SetDefaultSmdpAddress(defaultSmdpAddress);
|
||||
return TELEPHONY_ERR_SUCCESS;
|
||||
}
|
||||
|
||||
bool SimManager::IsEsimSupported(int32_t slotId)
|
||||
{
|
||||
if ((!IsValidSlotId(slotId, simFileManager_)) || (simFileManager_[slotId] == nullptr)) {
|
||||
TELEPHONY_LOGE("slotId is invalid or simFileManager_ is null!");
|
||||
return false;
|
||||
}
|
||||
return simFileManager_[slotId]->IsEsimSupported();
|
||||
}
|
||||
|
||||
int32_t SimManager::SendApduData(
|
||||
int32_t slotId, const std::u16string &aid, const std::u16string &apduData, ResponseEsimResult &responseResult)
|
||||
{
|
||||
if ((!IsValidSlotId(slotId, simFileManager_)) || (simFileManager_[slotId] == nullptr)) {
|
||||
TELEPHONY_LOGE("slotId is invalid or simFileManager_ is null!");
|
||||
return TELEPHONY_ERR_LOCAL_PTR_NULL;
|
||||
}
|
||||
responseResult = simFileManager_[slotId]->SendApduData(aid, apduData);
|
||||
return TELEPHONY_ERR_SUCCESS;
|
||||
}
|
||||
|
||||
int32_t SimManager::PrepareDownload(int32_t slotId, const DownLoadConfigInfo &downLoadConfigInfo,
|
||||
ResponseEsimResult &responseResult)
|
||||
{
|
||||
|
@ -75,6 +75,10 @@ protected:
|
||||
inline int32_t Response(const char *funcName, const HDI::Ril::V1_1::RilRadioResponseInfo &iResponseInfo,
|
||||
std::function<std::shared_ptr<T>(std::shared_ptr<TelRilRequest>)> getDataFunc);
|
||||
template<typename T>
|
||||
inline int32_t Response(const char *funcName, const HDI::Ril::V1_1::RilRadioResponseInfo &iResponseInfo,
|
||||
const HDI::Ril::V1_1::SetupDataCallResultInfo &iSetupDataCallResultInfo,
|
||||
std::function<std::shared_ptr<T>(std::shared_ptr<TelRilRequest>)> getDataFunc);
|
||||
template<typename T>
|
||||
inline int32_t Response(const char *funcName, const HDI::Ril::V1_1::RilRadioResponseInfo &iResponseInfo,
|
||||
std::function<T(std::shared_ptr<TelRilRequest>)> getDataFunc);
|
||||
inline int32_t Notify(const char *funcName, RadioEvent notifyId);
|
||||
@ -161,6 +165,26 @@ inline int32_t TelRilBase::Response(const char *funcName, const HDI::Ril::V1_1::
|
||||
return Response<std::shared_ptr<T>>(funcName, iResponseInfo, getDataFunc);
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
inline int32_t TelRilBase::Response(const char *funcName, const HDI::Ril::V1_1::RilRadioResponseInfo &iResponseInfo,
|
||||
const HDI::Ril::V1_1::SetupDataCallResultInfo &iSetupDataCallResultInfo,
|
||||
std::function<std::shared_ptr<T>(std::shared_ptr<TelRilRequest>)> getDataFunc)
|
||||
{
|
||||
const auto &radioResponseInfo = BuildHRilRadioResponseInfo(iResponseInfo);
|
||||
std::shared_ptr<TelRilRequest> telRilRequest = FindTelRilRequest(radioResponseInfo);
|
||||
if (telRilRequest == nullptr || telRilRequest->pointer_ == nullptr) {
|
||||
TELEPHONY_LOGE("func %{public}s telRilReques or telRilRequest->pointer or data is null", funcName);
|
||||
return TELEPHONY_ERR_ARGUMENT_INVALID;
|
||||
}
|
||||
if ((radioResponseInfo.error == ErrType::ERR_GENERIC_FAILURE) && (iSetupDataCallResultInfo.reason != 0)) {
|
||||
return SendHandlerEvent<std::shared_ptr<T>>(funcName, telRilRequest, getDataFunc);
|
||||
}
|
||||
if (radioResponseInfo.error != ErrType::NONE) {
|
||||
return ErrorResponse(telRilRequest, radioResponseInfo);
|
||||
}
|
||||
return SendHandlerEvent<std::shared_ptr<T>>(funcName, telRilRequest, getDataFunc);
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
inline int32_t TelRilBase::Response(const char *funcName, const HDI::Ril::V1_1::RilRadioResponseInfo &iResponseInfo,
|
||||
std::function<T(std::shared_ptr<TelRilRequest>)> getDataFunc)
|
||||
|
@ -88,7 +88,8 @@ int32_t TelRilData::ActivatePdpContextResponse(const HDI::Ril::V1_1::RilRadioRes
|
||||
setupDataCallResultInfo->flag = telRilRequest->pointer_->GetParam();
|
||||
return setupDataCallResultInfo;
|
||||
};
|
||||
return Response<SetupDataCallResultInfo>(TELEPHONY_LOG_FUNC_NAME, responseInfo, getDataFunc);
|
||||
return Response<SetupDataCallResultInfo>(TELEPHONY_LOG_FUNC_NAME, responseInfo, iSetupDataCallResultInfo,
|
||||
getDataFunc);
|
||||
}
|
||||
|
||||
int32_t TelRilData::GetPdpContextList(const AppExecFwk::InnerEvent::Pointer &response)
|
||||
|
@ -140,15 +140,17 @@ int32_t TelRilModem::OnRilAdapterHostDied()
|
||||
int32_t TelRilModem::RadioStateUpdated(int32_t state)
|
||||
{
|
||||
radioState_ = static_cast<ModemPowerState>(state);
|
||||
AAFwk::Want want;
|
||||
want.SetParam("slotId", slotId_);
|
||||
want.SetParam("radioState", state);
|
||||
want.SetAction(EventFwk::CommonEventSupport::COMMON_EVENT_RADIO_STATE_CHANGE);
|
||||
EventFwk::CommonEventData commonEventData;
|
||||
commonEventData.SetWant(want);
|
||||
EventFwk::CommonEventPublishInfo publishInfo;
|
||||
bool result = EventFwk::CommonEventManager::PublishCommonEvent(commonEventData, publishInfo, nullptr);
|
||||
TELEPHONY_LOGD("publish modem subscribed event result : %{public}d", result);
|
||||
TelFFRTUtils::Submit([=]() {
|
||||
AAFwk::Want want;
|
||||
want.SetParam("slotId", slotId_);
|
||||
want.SetParam("radioState", state);
|
||||
want.SetAction(EventFwk::CommonEventSupport::COMMON_EVENT_RADIO_STATE_CHANGE);
|
||||
EventFwk::CommonEventData commonEventData;
|
||||
commonEventData.SetWant(want);
|
||||
EventFwk::CommonEventPublishInfo publishInfo;
|
||||
bool result = EventFwk::CommonEventManager::PublishCommonEvent(commonEventData, publishInfo, nullptr);
|
||||
TELEPHONY_LOGD("publish modem subscribed event result : %{public}d", result);
|
||||
});
|
||||
return Notify<Int32Parcel>(
|
||||
TELEPHONY_LOG_FUNC_NAME, std::make_shared<Int32Parcel>(state), RadioEvent::RADIO_STATE_CHANGED);
|
||||
}
|
||||
|
@ -226,6 +226,7 @@ int32_t TelRilNetwork::GetCsRegStatusResponse(
|
||||
std::shared_ptr<CsRegStatusInfo> regStatusInfo = std::make_shared<CsRegStatusInfo>();
|
||||
this->BuildCsRegStatusInfo(regStatusInfo, csRegStatusInfo);
|
||||
regStatusInfo->flag = telRilRequest->pointer_->GetParam();
|
||||
Notify<CsRegStatusInfo>(TELEPHONY_LOG_FUNC_NAME, regStatusInfo, RadioEvent::RADIO_VOICE_REG_STATE);
|
||||
return regStatusInfo;
|
||||
};
|
||||
return Response<CsRegStatusInfo>(TELEPHONY_LOG_FUNC_NAME, responseInfo, getDataFunc);
|
||||
|
@ -62,6 +62,7 @@ public:
|
||||
typedef void (*GET_NR_OPTION_MODE_EXT)(int32_t slotId, int32_t &mode);
|
||||
typedef void (*GET_NR_OPTION_MODE_EXTEND)(int32_t slotId, OHOS::Telephony::NrMode &mode);
|
||||
typedef void (*GET_PREFERRED_NETWORK_EXT)(int32_t &preferredNetworkType);
|
||||
typedef bool (*IS_CHIPSET_NETWORK_EXT_SUPPORTED)();
|
||||
typedef bool (*IS_NR_SUPPORTED_NATIVE)(int32_t modemRaf);
|
||||
typedef void (*GET_SIGNAL_INFO_LIST_EXT)(int32_t slotId,
|
||||
std::vector<sptr<OHOS::Telephony::SignalInformation>> &signals);
|
||||
@ -123,6 +124,7 @@ public:
|
||||
GET_NR_OPTION_MODE_EXT getNrOptionModeExt_ = nullptr;
|
||||
GET_NR_OPTION_MODE_EXTEND getNrOptionModeExtend_ = nullptr;
|
||||
GET_PREFERRED_NETWORK_EXT getPreferredNetworkExt_ = nullptr;
|
||||
IS_CHIPSET_NETWORK_EXT_SUPPORTED isChipsetNetworkExtSupported_ = nullptr;
|
||||
IS_NR_SUPPORTED_NATIVE isNrSupportedNative_ = nullptr;
|
||||
GET_SIGNAL_INFO_LIST_EXT getSignalInfoListExt_ = nullptr;
|
||||
GET_NETWORK_CAPABILITY_EXT getNetworkCapabilityExt_ = nullptr;
|
||||
|
@ -65,6 +65,8 @@ void TelephonyExtWrapper::InitTelephonyExtWrapperForNetWork()
|
||||
getNrOptionModeExt_ = (GET_NR_OPTION_MODE_EXT)dlsym(telephonyExtWrapperHandle_, "GetNrOptionModeExt");
|
||||
getNrOptionModeExtend_ = (GET_NR_OPTION_MODE_EXTEND)dlsym(telephonyExtWrapperHandle_, "GetNrOptionModeExtend");
|
||||
getPreferredNetworkExt_ = (GET_PREFERRED_NETWORK_EXT)dlsym(telephonyExtWrapperHandle_, "GetPreferredNetworkExt");
|
||||
isChipsetNetworkExtSupported_ = (IS_CHIPSET_NETWORK_EXT_SUPPORTED)dlsym(telephonyExtWrapperHandle_,
|
||||
"IsChipsetNetworkExtSupported");
|
||||
isNrSupportedNative_ = (IS_NR_SUPPORTED_NATIVE)dlsym(telephonyExtWrapperHandle_, "IsNrSupportedNativeExt");
|
||||
getSignalInfoListExt_ = (GET_SIGNAL_INFO_LIST_EXT)dlsym(telephonyExtWrapperHandle_, "GetSignalInfoListExt");
|
||||
getNetworkCapabilityExt_ = (GET_NETWORK_CAPABILITY_EXT)dlsym(telephonyExtWrapperHandle_, "GetNetworkCapabilityExt");
|
||||
@ -75,7 +77,8 @@ void TelephonyExtWrapper::InitTelephonyExtWrapperForNetWork()
|
||||
getRadioTechExt_ == nullptr || getNrOptionModeExt_ == nullptr || getSignalInfoListExt_ == nullptr ||
|
||||
getNetworkCapabilityExt_ == nullptr || onGetNetworkSearchInformationExt_ == nullptr ||
|
||||
getNetworkStatusExt_ == nullptr || isNrSupportedNative_ == nullptr ||
|
||||
getNrOptionModeExtend_ == nullptr || getPreferredNetworkExt_ == nullptr) {
|
||||
getNrOptionModeExtend_ == nullptr || getPreferredNetworkExt_ == nullptr ||
|
||||
isChipsetNetworkExtSupported_ == nullptr) {
|
||||
TELEPHONY_LOGE("telephony ext wrapper symbol failed, error: %{public}s", dlerror());
|
||||
}
|
||||
updateCountryCodeExt_ = (UPDATE_COUNTRY_CODE_EXT)dlsym(telephonyExtWrapperHandle_, "UpdateCountryCodeExt");
|
||||
@ -101,11 +104,6 @@ void TelephonyExtWrapper::InitTelephonyExtWrapperForNetWork()
|
||||
if (processStateChangeExt_ == nullptr) {
|
||||
TELEPHONY_LOGE("telephony ext wrapper symbol failed, error: %{public}s", dlerror());
|
||||
}
|
||||
publishSpnInfoChangedExt_ = (PUBLISH_SPN_INFO_CHANGED_EXT)dlsym(telephonyExtWrapperHandle_,
|
||||
"PublishSpnInfoChangedExt");
|
||||
if (publishSpnInfoChangedExt_ == nullptr) {
|
||||
TELEPHONY_LOGE("telephony ext wrapper symbol failed, error: %{public}s", dlerror());
|
||||
}
|
||||
}
|
||||
|
||||
void TelephonyExtWrapper::InitTelephonyExtWrapperForVoiceMail()
|
||||
@ -148,6 +146,11 @@ void TelephonyExtWrapper::InitTelephonyExtWrapperForCust()
|
||||
if (updateNetworkStateExt_ == nullptr) {
|
||||
TELEPHONY_LOGE("telephony ext wrapper symbol failed, error: %{public}s", dlerror());
|
||||
}
|
||||
publishSpnInfoChangedExt_ = (PUBLISH_SPN_INFO_CHANGED_EXT)dlsym(telephonyExtWrapperHandle_,
|
||||
"PublishSpnInfoChangedExt");
|
||||
if (publishSpnInfoChangedExt_ == nullptr) {
|
||||
TELEPHONY_LOGE("telephony ext wrapper symbol failed, error: %{public}s", dlerror());
|
||||
}
|
||||
InitTelephonyExtWrapperForApnCust();
|
||||
}
|
||||
|
||||
|
@ -32,3 +32,7 @@ if (defined(global_parts_info) &&
|
||||
telephony_extra_defines += [ "OHOS_BUILD_ENABLE_TELEPHONY_EXT" ]
|
||||
telephony_extra_defines += [ "OHOS_BUILD_ENABLE_TELEPHONY_VSIM" ]
|
||||
}
|
||||
|
||||
if (core_service_support_esim) {
|
||||
telephony_extra_defines += [ "CORE_SERVICE_SUPPORT_ESIM" ]
|
||||
}
|
||||
|
@ -12,6 +12,8 @@
|
||||
# limitations under the License.
|
||||
|
||||
import("//build/test.gni")
|
||||
SUBSYSTEM_DIR = "../.."
|
||||
import("$SUBSYSTEM_DIR/core_service/telephony_core_service.gni")
|
||||
|
||||
group("unittest") {
|
||||
testonly = true
|
||||
@ -36,4 +38,14 @@ group("unittest") {
|
||||
"unittest/utils_vcard_gtest:utils_vcard_branch_gtest",
|
||||
"unittest/utils_vcard_gtest:utils_vcard_gtest",
|
||||
]
|
||||
|
||||
if (core_service_support_esim) {
|
||||
deps += [
|
||||
"unittest/esim_gtest:esim_core_service_client_branch_test",
|
||||
"unittest/esim_gtest:esim_service_client_branch_gtest",
|
||||
"unittest/esim_gtest:tel_esim_gtest",
|
||||
"unittest/esim_parcel_gtest:parcel_gtest",
|
||||
"unittest/utils_codec_gtest:utils_codec_gtest",
|
||||
]
|
||||
}
|
||||
}
|
||||
|
@ -86,6 +86,7 @@ const CellInformation::CellType WCDMA = CellInformation::CellType::CELL_TYPE_WCD
|
||||
const CellInformation::CellType TDSCDMA = CellInformation::CellType::CELL_TYPE_TDSCDMA;
|
||||
const CellInformation::CellType LTE = CellInformation::CellType::CELL_TYPE_LTE;
|
||||
const CellInformation::CellType NR = CellInformation::CellType::CELL_TYPE_NR;
|
||||
static const int32_t SLEEP_TIME = 3;
|
||||
} // namespace
|
||||
|
||||
class BranchTest : public testing::Test {
|
||||
@ -96,7 +97,10 @@ public:
|
||||
void TearDown();
|
||||
};
|
||||
|
||||
void BranchTest::TearDownTestCase() {}
|
||||
void BranchTest::TearDownTestCase()
|
||||
{
|
||||
sleep(SLEEP_TIME);
|
||||
}
|
||||
|
||||
void BranchTest::SetUp() {}
|
||||
|
||||
@ -1412,63 +1416,6 @@ HWTEST_F(BranchTest, Telephony_MultiSimController_003, Function | MediumTest | L
|
||||
EXPECT_FALSE(multiSimController->IsValidData(-1));
|
||||
}
|
||||
|
||||
/**
|
||||
* @tc.number Telephony_MultiSimController_004
|
||||
* @tc.name test error branch
|
||||
* @tc.desc Function test
|
||||
*/
|
||||
HWTEST_F(BranchTest, Telephony_MultiSimController_004, Function | MediumTest | Level1)
|
||||
{
|
||||
std::shared_ptr<TelRilManager> telRilManager = std::make_shared<TelRilManager>();
|
||||
telRilManager->OnInit();
|
||||
std::vector<std::shared_ptr<Telephony::SimStateManager>> simStateManager = { nullptr, nullptr};
|
||||
std::vector<std::shared_ptr<Telephony::SimFileManager>> simFileManager = { nullptr, nullptr};
|
||||
for (int32_t slotId = 0; slotId < 2; slotId++) {
|
||||
simStateManager[slotId] = std::make_shared<SimStateManager>(telRilManager);
|
||||
if (simStateManager[slotId] != nullptr) {
|
||||
simStateManager[slotId]->Init(slotId);
|
||||
}
|
||||
simFileManager[slotId] = SimFileManager::CreateInstance(std::weak_ptr<ITelRilManager>(telRilManager),
|
||||
std::weak_ptr<SimStateManager>(simStateManager[slotId]));
|
||||
if (simFileManager[slotId] != nullptr) {
|
||||
simFileManager[slotId]->Init(slotId);
|
||||
}
|
||||
}
|
||||
std::shared_ptr<Telephony::MultiSimController> multiSimController =
|
||||
std::make_shared<MultiSimController>(telRilManager, simStateManager, simFileManager);
|
||||
multiSimController->Init();
|
||||
telRilManager->InitTelExtraModule(2);
|
||||
simStateManager.resize(3);
|
||||
simFileManager.resize(3);
|
||||
simStateManager[2] = std::make_shared<SimStateManager>(telRilManager);
|
||||
if (simStateManager[2] != nullptr) {
|
||||
simStateManager[2]->Init(2);
|
||||
}
|
||||
simFileManager[2] = SimFileManager::CreateInstance(std::weak_ptr<ITelRilManager>(telRilManager),
|
||||
std::weak_ptr<SimStateManager>(simStateManager[2]));
|
||||
if (simFileManager[2] != nullptr) {
|
||||
simFileManager[2]->Init(2);
|
||||
}
|
||||
multiSimController->AddExtraManagers(simStateManager[2], simFileManager[2]);
|
||||
multiSimController->ForgetAllData(0);
|
||||
multiSimController->simStateManager_[0]->simStateHandle_->iccState_.simStatus_ = 1;
|
||||
multiSimController->simStateManager_[0]->simStateHandle_->iccState_.simType_ = 2;
|
||||
multiSimController->simStateManager_[0]->simStateHandle_->iccid_ = "898600520123F0102670";
|
||||
multiSimController->simStateManager_[0]->simStateHandle_->externalType_ = CardType::SINGLE_MODE_USIM_CARD;
|
||||
multiSimController->simStateManager_[0]->simStateHandle_->externalState_ = SimState::SIM_STATE_READY;
|
||||
EXPECT_FALSE(multiSimController->InitData(-1));
|
||||
EXPECT_TRUE(multiSimController->InitData(0));
|
||||
EXPECT_TRUE(multiSimController->InitShowNumber(0));
|
||||
std::vector<IccAccountInfo> iccAccountInfoList;
|
||||
EXPECT_GE(multiSimController->GetActiveSimAccountInfoList(false, iccAccountInfoList), TELEPHONY_ERR_SUCCESS);
|
||||
EXPECT_GE(multiSimController->GetActiveSimAccountInfoList(true, iccAccountInfoList), TELEPHONY_ERR_SUCCESS);
|
||||
EXPECT_GE(multiSimController->SaveImsSwitch(0, 1), TELEPHONY_ERR_SUCCESS);
|
||||
int32_t imsSwitchValue;
|
||||
EXPECT_GE(multiSimController->QueryImsSwitch(0, imsSwitchValue), TELEPHONY_ERR_SUCCESS);
|
||||
EXPECT_FALSE(multiSimController->IsSetActiveSimInProgress(0));
|
||||
EXPECT_FALSE(multiSimController->IsSetPrimarySlotIdInProgress());
|
||||
}
|
||||
|
||||
/**
|
||||
* @tc.number Telephony_SimManager_001
|
||||
* @tc.name test error branch
|
||||
@ -2560,6 +2507,7 @@ HWTEST_F(BranchTest, Telephony_SimFileController_001, Function | MediumTest | Le
|
||||
EXPECT_NE(simFileController->ObtainElementFilePath(ELEMENTARY_FILE_SPN), "");
|
||||
EXPECT_NE(simFileController->ObtainElementFilePath(ELEMENTARY_FILE_AD), "");
|
||||
EXPECT_NE(simFileController->ObtainElementFilePath(ELEMENTARY_FILE_PNN), "");
|
||||
EXPECT_NE(simFileController->ObtainElementFilePath(ELEMENTARY_FILE_OPL), "");
|
||||
EXPECT_NE(simFileController->ObtainElementFilePath(ELEMENTARY_FILE_MBDN), "");
|
||||
EXPECT_NE(simFileController->ObtainElementFilePath(ELEMENTARY_FILE_EXT6), "");
|
||||
EXPECT_NE(simFileController->ObtainElementFilePath(ELEMENTARY_FILE_MBI), "");
|
||||
|
@ -419,6 +419,7 @@ HWTEST_F(CoreServiceBranchTest, Telephony_CoreService_HiSysEvent_001, Function |
|
||||
std::string argStr = "";
|
||||
coreServiceHiSysEvent->WriteSignalLevelBehaviorEvent(slotId, argInt);
|
||||
coreServiceHiSysEvent->WriteNetworkStateBehaviorEvent(slotId, argInt, argInt, argInt);
|
||||
coreServiceHiSysEvent->WriteRadioStateBehaviorEvent(slotId, argInt);
|
||||
coreServiceHiSysEvent->WriteDefaultDataSlotIdBehaviorEvent(slotId);
|
||||
coreServiceHiSysEvent->WriteSimStateBehaviorEvent(slotId, argInt);
|
||||
coreServiceHiSysEvent->WriteDialCallFaultEvent(slotId, argInt, argStr);
|
||||
|
@ -373,7 +373,7 @@ HWTEST_F(SimRilBranchTest, Telephony_IccDiallingNumbersCache_004, Function | Med
|
||||
auto iccDiallingNumbersManager = IccDiallingNumbersManager::CreateInstance(simFileManager, simStateManager);
|
||||
diallingNumbersCache->simFileManager_ = nullptr;
|
||||
diallingNumbersCache->Init();
|
||||
EXPECT_NE(diallingNumbersCache->diallingNumbersHandler_, nullptr);
|
||||
EXPECT_EQ(diallingNumbersCache->diallingNumbersHandler_, nullptr);
|
||||
auto caller = iccDiallingNumbersManager->BuildCallerInfo(-1);
|
||||
AppExecFwk::InnerEvent::Pointer event = diallingNumbersCache->CreateUsimPointer(-1, ELEMENTARY_FILE_PBR, caller);
|
||||
std::unique_ptr<UsimFetcher> fd = event->GetUniqueObject<UsimFetcher>();
|
||||
@ -420,7 +420,7 @@ HWTEST_F(SimRilBranchTest, Telephony_IccDiallingNumbersCache_005, Function | Med
|
||||
auto iccDiallingNumbersManager = IccDiallingNumbersManager::CreateInstance(simFileManager, simStateManager);
|
||||
diallingNumbersCache->simFileManager_ = nullptr;
|
||||
diallingNumbersCache->Init();
|
||||
EXPECT_NE(diallingNumbersCache->diallingNumbersHandler_, nullptr);
|
||||
EXPECT_EQ(diallingNumbersCache->diallingNumbersHandler_, nullptr);
|
||||
int extensionEf = diallingNumbersCache->ExtendedElementFile(ELEMENTARY_FILE_ADN);
|
||||
AppExecFwk::InnerEvent::Pointer event = iccDiallingNumbersManager->BuildCallerInfo(-1);
|
||||
diallingNumbersCache->ObtainAllDiallingNumberFiles(ELEMENTARY_FILE_ADN, extensionEf, event);
|
||||
@ -465,7 +465,7 @@ HWTEST_F(SimRilBranchTest, Telephony_IccDiallingNumbersHandler_001, Function | M
|
||||
diallingNumberHandler->MakeExceptionResult(0);
|
||||
diallingNumberHandler->UpdateFileController(iccFileController);
|
||||
auto sequence = diallingNumberHandler->CreateSavingSequence(telNumber, -1);
|
||||
EXPECT_NE(sequence, nullptr);
|
||||
EXPECT_EQ(sequence, nullptr);
|
||||
telNumber = nullptr;
|
||||
diallingNumberHandler->FormatNameAndNumber(telNumber, true);
|
||||
std::shared_ptr<unsigned char> diallingNumberStringPac = nullptr;
|
||||
@ -656,7 +656,7 @@ HWTEST_F(SimRilBranchTest, Telephony_UsimDiallingNumbersService_004, Function |
|
||||
auto iccDiallingNumbersManager = IccDiallingNumbersManager::CreateInstance(simFileManager, simStateManager);
|
||||
diallingNumbersCache->simFileManager_ = nullptr;
|
||||
diallingNumbersCache->Init();
|
||||
EXPECT_NE(diallingNumbersCache->diallingNumbersHandler_, nullptr);
|
||||
EXPECT_EQ(diallingNumbersCache->diallingNumbersHandler_, nullptr);
|
||||
auto usimDiallingNumbersService = std::make_shared<UsimDiallingNumbersService>();
|
||||
usimDiallingNumbersService->InitFuncMap();
|
||||
AppExecFwk::InnerEvent::Pointer event = usimDiallingNumbersService->CreateHandlerPointer(
|
||||
@ -681,7 +681,7 @@ HWTEST_F(SimRilBranchTest, Telephony_UsimDiallingNumbersService_005, Function |
|
||||
auto iccDiallingNumbersManager = IccDiallingNumbersManager::CreateInstance(simFileManager, simStateManager);
|
||||
diallingNumbersCache->simFileManager_ = nullptr;
|
||||
diallingNumbersCache->Init();
|
||||
EXPECT_NE(diallingNumbersCache->usimDiallingNumberSrv_, nullptr);
|
||||
EXPECT_EQ(diallingNumbersCache->usimDiallingNumberSrv_, nullptr);
|
||||
auto usimDiallingNumbersService = std::make_shared<UsimDiallingNumbersService>();
|
||||
usimDiallingNumbersService->InitFuncMap();
|
||||
EXPECT_NE(usimDiallingNumbersService->memberFuncMap_.size(), 0);
|
||||
@ -754,44 +754,6 @@ HWTEST_F(SimRilBranchTest, Telephony_SimStateManager_002, Function | MediumTest
|
||||
EXPECT_NE(simStateManager->SendSimMatchedOperatorInfo(0, 0, "", ""), TELEPHONY_ERR_SUCCESS);
|
||||
}
|
||||
|
||||
/**
|
||||
* @tc.number Telephony_SimStateManager_005
|
||||
* @tc.name test error branch
|
||||
* @tc.desc Function test
|
||||
*/
|
||||
HWTEST_F(SimRilBranchTest, Telephony_SimStateManager_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);
|
||||
simStateManager->Init(0);
|
||||
LockInfo mLockInfo;
|
||||
LockStatusResponse mLockStatusResponse;
|
||||
EXPECT_GT(simStateManager->SetLockState(0, mLockInfo, mLockStatusResponse), TELEPHONY_ERR_SUCCESS);
|
||||
LockType mLockType = LockType::PIN_LOCK;
|
||||
LockState lockState;
|
||||
EXPECT_EQ(simStateManager->GetLockState(0, mLockType, lockState), TELEPHONY_ERR_SUCCESS);
|
||||
SimIoRequestInfo requestInfo;
|
||||
SimAuthenticationResponse response;
|
||||
EXPECT_EQ(simStateManager->GetSimIO(0, requestInfo, response), TELEPHONY_ERR_SUCCESS);
|
||||
}
|
||||
|
||||
/**
|
||||
* @tc.number Telephony_SimStateManager_004
|
||||
* @tc.name test error branch
|
||||
* @tc.desc Function test
|
||||
*/
|
||||
HWTEST_F(SimRilBranchTest, Telephony_SimStateManager_004, 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);
|
||||
simStateManager->SetSimState(SimState::SIM_STATE_LOADED);
|
||||
simStateManager->Init(0);
|
||||
simStateManager->SetSimState(SimState::SIM_STATE_LOADED);
|
||||
EXPECT_EQ(simStateManager->GetSimState(), SimState::SIM_STATE_LOADED);
|
||||
}
|
||||
|
||||
/**
|
||||
* @tc.number Telephony_SimStateHandle_002
|
||||
* @tc.name test error branch
|
||||
|
289
test/unittest/esim_gtest/BUILD.gn
Normal file
289
test/unittest/esim_gtest/BUILD.gn
Normal file
@ -0,0 +1,289 @@
|
||||
# Copyright (C) 2024 Huawei Device Co., Ltd.
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
import("//build/test.gni")
|
||||
SOURCE_DIR = "../../../"
|
||||
ohos_unittest("esim_service_client_branch_gtest") {
|
||||
install_enable = true
|
||||
subsystem_name = "telephony"
|
||||
part_name = "core_service"
|
||||
test_module = "tel_esim_gtest"
|
||||
module_out_path = part_name + "/" + test_module
|
||||
|
||||
sources = [
|
||||
"$SOURCE_DIR/frameworks/native/src/download_profile_config_info_parcel.cpp",
|
||||
"$SOURCE_DIR/frameworks/native/src/download_profile_result_parcel.cpp",
|
||||
"$SOURCE_DIR/frameworks/native/src/downloadable_profile_parcel.cpp",
|
||||
"$SOURCE_DIR/frameworks/native/src/euicc_info_parcel.cpp",
|
||||
"$SOURCE_DIR/frameworks/native/src/get_downloadable_profiles_result_parcel.cpp",
|
||||
"$SOURCE_DIR/frameworks/native/src/profile_info_list_parcel.cpp",
|
||||
"$SOURCE_DIR/frameworks/native/src/profile_metadata_result_parcel.cpp",
|
||||
"$SOURCE_DIR/frameworks/native/src/response_esim_result.cpp",
|
||||
"esim_service_client_branch_test.cpp",
|
||||
]
|
||||
|
||||
include_dirs = [
|
||||
"$SOURCE_DIR/interfaces/innerkits/include",
|
||||
"$SOURCE_DIR/test/unittest/esim_gtest/mock/include",
|
||||
]
|
||||
|
||||
configs = [ "$SOURCE_DIR/utils:telephony_log_config" ]
|
||||
|
||||
deps = [
|
||||
"$SOURCE_DIR/interfaces/innerkits:tel_core_service_api",
|
||||
"//third_party/googletest:gmock_main",
|
||||
"//third_party/googletest:gtest_main",
|
||||
]
|
||||
|
||||
external_deps = [
|
||||
"ability_base:want",
|
||||
"ability_base:zuri",
|
||||
"ability_runtime:ability_manager",
|
||||
"ability_runtime:data_ability_helper",
|
||||
"ability_runtime:wantagent_innerkits",
|
||||
"access_token:libaccesstoken_sdk",
|
||||
"access_token:libnativetoken",
|
||||
"access_token:libtoken_setproc",
|
||||
"cJSON:cjson",
|
||||
"c_utils:utils",
|
||||
"common_event_service:cesfwk_innerkits",
|
||||
"config_policy:configpolicy_util",
|
||||
"core_service:libtel_vcard",
|
||||
"data_share:datashare_common",
|
||||
"data_share:datashare_consumer",
|
||||
"drivers_interface_ril:ril_idl_headers",
|
||||
"eventhandler:libeventhandler",
|
||||
"hdf_core:libhdi",
|
||||
"hilog:libhilog",
|
||||
"init:libbegetutil",
|
||||
"ipc:ipc_single",
|
||||
"netmanager_base:net_conn_manager_if",
|
||||
"netmanager_ext:net_tether_manager_if",
|
||||
"power_manager:powermgr_client",
|
||||
"safwk:system_ability_fwk",
|
||||
"samgr:samgr_proxy",
|
||||
]
|
||||
|
||||
defines = [
|
||||
"TELEPHONY_LOG_TAG = \"CoreServiceGtest\"",
|
||||
"LOG_DOMAIN = 0xD000F00",
|
||||
]
|
||||
|
||||
cflags = [
|
||||
"-flto",
|
||||
"-fsanitize=cfi",
|
||||
"-fsanitize-cfi-cross-dso",
|
||||
"-fvisibility=hidden",
|
||||
]
|
||||
|
||||
ldflags = [
|
||||
"-flto",
|
||||
"-fsanitize=cfi",
|
||||
"-fsanitize-cfi-cross-dso",
|
||||
]
|
||||
}
|
||||
|
||||
ohos_unittest("tel_esim_gtest") {
|
||||
install_enable = true
|
||||
subsystem_name = "telephony"
|
||||
part_name = "core_service"
|
||||
test_module = "tel_esim_gtest"
|
||||
module_out_path = part_name + "/" + test_module
|
||||
|
||||
sources = [
|
||||
"esim_core_service_client_test.cpp",
|
||||
"esim_core_service_proxy_test.cpp",
|
||||
"esim_core_service_stub_test.cpp",
|
||||
"esim_core_service_test.cpp",
|
||||
"esim_file_manager_test.cpp",
|
||||
"esim_manager_test.cpp",
|
||||
"esim_test.cpp",
|
||||
]
|
||||
|
||||
include_dirs = [
|
||||
"$SOURCE_DIR/services/core/include",
|
||||
"$SOURCE_DIR/utils/codec/include",
|
||||
"$SOURCE_DIR/utils/log/include",
|
||||
"$SOURCE_DIR/utils/preferences/include",
|
||||
"$SOURCE_DIR/services/sim/include",
|
||||
"$SOURCE_DIR/services/network_search/include",
|
||||
"$SOURCE_DIR/services/tel_ril/include",
|
||||
"$SOURCE_DIR/services/telephony_ext_wrapper/include",
|
||||
"$SOURCE_DIR/interfaces/innerkits/include",
|
||||
"$SOURCE_DIR/test/unittest/esim_gtest/mock/include",
|
||||
]
|
||||
|
||||
configs = [ "$SOURCE_DIR/utils:telephony_log_config" ]
|
||||
|
||||
deps = [
|
||||
"$SOURCE_DIR:tel_core_service",
|
||||
"$SOURCE_DIR/interfaces/innerkits:tel_core_service_api",
|
||||
"$SOURCE_DIR/utils:libtel_common",
|
||||
"//third_party/googletest:gmock_main",
|
||||
"//third_party/googletest:gtest_main",
|
||||
]
|
||||
|
||||
external_deps = [
|
||||
"ability_base:want",
|
||||
"ability_base:zuri",
|
||||
"ability_runtime:ability_manager",
|
||||
"ability_runtime:data_ability_helper",
|
||||
"ability_runtime:wantagent_innerkits",
|
||||
"access_token:libaccesstoken_sdk",
|
||||
"access_token:libnativetoken",
|
||||
"access_token:libtoken_setproc",
|
||||
"cJSON:cjson",
|
||||
"c_utils:utils",
|
||||
"common_event_service:cesfwk_innerkits",
|
||||
"config_policy:configpolicy_util",
|
||||
"core_service:libtel_vcard",
|
||||
"data_share:datashare_common",
|
||||
"data_share:datashare_consumer",
|
||||
"drivers_interface_ril:ril_idl_headers",
|
||||
"eventhandler:libeventhandler",
|
||||
"hdf_core:libhdi",
|
||||
"hilog:libhilog",
|
||||
"init:libbegetutil",
|
||||
"ipc:ipc_single",
|
||||
"netmanager_base:net_conn_manager_if",
|
||||
"netmanager_ext:net_tether_manager_if",
|
||||
"power_manager:powermgr_client",
|
||||
"safwk:system_ability_fwk",
|
||||
"samgr:samgr_proxy",
|
||||
]
|
||||
defines = [
|
||||
"TELEPHONY_LOG_TAG = \"CoreServiceGtest\"",
|
||||
"LOG_DOMAIN = 0xD000F00",
|
||||
]
|
||||
|
||||
if (defined(global_parts_info) &&
|
||||
defined(global_parts_info.location_location) &&
|
||||
global_parts_info.location_location) {
|
||||
external_deps += [
|
||||
"location:lbsservice_common",
|
||||
"location:locator_sdk",
|
||||
]
|
||||
defines += [ "ABILITY_LOCATION_SUPPORT" ]
|
||||
}
|
||||
|
||||
cflags = [
|
||||
"-flto",
|
||||
"-fsanitize=cfi",
|
||||
"-fsanitize-cfi-cross-dso",
|
||||
"-fvisibility=hidden",
|
||||
]
|
||||
|
||||
ldflags = [
|
||||
"-flto",
|
||||
"-fsanitize=cfi",
|
||||
"-fsanitize-cfi-cross-dso",
|
||||
]
|
||||
}
|
||||
|
||||
ohos_unittest("esim_core_service_client_branch_test") {
|
||||
install_enable = true
|
||||
subsystem_name = "telephony"
|
||||
part_name = "core_service"
|
||||
test_module = "tel_esim_gtest"
|
||||
module_out_path = part_name + "/" + test_module
|
||||
|
||||
sources = [ "esim_core_service_client_branch_test.cpp" ]
|
||||
|
||||
include_dirs = [
|
||||
"$SOURCE_DIR/services/core/include",
|
||||
"$SOURCE_DIR/utils/codec/include",
|
||||
"$SOURCE_DIR/utils/log/include",
|
||||
"$SOURCE_DIR/utils/preferences/include",
|
||||
"$SOURCE_DIR/services/sim/include",
|
||||
"$SOURCE_DIR/services/network_search/include",
|
||||
"$SOURCE_DIR/services/tel_ril/include",
|
||||
"$SOURCE_DIR/services/telephony_ext_wrapper/include",
|
||||
"$SOURCE_DIR/interfaces/innerkits/include",
|
||||
"$SOURCE_DIR/test/unittest/esim_gtest/mock/include",
|
||||
]
|
||||
|
||||
configs = [ "$SOURCE_DIR/utils:telephony_log_config" ]
|
||||
|
||||
deps = [
|
||||
"$SOURCE_DIR:tel_core_service",
|
||||
"$SOURCE_DIR/interfaces/innerkits:tel_core_service_api",
|
||||
"$SOURCE_DIR/utils:libtel_common",
|
||||
"//third_party/googletest:gmock_main",
|
||||
"//third_party/googletest:gtest_main",
|
||||
]
|
||||
|
||||
external_deps = [
|
||||
"ability_base:want",
|
||||
"ability_base:zuri",
|
||||
"ability_runtime:ability_manager",
|
||||
"ability_runtime:data_ability_helper",
|
||||
"ability_runtime:wantagent_innerkits",
|
||||
"access_token:libaccesstoken_sdk",
|
||||
"access_token:libnativetoken",
|
||||
"access_token:libtoken_setproc",
|
||||
"cJSON:cjson",
|
||||
"c_utils:utils",
|
||||
"common_event_service:cesfwk_innerkits",
|
||||
"config_policy:configpolicy_util",
|
||||
"core_service:libtel_vcard",
|
||||
"data_share:datashare_common",
|
||||
"data_share:datashare_consumer",
|
||||
"drivers_interface_ril:ril_idl_headers",
|
||||
"eventhandler:libeventhandler",
|
||||
"hdf_core:libhdi",
|
||||
"hilog:libhilog",
|
||||
"init:libbegetutil",
|
||||
"ipc:ipc_single",
|
||||
"netmanager_base:net_conn_manager_if",
|
||||
"netmanager_ext:net_tether_manager_if",
|
||||
"power_manager:powermgr_client",
|
||||
"safwk:system_ability_fwk",
|
||||
"samgr:samgr_proxy",
|
||||
]
|
||||
defines = [
|
||||
"TELEPHONY_LOG_TAG = \"CoreServiceGtest\"",
|
||||
"LOG_DOMAIN = 0xD000F00",
|
||||
]
|
||||
|
||||
if (defined(global_parts_info) &&
|
||||
defined(global_parts_info.location_location) &&
|
||||
global_parts_info.location_location) {
|
||||
external_deps += [
|
||||
"location:lbsservice_common",
|
||||
"location:locator_sdk",
|
||||
]
|
||||
defines += [ "ABILITY_LOCATION_SUPPORT" ]
|
||||
}
|
||||
|
||||
cflags = [
|
||||
"-flto",
|
||||
"-fsanitize=cfi",
|
||||
"-fsanitize-cfi-cross-dso",
|
||||
"-fvisibility=hidden",
|
||||
]
|
||||
|
||||
ldflags = [
|
||||
"-flto",
|
||||
"-fsanitize=cfi",
|
||||
"-fsanitize-cfi-cross-dso",
|
||||
]
|
||||
}
|
||||
|
||||
group("unittest") {
|
||||
testonly = true
|
||||
deps = [
|
||||
":esim_core_service_client_branch_test",
|
||||
":esim_service_client_branch_gtest",
|
||||
":tel_esim_gtest",
|
||||
]
|
||||
}
|
@ -21,7 +21,6 @@
|
||||
|
||||
#include "core_service_client.h"
|
||||
#include "esim_state_type.h"
|
||||
#include "gtest/gtest.h"
|
||||
#include "if_system_ability_manager_mock.h"
|
||||
#include "iservice_registry.h"
|
||||
#include "securec.h"
|
||||
@ -29,6 +28,7 @@
|
||||
#include "string_ex.h"
|
||||
#include "telephony_errors.h"
|
||||
#include "telephony_log_wrapper.h"
|
||||
#include "gtest/gtest.h"
|
||||
|
||||
namespace OHOS {
|
||||
namespace Telephony {
|
||||
@ -58,6 +58,149 @@ void EsimCoreServiceClientBranchTest::SetUp() {}
|
||||
|
||||
void EsimCoreServiceClientBranchTest::TearDown() {}
|
||||
|
||||
HWTEST_F(EsimCoreServiceClientBranchTest, GetEid_0002, Function | MediumTest | Level1)
|
||||
{
|
||||
int32_t slotId = 0;
|
||||
std::u16string eId = Str8ToStr16("1A2B3C4D");
|
||||
EXPECT_CALL(*samgr, CheckSystemAbility(testing::_)).WillOnce(testing::Return(nullptr));
|
||||
int32_t result = CoreServiceClient::GetInstance().GetEid(slotId, eId);
|
||||
EXPECT_EQ(result, TELEPHONY_ERR_IPC_CONNECT_STUB_FAIL);
|
||||
}
|
||||
|
||||
HWTEST_F(EsimCoreServiceClientBranchTest, GetEuiccProfileInfoList_0001, Function | MediumTest | Level1)
|
||||
{
|
||||
int32_t slotId = 0;
|
||||
GetEuiccProfileInfoListResult euiccProfileInfoList;
|
||||
EXPECT_CALL(*samgr, CheckSystemAbility(testing::_)).WillOnce(testing::Return(nullptr));
|
||||
int32_t result = CoreServiceClient::GetInstance().GetEuiccProfileInfoList(slotId, euiccProfileInfoList);
|
||||
EXPECT_EQ(result, TELEPHONY_ERR_IPC_CONNECT_STUB_FAIL);
|
||||
}
|
||||
|
||||
HWTEST_F(EsimCoreServiceClientBranchTest, GetEuiccInfo_0001, Function | MediumTest | Level1)
|
||||
{
|
||||
int32_t slotId = 0;
|
||||
EuiccInfo euiccInfo;
|
||||
euiccInfo.osVersion = Str8ToStr16("BF2003010203");
|
||||
EXPECT_CALL(*samgr, CheckSystemAbility(testing::_)).WillOnce(testing::Return(nullptr));
|
||||
int32_t result = CoreServiceClient::GetInstance().GetEuiccInfo(slotId, euiccInfo);
|
||||
EXPECT_EQ(result, TELEPHONY_ERR_IPC_CONNECT_STUB_FAIL);
|
||||
}
|
||||
|
||||
HWTEST_F(EsimCoreServiceClientBranchTest, DisableProfile_0100, Function | MediumTest | Level1)
|
||||
{
|
||||
int32_t slotId = 0;
|
||||
int32_t portIndex = 0;
|
||||
std::u16string iccId = Str8ToStr16("98760000000000543210");
|
||||
bool refresh = true;
|
||||
ResultState disableProfileResult;
|
||||
EXPECT_CALL(*samgr, CheckSystemAbility(testing::_)).WillOnce(testing::Return(nullptr));
|
||||
int32_t result =
|
||||
CoreServiceClient::GetInstance().DisableProfile(slotId, portIndex, iccId, refresh, disableProfileResult);
|
||||
EXPECT_EQ(result, TELEPHONY_ERR_IPC_CONNECT_STUB_FAIL);
|
||||
}
|
||||
|
||||
HWTEST_F(EsimCoreServiceClientBranchTest, GetSmdsAddress_0100, Function | MediumTest | Level1)
|
||||
{
|
||||
int32_t slotId = 0;
|
||||
int32_t portIndex = 0;
|
||||
std::u16string smdsAddress;
|
||||
EXPECT_CALL(*samgr, CheckSystemAbility(testing::_)).WillOnce(testing::Return(nullptr));
|
||||
int32_t result = CoreServiceClient::GetInstance().GetSmdsAddress(slotId, portIndex, smdsAddress);
|
||||
EXPECT_EQ(result, TELEPHONY_ERR_IPC_CONNECT_STUB_FAIL);
|
||||
}
|
||||
|
||||
HWTEST_F(EsimCoreServiceClientBranchTest, GetRulesAuthTable_0100, Function | MediumTest | Level1)
|
||||
{
|
||||
int32_t slotId = 0;
|
||||
int32_t portIndex = 0;
|
||||
EuiccRulesAuthTable eUiccRulesAuthTable;
|
||||
EXPECT_CALL(*samgr, CheckSystemAbility(testing::_)).WillOnce(testing::Return(nullptr));
|
||||
int32_t result = CoreServiceClient::GetInstance().GetRulesAuthTable(slotId, portIndex, eUiccRulesAuthTable);
|
||||
EXPECT_EQ(result, TELEPHONY_ERR_IPC_CONNECT_STUB_FAIL);
|
||||
}
|
||||
|
||||
HWTEST_F(EsimCoreServiceClientBranchTest, GetEuiccChallenge_0100, Function | MediumTest | Level1)
|
||||
{
|
||||
int32_t slotId = 0;
|
||||
int32_t portIndex = 0;
|
||||
ResponseEsimResult responseResult;
|
||||
EXPECT_CALL(*samgr, CheckSystemAbility(testing::_)).WillOnce(testing::Return(nullptr));
|
||||
int32_t result = CoreServiceClient::GetInstance().GetEuiccChallenge(slotId, portIndex, responseResult);
|
||||
EXPECT_EQ(result, TELEPHONY_ERR_IPC_CONNECT_STUB_FAIL);
|
||||
}
|
||||
|
||||
HWTEST_F(EsimCoreServiceClientBranchTest, RequestDefaultSmdpAddress_0100, Function | MediumTest | Level1)
|
||||
{
|
||||
int32_t slotId = 0;
|
||||
std::u16string address = Str8ToStr16("test.com");
|
||||
EXPECT_CALL(*samgr, CheckSystemAbility(testing::_)).WillOnce(testing::Return(nullptr));
|
||||
int32_t result = CoreServiceClient::GetInstance().GetDefaultSmdpAddress(slotId, address);
|
||||
EXPECT_EQ(result, TELEPHONY_ERR_IPC_CONNECT_STUB_FAIL);
|
||||
}
|
||||
|
||||
HWTEST_F(EsimCoreServiceClientBranchTest, CancelSession_0100, Function | MediumTest | Level1)
|
||||
{
|
||||
int32_t slotId = 0;
|
||||
std::u16string transactionId = Str8ToStr16("A1B2C3");
|
||||
const CancelReason cancelReason = CancelReason::CANCEL_REASON_POSTPONED;
|
||||
ResponseEsimResult responseResult;
|
||||
EXPECT_CALL(*samgr, CheckSystemAbility(testing::_)).WillOnce(testing::Return(nullptr));
|
||||
int32_t result =
|
||||
CoreServiceClient::GetInstance().CancelSession(slotId, transactionId, cancelReason, responseResult);
|
||||
EXPECT_EQ(result, TELEPHONY_ERR_IPC_CONNECT_STUB_FAIL);
|
||||
}
|
||||
|
||||
HWTEST_F(EsimCoreServiceClientBranchTest, GetProfile_0100, Function | MediumTest | Level1)
|
||||
{
|
||||
int32_t slotId = 0;
|
||||
int32_t portIndex = 0;
|
||||
std::u16string iccId = Str8ToStr16("5A0A89670000000000216954");
|
||||
EuiccProfile eUiccProfile;
|
||||
EXPECT_CALL(*samgr, CheckSystemAbility(testing::_)).WillOnce(testing::Return(nullptr));
|
||||
int32_t result = CoreServiceClient::GetInstance().GetProfile(slotId, portIndex, iccId, eUiccProfile);
|
||||
EXPECT_EQ(result, TELEPHONY_ERR_IPC_CONNECT_STUB_FAIL);
|
||||
}
|
||||
|
||||
HWTEST_F(EsimCoreServiceClientBranchTest, ResetMemory_0100, Function | MediumTest | Level1)
|
||||
{
|
||||
int32_t slotId = 0;
|
||||
ResultState ResetMemoryResult;
|
||||
const ResetOption resetOption = ResetOption::DELETE_OPERATIONAL_PROFILES;
|
||||
EXPECT_CALL(*samgr, CheckSystemAbility(testing::_)).WillOnce(testing::Return(nullptr));
|
||||
int32_t result = CoreServiceClient::GetInstance().ResetMemory(slotId, resetOption, ResetMemoryResult);
|
||||
EXPECT_EQ(result, TELEPHONY_ERR_IPC_CONNECT_STUB_FAIL);
|
||||
}
|
||||
|
||||
HWTEST_F(EsimCoreServiceClientBranchTest, SetDefaultSmdpAddress_0100, Function | MediumTest | Level1)
|
||||
{
|
||||
int32_t slotId = 0;
|
||||
std::u16string defaultSmdpAddress = Str8ToStr16("test.com");
|
||||
ResultState SetAddressResult;
|
||||
EXPECT_CALL(*samgr, CheckSystemAbility(testing::_)).WillOnce(testing::Return(nullptr));
|
||||
int32_t result = CoreServiceClient::GetInstance().
|
||||
SetDefaultSmdpAddress(slotId, defaultSmdpAddress, SetAddressResult);
|
||||
EXPECT_EQ(result, TELEPHONY_ERR_IPC_CONNECT_STUB_FAIL);
|
||||
}
|
||||
|
||||
HWTEST_F(EsimCoreServiceClientBranchTest, IsEsimSupported_0100, Function | MediumTest | Level1)
|
||||
{
|
||||
int32_t slotId = 0;
|
||||
EXPECT_CALL(*samgr, CheckSystemAbility(testing::_)).WillOnce(testing::Return(nullptr));
|
||||
int32_t result = CoreServiceClient::GetInstance().IsEsimSupported(slotId);
|
||||
EXPECT_EQ(result, false);
|
||||
}
|
||||
|
||||
HWTEST_F(EsimCoreServiceClientBranchTest, SendApduData_0100, Function | MediumTest | Level1)
|
||||
{
|
||||
int32_t slotId = 0;
|
||||
std::u16string aid = Str8ToStr16("aid test");
|
||||
std::u16string apduData = Str8ToStr16("apduData test");
|
||||
ResponseEsimResult responseResult;
|
||||
EXPECT_CALL(*samgr, CheckSystemAbility(testing::_)).WillOnce(testing::Return(nullptr));
|
||||
int32_t result = CoreServiceClient::GetInstance().SendApduData(slotId, aid, apduData, responseResult);
|
||||
EXPECT_EQ(result, TELEPHONY_ERR_IPC_CONNECT_STUB_FAIL);
|
||||
}
|
||||
|
||||
HWTEST_F(EsimCoreServiceClientBranchTest, PrepareDownload_0100, Function | MediumTest | Level1)
|
||||
{
|
||||
DownLoadConfigInfo downLoadConfigInfo;
|
||||
|
@ -21,12 +21,12 @@
|
||||
|
||||
#include "core_service_client.h"
|
||||
#include "esim_state_type.h"
|
||||
#include "gtest/gtest.h"
|
||||
#include "securec.h"
|
||||
#include "str_convert.h"
|
||||
#include "string_ex.h"
|
||||
#include "telephony_errors.h"
|
||||
#include "telephony_log_wrapper.h"
|
||||
#include "gtest/gtest.h"
|
||||
|
||||
namespace OHOS {
|
||||
namespace Telephony {
|
||||
@ -47,6 +47,135 @@ void EsimCoreServiceClientTest::SetUp() {}
|
||||
|
||||
void EsimCoreServiceClientTest::TearDown() {}
|
||||
|
||||
HWTEST_F(EsimCoreServiceClientTest, GetEid_0001, Function | MediumTest | Level1)
|
||||
{
|
||||
int32_t slotId = 0;
|
||||
std::u16string eId = Str8ToStr16("1A2B3C4D");
|
||||
int32_t result = CoreServiceClient::GetInstance().GetEid(slotId, eId);
|
||||
EXPECT_NE(result, TELEPHONY_SUCCESS);
|
||||
}
|
||||
|
||||
HWTEST_F(EsimCoreServiceClientTest, GetEuiccProfileInfoList_0001, Function | MediumTest | Level1)
|
||||
{
|
||||
int32_t slotId = 0;
|
||||
GetEuiccProfileInfoListResult euiccProfileInfoList;
|
||||
int32_t result = CoreServiceClient::GetInstance().GetEuiccProfileInfoList(slotId, euiccProfileInfoList);
|
||||
EXPECT_NE(result, TELEPHONY_SUCCESS);
|
||||
}
|
||||
|
||||
HWTEST_F(EsimCoreServiceClientTest, GetEuiccInfo_0001, Function | MediumTest | Level1)
|
||||
{
|
||||
int32_t slotId = 0;
|
||||
EuiccInfo euiccInfo;
|
||||
euiccInfo.osVersion = Str8ToStr16("BF2003010203");
|
||||
int32_t result = CoreServiceClient::GetInstance().GetEuiccInfo(slotId, euiccInfo);
|
||||
EXPECT_NE(result, TELEPHONY_SUCCESS);
|
||||
}
|
||||
|
||||
HWTEST_F(EsimCoreServiceClientTest, DisableProfile_0001, Function | MediumTest | Level1)
|
||||
{
|
||||
int32_t slotId = 0;
|
||||
int32_t portIndex = 0;
|
||||
std::u16string iccId = Str8ToStr16("98760000000000543210");
|
||||
bool refresh = true;
|
||||
ResultState disableProfileResult;
|
||||
int32_t result = CoreServiceClient::GetInstance().DisableProfile(
|
||||
slotId, portIndex, iccId, refresh, disableProfileResult);
|
||||
EXPECT_NE(result, TELEPHONY_SUCCESS);
|
||||
}
|
||||
|
||||
HWTEST_F(EsimCoreServiceClientTest, GetSmdsAddress_0001, Function | MediumTest | Level1)
|
||||
{
|
||||
int32_t slotId = 0;
|
||||
int32_t portIndex = 0;
|
||||
std::u16string smdsAddress;
|
||||
int32_t result = CoreServiceClient::GetInstance().GetSmdsAddress(slotId, portIndex, smdsAddress);
|
||||
EXPECT_NE(result, TELEPHONY_SUCCESS);
|
||||
}
|
||||
|
||||
HWTEST_F(EsimCoreServiceClientTest, GetRulesAuthTable_0001, Function | MediumTest | Level1)
|
||||
{
|
||||
int32_t slotId = 0;
|
||||
int32_t portIndex = 0;
|
||||
EuiccRulesAuthTable eUiccRulesAuthTable;
|
||||
int32_t result = CoreServiceClient::GetInstance().GetRulesAuthTable(slotId, portIndex, eUiccRulesAuthTable);
|
||||
EXPECT_NE(result, TELEPHONY_SUCCESS);
|
||||
}
|
||||
|
||||
HWTEST_F(EsimCoreServiceClientTest, GetEuiccChallenge_0001, Function | MediumTest | Level1)
|
||||
{
|
||||
int32_t slotId = 0;
|
||||
int32_t portIndex = 0;
|
||||
ResponseEsimResult responseResult;
|
||||
int32_t result = CoreServiceClient::GetInstance().GetEuiccChallenge(slotId, portIndex, responseResult);
|
||||
EXPECT_NE(result, TELEPHONY_SUCCESS);
|
||||
}
|
||||
|
||||
HWTEST_F(EsimCoreServiceClientTest, RequestDefaultSmdpAddress_0001, Function | MediumTest | Level1)
|
||||
{
|
||||
int32_t slotId = 0;
|
||||
std::u16string address = Str8ToStr16("test.com");
|
||||
int32_t result = CoreServiceClient::GetInstance().GetDefaultSmdpAddress(slotId, address);
|
||||
EXPECT_NE(result, TELEPHONY_SUCCESS);
|
||||
}
|
||||
|
||||
HWTEST_F(EsimCoreServiceClientTest, CancelSession_0001, Function | MediumTest | Level1)
|
||||
{
|
||||
int32_t slotId = 0;
|
||||
std::u16string transactionId = Str8ToStr16("A1B2C3");
|
||||
const CancelReason cancelReason = CancelReason::CANCEL_REASON_POSTPONED;
|
||||
ResponseEsimResult responseResult;
|
||||
int32_t result = CoreServiceClient::GetInstance().CancelSession(
|
||||
slotId, transactionId, cancelReason, responseResult);
|
||||
EXPECT_NE(result, TELEPHONY_SUCCESS);
|
||||
}
|
||||
|
||||
HWTEST_F(EsimCoreServiceClientTest, GetProfile_0001, Function | MediumTest | Level1)
|
||||
{
|
||||
int32_t slotId = 0;
|
||||
int32_t portIndex = 0;
|
||||
std::u16string iccId = Str8ToStr16("5A0A89670000000000216954");
|
||||
EuiccProfile eUiccProfile;
|
||||
int32_t result = CoreServiceClient::GetInstance().GetProfile(slotId, portIndex, iccId, eUiccProfile);
|
||||
EXPECT_NE(result, TELEPHONY_SUCCESS);
|
||||
}
|
||||
|
||||
HWTEST_F(EsimCoreServiceClientTest, ResetMemory_0001, Function | MediumTest | Level1)
|
||||
{
|
||||
int32_t slotId = 0;
|
||||
ResultState ResetMemoryResult;
|
||||
const ResetOption resetOption = ResetOption::DELETE_OPERATIONAL_PROFILES;
|
||||
int32_t result = CoreServiceClient::GetInstance().ResetMemory(slotId, resetOption, ResetMemoryResult);
|
||||
EXPECT_NE(result, TELEPHONY_SUCCESS);
|
||||
}
|
||||
|
||||
HWTEST_F(EsimCoreServiceClientTest, SetDefaultSmdpAddress_0001, Function | MediumTest | Level1)
|
||||
{
|
||||
int32_t slotId = 0;
|
||||
std::u16string defaultSmdpAddress = Str8ToStr16("test.com");
|
||||
ResultState SetAddressResult;
|
||||
int32_t result = CoreServiceClient::GetInstance().SetDefaultSmdpAddress(
|
||||
slotId, defaultSmdpAddress, SetAddressResult);
|
||||
EXPECT_NE(result, TELEPHONY_SUCCESS);
|
||||
}
|
||||
|
||||
HWTEST_F(EsimCoreServiceClientTest, IsEsimSupported_0001, Function | MediumTest | Level1)
|
||||
{
|
||||
int32_t slotId = 0;
|
||||
bool result = CoreServiceClient::GetInstance().IsEsimSupported(slotId);
|
||||
EXPECT_NE(result, true);
|
||||
}
|
||||
|
||||
HWTEST_F(EsimCoreServiceClientTest, SendApduData_0001, Function | MediumTest | Level1)
|
||||
{
|
||||
int32_t slotId = 0;
|
||||
std::u16string aid = Str8ToStr16("aid test");
|
||||
std::u16string apduData = Str8ToStr16("apduData test");
|
||||
ResponseEsimResult responseResult;
|
||||
int32_t result = CoreServiceClient::GetInstance().SendApduData(slotId, aid, apduData, responseResult);
|
||||
EXPECT_NE(result, TELEPHONY_SUCCESS);
|
||||
}
|
||||
|
||||
HWTEST_F(EsimCoreServiceClientTest, PrepareDownload_0001, Function | MediumTest | Level1)
|
||||
{
|
||||
DownLoadConfigInfo downLoadConfigInfo;
|
||||
|
@ -19,12 +19,12 @@
|
||||
#include "core_service_proxy.h"
|
||||
#include "esim_state_type.h"
|
||||
#include "gmock/gmock.h"
|
||||
#include "gtest/gtest.h"
|
||||
#include "iremote_broker.h"
|
||||
#include "iremote_object.h"
|
||||
#include "string_ex.h"
|
||||
#include "telephony_errors.h"
|
||||
#include "telephony_log_wrapper.h"
|
||||
#include "gtest/gtest.h"
|
||||
|
||||
namespace OHOS {
|
||||
class MockIRemoteObject : public IRemoteObject {
|
||||
@ -104,6 +104,465 @@ void EsimCoreServiceProxyTest::TearDown() {}
|
||||
|
||||
void EsimCoreServiceProxyTest::SetUpTestCase() {}
|
||||
|
||||
HWTEST_F(EsimCoreServiceProxyTest, GetEid_001, Function | MediumTest | Level2)
|
||||
{
|
||||
sptr<MockIRemoteObject> remote = nullptr;
|
||||
CoreServiceProxy proxy(remote);
|
||||
std::u16string eId;
|
||||
EXPECT_EQ(proxy.GetEid(SLOT_ID, eId), TELEPHONY_ERR_IPC_CONNECT_STUB_FAIL);
|
||||
}
|
||||
|
||||
HWTEST_F(EsimCoreServiceProxyTest, GetEid_002, Function | MediumTest | Level2)
|
||||
{
|
||||
sptr<MockIRemoteObject> remote = new (std::nothrow) MockIRemoteObject();
|
||||
CoreServiceProxy proxy(remote);
|
||||
std::u16string eId;
|
||||
EXPECT_CALL(*remote, SendRequest(testing::_, testing::_, testing::_, testing::_)).WillOnce(testing::Return(-500));
|
||||
EXPECT_EQ(proxy.GetEid(SLOT_ID, eId), TELEPHONY_ERR_IPC_CONNECT_STUB_FAIL);
|
||||
}
|
||||
|
||||
HWTEST_F(EsimCoreServiceProxyTest, GetEid_003, Function | MediumTest | Level2)
|
||||
{
|
||||
sptr<MockIRemoteObject> remote = new (std::nothrow) MockIRemoteObject();
|
||||
CoreServiceProxy proxy(remote);
|
||||
std::u16string eId;
|
||||
EXPECT_CALL(*remote, SendRequest(testing::_, testing::_, testing::_, testing::_)).WillOnce(testing::Return(0));
|
||||
EXPECT_EQ(proxy.GetEid(SLOT_ID, eId), 0);
|
||||
}
|
||||
|
||||
HWTEST_F(EsimCoreServiceProxyTest, ReadEuiccProfileFromReply_001, Function | MediumTest | Level2)
|
||||
{
|
||||
sptr<MockIRemoteObject> remote = new (std::nothrow) MockIRemoteObject();
|
||||
CoreServiceProxy proxy(remote);
|
||||
MessageParcel reply;
|
||||
EuiccProfile euiccProfile;
|
||||
proxy.ReadEuiccProfileFromReply(reply, euiccProfile);
|
||||
}
|
||||
|
||||
HWTEST_F(EsimCoreServiceProxyTest, GetEuiccProfileInfoList_001, Function | MediumTest | Level2)
|
||||
{
|
||||
sptr<MockIRemoteObject> remote = nullptr;
|
||||
CoreServiceProxy proxy(remote);
|
||||
GetEuiccProfileInfoListResult euiccProfileInfoList;
|
||||
int32_t ret = proxy.GetEuiccProfileInfoList(SLOT_ID, euiccProfileInfoList);
|
||||
EXPECT_EQ(ret, TELEPHONY_ERR_IPC_CONNECT_STUB_FAIL);
|
||||
}
|
||||
|
||||
HWTEST_F(EsimCoreServiceProxyTest, GetEuiccProfileInfoList_002, Function | MediumTest | Level2)
|
||||
{
|
||||
sptr<MockIRemoteObject> remote = new (std::nothrow) MockIRemoteObject();
|
||||
CoreServiceProxy proxy(remote);
|
||||
GetEuiccProfileInfoListResult euiccProfileInfoList;
|
||||
EXPECT_CALL(*remote, SendRequest(testing::_, testing::_, testing::_, testing::_)).WillOnce(testing::Return(-500));
|
||||
int32_t ret = proxy.GetEuiccProfileInfoList(SLOT_ID, euiccProfileInfoList);
|
||||
EXPECT_EQ(ret, TELEPHONY_ERR_IPC_CONNECT_STUB_FAIL);
|
||||
}
|
||||
|
||||
HWTEST_F(EsimCoreServiceProxyTest, GetEuiccProfileInfoList_003, Function | MediumTest | Level2)
|
||||
{
|
||||
sptr<MockIRemoteObject> remote = new (std::nothrow) MockIRemoteObject();
|
||||
CoreServiceProxy proxy(remote);
|
||||
GetEuiccProfileInfoListResult euiccProfileInfoList;
|
||||
EXPECT_CALL(*remote, SendRequest(testing::_, testing::_, testing::_, testing::_)).WillOnce(testing::Return(0));
|
||||
int32_t ret = proxy.GetEuiccProfileInfoList(SLOT_ID, euiccProfileInfoList);
|
||||
EXPECT_EQ(ret, 0);
|
||||
}
|
||||
|
||||
HWTEST_F(EsimCoreServiceProxyTest, GetEuiccInfo_001, Function | MediumTest | Level2)
|
||||
{
|
||||
sptr<MockIRemoteObject> remote = nullptr;
|
||||
CoreServiceProxy proxy(remote);
|
||||
EuiccInfo eUiccInfo;
|
||||
int32_t ret = proxy.GetEuiccInfo(SLOT_ID, eUiccInfo);
|
||||
EXPECT_EQ(ret, TELEPHONY_ERR_IPC_CONNECT_STUB_FAIL);
|
||||
}
|
||||
|
||||
HWTEST_F(EsimCoreServiceProxyTest, GetEuiccInfo_002, Function | MediumTest | Level2)
|
||||
{
|
||||
sptr<MockIRemoteObject> remote = new (std::nothrow) MockIRemoteObject();
|
||||
CoreServiceProxy proxy(remote);
|
||||
EuiccInfo eUiccInfo;
|
||||
EXPECT_CALL(*remote, SendRequest(testing::_, testing::_, testing::_, testing::_)).WillOnce(testing::Return(-500));
|
||||
int32_t ret = proxy.GetEuiccInfo(SLOT_ID, eUiccInfo);
|
||||
EXPECT_EQ(ret, TELEPHONY_ERR_IPC_CONNECT_STUB_FAIL);
|
||||
}
|
||||
|
||||
HWTEST_F(EsimCoreServiceProxyTest, GetEuiccInfo_003, Function | MediumTest | Level2)
|
||||
{
|
||||
sptr<MockIRemoteObject> remote = new (std::nothrow) MockIRemoteObject();
|
||||
CoreServiceProxy proxy(remote);
|
||||
EuiccInfo eUiccInfo;
|
||||
EXPECT_CALL(*remote, SendRequest(testing::_, testing::_, testing::_, testing::_)).WillOnce(testing::Return(0));
|
||||
int32_t ret = proxy.GetEuiccInfo(SLOT_ID, eUiccInfo);
|
||||
EXPECT_EQ(ret, 0);
|
||||
}
|
||||
|
||||
HWTEST_F(EsimCoreServiceProxyTest, DisableProfile_001, Function | MediumTest | Level2)
|
||||
{
|
||||
sptr<MockIRemoteObject> remote = nullptr;
|
||||
CoreServiceProxy proxy(remote);
|
||||
int32_t portIndex = 0;
|
||||
std::u16string iccId = Str8ToStr16("98760000000000543210");
|
||||
bool refresh = true;
|
||||
ResultState DisableProfileResult;
|
||||
int32_t ret = proxy.DisableProfile(SLOT_ID, portIndex, iccId, refresh, DisableProfileResult);
|
||||
EXPECT_EQ(ret, TELEPHONY_ERR_IPC_CONNECT_STUB_FAIL);
|
||||
}
|
||||
|
||||
HWTEST_F(EsimCoreServiceProxyTest, DisableProfile_002, Function | MediumTest | Level2)
|
||||
{
|
||||
sptr<MockIRemoteObject> remote = new (std::nothrow) MockIRemoteObject();
|
||||
CoreServiceProxy proxy(remote);
|
||||
int32_t portIndex = 0;
|
||||
std::u16string iccId = Str8ToStr16("98760000000000543210");
|
||||
bool refresh = true;
|
||||
ResultState DisableProfileResult;
|
||||
EXPECT_CALL(*remote, SendRequest(testing::_, testing::_, testing::_, testing::_)).WillOnce(testing::Return(-500));
|
||||
int32_t ret = proxy.DisableProfile(SLOT_ID, portIndex, iccId, refresh, DisableProfileResult);
|
||||
EXPECT_EQ(ret, TELEPHONY_ERR_IPC_CONNECT_STUB_FAIL);
|
||||
}
|
||||
|
||||
HWTEST_F(EsimCoreServiceProxyTest, DisableProfile_003, Function | MediumTest | Level2)
|
||||
{
|
||||
sptr<MockIRemoteObject> remote = new (std::nothrow) MockIRemoteObject();
|
||||
CoreServiceProxy proxy(remote);
|
||||
int32_t portIndex = 0;
|
||||
std::u16string iccId = Str8ToStr16("98760000000000543210");
|
||||
bool refresh = true;
|
||||
ResultState DisableProfileResult;
|
||||
EXPECT_CALL(*remote, SendRequest(testing::_, testing::_, testing::_, testing::_)).WillOnce(testing::Return(0));
|
||||
int32_t ret = proxy.DisableProfile(SLOT_ID, portIndex, iccId, refresh, DisableProfileResult);
|
||||
EXPECT_EQ(ret, 0);
|
||||
}
|
||||
|
||||
HWTEST_F(EsimCoreServiceProxyTest, GetSmdsAddress_001, Function | MediumTest | Level2)
|
||||
{
|
||||
sptr<MockIRemoteObject> remote = nullptr;
|
||||
CoreServiceProxy proxy(remote);
|
||||
int32_t portIndex = 0;
|
||||
std::u16string smdsAddress;
|
||||
int32_t ret = proxy.GetSmdsAddress(SLOT_ID, portIndex, smdsAddress);
|
||||
EXPECT_EQ(ret, TELEPHONY_ERR_IPC_CONNECT_STUB_FAIL);
|
||||
}
|
||||
|
||||
HWTEST_F(EsimCoreServiceProxyTest, GetSmdsAddress_002, Function | MediumTest | Level2)
|
||||
{
|
||||
sptr<MockIRemoteObject> remote = new (std::nothrow) MockIRemoteObject();
|
||||
CoreServiceProxy proxy(remote);
|
||||
int32_t portIndex = 0;
|
||||
std::u16string smdsAddress;
|
||||
EXPECT_CALL(*remote, SendRequest(testing::_, testing::_, testing::_, testing::_)).WillOnce(testing::Return(-500));
|
||||
int32_t ret = proxy.GetSmdsAddress(SLOT_ID, portIndex, smdsAddress);
|
||||
EXPECT_EQ(ret, TELEPHONY_ERR_IPC_CONNECT_STUB_FAIL);
|
||||
}
|
||||
|
||||
HWTEST_F(EsimCoreServiceProxyTest, GetSmdsAddress_003, Function | MediumTest | Level2)
|
||||
{
|
||||
sptr<MockIRemoteObject> remote = new (std::nothrow) MockIRemoteObject();
|
||||
CoreServiceProxy proxy(remote);
|
||||
int32_t portIndex = 0;
|
||||
std::u16string smdsAddress;
|
||||
EXPECT_CALL(*remote, SendRequest(testing::_, testing::_, testing::_, testing::_)).WillOnce(testing::Return(0));
|
||||
int32_t ret = proxy.GetSmdsAddress(SLOT_ID, portIndex, smdsAddress);
|
||||
EXPECT_EQ(ret, 0);
|
||||
}
|
||||
|
||||
HWTEST_F(EsimCoreServiceProxyTest, ParseRulesAuthTableReply_001, Function | MediumTest | Level2)
|
||||
{
|
||||
sptr<MockIRemoteObject> remote = new (std::nothrow) MockIRemoteObject();
|
||||
CoreServiceProxy proxy(remote);
|
||||
MessageParcel reply;
|
||||
EuiccRulesAuthTable eUiccRulesAuthTable;
|
||||
int32_t ret = proxy.ParseRulesAuthTableReply(reply, eUiccRulesAuthTable);
|
||||
EXPECT_EQ(ret, 0);
|
||||
}
|
||||
|
||||
HWTEST_F(EsimCoreServiceProxyTest, GetRulesAuthTable_001, Function | MediumTest | Level2)
|
||||
{
|
||||
sptr<MockIRemoteObject> remote = nullptr;
|
||||
CoreServiceProxy proxy(remote);
|
||||
int32_t portIndex = 0;
|
||||
EuiccRulesAuthTable eUiccRulesAuthTable;
|
||||
int32_t ret = proxy.GetRulesAuthTable(SLOT_ID, portIndex, eUiccRulesAuthTable);
|
||||
EXPECT_EQ(ret, TELEPHONY_ERR_IPC_CONNECT_STUB_FAIL);
|
||||
}
|
||||
|
||||
HWTEST_F(EsimCoreServiceProxyTest, GetRulesAuthTable_002, Function | MediumTest | Level2)
|
||||
{
|
||||
sptr<MockIRemoteObject> remote = new (std::nothrow) MockIRemoteObject();
|
||||
CoreServiceProxy proxy(remote);
|
||||
int32_t portIndex = 0;
|
||||
EuiccRulesAuthTable eUiccRulesAuthTable;
|
||||
EXPECT_CALL(*remote, SendRequest(testing::_, testing::_, testing::_, testing::_)).WillOnce(testing::Return(-500));
|
||||
int32_t ret = proxy.GetRulesAuthTable(SLOT_ID, portIndex, eUiccRulesAuthTable);
|
||||
EXPECT_EQ(ret, TELEPHONY_ERR_IPC_CONNECT_STUB_FAIL);
|
||||
}
|
||||
|
||||
HWTEST_F(EsimCoreServiceProxyTest, GetRulesAuthTable_003, Function | MediumTest | Level2)
|
||||
{
|
||||
sptr<MockIRemoteObject> remote = new (std::nothrow) MockIRemoteObject();
|
||||
CoreServiceProxy proxy(remote);
|
||||
int32_t portIndex = 0;
|
||||
EuiccRulesAuthTable eUiccRulesAuthTable;
|
||||
EXPECT_CALL(*remote, SendRequest(testing::_, testing::_, testing::_, testing::_)).WillOnce(testing::Return(0));
|
||||
int32_t ret = proxy.GetRulesAuthTable(SLOT_ID, portIndex, eUiccRulesAuthTable);
|
||||
EXPECT_EQ(ret, 0);
|
||||
}
|
||||
|
||||
HWTEST_F(EsimCoreServiceProxyTest, GetEuiccChallenge_001, Function | MediumTest | Level2)
|
||||
{
|
||||
sptr<MockIRemoteObject> remote = nullptr;
|
||||
CoreServiceProxy proxy(remote);
|
||||
int32_t portIndex = 0;
|
||||
ResponseEsimResult responseResult;
|
||||
int32_t ret = proxy.GetEuiccChallenge(SLOT_ID, portIndex, responseResult);
|
||||
EXPECT_EQ(ret, TELEPHONY_ERR_IPC_CONNECT_STUB_FAIL);
|
||||
}
|
||||
|
||||
HWTEST_F(EsimCoreServiceProxyTest, GetEuiccChallenge_002, Function | MediumTest | Level2)
|
||||
{
|
||||
sptr<MockIRemoteObject> remote = new (std::nothrow) MockIRemoteObject();
|
||||
CoreServiceProxy proxy(remote);
|
||||
int32_t portIndex = 0;
|
||||
ResponseEsimResult responseResult;
|
||||
EXPECT_CALL(*remote, SendRequest(testing::_, testing::_, testing::_, testing::_)).WillOnce(testing::Return(-500));
|
||||
int32_t ret = proxy.GetEuiccChallenge(SLOT_ID, portIndex, responseResult);
|
||||
EXPECT_EQ(ret, TELEPHONY_ERR_IPC_CONNECT_STUB_FAIL);
|
||||
}
|
||||
|
||||
HWTEST_F(EsimCoreServiceProxyTest, GetEuiccChallenge_003, Function | MediumTest | Level2)
|
||||
{
|
||||
sptr<MockIRemoteObject> remote = new (std::nothrow) MockIRemoteObject();
|
||||
CoreServiceProxy proxy(remote);
|
||||
int32_t portIndex = 0;
|
||||
ResponseEsimResult responseResult;
|
||||
EXPECT_CALL(*remote, SendRequest(testing::_, testing::_, testing::_, testing::_)).WillOnce(testing::Return(0));
|
||||
int32_t ret = proxy.GetEuiccChallenge(SLOT_ID, portIndex, responseResult);
|
||||
EXPECT_EQ(ret, 0);
|
||||
}
|
||||
|
||||
HWTEST_F(EsimCoreServiceProxyTest, RequestDefaultSmdpAddress_001, Function | MediumTest | Level2)
|
||||
{
|
||||
sptr<MockIRemoteObject> remote = nullptr;
|
||||
CoreServiceProxy proxy(remote);
|
||||
std::u16string defaultSmdpAddress;
|
||||
int32_t ret = proxy.GetDefaultSmdpAddress(SLOT_ID, defaultSmdpAddress);
|
||||
EXPECT_EQ(ret, TELEPHONY_ERR_IPC_CONNECT_STUB_FAIL);
|
||||
}
|
||||
|
||||
HWTEST_F(EsimCoreServiceProxyTest, RequestDefaultSmdpAddress_002, Function | MediumTest | Level2)
|
||||
{
|
||||
sptr<MockIRemoteObject> remote = new (std::nothrow) MockIRemoteObject();
|
||||
CoreServiceProxy proxy(remote);
|
||||
std::u16string defaultSmdpAddress;
|
||||
EXPECT_CALL(*remote, SendRequest(testing::_, testing::_, testing::_, testing::_)).WillOnce(testing::Return(-500));
|
||||
int32_t ret = proxy.GetDefaultSmdpAddress(SLOT_ID, defaultSmdpAddress);
|
||||
EXPECT_EQ(ret, TELEPHONY_ERR_IPC_CONNECT_STUB_FAIL);
|
||||
}
|
||||
|
||||
HWTEST_F(EsimCoreServiceProxyTest, RequestDefaultSmdpAddress_003, Function | MediumTest | Level2)
|
||||
{
|
||||
sptr<MockIRemoteObject> remote = new (std::nothrow) MockIRemoteObject();
|
||||
CoreServiceProxy proxy(remote);
|
||||
std::u16string defaultSmdpAddress;
|
||||
EXPECT_CALL(*remote, SendRequest(testing::_, testing::_, testing::_, testing::_)).WillOnce(testing::Return(0));
|
||||
int32_t ret = proxy.GetDefaultSmdpAddress(SLOT_ID, defaultSmdpAddress);
|
||||
EXPECT_EQ(ret, 0);
|
||||
}
|
||||
|
||||
HWTEST_F(EsimCoreServiceProxyTest, CancelSession_001, Function | MediumTest | Level2)
|
||||
{
|
||||
sptr<MockIRemoteObject> remote = nullptr;
|
||||
CoreServiceProxy proxy(remote);
|
||||
std::u16string transactionId = Str8ToStr16("A1B2C3");
|
||||
const CancelReason cancelReason = CancelReason::CANCEL_REASON_POSTPONED;
|
||||
ResponseEsimResult responseResult;
|
||||
int32_t ret = proxy.CancelSession(SLOT_ID, transactionId, cancelReason, responseResult);
|
||||
EXPECT_EQ(ret, TELEPHONY_ERR_IPC_CONNECT_STUB_FAIL);
|
||||
}
|
||||
|
||||
HWTEST_F(EsimCoreServiceProxyTest, CancelSession_002, Function | MediumTest | Level2)
|
||||
{
|
||||
sptr<MockIRemoteObject> remote = new (std::nothrow) MockIRemoteObject();
|
||||
CoreServiceProxy proxy(remote);
|
||||
std::u16string transactionId = Str8ToStr16("A1B2C3");
|
||||
const CancelReason cancelReason = CancelReason::CANCEL_REASON_POSTPONED;
|
||||
ResponseEsimResult responseResult;
|
||||
EXPECT_CALL(*remote, SendRequest(testing::_, testing::_, testing::_, testing::_)).WillOnce(testing::Return(-500));
|
||||
int32_t ret = proxy.CancelSession(SLOT_ID, transactionId, cancelReason, responseResult);
|
||||
EXPECT_EQ(ret, TELEPHONY_ERR_IPC_CONNECT_STUB_FAIL);
|
||||
}
|
||||
|
||||
HWTEST_F(EsimCoreServiceProxyTest, CancelSession_003, Function | MediumTest | Level2)
|
||||
{
|
||||
sptr<MockIRemoteObject> remote = new (std::nothrow) MockIRemoteObject();
|
||||
CoreServiceProxy proxy(remote);
|
||||
std::u16string transactionId = Str8ToStr16("A1B2C3");
|
||||
const CancelReason cancelReason = CancelReason::CANCEL_REASON_POSTPONED;
|
||||
ResponseEsimResult responseResult;
|
||||
EXPECT_CALL(*remote, SendRequest(testing::_, testing::_, testing::_, testing::_)).WillOnce(testing::Return(0));
|
||||
int32_t ret = proxy.CancelSession(SLOT_ID, transactionId, cancelReason, responseResult);
|
||||
EXPECT_EQ(ret, 0);
|
||||
}
|
||||
|
||||
HWTEST_F(EsimCoreServiceProxyTest, GetProfile_001, Function | MediumTest | Level2)
|
||||
{
|
||||
sptr<MockIRemoteObject> remote = nullptr;
|
||||
CoreServiceProxy proxy(remote);
|
||||
int32_t portIndex = 0;
|
||||
std::u16string iccId;
|
||||
EuiccProfile eUiccProfile;
|
||||
int32_t ret = proxy.GetProfile(SLOT_ID, portIndex, iccId, eUiccProfile);
|
||||
EXPECT_EQ(ret, TELEPHONY_ERR_IPC_CONNECT_STUB_FAIL);
|
||||
}
|
||||
|
||||
HWTEST_F(EsimCoreServiceProxyTest, GetProfile_002, Function | MediumTest | Level2)
|
||||
{
|
||||
sptr<MockIRemoteObject> remote = new (std::nothrow) MockIRemoteObject();
|
||||
CoreServiceProxy proxy(remote);
|
||||
int32_t portIndex = 0;
|
||||
std::u16string iccId;
|
||||
EuiccProfile eUiccProfile;
|
||||
EXPECT_CALL(*remote, SendRequest(testing::_, testing::_, testing::_, testing::_)).WillOnce(testing::Return(-500));
|
||||
int32_t ret = proxy.GetProfile(SLOT_ID, portIndex, iccId, eUiccProfile);
|
||||
EXPECT_EQ(ret, TELEPHONY_ERR_IPC_CONNECT_STUB_FAIL);
|
||||
}
|
||||
|
||||
HWTEST_F(EsimCoreServiceProxyTest, GetProfile_003, Function | MediumTest | Level2)
|
||||
{
|
||||
sptr<MockIRemoteObject> remote = new (std::nothrow) MockIRemoteObject();
|
||||
CoreServiceProxy proxy(remote);
|
||||
int32_t portIndex = 0;
|
||||
std::u16string iccId;
|
||||
EuiccProfile eUiccProfile;
|
||||
EXPECT_CALL(*remote, SendRequest(testing::_, testing::_, testing::_, testing::_)).WillOnce(testing::Return(0));
|
||||
int32_t ret = proxy.GetProfile(SLOT_ID, portIndex, iccId, eUiccProfile);
|
||||
EXPECT_EQ(ret, 0);
|
||||
}
|
||||
|
||||
HWTEST_F(EsimCoreServiceProxyTest, ResetMemory_001, Function | MediumTest | Level2)
|
||||
{
|
||||
sptr<MockIRemoteObject> remote = nullptr;
|
||||
CoreServiceProxy proxy(remote);
|
||||
|
||||
ResetOption resetOption = ResetOption::DELETE_OPERATIONAL_PROFILES;
|
||||
ResultState resetMemoryResult;
|
||||
int32_t ret = proxy.ResetMemory(SLOT_ID, resetOption, resetMemoryResult);
|
||||
EXPECT_EQ(ret, TELEPHONY_ERR_IPC_CONNECT_STUB_FAIL);
|
||||
}
|
||||
|
||||
HWTEST_F(EsimCoreServiceProxyTest, ResetMemory_002, Function | MediumTest | Level2)
|
||||
{
|
||||
sptr<MockIRemoteObject> remote = new (std::nothrow) MockIRemoteObject();
|
||||
CoreServiceProxy proxy(remote);
|
||||
ResetOption resetOption = ResetOption::DELETE_OPERATIONAL_PROFILES;
|
||||
ResultState resetMemoryResult;
|
||||
EXPECT_CALL(*remote, SendRequest(testing::_, testing::_, testing::_, testing::_)).WillOnce(testing::Return(-500));
|
||||
int32_t ret = proxy.ResetMemory(SLOT_ID, resetOption, resetMemoryResult);
|
||||
EXPECT_EQ(ret, TELEPHONY_ERR_IPC_CONNECT_STUB_FAIL);
|
||||
}
|
||||
|
||||
HWTEST_F(EsimCoreServiceProxyTest, ResetMemory_003, Function | MediumTest | Level2)
|
||||
{
|
||||
sptr<MockIRemoteObject> remote = new (std::nothrow) MockIRemoteObject();
|
||||
CoreServiceProxy proxy(remote);
|
||||
ResetOption resetOption = ResetOption::DELETE_OPERATIONAL_PROFILES;
|
||||
ResultState resetMemoryResult;
|
||||
EXPECT_CALL(*remote, SendRequest(testing::_, testing::_, testing::_, testing::_)).WillOnce(testing::Return(0));
|
||||
int32_t ret = proxy.ResetMemory(SLOT_ID, resetOption, resetMemoryResult);
|
||||
EXPECT_EQ(ret, 0);
|
||||
}
|
||||
|
||||
HWTEST_F(EsimCoreServiceProxyTest, SetDefaultSmdpAddress_001, Function | MediumTest | Level2)
|
||||
{
|
||||
sptr<MockIRemoteObject> remote = nullptr;
|
||||
CoreServiceProxy proxy(remote);
|
||||
std::u16string defaultSmdpAddress = Str8ToStr16("test.com");
|
||||
ResultState setAddressResult;
|
||||
int32_t ret = proxy.SetDefaultSmdpAddress(SLOT_ID, defaultSmdpAddress, setAddressResult);
|
||||
EXPECT_EQ(ret, TELEPHONY_ERR_IPC_CONNECT_STUB_FAIL);
|
||||
}
|
||||
|
||||
HWTEST_F(EsimCoreServiceProxyTest, SetDefaultSmdpAddress_002, Function | MediumTest | Level2)
|
||||
{
|
||||
sptr<MockIRemoteObject> remote = new (std::nothrow) MockIRemoteObject();
|
||||
CoreServiceProxy proxy(remote);
|
||||
std::u16string defaultSmdpAddress = Str8ToStr16("test.com");
|
||||
ResultState setAddressResult;
|
||||
EXPECT_CALL(*remote, SendRequest(testing::_, testing::_, testing::_, testing::_)).WillOnce(testing::Return(-500));
|
||||
int32_t ret = proxy.SetDefaultSmdpAddress(SLOT_ID, defaultSmdpAddress, setAddressResult);
|
||||
EXPECT_EQ(ret, TELEPHONY_ERR_IPC_CONNECT_STUB_FAIL);
|
||||
}
|
||||
|
||||
HWTEST_F(EsimCoreServiceProxyTest, SetDefaultSmdpAddress_003, Function | MediumTest | Level2)
|
||||
{
|
||||
sptr<MockIRemoteObject> remote = new (std::nothrow) MockIRemoteObject();
|
||||
CoreServiceProxy proxy(remote);
|
||||
std::u16string defaultSmdpAddress = Str8ToStr16("test.com");
|
||||
ResultState setAddressResult;
|
||||
EXPECT_CALL(*remote, SendRequest(testing::_, testing::_, testing::_, testing::_)).WillOnce(testing::Return(0));
|
||||
int32_t ret = proxy.SetDefaultSmdpAddress(SLOT_ID, defaultSmdpAddress, setAddressResult);
|
||||
EXPECT_EQ(ret, 0);
|
||||
}
|
||||
|
||||
HWTEST_F(EsimCoreServiceProxyTest, IsEsimSupported_001, Function | MediumTest | Level2)
|
||||
{
|
||||
sptr<MockIRemoteObject> remote = nullptr;
|
||||
CoreServiceProxy proxy(remote);
|
||||
EXPECT_FALSE(proxy.IsEsimSupported(SLOT_ID));
|
||||
}
|
||||
|
||||
HWTEST_F(EsimCoreServiceProxyTest, IsEsimSupported_002, Function | MediumTest | Level2)
|
||||
{
|
||||
sptr<MockIRemoteObject> remote = new (std::nothrow) MockIRemoteObject();
|
||||
CoreServiceProxy proxy(remote);
|
||||
EXPECT_CALL(*remote, SendRequest(testing::_, testing::_, testing::_, testing::_)).WillOnce(testing::Return(-500));
|
||||
EXPECT_FALSE(proxy.IsEsimSupported(SLOT_ID));
|
||||
}
|
||||
|
||||
HWTEST_F(EsimCoreServiceProxyTest, IsEsimSupported_003, Function | MediumTest | Level2)
|
||||
{
|
||||
sptr<MockIRemoteObject> remote = new (std::nothrow) MockIRemoteObject();
|
||||
CoreServiceProxy proxy(remote);
|
||||
EXPECT_CALL(*remote, SendRequest(testing::_, testing::_, testing::_, testing::_)).WillOnce(testing::Return(0));
|
||||
EXPECT_FALSE(proxy.IsEsimSupported(SLOT_ID));
|
||||
}
|
||||
|
||||
HWTEST_F(EsimCoreServiceProxyTest, SendApduData_001, Function | MediumTest | Level2)
|
||||
{
|
||||
sptr<MockIRemoteObject> remote = nullptr;
|
||||
CoreServiceProxy proxy(remote);
|
||||
std::u16string aid = Str8ToStr16("aid test");
|
||||
std::u16string apduData = Str8ToStr16("apduData test");
|
||||
ResponseEsimResult responseResult;
|
||||
std::u16string eId;
|
||||
EXPECT_EQ(proxy.SendApduData(SLOT_ID, aid, apduData, responseResult), TELEPHONY_ERR_IPC_CONNECT_STUB_FAIL);
|
||||
}
|
||||
|
||||
HWTEST_F(EsimCoreServiceProxyTest, SendApduData_002, Function | MediumTest | Level2)
|
||||
{
|
||||
sptr<MockIRemoteObject> remote = new (std::nothrow) MockIRemoteObject();
|
||||
CoreServiceProxy proxy(remote);
|
||||
std::u16string aid = Str8ToStr16("aid test");
|
||||
std::u16string apduData = Str8ToStr16("apduData test");
|
||||
ResponseEsimResult responseResult;
|
||||
std::u16string eId;
|
||||
EXPECT_CALL(*remote, SendRequest(testing::_, testing::_, testing::_, testing::_)).WillOnce(testing::Return(-500));
|
||||
EXPECT_EQ(proxy.SendApduData(SLOT_ID, aid, apduData, responseResult), TELEPHONY_ERR_IPC_CONNECT_STUB_FAIL);
|
||||
}
|
||||
|
||||
HWTEST_F(EsimCoreServiceProxyTest, SendApduData_003, Function | MediumTest | Level2)
|
||||
{
|
||||
sptr<MockIRemoteObject> remote = new (std::nothrow) MockIRemoteObject();
|
||||
CoreServiceProxy proxy(remote);
|
||||
std::u16string aid = Str8ToStr16("aid test");
|
||||
std::u16string apduData = Str8ToStr16("apduData test");
|
||||
ResponseEsimResult responseResult;
|
||||
std::u16string eId;
|
||||
EXPECT_CALL(*remote, SendRequest(testing::_, testing::_, testing::_, testing::_)).WillOnce(testing::Return(0));
|
||||
EXPECT_EQ(proxy.SendApduData(SLOT_ID, aid, apduData, responseResult), 0);
|
||||
}
|
||||
|
||||
HWTEST_F(EsimCoreServiceProxyTest, PrepareDownload_001, Function | MediumTest | Level2)
|
||||
{
|
||||
sptr<MockIRemoteObject> remote = nullptr;
|
||||
|
@ -15,9 +15,9 @@
|
||||
|
||||
#include "core_service_ipc_interface_code.h"
|
||||
#include "esim_core_service_stub_test.h"
|
||||
#include "gtest/gtest.h"
|
||||
#include "telephony_errors.h"
|
||||
#include "telephony_log_wrapper.h"
|
||||
#include "gtest/gtest.h"
|
||||
|
||||
using namespace testing::ext;
|
||||
namespace OHOS {
|
||||
@ -40,6 +40,143 @@ void EsimCoreServiceStubTest::SetUp() {}
|
||||
|
||||
void EsimCoreServiceStubTest::TearDown() {}
|
||||
|
||||
int32_t EsimCoreServiceStubTest::SendRemoteRequest(MessageParcel &data, CoreServiceInterfaceCode code)
|
||||
{
|
||||
MessageParcel reply;
|
||||
MessageOption option;
|
||||
return instance_->OnRemoteRequest(static_cast<uint32_t>(code), data, reply, option);
|
||||
}
|
||||
|
||||
HWTEST_F(EsimCoreServiceStubTest, OnGetEid_001, Function | MediumTest | Level2)
|
||||
{
|
||||
MessageParcel data;
|
||||
if (!data.WriteInterfaceToken(CoreServiceStub::GetDescriptor())) {
|
||||
return;
|
||||
}
|
||||
int32_t ret = SendRemoteRequest(data, CoreServiceInterfaceCode::GET_EID);
|
||||
EXPECT_EQ(ret, TELEPHONY_ERR_SUCCESS);
|
||||
}
|
||||
|
||||
HWTEST_F(EsimCoreServiceStubTest, OnGetEuiccProfileInfoList_001, Function | MediumTest | Level2)
|
||||
{
|
||||
MessageParcel data;
|
||||
if (!data.WriteInterfaceToken(CoreServiceStub::GetDescriptor())) {
|
||||
return;
|
||||
}
|
||||
int32_t ret = SendRemoteRequest(data, CoreServiceInterfaceCode::GET_EUICC_PROFILE_INFO_LIST);
|
||||
EXPECT_EQ(ret, TELEPHONY_ERR_SUCCESS);
|
||||
}
|
||||
|
||||
HWTEST_F(EsimCoreServiceStubTest, OnGetEuiccInfo_001, Function | MediumTest | Level2)
|
||||
{
|
||||
MessageParcel data;
|
||||
if (!data.WriteInterfaceToken(CoreServiceStub::GetDescriptor())) {
|
||||
return;
|
||||
}
|
||||
int32_t ret = SendRemoteRequest(data, CoreServiceInterfaceCode::GET_EUICC_INFO);
|
||||
EXPECT_EQ(ret, TELEPHONY_ERR_SUCCESS);
|
||||
}
|
||||
|
||||
HWTEST_F(EsimCoreServiceStubTest, OnDisableProfile_001, Function | MediumTest | Level2)
|
||||
{
|
||||
MessageParcel data;
|
||||
if (!data.WriteInterfaceToken(CoreServiceStub::GetDescriptor())) {
|
||||
return;
|
||||
}
|
||||
int32_t ret = SendRemoteRequest(data, CoreServiceInterfaceCode::DISABLE_PROFILE);
|
||||
EXPECT_EQ(ret, TELEPHONY_ERR_SUCCESS);
|
||||
}
|
||||
|
||||
HWTEST_F(EsimCoreServiceStubTest, OnGetSmdsAddress_001, Function | MediumTest | Level2)
|
||||
{
|
||||
MessageParcel data;
|
||||
if (!data.WriteInterfaceToken(CoreServiceStub::GetDescriptor())) {
|
||||
return;
|
||||
}
|
||||
int32_t ret = SendRemoteRequest(data, CoreServiceInterfaceCode::GET_SMDSADDRESS);
|
||||
EXPECT_EQ(ret, TELEPHONY_ERR_SUCCESS);
|
||||
}
|
||||
|
||||
HWTEST_F(EsimCoreServiceStubTest, OnGetRulesAuthTable_001, Function | MediumTest | Level2)
|
||||
{
|
||||
MessageParcel data;
|
||||
if (!data.WriteInterfaceToken(CoreServiceStub::GetDescriptor())) {
|
||||
return;
|
||||
}
|
||||
int32_t ret = SendRemoteRequest(data, CoreServiceInterfaceCode::GET_RULES_AUTH_TABLE);
|
||||
EXPECT_EQ(ret, TELEPHONY_ERR_SUCCESS);
|
||||
}
|
||||
|
||||
HWTEST_F(EsimCoreServiceStubTest, OnGetEuiccChallenge_001, Function | MediumTest | Level2)
|
||||
{
|
||||
MessageParcel data;
|
||||
if (!data.WriteInterfaceToken(CoreServiceStub::GetDescriptor())) {
|
||||
return;
|
||||
}
|
||||
int32_t ret = SendRemoteRequest(data, CoreServiceInterfaceCode::GET_EUICC_CHALLENGE);
|
||||
EXPECT_EQ(ret, TELEPHONY_ERR_SUCCESS);
|
||||
}
|
||||
|
||||
HWTEST_F(EsimCoreServiceStubTest, OnRequestDefaultSmdpAddress_001, Function | MediumTest | Level2)
|
||||
{
|
||||
MessageParcel data;
|
||||
if (!data.WriteInterfaceToken(CoreServiceStub::GetDescriptor())) {
|
||||
return;
|
||||
}
|
||||
int32_t ret = SendRemoteRequest(data, CoreServiceInterfaceCode::REQUEST_DEFAULT_SMDP_ADDRESS);
|
||||
EXPECT_EQ(ret, TELEPHONY_ERR_SUCCESS);
|
||||
}
|
||||
|
||||
HWTEST_F(EsimCoreServiceStubTest, OnCancelSession_001, Function | MediumTest | Level2)
|
||||
{
|
||||
MessageParcel data;
|
||||
if (!data.WriteInterfaceToken(CoreServiceStub::GetDescriptor())) {
|
||||
return;
|
||||
}
|
||||
int32_t ret = SendRemoteRequest(data, CoreServiceInterfaceCode::CANCEL_SESSION);
|
||||
EXPECT_EQ(ret, TELEPHONY_ERR_SUCCESS);
|
||||
}
|
||||
|
||||
HWTEST_F(EsimCoreServiceStubTest, OnGetProfile_001, Function | MediumTest | Level2)
|
||||
{
|
||||
MessageParcel data;
|
||||
if (!data.WriteInterfaceToken(CoreServiceStub::GetDescriptor())) {
|
||||
return;
|
||||
}
|
||||
int32_t ret = SendRemoteRequest(data, CoreServiceInterfaceCode::GET_PROFILE);
|
||||
EXPECT_EQ(ret, TELEPHONY_ERR_SUCCESS);
|
||||
}
|
||||
|
||||
HWTEST_F(EsimCoreServiceStubTest, OnResetMemory_001, Function | MediumTest | Level2)
|
||||
{
|
||||
MessageParcel data;
|
||||
if (!data.WriteInterfaceToken(CoreServiceStub::GetDescriptor())) {
|
||||
return;
|
||||
}
|
||||
int32_t ret = SendRemoteRequest(data, CoreServiceInterfaceCode::RESET_MEMORY);
|
||||
EXPECT_EQ(ret, TELEPHONY_ERR_SUCCESS);
|
||||
}
|
||||
|
||||
HWTEST_F(EsimCoreServiceStubTest, OnSetDefaultSmdpAddress_001, Function | MediumTest | Level2)
|
||||
{
|
||||
MessageParcel data;
|
||||
if (!data.WriteInterfaceToken(CoreServiceStub::GetDescriptor())) {
|
||||
return;
|
||||
}
|
||||
int32_t ret = SendRemoteRequest(data, CoreServiceInterfaceCode::SET_DEFAULT_SMDP_ADDRESS);
|
||||
EXPECT_EQ(ret, TELEPHONY_ERR_SUCCESS);
|
||||
}
|
||||
|
||||
HWTEST_F(EsimCoreServiceStubTest, OnSendApduData_001, Function | MediumTest | Level2)
|
||||
{
|
||||
MessageParcel data;
|
||||
if (!data.WriteInterfaceToken(CoreServiceStub::GetDescriptor())) {
|
||||
return;
|
||||
}
|
||||
int32_t ret = SendRemoteRequest(data, CoreServiceInterfaceCode::SEND_APDU_DATA);
|
||||
EXPECT_EQ(ret, TELEPHONY_ERR_SUCCESS);
|
||||
}
|
||||
|
||||
HWTEST_F(EsimCoreServiceStubTest, OnPrepareDownload_001, Function | MediumTest | Level2)
|
||||
{
|
||||
MessageParcel data;
|
||||
|
@ -19,13 +19,13 @@
|
||||
#include "core_service.h"
|
||||
#include "esim_state_type.h"
|
||||
#include "gmock/gmock.h"
|
||||
#include "gtest/gtest.h"
|
||||
#include "string_ex.h"
|
||||
#include "str_convert.h"
|
||||
#include "sim_manager.h"
|
||||
#include "telephony_errors.h"
|
||||
#include "telephony_log_wrapper.h"
|
||||
#include "telephony_permission.h"
|
||||
#include "gtest/gtest.h"
|
||||
|
||||
namespace OHOS {
|
||||
namespace Telephony {
|
||||
@ -46,6 +46,206 @@ void EsimCoreServiceTest::SetUp() {}
|
||||
|
||||
void EsimCoreServiceTest::TearDown() {}
|
||||
|
||||
HWTEST_F(EsimCoreServiceTest, GetEid_0001, Function | MediumTest | Level1)
|
||||
{
|
||||
std::shared_ptr<CoreService> mCoreService = std::make_shared<CoreService>();
|
||||
std::shared_ptr<TelRilManager> telRilManager = std::make_shared<TelRilManager>();
|
||||
mCoreService->simManager_ = std::make_shared<SimManager>(telRilManager);
|
||||
int32_t slotId = 0;
|
||||
std::u16string eId;
|
||||
EXPECT_NE(mCoreService->GetEid(slotId, eId), TELEPHONY_ERR_SUCCESS);
|
||||
mCoreService->simManager_ = nullptr;
|
||||
EXPECT_EQ(mCoreService->GetEid(slotId, eId), TELEPHONY_ERR_LOCAL_PTR_NULL);
|
||||
}
|
||||
|
||||
HWTEST_F(EsimCoreServiceTest, GetEuiccProfileInfoList_0001, Function | MediumTest | Level1)
|
||||
{
|
||||
std::shared_ptr<CoreService> mCoreService = std::make_shared<CoreService>();
|
||||
std::shared_ptr<TelRilManager> telRilManager = std::make_shared<TelRilManager>();
|
||||
mCoreService->simManager_ = std::make_shared<SimManager>(telRilManager);
|
||||
int32_t slotId = 0;
|
||||
GetEuiccProfileInfoListResult euiccProfileInfoList;
|
||||
EXPECT_NE(mCoreService->GetEuiccProfileInfoList(slotId, euiccProfileInfoList), TELEPHONY_ERR_SUCCESS);
|
||||
mCoreService->simManager_ = nullptr;
|
||||
EXPECT_EQ(mCoreService->GetEuiccProfileInfoList(slotId, euiccProfileInfoList), TELEPHONY_ERR_LOCAL_PTR_NULL);
|
||||
}
|
||||
|
||||
HWTEST_F(EsimCoreServiceTest, GetEuiccInfo_0001, Function | MediumTest | Level1)
|
||||
{
|
||||
std::shared_ptr<CoreService> mCoreService = std::make_shared<CoreService>();
|
||||
std::shared_ptr<TelRilManager> telRilManager = std::make_shared<TelRilManager>();
|
||||
mCoreService->simManager_ = std::make_shared<SimManager>(telRilManager);
|
||||
int32_t slotId = 0;
|
||||
EuiccInfo euiccInfo;
|
||||
euiccInfo.osVersion = Str8ToStr16("BF2003010203");
|
||||
EXPECT_NE(mCoreService->GetEuiccInfo(slotId, euiccInfo), TELEPHONY_ERR_SUCCESS);
|
||||
mCoreService->simManager_ = nullptr;
|
||||
EXPECT_EQ(mCoreService->GetEuiccInfo(slotId, euiccInfo), TELEPHONY_ERR_LOCAL_PTR_NULL);
|
||||
}
|
||||
|
||||
HWTEST_F(EsimCoreServiceTest, DisableProfile_0001, Function | MediumTest | Level1)
|
||||
{
|
||||
std::shared_ptr<CoreService> mCoreService = std::make_shared<CoreService>();
|
||||
std::shared_ptr<TelRilManager> telRilManager = std::make_shared<TelRilManager>();
|
||||
mCoreService->simManager_ = std::make_shared<SimManager>(telRilManager);
|
||||
int32_t slotId = 0;
|
||||
int32_t portIndex = 0;
|
||||
std::u16string iccId = Str8ToStr16("98760000000000543210");
|
||||
bool refresh = true;
|
||||
ResultState disableProfileResult;
|
||||
EXPECT_NE(mCoreService->DisableProfile(
|
||||
slotId, portIndex, iccId, refresh, disableProfileResult), TELEPHONY_ERR_SUCCESS);
|
||||
mCoreService->simManager_ = nullptr;
|
||||
EXPECT_EQ(mCoreService->DisableProfile(
|
||||
slotId, portIndex, iccId, refresh, disableProfileResult), TELEPHONY_ERR_LOCAL_PTR_NULL);
|
||||
}
|
||||
|
||||
HWTEST_F(EsimCoreServiceTest, GetSmdsAddress_0001, Function | MediumTest | Level1)
|
||||
{
|
||||
std::shared_ptr<CoreService> mCoreService = std::make_shared<CoreService>();
|
||||
std::shared_ptr<TelRilManager> telRilManager = std::make_shared<TelRilManager>();
|
||||
mCoreService->simManager_ = std::make_shared<SimManager>(telRilManager);
|
||||
int32_t slotId = 0;
|
||||
int32_t portIndex = 0;
|
||||
std::u16string smdsAddress;
|
||||
EXPECT_NE(mCoreService->GetSmdsAddress(
|
||||
slotId, portIndex, smdsAddress), TELEPHONY_ERR_SUCCESS);
|
||||
mCoreService->simManager_ = nullptr;
|
||||
EXPECT_EQ(mCoreService->GetSmdsAddress(
|
||||
slotId, portIndex, smdsAddress), TELEPHONY_ERR_LOCAL_PTR_NULL);
|
||||
}
|
||||
|
||||
HWTEST_F(EsimCoreServiceTest, GetRulesAuthTable_0001, Function | MediumTest | Level1)
|
||||
{
|
||||
std::shared_ptr<CoreService> mCoreService = std::make_shared<CoreService>();
|
||||
std::shared_ptr<TelRilManager> telRilManager = std::make_shared<TelRilManager>();
|
||||
mCoreService->simManager_ = std::make_shared<SimManager>(telRilManager);
|
||||
int32_t slotId = 0;
|
||||
int32_t portIndex = 0;
|
||||
EuiccRulesAuthTable eUiccRulesAuthTable;
|
||||
EXPECT_NE(mCoreService->GetRulesAuthTable(
|
||||
slotId, portIndex, eUiccRulesAuthTable), TELEPHONY_ERR_SUCCESS);
|
||||
mCoreService->simManager_ = nullptr;
|
||||
EXPECT_EQ(mCoreService->GetRulesAuthTable(
|
||||
slotId, portIndex, eUiccRulesAuthTable), TELEPHONY_ERR_LOCAL_PTR_NULL);
|
||||
}
|
||||
|
||||
HWTEST_F(EsimCoreServiceTest, GetEuiccChallenge_0001, Function | MediumTest | Level1)
|
||||
{
|
||||
std::shared_ptr<CoreService> mCoreService = std::make_shared<CoreService>();
|
||||
std::shared_ptr<TelRilManager> telRilManager = std::make_shared<TelRilManager>();
|
||||
mCoreService->simManager_ = std::make_shared<SimManager>(telRilManager);
|
||||
int32_t slotId = 0;
|
||||
int32_t portIndex = 0;
|
||||
ResponseEsimResult responseResult;
|
||||
EXPECT_NE(mCoreService->GetEuiccChallenge(
|
||||
slotId, portIndex, responseResult), TELEPHONY_ERR_SUCCESS);
|
||||
mCoreService->simManager_ = nullptr;
|
||||
EXPECT_EQ(mCoreService->GetEuiccChallenge(
|
||||
slotId, portIndex, responseResult), TELEPHONY_ERR_LOCAL_PTR_NULL);
|
||||
}
|
||||
|
||||
HWTEST_F(EsimCoreServiceTest, RequestDefaultSmdpAddress_0001, Function | MediumTest | Level1)
|
||||
{
|
||||
std::shared_ptr<CoreService> mCoreService = std::make_shared<CoreService>();
|
||||
std::shared_ptr<TelRilManager> telRilManager = std::make_shared<TelRilManager>();
|
||||
mCoreService->simManager_ = std::make_shared<SimManager>(telRilManager);
|
||||
int32_t slotId = 0;
|
||||
std::u16string address = Str8ToStr16("test.com");
|
||||
EXPECT_NE(mCoreService->GetDefaultSmdpAddress(slotId, address), TELEPHONY_ERR_SUCCESS);
|
||||
mCoreService->simManager_ = nullptr;
|
||||
EXPECT_EQ(mCoreService->GetDefaultSmdpAddress(slotId, address), TELEPHONY_ERR_LOCAL_PTR_NULL);
|
||||
}
|
||||
|
||||
HWTEST_F(EsimCoreServiceTest, CancelSession_0001, Function | MediumTest | Level1)
|
||||
{
|
||||
std::shared_ptr<CoreService> mCoreService = std::make_shared<CoreService>();
|
||||
std::shared_ptr<TelRilManager> telRilManager = std::make_shared<TelRilManager>();
|
||||
mCoreService->simManager_ = std::make_shared<SimManager>(telRilManager);
|
||||
int32_t slotId = 0;
|
||||
std::u16string transactionId = Str8ToStr16("A1B2C3");
|
||||
const CancelReason cancelReason = CancelReason::CANCEL_REASON_POSTPONED;
|
||||
ResponseEsimResult responseResult;
|
||||
EXPECT_NE(mCoreService->CancelSession(
|
||||
slotId, transactionId, cancelReason, responseResult), TELEPHONY_ERR_SUCCESS);
|
||||
mCoreService->simManager_ = nullptr;
|
||||
EXPECT_EQ(mCoreService->CancelSession(
|
||||
slotId, transactionId, cancelReason, responseResult), TELEPHONY_ERR_LOCAL_PTR_NULL);
|
||||
}
|
||||
|
||||
HWTEST_F(EsimCoreServiceTest, GetProfile_0001, Function | MediumTest | Level1)
|
||||
{
|
||||
std::shared_ptr<CoreService> mCoreService = std::make_shared<CoreService>();
|
||||
std::shared_ptr<TelRilManager> telRilManager = std::make_shared<TelRilManager>();
|
||||
mCoreService->simManager_ = std::make_shared<SimManager>(telRilManager);
|
||||
int32_t slotId = 0;
|
||||
int32_t portIndex = 0;
|
||||
std::u16string iccId = Str8ToStr16("5A0A89670000000000216954");
|
||||
EuiccProfile eUiccProfile;
|
||||
EXPECT_NE(mCoreService->GetProfile(
|
||||
slotId, portIndex, iccId, eUiccProfile), TELEPHONY_ERR_SUCCESS);
|
||||
mCoreService->simManager_ = nullptr;
|
||||
EXPECT_EQ(mCoreService->GetProfile(
|
||||
slotId, portIndex, iccId, eUiccProfile), TELEPHONY_ERR_LOCAL_PTR_NULL);
|
||||
}
|
||||
|
||||
HWTEST_F(EsimCoreServiceTest, ResetMemory_0001, Function | MediumTest | Level1)
|
||||
{
|
||||
std::shared_ptr<CoreService> mCoreService = std::make_shared<CoreService>();
|
||||
std::shared_ptr<TelRilManager> telRilManager = std::make_shared<TelRilManager>();
|
||||
mCoreService->simManager_ = std::make_shared<SimManager>(telRilManager);
|
||||
int32_t slotId = 0;
|
||||
ResultState ResetMemoryResult;
|
||||
const ResetOption resetOption = ResetOption::DELETE_OPERATIONAL_PROFILES;
|
||||
EXPECT_NE(mCoreService->ResetMemory(
|
||||
slotId, resetOption, ResetMemoryResult), TELEPHONY_ERR_SUCCESS);
|
||||
mCoreService->simManager_ = nullptr;
|
||||
EXPECT_EQ(mCoreService->ResetMemory(
|
||||
slotId, resetOption, ResetMemoryResult), TELEPHONY_ERR_LOCAL_PTR_NULL);
|
||||
}
|
||||
|
||||
HWTEST_F(EsimCoreServiceTest, SetDefaultSmdpAddress_0001, Function | MediumTest | Level1)
|
||||
{
|
||||
std::shared_ptr<CoreService> mCoreService = std::make_shared<CoreService>();
|
||||
std::shared_ptr<TelRilManager> telRilManager = std::make_shared<TelRilManager>();
|
||||
mCoreService->simManager_ = std::make_shared<SimManager>(telRilManager);
|
||||
int32_t slotId = 0;
|
||||
std::u16string defaultSmdpAddress = Str8ToStr16("test.com");
|
||||
ResultState SetAddressResult;
|
||||
EXPECT_NE(mCoreService->SetDefaultSmdpAddress(
|
||||
slotId, defaultSmdpAddress, SetAddressResult), TELEPHONY_ERR_SUCCESS);
|
||||
mCoreService->simManager_ = nullptr;
|
||||
EXPECT_EQ(mCoreService->SetDefaultSmdpAddress(
|
||||
slotId, defaultSmdpAddress, SetAddressResult), TELEPHONY_ERR_LOCAL_PTR_NULL);
|
||||
}
|
||||
|
||||
HWTEST_F(EsimCoreServiceTest, IsEsimSupported_0001, Function | MediumTest | Level1)
|
||||
{
|
||||
std::shared_ptr<CoreService> mCoreService = std::make_shared<CoreService>();
|
||||
std::shared_ptr<TelRilManager> telRilManager = std::make_shared<TelRilManager>();
|
||||
mCoreService->simManager_ = std::make_shared<SimManager>(telRilManager);
|
||||
int32_t slotId = 0;
|
||||
EXPECT_FALSE(mCoreService->IsEsimSupported(slotId));
|
||||
mCoreService->simManager_ = nullptr;
|
||||
EXPECT_FALSE(mCoreService->IsEsimSupported(slotId));
|
||||
}
|
||||
|
||||
HWTEST_F(EsimCoreServiceTest, SendApduData_0001, Function | MediumTest | Level1)
|
||||
{
|
||||
std::shared_ptr<CoreService> mCoreService = std::make_shared<CoreService>();
|
||||
std::shared_ptr<TelRilManager> telRilManager = std::make_shared<TelRilManager>();
|
||||
mCoreService->simManager_ = std::make_shared<SimManager>(telRilManager);
|
||||
int32_t slotId = 0;
|
||||
std::u16string aid = Str8ToStr16("aid test");
|
||||
std::u16string apduData = Str8ToStr16("apduData test");
|
||||
ResponseEsimResult responseResult;
|
||||
EXPECT_NE(mCoreService->SendApduData(
|
||||
slotId, aid, apduData, responseResult), TELEPHONY_ERR_SUCCESS);
|
||||
mCoreService->simManager_ = nullptr;
|
||||
EXPECT_EQ(mCoreService->SendApduData(
|
||||
slotId, aid, apduData, responseResult), TELEPHONY_ERR_LOCAL_PTR_NULL);
|
||||
}
|
||||
|
||||
HWTEST_F(EsimCoreServiceTest, PrepareDownload_0001, Function | MediumTest | Level1)
|
||||
{
|
||||
std::shared_ptr<CoreService> mCoreService = std::make_shared<CoreService>();
|
||||
|
@ -20,13 +20,14 @@
|
||||
|
||||
#include "common_event_manager.h"
|
||||
#include "common_event_support.h"
|
||||
#include "gtest/gtest.h"
|
||||
#include "sim_file_manager.h"
|
||||
#include "tel_ril_manager.h"
|
||||
#include "gtest/gtest.h"
|
||||
|
||||
namespace OHOS {
|
||||
namespace Telephony {
|
||||
using namespace testing::ext;
|
||||
|
||||
class EsimFileManagerTest : public testing::Test {
|
||||
public:
|
||||
static void SetUpTestCase();
|
||||
@ -43,6 +44,269 @@ void EsimFileManagerTest::TearDown() {}
|
||||
|
||||
void EsimFileManagerTest::SetUpTestCase() {}
|
||||
|
||||
HWTEST_F(EsimFileManagerTest, GetEid_001, Function | MediumTest | Level2)
|
||||
{
|
||||
std::string expectedEid = "";
|
||||
std::shared_ptr<TelRilManager> telRilManager = std::make_shared<TelRilManager>();
|
||||
std::shared_ptr<Telephony::SimStateManager> simStateManager = std::make_shared<SimStateManager>(telRilManager);
|
||||
EventFwk::MatchingSkills matchingSkills;
|
||||
matchingSkills.AddEvent(EventFwk::CommonEventSupport::COMMON_EVENT_OPERATOR_CONFIG_CHANGED);
|
||||
EventFwk::CommonEventSubscribeInfo subcribeInfo(matchingSkills);
|
||||
SimFileManager simFileManager { subcribeInfo, std::weak_ptr<ITelRilManager>(telRilManager),
|
||||
std::weak_ptr<SimStateManager>(simStateManager) };
|
||||
simFileManager.eSimFile_ = std::make_shared<EsimFile>(simStateManager);
|
||||
EXPECT_EQ(simFileManager.GetEid(), Str8ToStr16(expectedEid));
|
||||
simFileManager.eSimFile_ = nullptr;
|
||||
EXPECT_EQ(simFileManager.GetEid(), u"");
|
||||
}
|
||||
|
||||
HWTEST_F(EsimFileManagerTest, GetEuiccProfileInfoList_001, Function | MediumTest | Level2)
|
||||
{
|
||||
std::string expectedEid = "12345";
|
||||
std::shared_ptr<TelRilManager> telRilManager = std::make_shared<TelRilManager>();
|
||||
std::shared_ptr<Telephony::SimStateManager> simStateManager = std::make_shared<SimStateManager>(telRilManager);
|
||||
EventFwk::MatchingSkills matchingSkills;
|
||||
matchingSkills.AddEvent(EventFwk::CommonEventSupport::COMMON_EVENT_OPERATOR_CONFIG_CHANGED);
|
||||
EventFwk::CommonEventSubscribeInfo subcribeInfo(matchingSkills);
|
||||
SimFileManager simFileManager { subcribeInfo, std::weak_ptr<ITelRilManager>(telRilManager),
|
||||
std::weak_ptr<SimStateManager>(simStateManager) };
|
||||
simFileManager.eSimFile_ = std::make_shared<EsimFile>(simStateManager);
|
||||
GetEuiccProfileInfoListResult eUiccRes = simFileManager.GetEuiccProfileInfoList();
|
||||
EXPECT_EQ(eUiccRes.result, ResultState::RESULT_OK);
|
||||
simFileManager.eSimFile_ = nullptr;
|
||||
eUiccRes = simFileManager.GetEuiccProfileInfoList();
|
||||
EXPECT_EQ(eUiccRes.result, ResultState::RESULT_OK);
|
||||
}
|
||||
|
||||
HWTEST_F(EsimFileManagerTest, GetEuiccInfo_001, Function | MediumTest | Level2)
|
||||
{
|
||||
std::string expectedEid = "12345";
|
||||
std::shared_ptr<TelRilManager> telRilManager = std::make_shared<TelRilManager>();
|
||||
std::shared_ptr<Telephony::SimStateManager> simStateManager = std::make_shared<SimStateManager>(telRilManager);
|
||||
EventFwk::MatchingSkills matchingSkills;
|
||||
matchingSkills.AddEvent(EventFwk::CommonEventSupport::COMMON_EVENT_OPERATOR_CONFIG_CHANGED);
|
||||
EventFwk::CommonEventSubscribeInfo subcribeInfo(matchingSkills);
|
||||
SimFileManager simFileManager { subcribeInfo, std::weak_ptr<ITelRilManager>(telRilManager),
|
||||
std::weak_ptr<SimStateManager>(simStateManager) };
|
||||
simFileManager.eSimFile_ = std::make_shared<EsimFile>(simStateManager);
|
||||
EuiccInfo eUiccInfo = simFileManager.GetEuiccInfo();
|
||||
EXPECT_EQ(eUiccInfo.osVersion, u"");
|
||||
simFileManager.eSimFile_ = nullptr;
|
||||
eUiccInfo = simFileManager.GetEuiccInfo();
|
||||
EXPECT_EQ(eUiccInfo.osVersion, u"");
|
||||
}
|
||||
|
||||
HWTEST_F(EsimFileManagerTest, DisableProfile_001, Function | MediumTest | Level2)
|
||||
{
|
||||
std::string expectedEid = "12345";
|
||||
std::shared_ptr<TelRilManager> telRilManager = std::make_shared<TelRilManager>();
|
||||
std::shared_ptr<Telephony::SimStateManager> simStateManager = std::make_shared<SimStateManager>(telRilManager);
|
||||
EventFwk::MatchingSkills matchingSkills;
|
||||
matchingSkills.AddEvent(EventFwk::CommonEventSupport::COMMON_EVENT_OPERATOR_CONFIG_CHANGED);
|
||||
EventFwk::CommonEventSubscribeInfo subcribeInfo(matchingSkills);
|
||||
SimFileManager simFileManager { subcribeInfo, std::weak_ptr<ITelRilManager>(telRilManager),
|
||||
std::weak_ptr<SimStateManager>(simStateManager) };
|
||||
simFileManager.eSimFile_ = std::make_shared<EsimFile>(simStateManager);
|
||||
int32_t portIndex = 0;
|
||||
std::u16string iccId = u"";
|
||||
ResultState res = simFileManager.DisableProfile(portIndex, iccId);
|
||||
EXPECT_NE(res, ResultState::RESULT_UNDEFINED_ERROR);
|
||||
simFileManager.eSimFile_ = nullptr;
|
||||
res = simFileManager.DisableProfile(portIndex, iccId);
|
||||
EXPECT_EQ(res, ResultState::RESULT_UNDEFINED_ERROR);
|
||||
}
|
||||
|
||||
HWTEST_F(EsimFileManagerTest, GetSmdsAddress_001, Function | MediumTest | Level2)
|
||||
{
|
||||
std::string expectedEid = "12345";
|
||||
std::shared_ptr<TelRilManager> telRilManager = std::make_shared<TelRilManager>();
|
||||
std::shared_ptr<Telephony::SimStateManager> simStateManager = std::make_shared<SimStateManager>(telRilManager);
|
||||
EventFwk::MatchingSkills matchingSkills;
|
||||
matchingSkills.AddEvent(EventFwk::CommonEventSupport::COMMON_EVENT_OPERATOR_CONFIG_CHANGED);
|
||||
EventFwk::CommonEventSubscribeInfo subcribeInfo(matchingSkills);
|
||||
SimFileManager simFileManager { subcribeInfo, std::weak_ptr<ITelRilManager>(telRilManager),
|
||||
std::weak_ptr<SimStateManager>(simStateManager) };
|
||||
simFileManager.eSimFile_ = std::make_shared<EsimFile>(simStateManager);
|
||||
int32_t portIndex = 0;
|
||||
std::u16string resStr = simFileManager.GetSmdsAddress(portIndex);
|
||||
EXPECT_EQ(resStr, u"");
|
||||
simFileManager.eSimFile_ = nullptr;
|
||||
resStr = simFileManager.GetSmdsAddress(portIndex);
|
||||
EXPECT_EQ(resStr, u"");
|
||||
}
|
||||
|
||||
HWTEST_F(EsimFileManagerTest, GetRulesAuthTable_001, Function | MediumTest | Level2)
|
||||
{
|
||||
std::string expectedEid = "12345";
|
||||
std::shared_ptr<TelRilManager> telRilManager = std::make_shared<TelRilManager>();
|
||||
std::shared_ptr<Telephony::SimStateManager> simStateManager = std::make_shared<SimStateManager>(telRilManager);
|
||||
EventFwk::MatchingSkills matchingSkills;
|
||||
matchingSkills.AddEvent(EventFwk::CommonEventSupport::COMMON_EVENT_OPERATOR_CONFIG_CHANGED);
|
||||
EventFwk::CommonEventSubscribeInfo subcribeInfo(matchingSkills);
|
||||
SimFileManager simFileManager { subcribeInfo, std::weak_ptr<ITelRilManager>(telRilManager),
|
||||
std::weak_ptr<SimStateManager>(simStateManager) };
|
||||
simFileManager.eSimFile_ = std::make_shared<EsimFile>(simStateManager);
|
||||
int32_t portIndex = 0;
|
||||
EuiccRulesAuthTable res = simFileManager.GetRulesAuthTable(portIndex);
|
||||
EXPECT_EQ(res.position, 0);
|
||||
simFileManager.eSimFile_ = nullptr;
|
||||
res = simFileManager.GetRulesAuthTable(portIndex);
|
||||
EXPECT_EQ(res.position, 0);
|
||||
}
|
||||
|
||||
HWTEST_F(EsimFileManagerTest, GetEuiccChallenge_001, Function | MediumTest | Level2)
|
||||
{
|
||||
std::string expectedEid = "12345";
|
||||
std::shared_ptr<TelRilManager> telRilManager = std::make_shared<TelRilManager>();
|
||||
std::shared_ptr<Telephony::SimStateManager> simStateManager = std::make_shared<SimStateManager>(telRilManager);
|
||||
EventFwk::MatchingSkills matchingSkills;
|
||||
matchingSkills.AddEvent(EventFwk::CommonEventSupport::COMMON_EVENT_OPERATOR_CONFIG_CHANGED);
|
||||
EventFwk::CommonEventSubscribeInfo subcribeInfo(matchingSkills);
|
||||
SimFileManager simFileManager { subcribeInfo, std::weak_ptr<ITelRilManager>(telRilManager),
|
||||
std::weak_ptr<SimStateManager>(simStateManager) };
|
||||
simFileManager.eSimFile_ = std::make_shared<EsimFile>(simStateManager);
|
||||
int32_t portIndex = 0;
|
||||
ResponseEsimResult res = simFileManager.GetEuiccChallenge(portIndex);
|
||||
EXPECT_EQ(res.resultCode, ResultState::RESULT_OK);
|
||||
simFileManager.eSimFile_ = nullptr;
|
||||
res = simFileManager.GetEuiccChallenge(portIndex);
|
||||
EXPECT_EQ(res.resultCode, ResultState::RESULT_OK);
|
||||
}
|
||||
|
||||
HWTEST_F(EsimFileManagerTest, RequestDefaultSmdpAddress_001, Function | MediumTest | Level2)
|
||||
{
|
||||
std::string expectedEid = "12345";
|
||||
std::shared_ptr<TelRilManager> telRilManager = std::make_shared<TelRilManager>();
|
||||
std::shared_ptr<Telephony::SimStateManager> simStateManager = std::make_shared<SimStateManager>(telRilManager);
|
||||
EventFwk::MatchingSkills matchingSkills;
|
||||
matchingSkills.AddEvent(EventFwk::CommonEventSupport::COMMON_EVENT_OPERATOR_CONFIG_CHANGED);
|
||||
EventFwk::CommonEventSubscribeInfo subcribeInfo(matchingSkills);
|
||||
SimFileManager simFileManager { subcribeInfo, std::weak_ptr<ITelRilManager>(telRilManager),
|
||||
std::weak_ptr<SimStateManager>(simStateManager) };
|
||||
simFileManager.eSimFile_ = std::make_shared<EsimFile>(simStateManager);
|
||||
std::u16string resStr = simFileManager.GetDefaultSmdpAddress();
|
||||
EXPECT_EQ(resStr, u"");
|
||||
simFileManager.eSimFile_ = nullptr;
|
||||
resStr = simFileManager.GetDefaultSmdpAddress();
|
||||
EXPECT_EQ(resStr, u"");
|
||||
}
|
||||
|
||||
HWTEST_F(EsimFileManagerTest, CancelSession_001, Function | MediumTest | Level2)
|
||||
{
|
||||
std::string expectedEid = "12345";
|
||||
std::shared_ptr<TelRilManager> telRilManager = std::make_shared<TelRilManager>();
|
||||
std::shared_ptr<Telephony::SimStateManager> simStateManager = std::make_shared<SimStateManager>(telRilManager);
|
||||
EventFwk::MatchingSkills matchingSkills;
|
||||
matchingSkills.AddEvent(EventFwk::CommonEventSupport::COMMON_EVENT_OPERATOR_CONFIG_CHANGED);
|
||||
EventFwk::CommonEventSubscribeInfo subcribeInfo(matchingSkills);
|
||||
SimFileManager simFileManager { subcribeInfo, std::weak_ptr<ITelRilManager>(telRilManager),
|
||||
std::weak_ptr<SimStateManager>(simStateManager) };
|
||||
simFileManager.eSimFile_ = std::make_shared<EsimFile>(simStateManager);
|
||||
std::u16string transactionId = u"";
|
||||
CancelReason cancelReason = CancelReason::CANCEL_REASON_END_USER_REJECTED;
|
||||
ResponseEsimResult res = simFileManager.CancelSession(transactionId, cancelReason);
|
||||
EXPECT_EQ(res.resultCode, ResultState::RESULT_OK);
|
||||
simFileManager.eSimFile_ = nullptr;
|
||||
res = simFileManager.CancelSession(transactionId, cancelReason);
|
||||
EXPECT_EQ(res.resultCode, ResultState::RESULT_OK);
|
||||
}
|
||||
|
||||
HWTEST_F(EsimFileManagerTest, GetProfile_001, Function | MediumTest | Level2)
|
||||
{
|
||||
std::string expectedEid = "12345";
|
||||
std::shared_ptr<TelRilManager> telRilManager = std::make_shared<TelRilManager>();
|
||||
std::shared_ptr<Telephony::SimStateManager> simStateManager = std::make_shared<SimStateManager>(telRilManager);
|
||||
EventFwk::MatchingSkills matchingSkills;
|
||||
matchingSkills.AddEvent(EventFwk::CommonEventSupport::COMMON_EVENT_OPERATOR_CONFIG_CHANGED);
|
||||
EventFwk::CommonEventSubscribeInfo subcribeInfo(matchingSkills);
|
||||
SimFileManager simFileManager { subcribeInfo, std::weak_ptr<ITelRilManager>(telRilManager),
|
||||
std::weak_ptr<SimStateManager>(simStateManager) };
|
||||
simFileManager.eSimFile_ = std::make_shared<EsimFile>(simStateManager);
|
||||
int32_t portIndex = 0;
|
||||
std::u16string iccId = u"";
|
||||
EuiccProfile res = simFileManager.GetProfile(portIndex, iccId);
|
||||
EXPECT_EQ(res.state, ProfileState::PROFILE_STATE_DISABLED);
|
||||
simFileManager.eSimFile_ = nullptr;
|
||||
res = simFileManager.GetProfile(portIndex, iccId);
|
||||
EXPECT_EQ(res.state, ProfileState::PROFILE_STATE_DISABLED);
|
||||
}
|
||||
|
||||
HWTEST_F(EsimFileManagerTest, ResetMemory_001, Function | MediumTest | Level2)
|
||||
{
|
||||
std::string expectedEid = "12345";
|
||||
std::shared_ptr<TelRilManager> telRilManager = std::make_shared<TelRilManager>();
|
||||
std::shared_ptr<Telephony::SimStateManager> simStateManager = std::make_shared<SimStateManager>(telRilManager);
|
||||
EventFwk::MatchingSkills matchingSkills;
|
||||
matchingSkills.AddEvent(EventFwk::CommonEventSupport::COMMON_EVENT_OPERATOR_CONFIG_CHANGED);
|
||||
EventFwk::CommonEventSubscribeInfo subcribeInfo(matchingSkills);
|
||||
SimFileManager simFileManager { subcribeInfo, std::weak_ptr<ITelRilManager>(telRilManager),
|
||||
std::weak_ptr<SimStateManager>(simStateManager) };
|
||||
simFileManager.eSimFile_ = std::make_shared<EsimFile>(simStateManager);
|
||||
ResetOption resetOption = ResetOption::DELETE_OPERATIONAL_PROFILES;
|
||||
ResultState res = simFileManager.ResetMemory(resetOption);
|
||||
EXPECT_NE(res, ResultState::RESULT_UNDEFINED_ERROR);
|
||||
simFileManager.eSimFile_ = nullptr;
|
||||
res = simFileManager.ResetMemory(resetOption);
|
||||
EXPECT_EQ(res, ResultState::RESULT_UNDEFINED_ERROR);
|
||||
}
|
||||
|
||||
HWTEST_F(EsimFileManagerTest, SetDefaultSmdpAddress_001, Function | MediumTest | Level2)
|
||||
{
|
||||
std::string expectedEid = "12345";
|
||||
std::shared_ptr<TelRilManager> telRilManager = std::make_shared<TelRilManager>();
|
||||
std::shared_ptr<Telephony::SimStateManager> simStateManager = std::make_shared<SimStateManager>(telRilManager);
|
||||
EventFwk::MatchingSkills matchingSkills;
|
||||
matchingSkills.AddEvent(EventFwk::CommonEventSupport::COMMON_EVENT_OPERATOR_CONFIG_CHANGED);
|
||||
EventFwk::CommonEventSubscribeInfo subcribeInfo(matchingSkills);
|
||||
SimFileManager simFileManager { subcribeInfo, std::weak_ptr<ITelRilManager>(telRilManager),
|
||||
std::weak_ptr<SimStateManager>(simStateManager) };
|
||||
simFileManager.eSimFile_ = std::make_shared<EsimFile>(simStateManager);
|
||||
std::u16string defaultSmdpAddress = u"";
|
||||
ResultState res = simFileManager.SetDefaultSmdpAddress(defaultSmdpAddress);
|
||||
EXPECT_NE(res, ResultState::RESULT_UNDEFINED_ERROR);
|
||||
simFileManager.eSimFile_ = nullptr;
|
||||
res = simFileManager.SetDefaultSmdpAddress(defaultSmdpAddress);
|
||||
EXPECT_EQ(res, ResultState::RESULT_UNDEFINED_ERROR);
|
||||
}
|
||||
|
||||
HWTEST_F(EsimFileManagerTest, IsEsimSupported_001, Function | MediumTest | Level2)
|
||||
{
|
||||
std::string expectedEid = "12345";
|
||||
std::shared_ptr<TelRilManager> telRilManager = std::make_shared<TelRilManager>();
|
||||
std::shared_ptr<Telephony::SimStateManager> simStateManager = std::make_shared<SimStateManager>(telRilManager);
|
||||
EventFwk::MatchingSkills matchingSkills;
|
||||
matchingSkills.AddEvent(EventFwk::CommonEventSupport::COMMON_EVENT_OPERATOR_CONFIG_CHANGED);
|
||||
EventFwk::CommonEventSubscribeInfo subcribeInfo(matchingSkills);
|
||||
SimFileManager simFileManager { subcribeInfo, std::weak_ptr<ITelRilManager>(telRilManager),
|
||||
std::weak_ptr<SimStateManager>(simStateManager) };
|
||||
simFileManager.eSimFile_ = std::make_shared<EsimFile>(simStateManager);
|
||||
bool res = simFileManager.IsEsimSupported();
|
||||
EXPECT_EQ(res, false);
|
||||
simFileManager.eSimFile_ = nullptr;
|
||||
res = simFileManager.IsEsimSupported();
|
||||
EXPECT_EQ(res, false);
|
||||
}
|
||||
|
||||
HWTEST_F(EsimFileManagerTest, SendApduData_001, Function | MediumTest | Level2)
|
||||
{
|
||||
std::string expectedEid = "12345";
|
||||
std::shared_ptr<TelRilManager> telRilManager = std::make_shared<TelRilManager>();
|
||||
std::shared_ptr<Telephony::SimStateManager> simStateManager = std::make_shared<SimStateManager>(telRilManager);
|
||||
EventFwk::MatchingSkills matchingSkills;
|
||||
matchingSkills.AddEvent(EventFwk::CommonEventSupport::COMMON_EVENT_OPERATOR_CONFIG_CHANGED);
|
||||
EventFwk::CommonEventSubscribeInfo subcribeInfo(matchingSkills);
|
||||
SimFileManager simFileManager { subcribeInfo, std::weak_ptr<ITelRilManager>(telRilManager),
|
||||
std::weak_ptr<SimStateManager>(simStateManager) };
|
||||
simFileManager.eSimFile_ = std::make_shared<EsimFile>(simStateManager);
|
||||
std::u16string aid = u"";
|
||||
std::u16string apduData = u"";
|
||||
ResponseEsimResult res = simFileManager.SendApduData(aid, apduData);
|
||||
EXPECT_EQ(res.resultCode, ResultState::RESULT_OK);
|
||||
simFileManager.eSimFile_ = nullptr;
|
||||
res = simFileManager.SendApduData(aid, apduData);
|
||||
EXPECT_EQ(res.resultCode, ResultState::RESULT_OK);
|
||||
}
|
||||
|
||||
HWTEST_F(EsimFileManagerTest, PrepareDownload_001, Function | MediumTest | Level2)
|
||||
{
|
||||
std::string expectedEid = "12345";
|
||||
|
@ -22,7 +22,6 @@
|
||||
#include "core_service.h"
|
||||
#include "core_service_client.h"
|
||||
#include "enum_convert.h"
|
||||
#include "gtest/gtest.h"
|
||||
#include "operator_config_cache.h"
|
||||
#include "operator_file_parser.h"
|
||||
#include "sim_manager.h"
|
||||
@ -32,6 +31,7 @@
|
||||
#include "tel_profile_util.h"
|
||||
#include "telephony_ext_wrapper.h"
|
||||
#include "tel_ril_manager.h"
|
||||
#include "gtest/gtest.h"
|
||||
|
||||
namespace OHOS {
|
||||
namespace Telephony {
|
||||
@ -52,6 +52,364 @@ void EsimManagerTest::TearDown() {}
|
||||
|
||||
void EsimManagerTest::SetUpTestCase() {}
|
||||
|
||||
HWTEST_F(EsimManagerTest, GetEid, Function | MediumTest | Level1)
|
||||
{
|
||||
int32_t slotId = 0;
|
||||
std::u16string eId;
|
||||
std::shared_ptr<TelRilManager> telRilManager = std::make_shared<TelRilManager>();
|
||||
std::shared_ptr<Telephony::SimManager> simManager = std::make_shared<SimManager>(telRilManager);
|
||||
int32_t ret = simManager->GetEid(slotId, eId);
|
||||
EXPECT_NE(ret, TELEPHONY_ERR_SUCCESS);
|
||||
std::shared_ptr<Telephony::SimStateManager> simStateManager = std::make_shared<SimStateManager>(telRilManager);
|
||||
simManager->simStateManager_.push_back(simStateManager);
|
||||
simManager->simStateManager_[slotId]->Init(slotId);
|
||||
simManager->simStateManager_[slotId]->simStateHandle_->iccState_.simStatus_ = -1;
|
||||
ret = simManager->GetEid(slotId, eId);
|
||||
EXPECT_EQ(ret, TELEPHONY_ERR_LOCAL_PTR_NULL);
|
||||
EventFwk::CommonEventSubscribeInfo sp;
|
||||
std::weak_ptr<Telephony::ITelRilManager> iTelRilManager = telRilManager;
|
||||
std::weak_ptr<Telephony::SimStateManager> state = simStateManager;
|
||||
std::shared_ptr<Telephony::SimFileManager> simFileManager =
|
||||
std::make_shared<SimFileManager>(sp, iTelRilManager, state);
|
||||
simManager->simFileManager_.push_back(simFileManager);
|
||||
simManager->simFileManager_[slotId]->Init(slotId);
|
||||
ret = simManager->GetEid(slotId, eId);
|
||||
EXPECT_EQ(ret, TELEPHONY_ERR_SUCCESS);
|
||||
}
|
||||
|
||||
HWTEST_F(EsimManagerTest, GetEuiccProfileInfoList, Function | MediumTest | Level1)
|
||||
{
|
||||
int32_t slotId = 0;
|
||||
GetEuiccProfileInfoListResult result;
|
||||
std::shared_ptr<TelRilManager> telRilManager = std::make_shared<TelRilManager>();
|
||||
std::shared_ptr<Telephony::SimManager> simManager = std::make_shared<SimManager>(telRilManager);
|
||||
int32_t ret = simManager->GetEuiccProfileInfoList(slotId, result);
|
||||
EXPECT_NE(ret, TELEPHONY_ERR_SUCCESS);
|
||||
std::shared_ptr<Telephony::SimStateManager> simStateManager = std::make_shared<SimStateManager>(telRilManager);
|
||||
simManager->simStateManager_.push_back(simStateManager);
|
||||
simManager->simStateManager_[slotId]->Init(slotId);
|
||||
simManager->simStateManager_[slotId]->simStateHandle_->iccState_.simStatus_ = -1;
|
||||
ret = simManager->GetEuiccProfileInfoList(slotId, result);
|
||||
EXPECT_EQ(ret, TELEPHONY_ERR_LOCAL_PTR_NULL);
|
||||
EventFwk::CommonEventSubscribeInfo sp;
|
||||
std::weak_ptr<Telephony::ITelRilManager> iTelRilManager = telRilManager;
|
||||
std::weak_ptr<Telephony::SimStateManager> state = simStateManager;
|
||||
std::shared_ptr<Telephony::SimFileManager> simFileManager =
|
||||
std::make_shared<SimFileManager>(sp, iTelRilManager, state);
|
||||
simManager->simFileManager_.push_back(simFileManager);
|
||||
simManager->simFileManager_[slotId]->Init(slotId);
|
||||
ret = simManager->GetEuiccProfileInfoList(slotId, result);
|
||||
EXPECT_EQ(ret, TELEPHONY_ERR_SUCCESS);
|
||||
}
|
||||
|
||||
HWTEST_F(EsimManagerTest, GetEuiccInfo, Function | MediumTest | Level1)
|
||||
{
|
||||
int32_t slotId = 0;
|
||||
EuiccInfo eUiccInfo;
|
||||
std::shared_ptr<TelRilManager> telRilManager = std::make_shared<TelRilManager>();
|
||||
std::shared_ptr<Telephony::SimManager> simManager = std::make_shared<SimManager>(telRilManager);
|
||||
int32_t ret = simManager->GetEuiccInfo(slotId, eUiccInfo);
|
||||
EXPECT_NE(ret, TELEPHONY_ERR_SUCCESS);
|
||||
std::shared_ptr<Telephony::SimStateManager> simStateManager = std::make_shared<SimStateManager>(telRilManager);
|
||||
simManager->simStateManager_.push_back(simStateManager);
|
||||
simManager->simStateManager_[slotId]->Init(slotId);
|
||||
simManager->simStateManager_[slotId]->simStateHandle_->iccState_.simStatus_ = -1;
|
||||
ret = simManager->GetEuiccInfo(slotId, eUiccInfo);
|
||||
EXPECT_EQ(ret, TELEPHONY_ERR_LOCAL_PTR_NULL);
|
||||
EventFwk::CommonEventSubscribeInfo sp;
|
||||
std::weak_ptr<Telephony::ITelRilManager> iTelRilManager = telRilManager;
|
||||
std::weak_ptr<Telephony::SimStateManager> state = simStateManager;
|
||||
std::shared_ptr<Telephony::SimFileManager> simFileManager =
|
||||
std::make_shared<SimFileManager>(sp, iTelRilManager, state);
|
||||
simManager->simFileManager_.push_back(simFileManager);
|
||||
simManager->simFileManager_[slotId]->Init(slotId);
|
||||
ret = simManager->GetEuiccInfo(slotId, eUiccInfo);
|
||||
EXPECT_EQ(ret, TELEPHONY_ERR_SUCCESS);
|
||||
}
|
||||
|
||||
HWTEST_F(EsimManagerTest, DisableProfile, Function | MediumTest | Level1)
|
||||
{
|
||||
int32_t slotId = 0;
|
||||
int32_t portIndex = 0;
|
||||
std::u16string iccId = Str8ToStr16("98760000000000543210");
|
||||
bool refresh = true;
|
||||
ResultState DisableProfileResult;
|
||||
std::shared_ptr<TelRilManager> telRilManager = std::make_shared<TelRilManager>();
|
||||
std::shared_ptr<Telephony::SimManager> simManager = std::make_shared<SimManager>(telRilManager);
|
||||
int32_t ret = simManager->DisableProfile(slotId, portIndex, iccId, refresh, DisableProfileResult);
|
||||
EXPECT_NE(ret, TELEPHONY_ERR_SUCCESS);
|
||||
|
||||
std::shared_ptr<Telephony::SimStateManager> simStateManager = std::make_shared<SimStateManager>(telRilManager);
|
||||
simManager->simStateManager_.push_back(simStateManager);
|
||||
simManager->simStateManager_[slotId]->Init(slotId);
|
||||
simManager->simStateManager_[slotId]->simStateHandle_->iccState_.simStatus_ = -1;
|
||||
ret = simManager->DisableProfile(slotId, portIndex, iccId, refresh, DisableProfileResult);
|
||||
EXPECT_EQ(ret, TELEPHONY_ERR_LOCAL_PTR_NULL);
|
||||
|
||||
EventFwk::CommonEventSubscribeInfo sp;
|
||||
std::weak_ptr<Telephony::ITelRilManager> iTelRilManager = telRilManager;
|
||||
std::weak_ptr<Telephony::SimStateManager> state = simStateManager;
|
||||
std::shared_ptr<Telephony::SimFileManager> simFileManager =
|
||||
std::make_shared<SimFileManager>(sp, iTelRilManager, state);
|
||||
simManager->simFileManager_.push_back(simFileManager);
|
||||
simManager->simFileManager_[slotId]->Init(slotId);
|
||||
ret = simManager->DisableProfile(slotId, portIndex, iccId, refresh, DisableProfileResult);
|
||||
EXPECT_EQ(ret, TELEPHONY_ERR_SUCCESS);
|
||||
}
|
||||
|
||||
HWTEST_F(EsimManagerTest, GetSmdsAddress, Function | MediumTest | Level1)
|
||||
{
|
||||
int32_t slotId = 0;
|
||||
int32_t portIndex = 0;
|
||||
std::u16string smdsAddress;
|
||||
std::shared_ptr<TelRilManager> telRilManager = std::make_shared<TelRilManager>();
|
||||
std::shared_ptr<Telephony::SimManager> simManager = std::make_shared<SimManager>(telRilManager);
|
||||
int32_t ret = simManager->GetSmdsAddress(slotId, portIndex, smdsAddress);
|
||||
EXPECT_NE(ret, TELEPHONY_ERR_SUCCESS);
|
||||
|
||||
std::shared_ptr<Telephony::SimStateManager> simStateManager = std::make_shared<SimStateManager>(telRilManager);
|
||||
simManager->simStateManager_.push_back(simStateManager);
|
||||
simManager->simStateManager_[slotId]->Init(slotId);
|
||||
simManager->simStateManager_[slotId]->simStateHandle_->iccState_.simStatus_ = -1;
|
||||
ret = simManager->GetSmdsAddress(slotId, portIndex, smdsAddress);
|
||||
EXPECT_EQ(ret, TELEPHONY_ERR_LOCAL_PTR_NULL);
|
||||
|
||||
EventFwk::CommonEventSubscribeInfo sp;
|
||||
std::weak_ptr<Telephony::ITelRilManager> iTelRilManager = telRilManager;
|
||||
std::weak_ptr<Telephony::SimStateManager> state = simStateManager;
|
||||
std::shared_ptr<Telephony::SimFileManager> simFileManager =
|
||||
std::make_shared<SimFileManager>(sp, iTelRilManager, state);
|
||||
simManager->simFileManager_.push_back(simFileManager);
|
||||
simManager->simFileManager_[slotId]->Init(slotId);
|
||||
ret = simManager->GetSmdsAddress(slotId, portIndex, smdsAddress);
|
||||
EXPECT_EQ(ret, TELEPHONY_ERR_SUCCESS);
|
||||
}
|
||||
|
||||
HWTEST_F(EsimManagerTest, GetRulesAuthTable, Function | MediumTest | Level1)
|
||||
{
|
||||
int32_t slotId = 0;
|
||||
int32_t portIndex = 0;
|
||||
EuiccRulesAuthTable eUiccRulesAuthTable;
|
||||
std::shared_ptr<TelRilManager> telRilManager = std::make_shared<TelRilManager>();
|
||||
std::shared_ptr<Telephony::SimManager> simManager = std::make_shared<SimManager>(telRilManager);
|
||||
int32_t ret = simManager->GetRulesAuthTable(slotId, portIndex, eUiccRulesAuthTable);
|
||||
EXPECT_NE(ret, TELEPHONY_ERR_SUCCESS);
|
||||
|
||||
std::shared_ptr<Telephony::SimStateManager> simStateManager = std::make_shared<SimStateManager>(telRilManager);
|
||||
simManager->simStateManager_.push_back(simStateManager);
|
||||
simManager->simStateManager_[slotId]->Init(slotId);
|
||||
simManager->simStateManager_[slotId]->simStateHandle_->iccState_.simStatus_ = -1;
|
||||
ret = simManager->GetRulesAuthTable(slotId, portIndex, eUiccRulesAuthTable);
|
||||
EXPECT_EQ(ret, TELEPHONY_ERR_LOCAL_PTR_NULL);
|
||||
|
||||
EventFwk::CommonEventSubscribeInfo sp;
|
||||
std::weak_ptr<Telephony::ITelRilManager> iTelRilManager = telRilManager;
|
||||
std::weak_ptr<Telephony::SimStateManager> state = simStateManager;
|
||||
std::shared_ptr<Telephony::SimFileManager> simFileManager =
|
||||
std::make_shared<SimFileManager>(sp, iTelRilManager, state);
|
||||
simManager->simFileManager_.push_back(simFileManager);
|
||||
simManager->simFileManager_[slotId]->Init(slotId);
|
||||
ret = simManager->GetRulesAuthTable(slotId, portIndex, eUiccRulesAuthTable);
|
||||
EXPECT_EQ(ret, TELEPHONY_ERR_SUCCESS);
|
||||
}
|
||||
|
||||
HWTEST_F(EsimManagerTest, GetEuiccChallenge, Function | MediumTest | Level1)
|
||||
{
|
||||
int32_t slotId = 0;
|
||||
int32_t portIndex = 0;
|
||||
ResponseEsimResult responseResult;
|
||||
std::shared_ptr<TelRilManager> telRilManager = std::make_shared<TelRilManager>();
|
||||
std::shared_ptr<Telephony::SimManager> simManager = std::make_shared<SimManager>(telRilManager);
|
||||
int32_t ret = simManager->GetEuiccChallenge(slotId, portIndex, responseResult);
|
||||
EXPECT_NE(ret, TELEPHONY_ERR_SUCCESS);
|
||||
|
||||
std::shared_ptr<Telephony::SimStateManager> simStateManager = std::make_shared<SimStateManager>(telRilManager);
|
||||
simManager->simStateManager_.push_back(simStateManager);
|
||||
simManager->simStateManager_[slotId]->Init(slotId);
|
||||
simManager->simStateManager_[slotId]->simStateHandle_->iccState_.simStatus_ = -1;
|
||||
ret = simManager->GetEuiccChallenge(slotId, portIndex, responseResult);
|
||||
EXPECT_EQ(ret, TELEPHONY_ERR_LOCAL_PTR_NULL);
|
||||
|
||||
EventFwk::CommonEventSubscribeInfo sp;
|
||||
std::weak_ptr<Telephony::ITelRilManager> iTelRilManager = telRilManager;
|
||||
std::weak_ptr<Telephony::SimStateManager> state = simStateManager;
|
||||
std::shared_ptr<Telephony::SimFileManager> simFileManager =
|
||||
std::make_shared<SimFileManager>(sp, iTelRilManager, state);
|
||||
simManager->simFileManager_.push_back(simFileManager);
|
||||
simManager->simFileManager_[slotId]->Init(slotId);
|
||||
ret = simManager->GetEuiccChallenge(slotId, portIndex, responseResult);
|
||||
EXPECT_EQ(ret, TELEPHONY_ERR_SUCCESS);
|
||||
}
|
||||
|
||||
HWTEST_F(EsimManagerTest, GetDefaultSmdpAddress, Function | MediumTest | Level1)
|
||||
{
|
||||
int32_t slotId = 0;
|
||||
std::u16string actualAddress;
|
||||
std::shared_ptr<TelRilManager> telRilManager = std::make_shared<TelRilManager>();
|
||||
std::shared_ptr<Telephony::SimManager> simManager = std::make_shared<SimManager>(telRilManager);
|
||||
int32_t ret = simManager->GetDefaultSmdpAddress(slotId, actualAddress);
|
||||
EXPECT_NE(ret, TELEPHONY_ERR_SUCCESS);
|
||||
std::shared_ptr<Telephony::SimStateManager> simStateManager = std::make_shared<SimStateManager>(telRilManager);
|
||||
simManager->simStateManager_.push_back(simStateManager);
|
||||
simManager->simStateManager_[slotId]->Init(slotId);
|
||||
simManager->simStateManager_[slotId]->simStateHandle_->iccState_.simStatus_ = -1;
|
||||
ret = simManager->GetDefaultSmdpAddress(slotId, actualAddress);
|
||||
EXPECT_EQ(ret, TELEPHONY_ERR_LOCAL_PTR_NULL);
|
||||
EventFwk::CommonEventSubscribeInfo sp;
|
||||
std::weak_ptr<Telephony::ITelRilManager> iTelRilManager = telRilManager;
|
||||
std::weak_ptr<Telephony::SimStateManager> state = simStateManager;
|
||||
std::shared_ptr<Telephony::SimFileManager> simFileManager =
|
||||
std::make_shared<SimFileManager>(sp, iTelRilManager, state);
|
||||
simManager->simFileManager_.push_back(simFileManager);
|
||||
simManager->simFileManager_[slotId]->Init(slotId);
|
||||
ret = simManager->GetDefaultSmdpAddress(slotId, actualAddress);
|
||||
EXPECT_EQ(ret, TELEPHONY_ERR_SUCCESS);
|
||||
}
|
||||
|
||||
HWTEST_F(EsimManagerTest, CancelSession, Function | MediumTest | Level1)
|
||||
{
|
||||
int32_t slotId = 0;
|
||||
std::u16string transactionId = Str8ToStr16("A1B2C3");
|
||||
const CancelReason cancelReason = CancelReason::CANCEL_REASON_POSTPONED;
|
||||
ResponseEsimResult responseResult;
|
||||
std::shared_ptr<TelRilManager> telRilManager = std::make_shared<TelRilManager>();
|
||||
std::shared_ptr<Telephony::SimManager> simManager = std::make_shared<SimManager>(telRilManager);
|
||||
int32_t ret = simManager->CancelSession(slotId, transactionId, cancelReason, responseResult);
|
||||
EXPECT_NE(ret, TELEPHONY_ERR_SUCCESS);
|
||||
std::shared_ptr<Telephony::SimStateManager> simStateManager =
|
||||
std::make_shared<SimStateManager>(telRilManager);
|
||||
simManager->simStateManager_.push_back(simStateManager);
|
||||
simManager->simStateManager_[slotId]->Init(slotId);
|
||||
simManager->simStateManager_[slotId]->simStateHandle_->iccState_.simStatus_ = -1;
|
||||
ret = simManager->CancelSession(slotId, transactionId, cancelReason, responseResult);
|
||||
EXPECT_EQ(ret, TELEPHONY_ERR_LOCAL_PTR_NULL);
|
||||
EventFwk::CommonEventSubscribeInfo sp;
|
||||
std::weak_ptr<Telephony::ITelRilManager> iTelRilManager = telRilManager;
|
||||
std::weak_ptr<Telephony::SimStateManager> state = simStateManager;
|
||||
std::shared_ptr<Telephony::SimFileManager> simFileManager =
|
||||
std::make_shared<SimFileManager>(sp, iTelRilManager, state);
|
||||
simManager->simFileManager_.push_back(simFileManager);
|
||||
simManager->simFileManager_[slotId]->Init(slotId);
|
||||
ret = simManager->CancelSession(slotId, transactionId, cancelReason, responseResult);
|
||||
EXPECT_EQ(ret, TELEPHONY_ERR_SUCCESS);
|
||||
}
|
||||
|
||||
HWTEST_F(EsimManagerTest, GetProfile, Function | MediumTest | Level1)
|
||||
{
|
||||
int32_t slotId = 0;
|
||||
int32_t portIndex = 0;
|
||||
std::u16string iccId = Str8ToStr16("5A0A89670000000000216954");
|
||||
EuiccProfile eUiccProfile;
|
||||
std::shared_ptr<TelRilManager> telRilManager = std::make_shared<TelRilManager>();
|
||||
std::shared_ptr<Telephony::SimManager> simManager = std::make_shared<SimManager>(telRilManager);
|
||||
int32_t ret = simManager->GetProfile(slotId, portIndex, iccId, eUiccProfile);
|
||||
EXPECT_NE(ret, TELEPHONY_ERR_SUCCESS);
|
||||
|
||||
std::shared_ptr<Telephony::SimStateManager> simStateManager = std::make_shared<SimStateManager>(telRilManager);
|
||||
simManager->simStateManager_.push_back(simStateManager);
|
||||
simManager->simStateManager_[slotId]->Init(slotId);
|
||||
simManager->simStateManager_[slotId]->simStateHandle_->iccState_.simStatus_ = -1;
|
||||
ret = simManager->GetProfile(slotId, portIndex, iccId, eUiccProfile);
|
||||
EXPECT_EQ(ret, TELEPHONY_ERR_LOCAL_PTR_NULL);
|
||||
|
||||
EventFwk::CommonEventSubscribeInfo sp;
|
||||
std::weak_ptr<Telephony::ITelRilManager> iTelRilManager = telRilManager;
|
||||
std::weak_ptr<Telephony::SimStateManager> state = simStateManager;
|
||||
std::shared_ptr<Telephony::SimFileManager> simFileManager =
|
||||
std::make_shared<SimFileManager>(sp, iTelRilManager, state);
|
||||
simManager->simFileManager_.push_back(simFileManager);
|
||||
simManager->simFileManager_[slotId]->Init(slotId);
|
||||
ret = simManager->GetProfile(slotId, portIndex, iccId, eUiccProfile);
|
||||
EXPECT_EQ(ret, TELEPHONY_ERR_SUCCESS);
|
||||
}
|
||||
|
||||
HWTEST_F(EsimManagerTest, ResetMemory, Function | MediumTest | Level1)
|
||||
{
|
||||
int32_t slotId = 0;
|
||||
ResultState ResetMemoryResult;
|
||||
const ResetOption resetOption = ResetOption::DELETE_OPERATIONAL_PROFILES;
|
||||
std::shared_ptr<TelRilManager> telRilManager = std::make_shared<TelRilManager>();
|
||||
std::shared_ptr<Telephony::SimManager> simManager = std::make_shared<SimManager>(telRilManager);
|
||||
int32_t ret = simManager->ResetMemory(slotId, resetOption, ResetMemoryResult);
|
||||
EXPECT_NE(ret, TELEPHONY_ERR_SUCCESS);
|
||||
std::shared_ptr<Telephony::SimStateManager> simStateManager = std::make_shared<SimStateManager>(telRilManager);
|
||||
simManager->simStateManager_.push_back(simStateManager);
|
||||
simManager->simStateManager_[slotId]->Init(slotId);
|
||||
simManager->simStateManager_[slotId]->simStateHandle_->iccState_.simStatus_ = -1;
|
||||
ret = simManager->ResetMemory(slotId, resetOption, ResetMemoryResult);
|
||||
EXPECT_EQ(ret, TELEPHONY_ERR_LOCAL_PTR_NULL);
|
||||
EventFwk::CommonEventSubscribeInfo sp;
|
||||
std::weak_ptr<Telephony::ITelRilManager> iTelRilManager = telRilManager;
|
||||
std::weak_ptr<Telephony::SimStateManager> state = simStateManager;
|
||||
std::shared_ptr<Telephony::SimFileManager> simFileManager =
|
||||
std::make_shared<SimFileManager>(sp, iTelRilManager, state);
|
||||
simManager->simFileManager_.push_back(simFileManager);
|
||||
simManager->simFileManager_[slotId]->Init(slotId);
|
||||
ret = simManager->ResetMemory(slotId, resetOption, ResetMemoryResult);
|
||||
EXPECT_EQ(ret, TELEPHONY_ERR_SUCCESS);
|
||||
}
|
||||
|
||||
HWTEST_F(EsimManagerTest, SetDefaultSmdpAddress, Function | MediumTest | Level1)
|
||||
{
|
||||
int32_t slotId = 0;
|
||||
std::u16string defaultSmdpAddress = Str8ToStr16("test.com");
|
||||
ResultState SetAddressResult;
|
||||
std::shared_ptr<TelRilManager> telRilManager = std::make_shared<TelRilManager>();
|
||||
std::shared_ptr<Telephony::SimManager> simManager = std::make_shared<SimManager>(telRilManager);
|
||||
int32_t ret = simManager->SetDefaultSmdpAddress(slotId, defaultSmdpAddress, SetAddressResult);
|
||||
EXPECT_NE(ret, TELEPHONY_ERR_SUCCESS);
|
||||
std::shared_ptr<Telephony::SimStateManager> simStateManager = std::make_shared<SimStateManager>(telRilManager);
|
||||
simManager->simStateManager_.push_back(simStateManager);
|
||||
simManager->simStateManager_[slotId]->Init(slotId);
|
||||
simManager->simStateManager_[slotId]->simStateHandle_->iccState_.simStatus_ = -1;
|
||||
ret = simManager->SetDefaultSmdpAddress(slotId, defaultSmdpAddress, SetAddressResult);
|
||||
EXPECT_EQ(ret, TELEPHONY_ERR_LOCAL_PTR_NULL);
|
||||
EventFwk::CommonEventSubscribeInfo sp;
|
||||
std::weak_ptr<Telephony::ITelRilManager> iTelRilManager = telRilManager;
|
||||
std::weak_ptr<Telephony::SimStateManager> state = simStateManager;
|
||||
std::shared_ptr<Telephony::SimFileManager> simFileManager =
|
||||
std::make_shared<SimFileManager>(sp, iTelRilManager, state);
|
||||
simManager->simFileManager_.push_back(simFileManager);
|
||||
simManager->simFileManager_[slotId]->Init(slotId);
|
||||
ret = simManager->SetDefaultSmdpAddress(slotId, defaultSmdpAddress, SetAddressResult);
|
||||
EXPECT_EQ(ret, TELEPHONY_ERR_SUCCESS);
|
||||
}
|
||||
|
||||
HWTEST_F(EsimManagerTest, IsEsimSupported, Function | MediumTest | Level1)
|
||||
{
|
||||
int32_t slotId = 0;
|
||||
std::shared_ptr<TelRilManager> telRilManager = std::make_shared<TelRilManager>();
|
||||
std::shared_ptr<Telephony::SimManager> simManager = std::make_shared<SimManager>(telRilManager);
|
||||
EXPECT_FALSE(simManager->IsEsimSupported(slotId));
|
||||
}
|
||||
|
||||
HWTEST_F(EsimManagerTest, SendApduData, Function | MediumTest | Level1)
|
||||
{
|
||||
int32_t slotId = 0;
|
||||
std::u16string aid = Str8ToStr16("aid test");
|
||||
std::u16string apduData = Str8ToStr16("apduData test");
|
||||
ResponseEsimResult responseResult;
|
||||
std::shared_ptr<TelRilManager> telRilManager = std::make_shared<TelRilManager>();
|
||||
std::shared_ptr<Telephony::SimManager> simManager = std::make_shared<SimManager>(telRilManager);
|
||||
int32_t ret = simManager->SendApduData(slotId, aid, apduData, responseResult);
|
||||
EXPECT_NE(ret, TELEPHONY_ERR_SUCCESS);
|
||||
std::shared_ptr<Telephony::SimStateManager> simStateManager = std::make_shared<SimStateManager>(telRilManager);
|
||||
simManager->simStateManager_.push_back(simStateManager);
|
||||
simManager->simStateManager_[slotId]->Init(slotId);
|
||||
simManager->simStateManager_[slotId]->simStateHandle_->iccState_.simStatus_ = -1;
|
||||
ret = simManager->SendApduData(slotId, aid, apduData, responseResult);
|
||||
EXPECT_EQ(ret, TELEPHONY_ERR_LOCAL_PTR_NULL);
|
||||
EventFwk::CommonEventSubscribeInfo sp;
|
||||
std::weak_ptr<Telephony::ITelRilManager> iTelRilManager = telRilManager;
|
||||
std::weak_ptr<Telephony::SimStateManager> state = simStateManager;
|
||||
std::shared_ptr<Telephony::SimFileManager> simFileManager =
|
||||
std::make_shared<SimFileManager>(sp, iTelRilManager, state);
|
||||
simManager->simFileManager_.push_back(simFileManager);
|
||||
simManager->simFileManager_[slotId]->Init(slotId);
|
||||
ret = simManager->SendApduData(slotId, aid, apduData, responseResult);
|
||||
EXPECT_EQ(ret, TELEPHONY_ERR_SUCCESS);
|
||||
}
|
||||
|
||||
HWTEST_F(EsimManagerTest, PrepareDownload, Function | MediumTest | Level1)
|
||||
{
|
||||
int32_t slotId = 0;
|
||||
|
315
test/unittest/esim_gtest/esim_service_client_branch_test.cpp
Normal file
315
test/unittest/esim_gtest/esim_service_client_branch_test.cpp
Normal file
@ -0,0 +1,315 @@
|
||||
/*
|
||||
* Copyright (C) 2024 Huawei Device Co., Ltd.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#define private public
|
||||
#define protected public
|
||||
|
||||
#include "esim_mock_iremote_object.h"
|
||||
#include "esim_service_client.h"
|
||||
#include "esim_state_type.h"
|
||||
#include "if_system_ability_manager_mock.h"
|
||||
#include "iservice_registry.h"
|
||||
#include "telephony_errors.h"
|
||||
#include "telephony_log_wrapper.h"
|
||||
|
||||
#include "gtest/gtest.h"
|
||||
|
||||
using namespace testing;
|
||||
using namespace testing::ext;
|
||||
|
||||
namespace OHOS {
|
||||
namespace Telephony {
|
||||
constexpr int32_t SLOT_ID = 0;
|
||||
class EsimServiceClientBranchTest : public testing::Test {
|
||||
public:
|
||||
static void SetUpTestCase();
|
||||
static void TearDownTestCase();
|
||||
void SetUp();
|
||||
void TearDown();
|
||||
|
||||
static inline std::shared_ptr<ISystemAbilityManagerMock> samgr = std::make_shared<ISystemAbilityManagerMock>();
|
||||
};
|
||||
|
||||
void EsimServiceClientBranchTest::SetUpTestCase()
|
||||
{
|
||||
SystemAbilityManagerClient::GetInstance().systemAbilityManager_ = sptr<ISystemAbilityManager>(samgr.get());
|
||||
}
|
||||
|
||||
void EsimServiceClientBranchTest::TearDownTestCase()
|
||||
{
|
||||
samgr = nullptr;
|
||||
SystemAbilityManagerClient::GetInstance().systemAbilityManager_ = nullptr;
|
||||
}
|
||||
|
||||
void EsimServiceClientBranchTest::SetUp() {}
|
||||
|
||||
void EsimServiceClientBranchTest::TearDown() {}
|
||||
|
||||
HWTEST_F(EsimServiceClientBranchTest, GetEid_0001, Function | MediumTest | Level1)
|
||||
{
|
||||
std::string eId;
|
||||
EXPECT_CALL(*samgr, LoadSystemAbility(testing::_,
|
||||
testing::A<const sptr<ISystemAbilityLoadCallback>&>())).WillOnce(testing::Return(-1));
|
||||
int32_t result = EsimServiceClient::GetInstance().GetEid(SLOT_ID, eId);
|
||||
EXPECT_EQ(result, TELEPHONY_ERR_IPC_CONNECT_STUB_FAIL);
|
||||
}
|
||||
|
||||
HWTEST_F(EsimServiceClientBranchTest, GetOsuStatus_0001, Function | MediumTest | Level1)
|
||||
{
|
||||
int32_t osuStatus;
|
||||
EXPECT_CALL(*samgr, LoadSystemAbility(testing::_,
|
||||
testing::A<const sptr<ISystemAbilityLoadCallback>&>())).WillOnce(testing::Return(-1));
|
||||
int32_t result = EsimServiceClient::GetInstance().GetOsuStatus(SLOT_ID, osuStatus);
|
||||
EXPECT_EQ(result, TELEPHONY_ERR_IPC_CONNECT_STUB_FAIL);
|
||||
}
|
||||
|
||||
HWTEST_F(EsimServiceClientBranchTest, StartOsu_0001, Function | MediumTest | Level1)
|
||||
{
|
||||
int32_t startOsuResult;
|
||||
|
||||
EXPECT_CALL(*samgr, LoadSystemAbility(testing::_,
|
||||
testing::A<const sptr<ISystemAbilityLoadCallback>&>())).WillOnce(testing::Return(-1));
|
||||
int32_t result = EsimServiceClient::GetInstance().StartOsu(SLOT_ID, startOsuResult);
|
||||
EXPECT_EQ(result, TELEPHONY_ERR_IPC_CONNECT_STUB_FAIL);
|
||||
}
|
||||
|
||||
HWTEST_F(EsimServiceClientBranchTest, GetDownloadableProfileMetadata_0001, Function | MediumTest | Level1)
|
||||
{
|
||||
int32_t portIndex = 0;
|
||||
DownloadableProfile profile;
|
||||
bool forceDeactivateSim = false;
|
||||
GetDownloadableProfileMetadataResult profileMetadataResult;
|
||||
|
||||
EXPECT_CALL(*samgr, LoadSystemAbility(testing::_,
|
||||
testing::A<const sptr<ISystemAbilityLoadCallback>&>())).WillOnce(testing::Return(-1));
|
||||
int32_t result = EsimServiceClient::GetInstance().GetDownloadableProfileMetadata(
|
||||
SLOT_ID, portIndex, profile, forceDeactivateSim, profileMetadataResult);
|
||||
EXPECT_EQ(result, TELEPHONY_ERR_IPC_CONNECT_STUB_FAIL);
|
||||
}
|
||||
|
||||
HWTEST_F(EsimServiceClientBranchTest, GetDownloadableProfiles_0001, Function | MediumTest | Level1)
|
||||
{
|
||||
bool forceDeactivateSim = false;
|
||||
int32_t portIndex = 0;
|
||||
GetDownloadableProfilesResult profileListResult;
|
||||
|
||||
EXPECT_CALL(*samgr, LoadSystemAbility(testing::_,
|
||||
testing::A<const sptr<ISystemAbilityLoadCallback>&>())).WillOnce(testing::Return(-1));
|
||||
int32_t result = EsimServiceClient::GetInstance().GetDownloadableProfiles(
|
||||
SLOT_ID, portIndex, forceDeactivateSim, profileListResult);
|
||||
EXPECT_EQ(result, TELEPHONY_ERR_IPC_CONNECT_STUB_FAIL);
|
||||
}
|
||||
|
||||
HWTEST_F(EsimServiceClientBranchTest, DownloadProfile_0001, Function | MediumTest | Level1)
|
||||
{
|
||||
DownloadProfileConfigInfo configInfo;
|
||||
DownloadableProfile profile;
|
||||
DownloadProfileResult downloadProfileResult;
|
||||
|
||||
EXPECT_CALL(*samgr, LoadSystemAbility(testing::_,
|
||||
testing::A<const sptr<ISystemAbilityLoadCallback>&>())).WillOnce(testing::Return(-1));
|
||||
int32_t result = EsimServiceClient::GetInstance().DownloadProfile(
|
||||
SLOT_ID, configInfo, profile, downloadProfileResult);
|
||||
EXPECT_EQ(result, TELEPHONY_ERR_IPC_CONNECT_STUB_FAIL);
|
||||
}
|
||||
|
||||
HWTEST_F(EsimServiceClientBranchTest, GetEuiccProfileInfoList_0001, Function | MediumTest | Level1)
|
||||
{
|
||||
GetEuiccProfileInfoListResult euiccProfileInfoList;
|
||||
|
||||
EXPECT_CALL(*samgr, LoadSystemAbility(testing::_,
|
||||
testing::A<const sptr<ISystemAbilityLoadCallback>&>())).WillOnce(testing::Return(-1));
|
||||
int32_t result = EsimServiceClient::GetInstance().GetEuiccProfileInfoList(SLOT_ID, euiccProfileInfoList);
|
||||
EXPECT_EQ(result, TELEPHONY_ERR_IPC_CONNECT_STUB_FAIL);
|
||||
}
|
||||
|
||||
HWTEST_F(EsimServiceClientBranchTest, GetEuiccInfo_0001, Function | MediumTest | Level1)
|
||||
{
|
||||
EuiccInfo eUiccInfo;
|
||||
|
||||
EXPECT_CALL(*samgr, LoadSystemAbility(testing::_,
|
||||
testing::A<const sptr<ISystemAbilityLoadCallback>&>())).WillOnce(testing::Return(-1));
|
||||
int32_t result = EsimServiceClient::GetInstance().GetEuiccInfo(SLOT_ID, eUiccInfo);
|
||||
EXPECT_EQ(result, TELEPHONY_ERR_IPC_CONNECT_STUB_FAIL);
|
||||
}
|
||||
|
||||
HWTEST_F(EsimServiceClientBranchTest, DeleteProfile_0001, Function | MediumTest | Level1)
|
||||
{
|
||||
std::string iccId = "98760000000000543210";
|
||||
int32_t deleteProfileResult;
|
||||
|
||||
EXPECT_CALL(*samgr, LoadSystemAbility(testing::_,
|
||||
testing::A<const sptr<ISystemAbilityLoadCallback>&>())).WillOnce(testing::Return(-1));
|
||||
int32_t result = EsimServiceClient::GetInstance().DeleteProfile(SLOT_ID, iccId, deleteProfileResult);
|
||||
EXPECT_EQ(result, TELEPHONY_ERR_IPC_CONNECT_STUB_FAIL);
|
||||
}
|
||||
|
||||
HWTEST_F(EsimServiceClientBranchTest, SwitchToProfile_0001, Function | MediumTest | Level1)
|
||||
{
|
||||
int32_t portIndex = 0;
|
||||
std::string iccId = "98760000000000543210";
|
||||
bool forceDeactivateSim = true;
|
||||
int32_t switchToProfileResult;
|
||||
|
||||
EXPECT_CALL(*samgr, LoadSystemAbility(testing::_,
|
||||
testing::A<const sptr<ISystemAbilityLoadCallback>&>())).WillOnce(testing::Return(-1));
|
||||
int32_t result = EsimServiceClient::GetInstance().SwitchToProfile(
|
||||
SLOT_ID, portIndex, iccId, forceDeactivateSim, switchToProfileResult);
|
||||
EXPECT_EQ(result, TELEPHONY_ERR_IPC_CONNECT_STUB_FAIL);
|
||||
}
|
||||
|
||||
HWTEST_F(EsimServiceClientBranchTest, SetProfileNickname_0001, Function | MediumTest | Level1)
|
||||
{
|
||||
std::string iccId = "98760000000000543210";
|
||||
std::string nickname = "nick";
|
||||
int32_t setProfileNicknameResult;
|
||||
|
||||
EXPECT_CALL(*samgr, LoadSystemAbility(testing::_,
|
||||
testing::A<const sptr<ISystemAbilityLoadCallback>&>())).WillOnce(testing::Return(-1));
|
||||
int32_t result = EsimServiceClient::GetInstance().SetProfileNickname(
|
||||
SLOT_ID, iccId, nickname, setProfileNicknameResult);
|
||||
EXPECT_EQ(result, TELEPHONY_ERR_IPC_CONNECT_STUB_FAIL);
|
||||
}
|
||||
|
||||
HWTEST_F(EsimServiceClientBranchTest, ResetMemory_0001, Function | MediumTest | Level1)
|
||||
{
|
||||
int32_t resetOption = static_cast<int32_t>(ResetOption::DELETE_FIELD_LOADED_TEST_PROFILES);
|
||||
int32_t resetMemoryResult;
|
||||
|
||||
EXPECT_CALL(*samgr, LoadSystemAbility(testing::_,
|
||||
testing::A<const sptr<ISystemAbilityLoadCallback>&>())).WillOnce(testing::Return(-1));
|
||||
int32_t result = EsimServiceClient::GetInstance().ResetMemory(SLOT_ID, resetOption, resetMemoryResult);
|
||||
EXPECT_EQ(result, TELEPHONY_ERR_IPC_CONNECT_STUB_FAIL);
|
||||
}
|
||||
|
||||
HWTEST_F(EsimServiceClientBranchTest, ReserveProfilesForFactoryRestore_0001, Function | MediumTest | Level1)
|
||||
{
|
||||
int32_t reserveProfilesForFactoryRestoreResult;
|
||||
|
||||
EXPECT_CALL(*samgr, LoadSystemAbility(testing::_,
|
||||
testing::A<const sptr<ISystemAbilityLoadCallback>&>())).WillOnce(testing::Return(-1));
|
||||
int32_t result = EsimServiceClient::GetInstance().ReserveProfilesForFactoryRestore(
|
||||
SLOT_ID, reserveProfilesForFactoryRestoreResult);
|
||||
EXPECT_EQ(result, TELEPHONY_ERR_IPC_CONNECT_STUB_FAIL);
|
||||
}
|
||||
|
||||
HWTEST_F(EsimServiceClientBranchTest, SetDefaultSmdpAddress_0001, Function | MediumTest | Level1)
|
||||
{
|
||||
std::string defaultSmdpAddress = "smdp.gsma.com";
|
||||
int32_t setAddressResult;
|
||||
|
||||
EXPECT_CALL(*samgr, LoadSystemAbility(testing::_,
|
||||
testing::A<const sptr<ISystemAbilityLoadCallback>&>())).WillOnce(testing::Return(-1));
|
||||
int32_t result = EsimServiceClient::GetInstance().SetDefaultSmdpAddress(
|
||||
SLOT_ID, defaultSmdpAddress, setAddressResult);
|
||||
EXPECT_EQ(result, TELEPHONY_ERR_IPC_CONNECT_STUB_FAIL);
|
||||
}
|
||||
|
||||
HWTEST_F(EsimServiceClientBranchTest, GetDefaultSmdpAddress_0001, Function | MediumTest | Level1)
|
||||
{
|
||||
std::string defaultSmdpAddress;
|
||||
|
||||
EXPECT_CALL(*samgr, LoadSystemAbility(testing::_,
|
||||
testing::A<const sptr<ISystemAbilityLoadCallback>&>())).WillOnce(testing::Return(-1));
|
||||
int32_t result = EsimServiceClient::GetInstance().GetDefaultSmdpAddress(SLOT_ID, defaultSmdpAddress);
|
||||
EXPECT_EQ(result, TELEPHONY_ERR_IPC_CONNECT_STUB_FAIL);
|
||||
}
|
||||
|
||||
HWTEST_F(EsimServiceClientBranchTest, CancelSession_0001, Function | MediumTest | Level1)
|
||||
{
|
||||
std::string transactionId = "A1B2C3";
|
||||
const int32_t cancelReason = static_cast<int32_t>(CancelReason::CANCEL_REASON_POSTPONED);
|
||||
ResponseEsimResult responseResult;
|
||||
|
||||
EXPECT_CALL(*samgr, LoadSystemAbility(testing::_,
|
||||
testing::A<const sptr<ISystemAbilityLoadCallback>&>())).WillOnce(testing::Return(-1));
|
||||
int32_t result = EsimServiceClient::GetInstance().CancelSession(
|
||||
SLOT_ID, transactionId, cancelReason, responseResult);
|
||||
EXPECT_EQ(result, TELEPHONY_ERR_IPC_CONNECT_STUB_FAIL);
|
||||
}
|
||||
|
||||
HWTEST_F(EsimServiceClientBranchTest, IsEsimSupported_0001, Function | MediumTest | Level1)
|
||||
{
|
||||
EXPECT_CALL(*samgr, LoadSystemAbility(testing::_,
|
||||
testing::A<const sptr<ISystemAbilityLoadCallback>&>())).WillOnce(testing::Return(-1));
|
||||
bool result = EsimServiceClient::GetInstance().IsEsimSupported(SLOT_ID);
|
||||
EXPECT_EQ(result, false);
|
||||
}
|
||||
|
||||
HWTEST_F(EsimServiceClientBranchTest, RemoveDeathRecipient_0001, Function | MediumTest | Level1)
|
||||
{
|
||||
sptr<MockIRemoteObject> remote = new (std::nothrow) MockIRemoteObject();
|
||||
bool isRemoteDied = true;
|
||||
EsimServiceClient::GetInstance().RemoveDeathRecipient(remote, isRemoteDied);
|
||||
EXPECT_NE(remote, nullptr);
|
||||
}
|
||||
|
||||
HWTEST_F(EsimServiceClientBranchTest, RemoveDeathRecipient_0002, Function | MediumTest | Level1)
|
||||
{
|
||||
sptr<MockIRemoteObject> remote = nullptr;
|
||||
bool isRemoteDied = true;
|
||||
EsimServiceClient::GetInstance().RemoveDeathRecipient(remote, isRemoteDied);
|
||||
EXPECT_EQ(remote, nullptr);
|
||||
|
||||
remote = new (std::nothrow) MockIRemoteObject();
|
||||
isRemoteDied = false;
|
||||
EsimServiceClient::GetInstance().RemoveDeathRecipient(remote, isRemoteDied);
|
||||
EXPECT_NE(remote, nullptr);
|
||||
}
|
||||
|
||||
HWTEST_F(EsimServiceClientBranchTest, OnLoadSystemAbilitySuccess_0001, Function | MediumTest | Level1)
|
||||
{
|
||||
sptr<MockIRemoteObject> remote = new (std::nothrow) MockIRemoteObject();
|
||||
EXPECT_NE(remote, nullptr);
|
||||
int32_t systemAbilityId = 66250;
|
||||
EsimServiceClientCallback call;
|
||||
call.OnLoadSystemAbilitySuccess(systemAbilityId, remote);
|
||||
EXPECT_NE(call.remoteObject_, nullptr);
|
||||
}
|
||||
|
||||
HWTEST_F(EsimServiceClientBranchTest, OnLoadSystemAbilityFail_0001, Function | MediumTest | Level1)
|
||||
{
|
||||
int32_t systemAbilityId = 66250;
|
||||
EsimServiceClientCallback call;
|
||||
call.OnLoadSystemAbilityFail(systemAbilityId);
|
||||
EXPECT_TRUE(call.isLoadSAFailed_);
|
||||
}
|
||||
|
||||
HWTEST_F(EsimServiceClientBranchTest, IsFailed_0001, Function | MediumTest | Level1)
|
||||
{
|
||||
EsimServiceClientCallback call;
|
||||
call.isLoadSAFailed_ = true;
|
||||
call.IsFailed();
|
||||
EXPECT_TRUE(call.isLoadSAFailed_);
|
||||
}
|
||||
|
||||
HWTEST_F(EsimServiceClientBranchTest, GetRemoteObject_0001, Function | MediumTest | Level1)
|
||||
{
|
||||
EsimServiceClientCallback call;
|
||||
call.remoteObject_ = new (std::nothrow) MockIRemoteObject();
|
||||
call.GetRemoteObject();
|
||||
EXPECT_NE(call.remoteObject_, nullptr);
|
||||
}
|
||||
|
||||
HWTEST_F(EsimServiceClientBranchTest, OnRemoteDied_0001, Function | MediumTest | Level1)
|
||||
{
|
||||
sptr<MockIRemoteObject> remote = new (std::nothrow) MockIRemoteObject();
|
||||
EXPECT_NE(remote, nullptr);
|
||||
EsimServiceClient::GetInstance().proxy_ = nullptr;
|
||||
EsimServiceClient::GetInstance().OnRemoteDied(remote);
|
||||
EXPECT_EQ(EsimServiceClient::GetInstance().proxy_, nullptr);
|
||||
}
|
||||
} // namespace Telephony
|
||||
} // namespace OHOS
|
File diff suppressed because it is too large
Load Diff
@ -0,0 +1,695 @@
|
||||
/*
|
||||
* Copyright (C) 2024 Huawei Device Co., Ltd.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#ifndef ESIM_CORE_SERVICE_STUB_TEST_H
|
||||
#define ESIM_CORE_SERVICE_STUB_TEST_H
|
||||
|
||||
#include "i_core_service.h"
|
||||
#include "core_service_stub.h"
|
||||
|
||||
#include "gmock/gmock.h"
|
||||
|
||||
#define private public
|
||||
#define protected public
|
||||
|
||||
namespace OHOS {
|
||||
namespace Telephony {
|
||||
class MockCoreServiceStub : public CoreServiceStub {
|
||||
public:
|
||||
MockCoreServiceStub() = default;
|
||||
~MockCoreServiceStub() override {};
|
||||
|
||||
int32_t GetPsRadioTech(int32_t slotId, int32_t &psRadioTech) override
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
int32_t GetCsRadioTech(int32_t slotId, int32_t &csRadioTech) override
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
std::u16string GetOperatorNumeric(int32_t slotId) override
|
||||
{
|
||||
return u"";
|
||||
}
|
||||
|
||||
std::string GetResidentNetworkNumeric(int32_t slotId) override
|
||||
{
|
||||
return "";
|
||||
}
|
||||
|
||||
int32_t GetOperatorName(int32_t slotId, std::u16string &operatorName) override
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
int32_t GetSignalInfoList(int32_t slotId, std::vector<sptr<SignalInformation>> &signals) override
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
int32_t GetNetworkState(int32_t slotId, sptr<NetworkState> &networkState) override
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
int32_t SetRadioState(int32_t slotId, bool isOn, const sptr<INetworkSearchCallback> &callback) override
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
int32_t GetRadioState(int32_t slotId, const sptr<INetworkSearchCallback> &callback) override
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
int32_t GetImei(int32_t slotId, std::u16string &imei) override
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
int32_t GetImeiSv(int32_t slotId, std::u16string &imeiSv) override
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
int32_t GetMeid(int32_t slotId, std::u16string &meid) override
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
int32_t GetUniqueDeviceId(int32_t slotId, std::u16string &deviceId) override
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
bool IsNrSupported(int32_t slotId) override
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
int32_t SetNrOptionMode(int32_t slotId, int32_t mode, const sptr<INetworkSearchCallback> &callback) override
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
int32_t GetNrOptionMode(int32_t slotId, const sptr<INetworkSearchCallback> &callback) override
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
int32_t HasSimCard(int32_t slotId, bool &hasSimCard) override
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
int32_t GetSimState(int32_t slotId, SimState &simState) override
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
int32_t GetDsdsMode(int32_t &dsdsMode) override
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
int32_t GetCardType(int32_t slotId, CardType &cardType) override
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
int32_t UnlockPin(int32_t slotId, const std::u16string &pin, LockStatusResponse &response) override
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
int32_t UnlockPuk(
|
||||
int32_t slotId, const std::u16string &newPin, const std::u16string &puk, LockStatusResponse &response) override
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
int32_t AlterPin(int32_t slotId, const std::u16string &newPin,
|
||||
const std::u16string &oldPin, LockStatusResponse &response) override
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
int32_t UnlockPin2(int32_t slotId, const std::u16string &pin2, LockStatusResponse &response) override
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
int32_t UnlockPuk2(int32_t slotId, const std::u16string &newPin2,
|
||||
const std::u16string &puk2, LockStatusResponse &response) override
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
int32_t AlterPin2(int32_t slotId, const std::u16string &newPin2,
|
||||
const std::u16string &oldPin2, LockStatusResponse &response) override
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
int32_t SetLockState(int32_t slotId, const LockInfo &options, LockStatusResponse &response) override
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
int32_t GetLockState(int32_t slotId, LockType lockType, LockState &lockState) override
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
int32_t GetSimOperatorNumeric(int32_t slotId, std::u16string &operatorNumeric) override
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
int32_t GetISOCountryCodeForSim(int32_t slotId, std::u16string &countryCode) override
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
int32_t GetSimSpn(int32_t slotId, std::u16string &spn) override
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
int32_t GetSimIccId(int32_t slotId, std::u16string &iccId) override
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
int32_t GetIMSI(int32_t slotId, std::u16string &imsi) override
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
int32_t IsCTSimCard(int32_t slotId, bool &isCTSimCard) override
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
bool IsSimActive(int32_t slotId) override
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
int32_t GetSlotId(int32_t simId) override
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
int32_t GetSimId(int32_t slotId) override
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
int32_t GetNetworkSearchInformation(int32_t slotId, const sptr<INetworkSearchCallback> &callback) override
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
int32_t GetNetworkSelectionMode(int32_t slotId, const sptr<INetworkSearchCallback> &callback) override
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
std::u16string GetLocaleFromDefaultSim() override
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
int32_t GetSimGid1(int32_t slotId, std::u16string &gid1) override
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
std::u16string GetSimGid2(int32_t slotId) override
|
||||
{
|
||||
return u"";
|
||||
}
|
||||
|
||||
std::u16string GetSimEons(int32_t slotId, const std::string &plmn, int32_t lac, bool longNameRequired) override
|
||||
{
|
||||
return u"";
|
||||
}
|
||||
|
||||
int32_t SetNetworkSelectionMode(int32_t slotId, int32_t selectMode,
|
||||
const sptr<NetworkInformation> &networkInformation, bool resumeSelection,
|
||||
const sptr<INetworkSearchCallback> &callback) override
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
int32_t GetIsoCountryCodeForNetwork(int32_t slotId, std::u16string &countryCode) override
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
int32_t GetSimAccountInfo(int32_t slotId, IccAccountInfo &info) override
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
int32_t SetDefaultVoiceSlotId(int32_t slotId) override
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
int32_t GetDefaultVoiceSlotId() override
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
int32_t GetDefaultVoiceSimId(int32_t &simId) override
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
int32_t SetPrimarySlotId(int32_t slotId) override
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
int32_t GetPrimarySlotId(int32_t &slotId) override
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
int32_t SetShowNumber(int32_t slotId, const std::u16string &number) override
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
int32_t GetShowNumber(int32_t slotId, std::u16string &showNumber) override
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
int32_t SetShowName(int32_t slotId, const std::u16string &name) override
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
int32_t GetShowName(int32_t slotId, std::u16string &showName) override
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
int32_t GetActiveSimAccountInfoList(std::vector<IccAccountInfo> &iccAccountInfoList) override
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
int32_t GetOperatorConfigs(int32_t slotId, OperatorConfig &poc) override
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
int32_t RefreshSimState(int32_t slotId) override
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
int32_t SetActiveSim(int32_t slotId, int32_t enable) override
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
int32_t GetPreferredNetwork(int32_t slotId, const sptr<INetworkSearchCallback> &callback) override
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
int32_t SetPreferredNetwork(
|
||||
int32_t slotId, int32_t networkMode, const sptr<INetworkSearchCallback> &callback) override
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
int32_t GetNetworkCapability(
|
||||
int32_t slotId, int32_t networkCapabilityType, int32_t &networkCapabilityState) override
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
int32_t SetNetworkCapability(
|
||||
int32_t slotId, int32_t networkCapabilityType, int32_t networkCapabilityState) override
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
int32_t GetSimTelephoneNumber(int32_t slotId, std::u16string &telephoneNumber) override
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
std::u16string GetSimTeleNumberIdentifier(const int32_t slotId) override
|
||||
{
|
||||
return u"";
|
||||
}
|
||||
|
||||
int32_t GetVoiceMailIdentifier(int32_t slotId, std::u16string &voiceMailIdentifier) override
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
int32_t GetVoiceMailNumber(int32_t slotId, std::u16string &voiceMailNumber) override
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
int32_t GetVoiceMailCount(int32_t slotId, int32_t &voiceMailCount) override
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
int32_t SetVoiceMailCount(int32_t slotId, int32_t voiceMailCount) override
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
int32_t SetVoiceCallForwarding(int32_t slotId, bool enable, const std::string &number) override
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
int32_t QueryIccDiallingNumbers(
|
||||
int slotId, int type, std::vector<std::shared_ptr<DiallingNumbersInfo>> &result) override
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
int32_t AddIccDiallingNumbers(
|
||||
int slotId, int type, const std::shared_ptr<DiallingNumbersInfo> &diallingNumber) override
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
int32_t DelIccDiallingNumbers(
|
||||
int slotId, int type, const std::shared_ptr<DiallingNumbersInfo> &diallingNumber) override
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
int32_t UpdateIccDiallingNumbers(
|
||||
int slotId, int type, const std::shared_ptr<DiallingNumbersInfo> &diallingNumber) override
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
int32_t SetVoiceMailInfo(
|
||||
const int32_t slotId, const std::u16string &mailName, const std::u16string &mailNumber) override
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
int32_t GetImsRegStatus(int32_t slotId, ImsServiceType imsSrvType, ImsRegInfo &info) override
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
int32_t GetMaxSimCount() override
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
int32_t GetOpKey(int32_t slotId, std::u16string &opkey) override
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
int32_t GetOpKeyExt(int32_t slotId, std::u16string &opkeyExt) override
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
int32_t GetOpName(int32_t slotId, std::u16string &opname) override
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
int32_t SendEnvelopeCmd(int32_t slotId, const std::string &cmd) override
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
int32_t SendTerminalResponseCmd(int32_t slotId, const std::string &cmd) override
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
int32_t SendCallSetupRequestResult(int32_t slotId, bool accept) override
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
int32_t UnlockSimLock(int32_t slotId, const PersoLockInfo &lockInfo, LockStatusResponse &response) override
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
int32_t GetCellInfoList(int32_t slotId, std::vector<sptr<CellInformation>> &cellInfo) override
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
int32_t SendUpdateCellLocationRequest(int32_t slotId) override
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
int32_t HasOperatorPrivileges(const int32_t slotId, bool &hasOperatorPrivileges) override
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
int32_t SimAuthentication(
|
||||
int32_t slotId, AuthType authType, const std::string &authData, SimAuthenticationResponse &response) override
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
int32_t RegisterImsRegInfoCallback(
|
||||
int32_t slotId, ImsServiceType imsSrvType, const sptr<ImsRegInfoCallback> &callback) override
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
int32_t UnregisterImsRegInfoCallback(int32_t slotId, ImsServiceType imsSrvType) override
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
int32_t GetBasebandVersion(int32_t slotId, std::string &version) override
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
int32_t FactoryReset(int32_t slotId) override
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
int32_t GetNrSsbIdInfo(int32_t slotId, const std::shared_ptr<NrSsbInformation> &nrSsbInformation) override
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
int32_t InitExtraModule(int32_t slotId) override
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
bool IsAllowedInsertApn(std::string &value) override
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
int32_t GetTargetOpkey(int32_t slotId, std::u16string &opkey) override
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
int32_t GetOpkeyVersion(std::string &versionInfo) override
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
int32_t GetSimIO(int32_t slotId, int32_t command,
|
||||
int32_t fileId, const std::string &data, const std::string &path, SimAuthenticationResponse &response) override
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
int32_t GetEid(int32_t slotId, std::u16string &eId) override
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
int32_t GetEuiccProfileInfoList(int32_t slotId, GetEuiccProfileInfoListResult &euiccProfileInfoList) override
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
int32_t GetEuiccInfo(int32_t slotId, EuiccInfo &eUiccInfo) override
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
int32_t DeleteProfile(int32_t slotId, const std::u16string &iccId, ResultState &enumResult) override
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
int32_t SwitchToProfile(int32_t slotId, int32_t portIndex,
|
||||
const std::u16string &iccId, bool forceDeactivateSim, ResultState &enumResult) override
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
int32_t SetProfileNickname(
|
||||
int32_t slotId, const std::u16string &iccId, const std::u16string &nickname, ResultState &enumResult) override
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
int32_t ResetMemory(int32_t slotId, ResetOption resetOption, ResultState &enumResult) override
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
int32_t SetDefaultSmdpAddress(
|
||||
int32_t slotId, const std::u16string &defaultSmdpAddress, ResultState &enumResult) override
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
int32_t GetDefaultSmdpAddress(int32_t slotId, std::u16string &defaultSmdpAddress) override
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
int32_t CancelSession(int32_t slotId, const std::u16string &transactionId, CancelReason cancelReason,
|
||||
ResponseEsimResult &responseResult) override
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
bool IsEsimSupported(int32_t slotId) override
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
int32_t GetProfile(
|
||||
int32_t slotId, int32_t portIndex, const std::u16string &iccId, EuiccProfile &eUiccProfile) override
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
int32_t DisableProfile(
|
||||
int32_t slotId, int32_t portIndex, const std::u16string &iccId, bool refresh, ResultState &enumResult) override
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
int32_t GetSmdsAddress(int32_t slotId, int32_t portIndex, std::u16string &smdsAddress) override
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
int32_t GetRulesAuthTable(
|
||||
int32_t slotId, int32_t portIndex, EuiccRulesAuthTable &eUiccRulesAuthTable) override
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
int32_t GetEuiccChallenge(
|
||||
int32_t slotId, int32_t portIndex, ResponseEsimResult &responseResult) override
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
int32_t GetEuiccInfo2(int32_t slotId, int32_t portIndex, ResponseEsimResult &responseResult) override
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
int32_t AuthenticateServer(
|
||||
int32_t slotId, int32_t portIndex,
|
||||
const std::u16string &matchingId,
|
||||
const std::u16string &serverSigned1,
|
||||
const std::u16string &serverSignature1,
|
||||
const std::u16string &euiccCiPkIdToBeUsed,
|
||||
const std::u16string &serverCertificate,
|
||||
ResponseEsimResult &responseResult) override
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
int32_t PrepareDownload(
|
||||
int32_t slotId, int32_t portIndex,
|
||||
const std::u16string &hashCc,
|
||||
const std::u16string &smdpSigned2,
|
||||
const std::u16string &smdpSignature2,
|
||||
const std::u16string &smdpCertificate,
|
||||
ResponseEsimResult &responseResult) override
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
int32_t LoadBoundProfilePackage(int32_t slotId, int32_t portIndex,
|
||||
const std::u16string &boundProfilePackage, ResponseEsimBppResult &responseResult) override
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
int32_t ListNotifications(
|
||||
int32_t slotId, int32_t portIndex, Event events, EuiccNotificationList ¬ificationList) override
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
int32_t RetrieveNotificationList(
|
||||
int32_t slotId, int32_t portIndex, Event events, EuiccNotificationList ¬ificationList) override
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
int32_t RetrieveNotification(
|
||||
int32_t slotId, int32_t portIndex, int32_t seqNumber, EuiccNotification ¬ification) override
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
int32_t RemoveNotificationFromList(
|
||||
int32_t slotId, int32_t portIndex, int32_t seqNumber, ResultState &enumResult) override
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
int32_t SendApduData(int32_t slotId, const std::u16string &aid,
|
||||
const std::u16string &apduData, ResponseEsimResult &responseResult) override
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
};
|
||||
} // namespace Telephony
|
||||
} // namespace OHOS
|
||||
#endif // ESIM_CORE_SERVICE_STUB_TEST_H
|
@ -0,0 +1,80 @@
|
||||
/*
|
||||
* Copyright (c) 2024 Huawei Device Co., Ltd.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#ifndef OHOS_TELEPHONY_MOCK_IREMOTEOBJECT_H
|
||||
#define OHOS_TELEPHONY_MOCK_IREMOTEOBJECT_H
|
||||
|
||||
#include "gmock/gmock.h"
|
||||
|
||||
#include "iremote_broker.h"
|
||||
#include "iremote_object.h"
|
||||
|
||||
namespace OHOS {
|
||||
class MockIRemoteObject : public IRemoteObject {
|
||||
public:
|
||||
MockIRemoteObject() : IRemoteObject(u"mock_i_remote_object") {}
|
||||
|
||||
~MockIRemoteObject() {}
|
||||
|
||||
int32_t GetObjectRefCount() override
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
MOCK_METHOD4(SendRequest, int(uint32_t code, MessageParcel &data, MessageParcel &reply, MessageOption &option));
|
||||
|
||||
bool IsProxyObject() const override
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
bool CheckObjectLegality() const override
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
bool AddDeathRecipient(const sptr<DeathRecipient> &recipient) override
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
bool RemoveDeathRecipient(const sptr<DeathRecipient> &recipient) override
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
bool Marshalling(Parcel &parcel) const override
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
sptr<IRemoteBroker> AsInterface() override
|
||||
{
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
int Dump(int fd, const std::vector<std::u16string> &args) override
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
std::u16string GetObjectDescriptor() const
|
||||
{
|
||||
std::u16string descriptor = std::u16string();
|
||||
return descriptor;
|
||||
}
|
||||
};
|
||||
} // namespace OHOS
|
||||
#endif
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user