mirror of
https://gitee.com/openharmony/telephony_core_service
synced 2024-11-22 23:50:24 +00:00
添加esim相关业务代码
Signed-off-by: yangyang <yangyang651@h-partners.com>
This commit is contained in:
parent
f83613223e
commit
9ae7cd0716
14
BUILD.gn
14
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",
|
||||
@ -131,6 +134,13 @@ ohos_shared_library("tel_core_service") {
|
||||
"utils/log/include",
|
||||
]
|
||||
|
||||
if (core_service_support_esim) {
|
||||
include_dirs += [
|
||||
"utils/codec/include",
|
||||
"utils/vcard/include",
|
||||
]
|
||||
}
|
||||
|
||||
configs = [ "utils:telephony_log_config" ]
|
||||
|
||||
defines = [
|
||||
@ -150,6 +160,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",
|
||||
|
@ -1081,5 +1081,37 @@ int32_t CoreServiceClient::GetSimIO(int32_t slotId, int32_t command,
|
||||
}
|
||||
return proxy->GetSimIO(slotId, command, fileId, dataStr, path, response);
|
||||
}
|
||||
|
||||
#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);
|
||||
}
|
||||
#endif
|
||||
} // namespace Telephony
|
||||
} // namespace OHOS
|
||||
|
@ -22,7 +22,9 @@
|
||||
#include "telephony_errors.h"
|
||||
#include "telephony_log_wrapper.h"
|
||||
#include "telephony_types.h"
|
||||
|
||||
#ifdef CORE_SERVICE_SUPPORT_ESIM
|
||||
#include "esim_state_type.h"
|
||||
#endif
|
||||
namespace OHOS {
|
||||
namespace Telephony {
|
||||
constexpr int32_t MAX_SIZE = 1000;
|
||||
@ -3188,5 +3190,121 @@ int32_t CoreServiceProxy::GetSimIO(int32_t slotId, int32_t command,
|
||||
response.response = reply.ReadString();
|
||||
return ret;
|
||||
}
|
||||
|
||||
#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;
|
||||
}
|
||||
data.WriteInt32(slotId);
|
||||
auto remote = Remote();
|
||||
if (remote == nullptr) {
|
||||
TELEPHONY_LOGE("Remote is null");
|
||||
return TELEPHONY_ERR_IPC_CONNECT_STUB_FAIL;
|
||||
}
|
||||
int32_t st = remote->SendRequest(static_cast<uint32_t>(CoreServiceInterfaceCode::GET_EID), data, reply, option);
|
||||
if (st != ERR_NONE) {
|
||||
TELEPHONY_LOGE("GetEid failed, error code is %{public}d", st);
|
||||
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());
|
||||
|
||||
int32_t accessRulesSize = reply.ReadInt32();
|
||||
euiccProfile.accessRules.resize(accessRulesSize);
|
||||
for (int32_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;
|
||||
}
|
||||
data.WriteInt32(slotId);
|
||||
auto remote = Remote();
|
||||
if (remote == nullptr) {
|
||||
TELEPHONY_LOGE("Remote is null");
|
||||
return TELEPHONY_ERR_IPC_CONNECT_STUB_FAIL;
|
||||
}
|
||||
int32_t st = remote->SendRequest(static_cast<uint32_t>(CoreServiceInterfaceCode::GET_EUICC_PROFILE_INFO_LIST),
|
||||
data, reply, option);
|
||||
if (st != ERR_NONE) {
|
||||
TELEPHONY_LOGE("GetEuiccProfileInfoList failed, error code is %{public}d", st);
|
||||
return TELEPHONY_ERR_IPC_CONNECT_STUB_FAIL;
|
||||
}
|
||||
int32_t result = reply.ReadInt32();
|
||||
if (result == TELEPHONY_ERR_SUCCESS) {
|
||||
int32_t profileCount = reply.ReadInt32();
|
||||
euiccProfileInfoList.profiles.resize(profileCount);
|
||||
for (int32_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;
|
||||
}
|
||||
data.WriteInt32(slotId);
|
||||
auto remote = Remote();
|
||||
if (remote == nullptr) {
|
||||
TELEPHONY_LOGE("Remote is null");
|
||||
return TELEPHONY_ERR_IPC_CONNECT_STUB_FAIL;
|
||||
}
|
||||
int32_t st = remote->SendRequest(static_cast<uint32_t>(CoreServiceInterfaceCode::GET_EUICC_INFO), data, reply, option);
|
||||
if (st != ERR_NONE) {
|
||||
TELEPHONY_LOGE("GetEuiccInfo failed, error code is %{public}d", st);
|
||||
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;
|
||||
}
|
||||
#endif
|
||||
} // namespace Telephony
|
||||
} // namespace OHOS
|
||||
|
@ -918,6 +918,35 @@ public:
|
||||
int32_t GetSimIO(int32_t slotId, int32_t command, int32_t fileId,
|
||||
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);
|
||||
#endif
|
||||
|
||||
private:
|
||||
void RemoveDeathRecipient(const wptr<IRemoteObject> &remote, bool isRemoteDied);
|
||||
class CoreServiceDeathRecipient : public IRemoteObject::DeathRecipient {
|
||||
|
@ -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
|
||||
|
@ -146,6 +146,12 @@ public:
|
||||
int32_t GetOpkeyVersion(std::string &versionInfo) override;
|
||||
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
|
||||
void ReadEuiccProfileFromReply(MessageParcel &reply, EuiccProfile &euiccProfile);
|
||||
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;
|
||||
#endif
|
||||
|
||||
private:
|
||||
template<class T>
|
||||
|
@ -26,6 +26,9 @@
|
||||
#include "operator_config_types.h"
|
||||
#include "signal_information.h"
|
||||
#include "sim_state_type.h"
|
||||
#ifdef CORE_SERVICE_SUPPORT_ESIM
|
||||
#include "esim_state_type.h"
|
||||
#endif
|
||||
|
||||
namespace OHOS {
|
||||
namespace Telephony {
|
||||
@ -149,6 +152,11 @@ public:
|
||||
virtual int32_t GetOpkeyVersion(std::string &versionInfo) = 0;
|
||||
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;
|
||||
#endif
|
||||
|
||||
protected:
|
||||
const int32_t ERROR = -1;
|
||||
|
@ -21,6 +21,9 @@
|
||||
#include "operator_config_types.h"
|
||||
#include "sim_account_callback.h"
|
||||
#include "sim_state_type.h"
|
||||
#ifdef CORE_SERVICE_SUPPORT_ESIM
|
||||
#include "esim_state_type.h"
|
||||
#endif
|
||||
|
||||
namespace OHOS {
|
||||
namespace Telephony {
|
||||
@ -141,6 +144,11 @@ 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;
|
||||
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;
|
||||
#endif
|
||||
};
|
||||
} // namespace Telephony
|
||||
} // namespace OHOS
|
||||
|
@ -259,6 +259,14 @@ 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;
|
||||
#endif
|
||||
|
||||
private:
|
||||
bool Init();
|
||||
|
||||
|
@ -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);
|
||||
|
||||
@ -141,6 +144,11 @@ private:
|
||||
int32_t OnGetTargetOpkey(MessageParcel &data, MessageParcel &reply);
|
||||
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);
|
||||
#endif
|
||||
|
||||
private:
|
||||
std::map<uint32_t, CoreServiceFunc> memberFuncMap_;
|
||||
|
@ -1649,5 +1649,45 @@ int32_t CoreService::GetSimIO(int32_t slotId, int32_t command,
|
||||
return simManager_->GetSimIO(slotId, command, fileId, data, path, response);
|
||||
}
|
||||
|
||||
#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 (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 (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 (simManager_ == nullptr) {
|
||||
TELEPHONY_LOGE("simManager_ is null");
|
||||
return TELEPHONY_ERR_LOCAL_PTR_NULL;
|
||||
}
|
||||
return simManager_->GetEuiccInfo(slotId, eUiccInfo);
|
||||
}
|
||||
#endif
|
||||
} // namespace Telephony
|
||||
} // namespace OHOS
|
||||
|
@ -40,6 +40,10 @@ CoreServiceStub::CoreServiceStub()
|
||||
AddHandlerVoiceMailToMap();
|
||||
AddHandlerPdpProfileToMap();
|
||||
AddHandlerOpkeyVersionToMap();
|
||||
|
||||
#ifdef CORE_SERVICE_SUPPORT_ESIM
|
||||
AddHandlerEsimToMap();
|
||||
#endif
|
||||
}
|
||||
|
||||
void CoreServiceStub::AddHandlerNetWorkToMap()
|
||||
@ -272,6 +276,18 @@ void CoreServiceStub::AddHandlerOpkeyVersionToMap()
|
||||
[this](MessageParcel &data, MessageParcel &reply) { return OnGetOpkeyVersion(data, reply); };
|
||||
}
|
||||
|
||||
#ifdef CORE_SERVICE_SUPPORT_ESIM
|
||||
void CoreServiceStub::AddHandlerEsimToMap()
|
||||
{
|
||||
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); };
|
||||
}
|
||||
#endif
|
||||
|
||||
int32_t CoreServiceStub::OnRemoteRequest(
|
||||
uint32_t code, MessageParcel &data, MessageParcel &reply, MessageOption &option)
|
||||
{
|
||||
@ -1938,5 +1954,72 @@ int32_t CoreServiceStub::OnGetSimIO(MessageParcel &data, MessageParcel &reply)
|
||||
|
||||
return NO_ERROR;
|
||||
}
|
||||
|
||||
#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) {
|
||||
reply.WriteInt32(euiccProfileInfoList.profiles.size());
|
||||
for (const auto& profile : euiccProfileInfoList.profiles) {
|
||||
reply.WriteString16(profile.iccId);
|
||||
reply.WriteString16(profile.nickName);
|
||||
reply.WriteString16(profile.serviceProviderName);
|
||||
reply.WriteString16(profile.profileName);
|
||||
reply.WriteInt32(static_cast<int32_t>(profile.state));
|
||||
reply.WriteInt32(static_cast<int32_t>(profile.profileClass));
|
||||
reply.WriteString16(profile.carrierId.mcc);
|
||||
reply.WriteString16(profile.carrierId.mnc);
|
||||
reply.WriteString16(profile.carrierId.gid1);
|
||||
reply.WriteString16(profile.carrierId.gid2);
|
||||
reply.WriteInt32(static_cast<int32_t>(profile.policyRules));
|
||||
reply.WriteInt32(profile.accessRules.size());
|
||||
for (const auto& rule : profile.accessRules) {
|
||||
reply.WriteString16(rule.certificateHashHexStr);
|
||||
reply.WriteString16(rule.packageName);
|
||||
reply.WriteInt32(rule.accessType);
|
||||
}
|
||||
}
|
||||
reply.WriteBool(euiccProfileInfoList.isRemovable);
|
||||
reply.WriteInt32(static_cast<int32_t>(euiccProfileInfoList.result));
|
||||
}
|
||||
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;
|
||||
}
|
||||
#endif
|
||||
} // namespace Telephony
|
||||
} // namespace OHOS
|
||||
|
133
services/sim/include/esim_file.h
Normal file
133
services/sim/include/esim_file.h
Normal file
@ -0,0 +1,133 @@
|
||||
/*
|
||||
* Copyright (C) 2021 Huawei Device Co., Ltd.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#ifndef OHOS_ESIM_FILE_H
|
||||
#define OHOS_ESIM_FILE_H
|
||||
|
||||
#include "apdu_command.h"
|
||||
#include "asn1_builder.h"
|
||||
#include "asn1_decoder.h"
|
||||
#include "asn1_node.h"
|
||||
#include "asn1_utils.h"
|
||||
#include "esim_state_type.h"
|
||||
#include "esim_service.h"
|
||||
#include "icc_file.h"
|
||||
#include "request_apdu_build.h"
|
||||
#include "reset_response.h"
|
||||
#include "tel_ril_sim_parcel.h"
|
||||
|
||||
namespace OHOS {
|
||||
namespace Telephony {
|
||||
constexpr static const int32_t WAIT_TIME_LONG_SECOND_FOR_ESIM = 20;
|
||||
class EsimFile : public IccFile {
|
||||
public:
|
||||
explicit EsimFile(std::shared_ptr<SimStateManager> simStateManager);
|
||||
int 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;
|
||||
// eSim Function
|
||||
std::string ObtainEid();
|
||||
GetEuiccProfileInfoListResult GetEuiccProfileInfoList();
|
||||
EuiccInfo GetEuiccInfo();
|
||||
|
||||
private:
|
||||
using FileProcessFunc = std::function<bool(const AppExecFwk::InnerEvent::Pointer &event)>;
|
||||
std::map<int, FileProcessFunc> memberFuncMap_;
|
||||
void InitMemberFunc();
|
||||
int32_t currentChannelId;
|
||||
void SyncCloseChannel();
|
||||
bool IsLogicChannelOpen();
|
||||
void ProcessEsimOpenChannel();
|
||||
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);
|
||||
|
||||
protected:
|
||||
int slotId_ = 0;
|
||||
EsimProfile esimProfile_;
|
||||
std::string eid_ = "";
|
||||
EuiccInfo2 euiccInfo2_; // 待修改,与responseInfo2Result_合并
|
||||
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;
|
||||
|
||||
private:
|
||||
std::mutex closeChannelMutex_;
|
||||
std::condition_variable closeChannelCv_;
|
||||
|
||||
std::mutex openChannelMutex_;
|
||||
std::condition_variable openChannelCv_;
|
||||
|
||||
std::mutex getEidMutex_;
|
||||
std::condition_variable getEidCv_;
|
||||
bool getEidReady_ = false;
|
||||
|
||||
std::mutex allProfileInfoMutex_;
|
||||
std::condition_variable allProfileInfoCv_;
|
||||
bool areAllProfileInfoReady_ = false;
|
||||
|
||||
std::mutex euiccInfo1Mutex_;
|
||||
std::condition_variable euiccInfo1Cv_;
|
||||
bool areEuiccInfo1Ready_ = false;
|
||||
};
|
||||
} // namespace Telephony
|
||||
} // namespace OHOS
|
||||
|
||||
#endif // OHOS_ESIM_FILE_H
|
@ -92,6 +92,35 @@ 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_IS_ESIM_SUPPORT,
|
||||
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 {
|
||||
|
@ -33,6 +33,9 @@
|
||||
#include "csim_file_controller.h"
|
||||
#include "telephony_log_wrapper.h"
|
||||
#include "usim_file_controller.h"
|
||||
#ifdef CORE_SERVICE_SUPPORT_ESIM
|
||||
#include "esim_file.h"
|
||||
#endif
|
||||
|
||||
namespace OHOS {
|
||||
namespace Telephony {
|
||||
@ -90,11 +93,19 @@ public:
|
||||
std::weak_ptr<Telephony::ITelRilManager> ril, std::weak_ptr<SimStateManager> simState);
|
||||
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();
|
||||
#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;
|
||||
|
@ -155,6 +155,11 @@ public:
|
||||
int32_t GetSimIO(int32_t slotId, int32_t command, int32_t fileId,
|
||||
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;
|
||||
#endif
|
||||
|
||||
private:
|
||||
bool IsValidSlotId(int32_t slotId);
|
||||
|
611
services/sim/src/esim_file.cpp
Normal file
611
services/sim/src/esim_file.cpp
Normal file
@ -0,0 +1,611 @@
|
||||
/*
|
||||
* 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_file.h"
|
||||
|
||||
#include <unistd.h>
|
||||
|
||||
#include "common_event_manager.h"
|
||||
#include "common_event_support.h"
|
||||
#include "core_manager_inner.h"
|
||||
#include "core_service.h"
|
||||
#include "core_manager_inner.h"
|
||||
#include "parameters.h"
|
||||
#include "radio_event.h"
|
||||
#include "sim_number_decode.h"
|
||||
#include "str_convert.h"
|
||||
#include "telephony_common_utils.h"
|
||||
#include "telephony_ext_wrapper.h"
|
||||
#include "telephony_state_registry_client.h"
|
||||
#include "telephony_tag_def.h"
|
||||
#include "vcard_utils.h"
|
||||
|
||||
|
||||
|
||||
using namespace OHOS::AppExecFwk;
|
||||
using namespace OHOS::EventFwk;
|
||||
|
||||
#define NUMBER_ZERO (0)
|
||||
#define NUMBER_ONE (1)
|
||||
#define NUMBER_TWO (2)
|
||||
#define NUMBER_THREE (3)
|
||||
#define NUMBER_FOUR (4)
|
||||
#define NUMBER_FIVE (5)
|
||||
#define NUMBER_ELEVEN (11)
|
||||
|
||||
#define SW1_MORE_RESPONSE 0x61
|
||||
#define INS_GET_MORE_RESPONSE 0xC0
|
||||
#define SW1_VALUE_90 0x90
|
||||
#define SW2_VALUE_00 0x00
|
||||
|
||||
namespace OHOS {
|
||||
namespace Telephony {
|
||||
EsimFile::EsimFile(std::shared_ptr<SimStateManager> simStateManager) : IccFile("EsimFile", simStateManager)
|
||||
{
|
||||
currentChannelId = 0;
|
||||
InitMemberFunc();
|
||||
}
|
||||
|
||||
void EsimFile::StartLoad() {}
|
||||
|
||||
void EsimFile::SyncOpenChannel()
|
||||
{
|
||||
int tryCnt = 0;
|
||||
while (!IsLogicChannelOpen()) {
|
||||
ProcessEsimOpenChannel();
|
||||
std::unique_lock<std::mutex> lck(openChannelMutex_);
|
||||
if (openChannelCv_.wait_for(lck, std::chrono::seconds(WAIT_TIME_LONG_SECOND_FOR_ESIM),
|
||||
[this]() { return IsLogicChannelOpen(); })) {
|
||||
break;
|
||||
}
|
||||
tryCnt++;
|
||||
if (tryCnt >= NUMBER_THREE) {
|
||||
TELEPHONY_LOGE("failed to open the channel");
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void EsimFile::SyncOpenChannel(const std::u16string &aid)
|
||||
{
|
||||
int tryCnt = 0;
|
||||
while (!IsLogicChannelOpen()) {
|
||||
ProcessEsimOpenChannel(aid);
|
||||
std::unique_lock<std::mutex> lck(openChannelMutex_);
|
||||
if (openChannelCv_.wait_for(lck, std::chrono::seconds(WAIT_TIME_LONG_SECOND_FOR_ESIM),
|
||||
[this]() { return IsLogicChannelOpen(); })) {
|
||||
break;
|
||||
}
|
||||
tryCnt++;
|
||||
if (tryCnt >= NUMBER_THREE) {
|
||||
TELEPHONY_LOGE("failed to open the channel");
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void EsimFile::SyncCloseChannel()
|
||||
{
|
||||
int tryCnt = 0;
|
||||
while (IsLogicChannelOpen()) {
|
||||
ProcessEsimCloseChannel();
|
||||
std::unique_lock<std::mutex> lck(closeChannelMutex_);
|
||||
if (closeChannelCv_.wait_for(lck, std::chrono::seconds(WAIT_TIME_LONG_SECOND_FOR_ESIM),
|
||||
[this]() { return !IsLogicChannelOpen(); })) {
|
||||
break;
|
||||
}
|
||||
tryCnt++;
|
||||
if (tryCnt >= NUMBER_THREE) {
|
||||
currentChannelId = 0;
|
||||
TELEPHONY_LOGE("failed to close the channel");
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
std::string EsimFile::ObtainEid()
|
||||
{
|
||||
SyncOpenChannel();
|
||||
AppExecFwk::InnerEvent::Pointer eventGetEid = BuildCallerInfo(MSG_ESIM_OBTAIN_EID_DONE);
|
||||
if (!ProcessObtainEid(0, eventGetEid)) {
|
||||
TELEPHONY_LOGE("ProcessObtainEid encode failed");
|
||||
return "";
|
||||
}
|
||||
// wait profileInfo is ready
|
||||
getEidReady_ = false;
|
||||
std::unique_lock<std::mutex> lock(getEidMutex_);
|
||||
if (!getEidCv_.wait_for(lock, std::chrono::seconds(WAIT_TIME_LONG_SECOND_FOR_ESIM),
|
||||
[this]() { return getEidReady_; })) {
|
||||
SyncCloseChannel();
|
||||
return "";
|
||||
}
|
||||
SyncCloseChannel();
|
||||
return eid_;
|
||||
}
|
||||
|
||||
GetEuiccProfileInfoListResult EsimFile::GetEuiccProfileInfoList()
|
||||
{
|
||||
SyncOpenChannel();
|
||||
AppExecFwk::InnerEvent::Pointer eventRequestAllProfiles = BuildCallerInfo(MSG_ESIM_REQUEST_ALL_PROFILES);
|
||||
if (!ProcessRequestAllProfiles(slotId_, eventRequestAllProfiles)) {
|
||||
TELEPHONY_LOGE("ProcessRequestAllProfiles encode failed");
|
||||
return GetEuiccProfileInfoListResult();
|
||||
}
|
||||
areAllProfileInfoReady_ = false;
|
||||
std::unique_lock<std::mutex> lock(allProfileInfoMutex_);
|
||||
if (!allProfileInfoCv_.wait_for(lock, std::chrono::seconds(WAIT_TIME_LONG_SECOND_FOR_ESIM),
|
||||
[this]() { return areAllProfileInfoReady_; })) {
|
||||
SyncCloseChannel();
|
||||
return GetEuiccProfileInfoListResult();
|
||||
}
|
||||
SyncCloseChannel();
|
||||
return euiccProfileInfoList_;
|
||||
}
|
||||
|
||||
EuiccInfo EsimFile::GetEuiccInfo()
|
||||
{
|
||||
SyncOpenChannel();
|
||||
AppExecFwk::InnerEvent::Pointer eventEUICCInfo1 = BuildCallerInfo(MSG_ESIM_OBTAIN_EUICC_INFO_1_DONE);
|
||||
if (!ProcessObtainEuiccInfo1(slotId_, eventEUICCInfo1)) {
|
||||
TELEPHONY_LOGE("ProcessObtainEuiccInfo1 encode failed");
|
||||
return EuiccInfo();
|
||||
}
|
||||
areEuiccInfo1Ready_ = false;
|
||||
std::unique_lock<std::mutex> lock(euiccInfo1Mutex_);
|
||||
if (!euiccInfo1Cv_.wait_for(lock, std::chrono::seconds(WAIT_TIME_LONG_SECOND_FOR_ESIM),
|
||||
[this]() { return areEuiccInfo1Ready_; })) {
|
||||
SyncCloseChannel();
|
||||
return EuiccInfo();
|
||||
}
|
||||
SyncCloseChannel();
|
||||
return eUiccInfo_;
|
||||
}
|
||||
|
||||
void EsimFile::CopyApdCmdToReqInfo(ApduSimIORequestInfo *pReqInfo, ApduCommand *apdCmd)
|
||||
{
|
||||
if (apdCmd == nullptr || pReqInfo == nullptr) {
|
||||
TELEPHONY_LOGE("CopyApdCmdToReqInfo failed");
|
||||
return;
|
||||
}
|
||||
static int32_t cnt = 0;
|
||||
pReqInfo->serial = cnt;
|
||||
cnt++;
|
||||
pReqInfo->channelId = apdCmd->channel;
|
||||
pReqInfo->type = apdCmd->data.cla;
|
||||
pReqInfo->instruction = apdCmd->data.ins;
|
||||
pReqInfo->p1 = apdCmd->data.p1;
|
||||
pReqInfo->p2 = apdCmd->data.p2;
|
||||
pReqInfo->p3 = apdCmd->data.p3;
|
||||
pReqInfo->data = apdCmd->data.cmdHex;
|
||||
}
|
||||
|
||||
void EsimFile::CommBuildOneApduReqInfo(ApduSimIORequestInfo& reqInfo, std::shared_ptr<Asn1Builder> &builder)
|
||||
{
|
||||
if (builder == nullptr) {
|
||||
TELEPHONY_LOGE("builder is nullptr");
|
||||
return;
|
||||
}
|
||||
std::string hexStr;
|
||||
int hexStrLen = builder->Asn1BuilderToHexStr(hexStr);
|
||||
RequestApduBuild codec(currentChannelId);
|
||||
codec.BuildStoreData(hexStr);
|
||||
std::list<std::unique_ptr<ApduCommand>> lst = codec.getCommands();
|
||||
std::unique_ptr<ApduCommand> apdCmd = std::move(lst.front());
|
||||
CopyApdCmdToReqInfo(&reqInfo, apdCmd.get());
|
||||
reqInfo.p2 = 0 ;
|
||||
}
|
||||
|
||||
bool EsimFile::ProcessObtainEid(int32_t slotId, const AppExecFwk::InnerEvent::Pointer &responseEvent)
|
||||
{
|
||||
if (IsLogicChannelOpen()) {
|
||||
std::shared_ptr<Asn1Builder> builder = std::make_shared<Asn1Builder>(TAG_ESIM_GET_EID);
|
||||
if (builder == nullptr) {
|
||||
TELEPHONY_LOGE("builder is nullptr");
|
||||
return false;
|
||||
}
|
||||
std::string eidTags;
|
||||
eidTags += (unsigned char)TAG_ESIM_EID;
|
||||
builder->Asn1AddChildAsBytes(TAG_ESIM_TAG_LIST, eidTags, eidTags.length());
|
||||
ApduSimIORequestInfo reqInfo;
|
||||
CommBuildOneApduReqInfo(reqInfo, builder);
|
||||
if (telRilManager_ == nullptr) {
|
||||
return false;
|
||||
}
|
||||
telRilManager_->SimTransmitApduLogicalChannel(slotId, reqInfo, responseEvent);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
bool EsimFile::ProcessObtainEuiccInfo1(int32_t slotId, const AppExecFwk::InnerEvent::Pointer &responseEvent)
|
||||
{
|
||||
if (IsLogicChannelOpen()) {
|
||||
std::shared_ptr<Asn1Builder> builder = std::make_shared<Asn1Builder>(TAG_ESIM_GET_EUICC_INFO_1);
|
||||
ApduSimIORequestInfo reqInfo;
|
||||
CommBuildOneApduReqInfo(reqInfo, builder);
|
||||
if (telRilManager_ == nullptr) {
|
||||
return false;
|
||||
}
|
||||
telRilManager_->SimTransmitApduLogicalChannel(slotId, reqInfo, responseEvent);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
bool EsimFile::ProcessRequestAllProfiles(int32_t slotId, const AppExecFwk::InnerEvent::Pointer &responseEvent)
|
||||
{
|
||||
if (IsLogicChannelOpen()) {
|
||||
std::shared_ptr<Asn1Builder> builder = std::make_shared<Asn1Builder>(TAG_ESIM_GET_PROFILES);
|
||||
if (builder == nullptr) {
|
||||
TELEPHONY_LOGE("builder is nullptr");
|
||||
return false;
|
||||
}
|
||||
unsigned char EUICC_PROFILE_TAGS[] = {
|
||||
(unsigned char) TAG_ESIM_ICCID,
|
||||
(unsigned char) TAG_ESIM_NICKNAME,
|
||||
(unsigned char) TAG_ESIM_OBTAIN_OPERATOR_NAME,
|
||||
(unsigned char) TAG_ESIM_PROFILE_NAME,
|
||||
(unsigned char) TAG_ESIM_OPERATOR_ID,
|
||||
(unsigned char) (TAG_ESIM_PROFILE_STATE / 256),
|
||||
(unsigned char) (TAG_ESIM_PROFILE_STATE % 256),
|
||||
(unsigned char) TAG_ESIM_PROFILE_CLASS,
|
||||
(unsigned char) TAG_ESIM_PROFILE_POLICY_RULE,
|
||||
(unsigned char) (TAG_ESIM_CARRIER_PRIVILEGE_RULES / 256),
|
||||
(unsigned char) (TAG_ESIM_CARRIER_PRIVILEGE_RULES % 256),
|
||||
};
|
||||
std::string euiccProfileTags;
|
||||
for (unsigned char tag : EUICC_PROFILE_TAGS) {
|
||||
euiccProfileTags += tag;
|
||||
}
|
||||
builder->Asn1AddChildAsBytes(TAG_ESIM_TAG_LIST, euiccProfileTags, euiccProfileTags.length());
|
||||
ApduSimIORequestInfo reqInfo;
|
||||
CommBuildOneApduReqInfo(reqInfo, builder);
|
||||
if (telRilManager_ == nullptr) {
|
||||
return false;
|
||||
}
|
||||
telRilManager_->SimTransmitApduLogicalChannel(slotId, reqInfo, responseEvent);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
bool EsimFile::IsLogicChannelOpen()
|
||||
{
|
||||
if (currentChannelId > 0) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
void EsimFile::ProcessEsimOpenChannel()
|
||||
{
|
||||
std::string esimID = "A0000005591010FFFFFFFF8900000100";
|
||||
int32_t p2 = -1;
|
||||
AppExecFwk::InnerEvent::Pointer response = BuildCallerInfo(MSG_ESIM_OPEN_CHANNEL_DONE);
|
||||
if (telRilManager_ == nullptr) {
|
||||
return;
|
||||
}
|
||||
telRilManager_->SimOpenLogicalChannel(0, esimID, p2, response);
|
||||
return;
|
||||
}
|
||||
|
||||
void EsimFile::ProcessEsimOpenChannel(const std::u16string &aid)
|
||||
{
|
||||
std::string appId = OHOS::Telephony::ToUtf8(aid);
|
||||
int32_t p2 = -1;
|
||||
AppExecFwk::InnerEvent::Pointer response = BuildCallerInfo(MSG_ESIM_OPEN_CHANNEL_DONE);
|
||||
if (telRilManager_ == nullptr) {
|
||||
return;
|
||||
}
|
||||
telRilManager_->SimOpenLogicalChannel(0, appId, p2, response);
|
||||
return;
|
||||
}
|
||||
|
||||
bool EsimFile::ProcessEsimOpenChannelDone(const AppExecFwk::InnerEvent::Pointer &event)
|
||||
{
|
||||
if (event == nullptr) {
|
||||
TELEPHONY_LOGE("open logical channel event is nullptr!");
|
||||
return false;
|
||||
}
|
||||
auto resultPtr = event->GetSharedObject<OpenLogicalChannelResponse>();
|
||||
if (resultPtr == nullptr) {
|
||||
TELEPHONY_LOGE("open logical channel fd is nullptr!");
|
||||
return false;
|
||||
}
|
||||
if (resultPtr->channelId > 0) {
|
||||
currentChannelId = resultPtr->channelId;
|
||||
openChannelCv_.notify_one();
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
void EsimFile::ProcessEsimCloseChannel()
|
||||
{
|
||||
AppExecFwk::InnerEvent::Pointer response = BuildCallerInfo(MSG_ESIM_CLOSE_CHANNEL_DONE);
|
||||
if (telRilManager_ == nullptr) {
|
||||
return;
|
||||
}
|
||||
telRilManager_->SimCloseLogicalChannel(0, currentChannelId, response);
|
||||
return;
|
||||
}
|
||||
|
||||
bool EsimFile::ProcessEsimCloseChannelDone(const AppExecFwk::InnerEvent::Pointer &event)
|
||||
{
|
||||
{
|
||||
std::lock_guard<std::mutex> lock(closeChannelMutex_);
|
||||
currentChannelId = 0;
|
||||
TELEPHONY_LOGI("Logical channel closed successfully. Notifying waiting thread.");
|
||||
}
|
||||
closeChannelCv_.notify_one();
|
||||
return true;
|
||||
}
|
||||
|
||||
bool EsimFile::ProcessObtainEidDone(const AppExecFwk::InnerEvent::Pointer &event)
|
||||
{
|
||||
bool isFileHandleResponse = true;
|
||||
if (event == nullptr) {
|
||||
TELEPHONY_LOGE("event is nullptr!");
|
||||
return false;
|
||||
}
|
||||
std::unique_ptr<IccFromRilMsg> rcvMsg = event->GetUniqueObject<IccFromRilMsg>();
|
||||
if (rcvMsg == nullptr) {
|
||||
TELEPHONY_LOGE("rcvMsg is nullptr");
|
||||
return false;
|
||||
}
|
||||
IccFileData *result = &(rcvMsg->fileData);
|
||||
std::string responseByte = Asn1Utils::HexStrToBytes(result->resultData);
|
||||
std::shared_ptr<Asn1Node> root = Asn1ParseResponse(responseByte, responseByte.length());
|
||||
if (root == nullptr) {
|
||||
TELEPHONY_LOGE("Asn1ParseResponse failed");
|
||||
return false;
|
||||
}
|
||||
std::shared_ptr<Asn1Node> profileRoot = root->Asn1GetChild(TAG_ESIM_EID);
|
||||
std::string outPutBytes;
|
||||
int32_t byteLen = profileRoot->Asn1AsBytes(outPutBytes);
|
||||
if (byteLen == 0) {
|
||||
TELEPHONY_LOGE("byteLen is zero!");
|
||||
return false;
|
||||
}
|
||||
std::string strResult = Asn1Utils::BytesToHexStr(outPutBytes);
|
||||
{
|
||||
std::lock_guard<std::mutex> lock(getEidMutex_);
|
||||
eid_ = strResult;
|
||||
getEidReady_ = true;
|
||||
}
|
||||
getEidCv_.notify_one();
|
||||
return isFileHandleResponse;
|
||||
}
|
||||
|
||||
std::shared_ptr<Asn1Node> EsimFile::Asn1ParseResponse(std::string response, int32_t respLength)
|
||||
{
|
||||
if (response.empty() || respLength == 0) {
|
||||
TELEPHONY_LOGE("response null, respLen = %{public}d", respLength);
|
||||
return nullptr;
|
||||
}
|
||||
Asn1Decoder decoder(response, 0, respLength);
|
||||
if (!decoder.Asn1HasNextNode()) {
|
||||
TELEPHONY_LOGE("Empty response");
|
||||
return nullptr;
|
||||
}
|
||||
std::shared_ptr<Asn1Node> node = decoder.Asn1NextNode();
|
||||
return node;
|
||||
}
|
||||
|
||||
bool EsimFile::ProcessObtainEuiccInfo1Done(const AppExecFwk::InnerEvent::Pointer &event)
|
||||
{
|
||||
if (event == nullptr) {
|
||||
TELEPHONY_LOGE("event is nullptr!");
|
||||
return false;
|
||||
}
|
||||
std::unique_ptr<IccFromRilMsg> rcvMsg = event->GetUniqueObject<IccFromRilMsg>();
|
||||
if (rcvMsg == nullptr) {
|
||||
TELEPHONY_LOGE("rcvMsg is nullptr");
|
||||
return false;
|
||||
}
|
||||
IccFileData *result = &(rcvMsg->fileData);
|
||||
std::string responseByte = Asn1Utils::HexStrToBytes(result->resultData);
|
||||
std::shared_ptr<Asn1Node> root = Asn1ParseResponse(responseByte, responseByte.length());
|
||||
if (root == nullptr) {
|
||||
TELEPHONY_LOGE("Asn1ParseResponse failed");
|
||||
return false;
|
||||
}
|
||||
if (!ObtainEuiccInfo1ParseTagCtx2(root)) {
|
||||
TELEPHONY_LOGE("ObtainEuiccInfo1ParseTagCtx2 error!");
|
||||
return false;
|
||||
}
|
||||
eUiccInfo_.response = Str8ToStr16(result->resultData);
|
||||
{
|
||||
std::lock_guard<std::mutex> lock(euiccInfo1Mutex_);
|
||||
areEuiccInfo1Ready_ = true;
|
||||
}
|
||||
euiccInfo1Cv_.notify_one();
|
||||
return true;
|
||||
}
|
||||
|
||||
bool EsimFile::ObtainEuiccInfo1ParseTagCtx2(std::shared_ptr<Asn1Node> &root)
|
||||
{
|
||||
bool isFileHandleResponse = true;
|
||||
EuiccInfo1 euiccInfo1;
|
||||
std::shared_ptr<Asn1Node> svnNode = root->Asn1GetChild(TAG_ESIM_CTX_2);
|
||||
if (svnNode == nullptr) {
|
||||
TELEPHONY_LOGE("svnNode is nullptr");
|
||||
return false;
|
||||
}
|
||||
std::string svnRaw;
|
||||
int svnRawlen = svnNode->Asn1AsBytes(svnRaw);
|
||||
if (svnRawlen < SVN_RAW_LENGTH_MIN) {
|
||||
TELEPHONY_LOGE("invalid SVN data");
|
||||
return false;
|
||||
}
|
||||
std::ostringstream oss;
|
||||
oss << std::hex << std::setw(2) << std::setfill('0') << static_cast<unsigned char>(svnRaw[VERSION_HIGH])
|
||||
<< "." << std::setw(2) << std::setfill('0') << static_cast<unsigned char>(svnRaw[VERSION_MIDDLE])
|
||||
<< "." << std::setw(2) << std::setfill('0') << static_cast<unsigned char>(svnRaw[VERSION_LOW]);
|
||||
|
||||
std::string formattedVersion = oss.str();
|
||||
euiccInfo1.svn = formattedVersion;
|
||||
|
||||
eUiccInfo_.osVersion = Str8ToStr16(euiccInfo1.svn);
|
||||
return isFileHandleResponse;
|
||||
}
|
||||
|
||||
bool EsimFile::ProcessRequestAllProfilesDone(const AppExecFwk::InnerEvent::Pointer &event)
|
||||
{
|
||||
bool isFileHandleResponse = true;
|
||||
if (event == nullptr) {
|
||||
TELEPHONY_LOGE("event is nullptr!");
|
||||
return false;
|
||||
}
|
||||
std::unique_ptr<IccFromRilMsg> rcvMsg = event->GetUniqueObject<IccFromRilMsg>();
|
||||
if (rcvMsg == nullptr) {
|
||||
TELEPHONY_LOGE("rcvMsg is nullptr");
|
||||
return false;
|
||||
}
|
||||
IccFileData *result = &(rcvMsg->fileData);
|
||||
std::string responseByte = Asn1Utils::HexStrToBytes(result->resultData);
|
||||
std::shared_ptr<Asn1Node> root = Asn1ParseResponse(responseByte, responseByte.length());
|
||||
if(root == nullptr) {
|
||||
TELEPHONY_LOGE("root is nullptr");
|
||||
return isFileHandleResponse;
|
||||
}
|
||||
|
||||
if (!RequestAllProfilesParseProfileInfo(root)) {
|
||||
TELEPHONY_LOGE("RequestAllProfilesParseProfileInfo error!");
|
||||
return false;
|
||||
}
|
||||
|
||||
{
|
||||
std::lock_guard<std::mutex> lock(allProfileInfoMutex_);
|
||||
areAllProfileInfoReady_ = true;
|
||||
}
|
||||
allProfileInfoCv_.notify_one();
|
||||
return isFileHandleResponse;
|
||||
}
|
||||
|
||||
bool EsimFile::RequestAllProfilesParseProfileInfo(std::shared_ptr<Asn1Node> &root)
|
||||
{
|
||||
bool isFileHandleResponse = true;
|
||||
std::shared_ptr<Asn1Node> profileRoot = root->Asn1GetChild(TAG_ESIM_CTX_COMP_0);
|
||||
if (profileRoot == nullptr) {
|
||||
TELEPHONY_LOGE("profileRoot is nullptr");
|
||||
return isFileHandleResponse;
|
||||
}
|
||||
|
||||
std::list<std::shared_ptr<Asn1Node>> profileNodes;
|
||||
profileRoot->Asn1GetChildren(TAG_ESIM_PROFILE_INFO, profileNodes);
|
||||
std::shared_ptr<Asn1Node> curNode = NULL;
|
||||
EuiccProfileInfo euiccProfileInfo = {{0}};
|
||||
for(auto it = profileNodes.begin(); it != profileNodes.end(); ++it) {
|
||||
curNode = *it;
|
||||
if (!curNode->Asn1HasChild(TAG_ESIM_ICCID)) {
|
||||
TELEPHONY_LOGE("Profile must have an ICCID.");
|
||||
continue;
|
||||
}
|
||||
BuildProfile(&euiccProfileInfo, curNode);
|
||||
EuiccProfile euiccProfile;
|
||||
ConvertProfileInfoToApiStruct(euiccProfile, euiccProfileInfo);
|
||||
euiccProfileInfoList_.profiles.push_back(euiccProfile);
|
||||
}
|
||||
euiccProfileInfoList_.result = ResultState::RESULT_OK;
|
||||
|
||||
return isFileHandleResponse;
|
||||
}
|
||||
|
||||
void EsimFile::InitMemberFunc()
|
||||
{
|
||||
memberFuncMap_[MSG_ESIM_OPEN_CHANNEL_DONE] =
|
||||
[this](const AppExecFwk::InnerEvent::Pointer &event) { return ProcessEsimOpenChannelDone(event); };
|
||||
memberFuncMap_[MSG_ESIM_CLOSE_CHANNEL_DONE] =
|
||||
[this](const AppExecFwk::InnerEvent::Pointer &event) { return ProcessEsimCloseChannelDone(event); };
|
||||
memberFuncMap_[MSG_ESIM_OBTAIN_EID_DONE] =
|
||||
[this](const AppExecFwk::InnerEvent::Pointer &event) { return ProcessObtainEidDone(event); };
|
||||
memberFuncMap_[MSG_ESIM_OBTAIN_EUICC_INFO_1_DONE] =
|
||||
[this](const AppExecFwk::InnerEvent::Pointer &event) { return ProcessObtainEuiccInfo1Done(event); };
|
||||
memberFuncMap_[MSG_ESIM_REQUEST_ALL_PROFILES] =
|
||||
[this](const AppExecFwk::InnerEvent::Pointer &event) { return ProcessRequestAllProfilesDone(event); };
|
||||
}
|
||||
|
||||
void EsimFile::ProcessEvent(const AppExecFwk::InnerEvent::Pointer &event)
|
||||
{
|
||||
if (event == nullptr) {
|
||||
TELEPHONY_LOGE("event is nullptr");
|
||||
return;
|
||||
}
|
||||
auto id = event->GetInnerEventId();
|
||||
auto itFunc = memberFuncMap_.find(id);
|
||||
if (itFunc != memberFuncMap_.end()) {
|
||||
auto memberFunc = itFunc->second;
|
||||
if (memberFunc != nullptr) {
|
||||
bool isFileProcessResponse = memberFunc(event);
|
||||
ProcessFileLoaded(isFileProcessResponse);
|
||||
}
|
||||
} else {
|
||||
IccFile::ProcessEvent(event);
|
||||
}
|
||||
}
|
||||
|
||||
int EsimFile::ObtainSpnCondition(bool roaming, const std::string &operatorNum)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
bool EsimFile::ProcessIccReady(const AppExecFwk::InnerEvent::Pointer &event)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
bool EsimFile::UpdateVoiceMail(const std::string &mailName, const std::string &mailNumber)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
bool EsimFile::SetVoiceMailCount(int32_t voiceMailCount)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
bool EsimFile::SetVoiceCallForwarding(bool enable, const std::string &number)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
std::string EsimFile::GetVoiceMailNumber()
|
||||
{
|
||||
return "";
|
||||
}
|
||||
|
||||
void EsimFile::SetVoiceMailNumber(const std::string mailNumber)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
void EsimFile::ProcessIccRefresh(int msgId)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
void EsimFile::ProcessFileLoaded(bool response)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
void EsimFile::OnAllFilesFetched()
|
||||
{
|
||||
return;
|
||||
}
|
||||
} // namespace Telephony
|
||||
} // namespace OHOS
|
@ -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();
|
||||
@ -982,5 +989,42 @@ void SimFileManager::ClearData()
|
||||
}
|
||||
simFile_->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();
|
||||
}
|
||||
GetEuiccProfileInfoListResult result = eSimFile_->GetEuiccProfileInfoList();
|
||||
return result;
|
||||
}
|
||||
|
||||
EuiccInfo SimFileManager::GetEuiccInfo()
|
||||
{
|
||||
if (eSimFile_ == nullptr) {
|
||||
TELEPHONY_LOGE("simFile is nullptr");
|
||||
return EuiccInfo();
|
||||
}
|
||||
EuiccInfo result = eSimFile_->GetEuiccInfo();
|
||||
return result;
|
||||
}
|
||||
#endif
|
||||
} // namespace Telephony
|
||||
} // namespace OHOS
|
||||
|
@ -20,6 +20,7 @@
|
||||
#include "telephony_errors.h"
|
||||
#include "telephony_ext_wrapper.h"
|
||||
#include "telephony_permission.h"
|
||||
#include "str_convert.h"
|
||||
|
||||
namespace OHOS {
|
||||
namespace Telephony {
|
||||
@ -1256,5 +1257,36 @@ int32_t SimManager::SavePrimarySlotId(int32_t slotId)
|
||||
return multiSimController_->SavePrimarySlotId(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;
|
||||
}
|
||||
#endif
|
||||
} // namespace Telephony
|
||||
} // namespace OHOS
|
||||
|
@ -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" ]
|
||||
}
|
||||
|
186
utils/common/include/esim_service.h
Normal file
186
utils/common/include/esim_service.h
Normal file
@ -0,0 +1,186 @@
|
||||
/*
|
||||
* Copyright (C) 2021 Huawei Device Co., Ltd.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#ifndef ESIM_SERVICE_PROFILE_H
|
||||
#define ESIM_SERVICE_PROFILE_H
|
||||
|
||||
#include <stdbool.h>
|
||||
#include "esim_state_type.h"
|
||||
#include "asn1_node.h"
|
||||
#include "asn1_builder.h"
|
||||
#include "asn1_decoder.h"
|
||||
#include "asn1_utils.h"
|
||||
|
||||
namespace OHOS {
|
||||
namespace Telephony {
|
||||
#define VERSION_BYTES_LEN 3
|
||||
#define BASE64_TO_HEX_RATIO 2
|
||||
|
||||
#define APDU_MSG_STATUS_WAIT_RSP (1)
|
||||
#define APDU_MSG_STATUS_RCV_RSP (2)
|
||||
#define APDU_MSG_STATUS_DECODE_OK (0)
|
||||
|
||||
#define SVN_RAW_LENGTH_MIN (3)
|
||||
#define EUICC_INFO_RAW_LENGTH (1024)
|
||||
#define EUICC_INFO_SVN_LENGTH (255)
|
||||
#define EUICC_INFO_VERSION_MIN_LENGTH (3)
|
||||
#define EUICC_INFO2_RAW_LENGTH (2048)
|
||||
#define EUICC_INFO2_VERSION_TYPE_LENGTH (32)
|
||||
#define EUICC_INFO2_EXT_CARD_RES_LENGTH (128)
|
||||
#define EUICC_INFO2_CAPABILITY_LENGTH (128)
|
||||
#define EUICC_INFO2_CIPKID_LIST_LENGTH (1024)
|
||||
#define EUICC_INFO2_FORBIDDEN_PROFILE_POLICY_RULES_LEN (128)
|
||||
#define EUICC_INFO2_SAS_ACCREDITATION_NUMBER_LEN (255)
|
||||
#define VERSION_HIGH (0)
|
||||
#define VERSION_MIDDLE (1)
|
||||
#define VERSION_LOW (2)
|
||||
#define ESIM_PROFILE_STATE_DISABLED (0)
|
||||
#define ESIM_PROFILE_STATE_ENABLED (1)
|
||||
#define ESIM_PROFILE_STATE_UNSPECIFIED (-1)
|
||||
#define SERVICE_PROVIDER_NAME_LENGTH (255)
|
||||
#define PROFILE_NICK_NAME_LENGTH (255)
|
||||
#define PROFILE_ICCID_LENGTH (255)
|
||||
#define PROFILE_NAME_LENGTH (255)
|
||||
#define TRANSACTION_ID_LENGTH (255)
|
||||
#define CANCEL_SESSION_RESP_LEN (1024)
|
||||
#define SERVER_SIGNED1_LENGTH (255)
|
||||
#define SERVER_SIGNATURE1_LENGTH (255)
|
||||
#define EUICC_CI_PK_ID_TO_BE_USED_LENGTH (255)
|
||||
#define SERVER_CERTIFICATE_LENGTH (2048)
|
||||
#define EUICC_MEMORY_RESET_BIT_STR_FILL_LEN (0x05)
|
||||
#define EUICC_MEMORY_RESET_BIT_STR_VALUE (0xA0)
|
||||
#define PROFILE_ICCID_BYTE_LENGTH (255)
|
||||
#define PROFILE_ICCID_MASK_LEN (13)
|
||||
#define PROFILE_CLASS_TESTING (0) // Testing profiles
|
||||
#define PROFILE_CLASS_PROVISIONING (1) // Provisioning profiles which are pre-loaded on eUICC
|
||||
#define PROFILE_CLASS_OPERATIONAL (2) // Operational profiles which can be pre-loaded or downloaded
|
||||
#define PROFILE_OPERATOR_ID_MCCMNC_LEN (10)
|
||||
#define PROFILE_OPERATOR_ID_GID1_LEN (10)
|
||||
#define PROFILE_OPERATOR_ID_GID2_LEN (10)
|
||||
#define PROFILE_ICON_LENGTH (2048)
|
||||
#define AUTH_SERVER_RESPONSE_LENGTH (10240)
|
||||
#define AUTH_SERVER_TAC_LEN (4)
|
||||
#define AUTH_SERVER_IMEI_LEN (8)
|
||||
#define LAST_BYTE_OF_IMEI (7)
|
||||
#define EUICC_PRE_DOWNLOAD_RESP_MAX_LENGTH (510)
|
||||
#define SMDP_HASHCC_LENGTH (64)
|
||||
#define SMDP_SIGNED2_LENGTH (2048)
|
||||
#define SMDP_SIGNATURE2_LENGTH (2048)
|
||||
#define SMDP_CERTIFICATE_LENGTH (2048)
|
||||
#define BOUND_PROFILE_PACKAGE_MAX_LENGTH (20480)
|
||||
#define LOAD_BPP_RESULTS_LENGTH (10240)
|
||||
#define TARGET_ADDRESS_MAX_LENGTH (128)
|
||||
#define SEQUENCE_NUMBER_BYTES_NUMBER_MAX (10)
|
||||
#define NOTIF_ADDRESS_LENGTH (255)
|
||||
#define ICCID_NUMBER_MAX (10)
|
||||
#define EVENT_INSTALL (1152)
|
||||
#define CMD_HEX_MAX_DATA_LENGTH (255)
|
||||
|
||||
typedef struct TagEuiccInfo {
|
||||
std::string raw;
|
||||
uint rawLen;
|
||||
std::string svn;
|
||||
} EuiccInfo1;
|
||||
|
||||
typedef struct TagEuiccInfo2 {
|
||||
std::string raw;
|
||||
uint rawLen;
|
||||
std::string svn;
|
||||
std::string profileVersion;
|
||||
std::string firmwareVer; // VersionType,
|
||||
std::string extCardResource; // OCTET STRING,
|
||||
std::string uiccCapability; // BIT STRING
|
||||
std::string ts102241Version;
|
||||
std::string globalPlatformVersion;
|
||||
std::string rspCapability; // BIT STRING
|
||||
std::string euiccCiPKIdListForVerification;
|
||||
std::string euiccCiPKIdListForSigning;
|
||||
int32_t euiccCategory;
|
||||
std::string forbiddenProfilePolicyRules; // BIT STRING
|
||||
std::string ppVersion;
|
||||
std::string sasAccreditationNumber; // UTF8String
|
||||
} EuiccInfo2;
|
||||
|
||||
typedef struct TagEsimProfile {
|
||||
std::u16string iccId = u"";
|
||||
std::u16string portIndex = u"";
|
||||
std::u16string nickname = u"";
|
||||
std::u16string hashCc = u"";
|
||||
std::u16string smdpSigned2 = u"";
|
||||
std::u16string smdpSignature2 = u"";
|
||||
std::u16string smdpCertificate = u"";
|
||||
int seqNumber = 0;
|
||||
bool activeAfterDown;
|
||||
bool forceDeactivateSim = false;
|
||||
OHOS::Telephony::ResetOption option = OHOS::Telephony::ResetOption::DELETE_OPERATIONAL_PROFILES;
|
||||
std::u16string transactionId = u"";
|
||||
OHOS::Telephony::CancelReason cancelReason = OHOS::Telephony::CancelReason::CANCEL_REASON_POSTPONED;
|
||||
std::u16string serverSigned1;
|
||||
std::u16string serverSignature1;
|
||||
std::u16string euiccCiPkIdToBeUsed;
|
||||
std::u16string serverCertificate;
|
||||
std::u16string matchingId;
|
||||
std::u16string imei;
|
||||
std::u16string toBeSendApduDataHexStr;
|
||||
std::u16string boundProfilePackage;
|
||||
OHOS::Telephony::Event events = OHOS::Telephony::Event::EVENT_DONOTHING;
|
||||
std::u16string defaultSmdpAddress = u"";
|
||||
std::u16string aid = u"";
|
||||
std::u16string apduData = u"";
|
||||
} EsimProfile;
|
||||
|
||||
typedef struct TagEs9PlusInitAuthResp {
|
||||
std::string serverSigned1;
|
||||
std::string serverSignature1;
|
||||
std::string euiccCiPKIdToBeUsed;
|
||||
std::string serverCertificate;
|
||||
std::string matchingId;
|
||||
std::string imei;
|
||||
} Es9PlusInitAuthResp;
|
||||
|
||||
typedef struct TagAuthServerResponse {
|
||||
int errCode;
|
||||
std::string transactionId;
|
||||
std::string respStr;
|
||||
int respLength;
|
||||
} AuthServerResponse;
|
||||
|
||||
typedef struct TagOperatorId {
|
||||
std::string mccMnc;
|
||||
std::string gid1;
|
||||
std::string gid2;
|
||||
} EsimOperatorId;
|
||||
|
||||
typedef struct TagEuiccProfileInfo {
|
||||
std::string iccid;
|
||||
std::string nickname;
|
||||
std::string serviceProviderName;
|
||||
std::string profileName;
|
||||
int profileClass; // Profile class for the subscription.
|
||||
int profileState; // The profile state of the subscription.
|
||||
EsimOperatorId operatorId; // The operator Id of the subscription.
|
||||
int policyRules; // The policy rules of the subscription.
|
||||
std::list<std::shared_ptr<Asn1Node>> accessRules; // UiccAccessRule
|
||||
} EuiccProfileInfo;
|
||||
|
||||
typedef struct TagPrepareDownloadResp {
|
||||
std::string hashCc;
|
||||
std::string smdpSigned2;
|
||||
std::string smdpSignature2;
|
||||
std::string smdpCertificate;
|
||||
}PrepareDownloadResp;
|
||||
} // namespace Telephony
|
||||
} // namespace OHOS
|
||||
#endif // ESIM_SERVICE_PROFILE_H
|
Loading…
Reference in New Issue
Block a user