mirror of
https://gitee.com/openharmony/telephony_core_service
synced 2024-11-23 08:00:07 +00:00
fix esim bug
Signed-off-by: wangxingboo <wangxingbo11@h-partners.com>
This commit is contained in:
parent
e42a94c49c
commit
ba0cdc3a80
1
BUILD.gn
1
BUILD.gn
@ -132,7 +132,6 @@ 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) {
|
||||
|
@ -52,7 +52,6 @@
|
||||
"hicollie",
|
||||
"hilog",
|
||||
"hisysevent",
|
||||
"hitrace",
|
||||
"i18n",
|
||||
"init",
|
||||
"ipc",
|
||||
|
@ -1221,7 +1221,7 @@ bool CoreServiceClient::IsEsimSupported(int32_t slotId)
|
||||
}
|
||||
|
||||
int32_t CoreServiceClient::SendApduData(
|
||||
int32_t slotId, const std::u16string &aid, const std::u16string &apduData, ResponseEsimResult &responseResult)
|
||||
int32_t slotId, const std::u16string &aid, const EsimApduData &apduData, ResponseEsimResult &responseResult)
|
||||
{
|
||||
auto proxy = GetProxy();
|
||||
if (proxy == nullptr) {
|
||||
|
@ -3724,8 +3724,45 @@ bool CoreServiceProxy::IsEsimSupported(int32_t slotId)
|
||||
return reply.ReadBool();
|
||||
}
|
||||
|
||||
bool CoreServiceProxy::WriteEsimApduData(MessageParcel &data, const EsimApduData &apduData)
|
||||
{
|
||||
if (!data.WriteBool(apduData.closeChannelFlag_)) {
|
||||
TELEPHONY_LOGE("WriteBool closeChannelFlag is failed");
|
||||
return false;
|
||||
}
|
||||
if (!data.WriteBool(apduData.unusedDefaultReqHeadFlag_)) {
|
||||
TELEPHONY_LOGE("WriteBool unusedDefaultReqHeadFlag is failed");
|
||||
return false;
|
||||
}
|
||||
if (!data.WriteString16(apduData.data_)) {
|
||||
TELEPHONY_LOGE("WriteString16 data is failed");
|
||||
return false;
|
||||
}
|
||||
if (!data.WriteInt32(apduData.instructionType_)) {
|
||||
TELEPHONY_LOGE("WriteInt32 instructionType_ is failed");
|
||||
return false;
|
||||
}
|
||||
if (!data.WriteInt32(apduData.instruction_)) {
|
||||
TELEPHONY_LOGE("WriteInt32 instruction_ is failed");
|
||||
return false;
|
||||
}
|
||||
if (!data.WriteInt32(apduData.p1_)) {
|
||||
TELEPHONY_LOGE("WriteInt32 p1 is failed");
|
||||
return false;
|
||||
}
|
||||
if (!data.WriteInt32(apduData.p2_)) {
|
||||
TELEPHONY_LOGE("WriteInt32 p2 is failed");
|
||||
return false;
|
||||
}
|
||||
if (!data.WriteInt32(apduData.p3_)) {
|
||||
TELEPHONY_LOGE("WriteInt32 p3 is failed");
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
int32_t CoreServiceProxy::SendApduData(
|
||||
int32_t slotId, const std::u16string &aid, const std::u16string &apduData, ResponseEsimResult &responseResult)
|
||||
int32_t slotId, const std::u16string &aid, const EsimApduData &apduData, ResponseEsimResult &responseResult)
|
||||
{
|
||||
MessageParcel data;
|
||||
MessageParcel reply;
|
||||
@ -3742,8 +3779,8 @@ int32_t CoreServiceProxy::SendApduData(
|
||||
TELEPHONY_LOGE("WriteString16 aid is false");
|
||||
return TELEPHONY_ERR_WRITE_DATA_FAIL;
|
||||
}
|
||||
if (!data.WriteString16(apduData)) {
|
||||
TELEPHONY_LOGE("WriteString16 apduData is false");
|
||||
if (!WriteEsimApduData(data, apduData)) {
|
||||
TELEPHONY_LOGE("WriteEsimApduData is false");
|
||||
return TELEPHONY_ERR_WRITE_DATA_FAIL;
|
||||
}
|
||||
auto remote = Remote();
|
||||
@ -3761,6 +3798,8 @@ int32_t CoreServiceProxy::SendApduData(
|
||||
if (result == TELEPHONY_ERR_SUCCESS) {
|
||||
responseResult.resultCode_ = static_cast<ResultState>(reply.ReadInt32());
|
||||
responseResult.response_ = reply.ReadString16();
|
||||
responseResult.sw1_ = reply.ReadInt32();
|
||||
responseResult.sw2_ = reply.ReadInt32();
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
@ -55,7 +55,6 @@ if (core_service_support_esim) {
|
||||
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"
|
||||
}
|
||||
@ -136,10 +135,7 @@ ohos_shared_library("tel_core_service_api") {
|
||||
]
|
||||
|
||||
if (core_service_support_esim) {
|
||||
external_deps += [
|
||||
"hitrace:hitrace_meter",
|
||||
"ipc:ipc_core",
|
||||
]
|
||||
external_deps += [ "ipc:ipc_core" ]
|
||||
}
|
||||
|
||||
cflags_cc = [
|
||||
|
@ -1059,7 +1059,7 @@ public:
|
||||
* @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);
|
||||
int32_t slotId, const std::u16string &aid, const EsimApduData &apduData, ResponseEsimResult &responseResult);
|
||||
|
||||
/**
|
||||
* @brief Prepares the profile download request sent to SM-DP+.
|
||||
|
@ -166,7 +166,7 @@ public:
|
||||
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,
|
||||
int32_t SendApduData(int32_t slotId, const std::u16string &aid, const EsimApduData &apduData,
|
||||
ResponseEsimResult &responseResult) override;
|
||||
int32_t PrepareDownload(int32_t slotId, const DownLoadConfigInfo &downLoadConfigInfo,
|
||||
ResponseEsimResult &responseResult) override;
|
||||
@ -208,6 +208,7 @@ private:
|
||||
void ReadEuiccProfileFromReply(MessageParcel &reply, EuiccProfile &euiccProfile);
|
||||
int32_t RealAuthenticateServer(
|
||||
MessageParcel &data, MessageParcel &reply, MessageOption &option, ResponseEsimResult &responseResult);
|
||||
bool WriteEsimApduData(MessageParcel &data, const EsimApduData &apduData);
|
||||
#endif
|
||||
|
||||
private:
|
||||
|
@ -221,6 +221,45 @@ struct EuiccNotification {
|
||||
struct EuiccNotificationList {
|
||||
std::vector<EuiccNotification> euiccNotification_{};
|
||||
};
|
||||
|
||||
/**
|
||||
* @brief The Data which is sent by the service of LPA
|
||||
*/
|
||||
struct EsimApduData {
|
||||
/** Query result. For details, see {@link RilErrType}. */
|
||||
bool closeChannelFlag_ = false;
|
||||
|
||||
/** Query result. For details, see {@link RilErrType}. */
|
||||
bool unusedDefaultReqHeadFlag_ = false;
|
||||
|
||||
/** Number of remaining attempts */
|
||||
std::u16string data_ = u"";
|
||||
|
||||
/** APDU instruction type. For details, see ETSI 102 221 [55]. */
|
||||
int32_t instructionType_ = 0;
|
||||
|
||||
/** APDU instruction. For details, see ETSI 102 221 [55]. */
|
||||
int32_t instruction_ = 0;
|
||||
|
||||
/**
|
||||
* Command parameter 1 of the SIM data request. For details, see 3GPP
|
||||
* TS 51.011[28].
|
||||
*/
|
||||
int32_t p1_ = 0;
|
||||
|
||||
/**
|
||||
* Command parameter 2 of the SIM data request. For details, see 3GPP
|
||||
* TS 51.011[28].
|
||||
*/
|
||||
int32_t p2_ = 0;
|
||||
|
||||
/**
|
||||
* Command parameter 3 of the SIM data request. For details, see 3GPP
|
||||
* TS 51.011[28]. If p3 is a negative value, a 4-byte APDU is sent to the
|
||||
* SIM card.
|
||||
*/
|
||||
int32_t p3_ = 0;
|
||||
};
|
||||
} // namespace Telephony
|
||||
} // namespace OHOS
|
||||
#endif // OHOS_ESIM_STATE_TYPE_H
|
||||
|
@ -181,7 +181,7 @@ public:
|
||||
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;
|
||||
const EsimApduData &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,
|
||||
|
@ -172,8 +172,8 @@ public:
|
||||
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 SendApduData(int32_t slotId, const std::u16string &aid, const EsimApduData &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,
|
||||
|
@ -29,6 +29,8 @@ namespace Telephony {
|
||||
struct ResponseEsimResult : public Parcelable {
|
||||
ResultState resultCode_;
|
||||
std::u16string response_ = u"";
|
||||
int32_t sw1_ = 0;
|
||||
int32_t sw2_ = 0;
|
||||
|
||||
bool ReadFromParcel(Parcel &parcel);
|
||||
virtual bool Marshalling(Parcel &parcel) const override;
|
||||
|
@ -22,6 +22,7 @@
|
||||
*CoreManagerInner*;
|
||||
*CoreServiceClient*;
|
||||
*CoreServiceProxy*;
|
||||
*DownloadProfileConfigInfo*;
|
||||
*DownloadProfileResult*;
|
||||
*DownloadableProfile*;
|
||||
*EsimServiceClient*;
|
||||
|
@ -289,7 +289,7 @@ public:
|
||||
|
||||
bool IsEsimSupported(int32_t slotId) override;
|
||||
|
||||
int32_t SendApduData(int32_t slotId, const std::u16string &aid, const std::u16string &apduData,
|
||||
int32_t SendApduData(int32_t slotId, const std::u16string &aid, const EsimApduData &apduData,
|
||||
ResponseEsimResult &responseResult) override;
|
||||
|
||||
int32_t PrepareDownload(int32_t slotId, const DownLoadConfigInfo &downLoadConfigInfo,
|
||||
|
@ -1868,7 +1868,7 @@ bool CoreService::IsEsimSupported(int32_t slotId)
|
||||
}
|
||||
|
||||
int32_t CoreService::SendApduData(
|
||||
int32_t slotId, const std::u16string &aid, const std::u16string &apduData, ResponseEsimResult &responseResult)
|
||||
int32_t slotId, const std::u16string &aid, const EsimApduData &apduData, ResponseEsimResult &responseResult)
|
||||
{
|
||||
if (!TelephonyPermission::CheckCallerIsSystemApp()) {
|
||||
TELEPHONY_LOGE("Non-system applications use system APIs!");
|
||||
|
@ -2283,15 +2283,25 @@ int32_t CoreServiceStub::OnIsEsimSupported(MessageParcel &data, MessageParcel &r
|
||||
|
||||
int32_t CoreServiceStub::OnSendApduData(MessageParcel &data, MessageParcel &reply)
|
||||
{
|
||||
EsimApduData apduData;
|
||||
int32_t slotId = data.ReadInt32();
|
||||
std::u16string aid = data.ReadString16();
|
||||
std::u16string apduData = data.ReadString16();
|
||||
apduData.closeChannelFlag_ = data.ReadBool();
|
||||
apduData.unusedDefaultReqHeadFlag_ = data.ReadBool();
|
||||
apduData.data_ = data.ReadString16();
|
||||
apduData.instructionType_ = data.ReadInt32();
|
||||
apduData.instruction_ = data.ReadInt32();
|
||||
apduData.p1_ = data.ReadInt32();
|
||||
apduData.p2_ = data.ReadInt32();
|
||||
apduData.p3_ = data.ReadInt32();
|
||||
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_));
|
||||
ret = (ret && reply.WriteInt32(responseResult.sw1_));
|
||||
ret = (ret && reply.WriteInt32(responseResult.sw2_));
|
||||
}
|
||||
if (!ret) {
|
||||
TELEPHONY_LOGE("write reply failed.");
|
||||
|
@ -94,7 +94,7 @@ public:
|
||||
ResultState ResetMemory(ResetOption resetOption);
|
||||
ResultState SetDefaultSmdpAddress(const std::u16string &defaultSmdpAddress);
|
||||
bool IsEsimSupported();
|
||||
ResponseEsimResult SendApduData(const std::u16string &aid, const std::u16string &apduData);
|
||||
ResponseEsimResult SendApduData(const std::u16string &aid, const EsimApduData &apduData);
|
||||
ResponseEsimResult ObtainPrepareDownload(const DownLoadConfigInfo &downLoadConfigInfo);
|
||||
ResponseEsimBppResult ObtainLoadBoundProfilePackage(int32_t portIndex, const std::u16string boundProfilePackage);
|
||||
EuiccNotificationList ListNotifications(int32_t portIndex, Event events);
|
||||
|
@ -106,7 +106,7 @@ public:
|
||||
ResultState ResetMemory(ResetOption resetOption);
|
||||
ResultState SetDefaultSmdpAddress(const std::u16string &defaultSmdpAddress);
|
||||
bool IsEsimSupported();
|
||||
ResponseEsimResult SendApduData(const std::u16string &aid, const std::u16string &apduData);
|
||||
ResponseEsimResult SendApduData(const std::u16string &aid, const EsimApduData &apduData);
|
||||
ResponseEsimResult PrepareDownload(const DownLoadConfigInfo &downLoadConfigInfo);
|
||||
ResponseEsimBppResult LoadBoundProfilePackage(int32_t portIndex, const std::u16string &boundProfilePackage);
|
||||
EuiccNotificationList ListNotifications(int32_t portIndex, Event events);
|
||||
|
@ -173,7 +173,7 @@ public:
|
||||
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,
|
||||
int32_t SendApduData(int32_t slotId, const std::u16string &aid, const EsimApduData &apduData,
|
||||
ResponseEsimResult &responseResult) override;
|
||||
int32_t PrepareDownload(int32_t slotId, const DownLoadConfigInfo &downLoadConfigInfo,
|
||||
ResponseEsimResult &responseResult) override;
|
||||
|
@ -47,6 +47,11 @@ void EsimFile::StartLoad() {}
|
||||
void EsimFile::SyncOpenChannel()
|
||||
{
|
||||
uint32_t tryCnt = 0;
|
||||
std::u16string aid = OHOS::Telephony::ToUtf16(ISDR_AID);
|
||||
if (esimProfile_.aid != aid) {
|
||||
SyncCloseChannel();
|
||||
esimProfile_.aid = aid;
|
||||
}
|
||||
while (!IsLogicChannelOpen()) {
|
||||
ProcessEsimOpenChannel(OHOS::Telephony::ToUtf16(ISDR_AID));
|
||||
std::unique_lock<std::mutex> lck(openChannelMutex_);
|
||||
@ -332,14 +337,14 @@ bool EsimFile::ProcessEsimCloseChannelDone(const AppExecFwk::InnerEvent::Pointer
|
||||
|
||||
std::string EsimFile::MakeVersionString(std::vector<uint8_t> &versionRaw)
|
||||
{
|
||||
if (versionRaw.size() < BYTE_NUM3) {
|
||||
TELEPHONY_LOGE("versionRaw.size error!");
|
||||
if (versionRaw.size() < NUMBER_THREE) {
|
||||
TELEPHONY_LOGE("versionRaw.size(%{public}zu) error!", versionRaw.size());
|
||||
return "";
|
||||
}
|
||||
std::ostringstream oss;
|
||||
oss << std::hex << static_cast<unsigned char>(versionRaw[VERSION_HIGH]) << "." <<
|
||||
static_cast<unsigned char>(versionRaw[VERSION_MIDDLE]) << "." <<
|
||||
static_cast<unsigned char>(versionRaw[VERSION_LOW]);
|
||||
oss << std::hex << std::uppercase << (versionRaw[VERSION_HIGH] & MAX_UINT8) << "." <<
|
||||
(versionRaw[VERSION_MIDDLE] & MAX_UINT8) << "." <<
|
||||
(versionRaw[VERSION_LOW] & MAX_UINT8);
|
||||
return oss.str();
|
||||
}
|
||||
|
||||
@ -387,22 +392,24 @@ std::shared_ptr<Asn1Node> EsimFile::Asn1ParseResponse(const std::vector<uint8_t>
|
||||
|
||||
bool EsimFile::ProcessObtainEuiccInfo1Done(const AppExecFwk::InnerEvent::Pointer &event)
|
||||
{
|
||||
std::shared_ptr<Asn1Node> root = ParseEvent(event);
|
||||
if (root == nullptr) {
|
||||
TELEPHONY_LOGE("Asn1ParseResponse failed");
|
||||
IccFileData rawData;
|
||||
if (!GetRawDataFromEvent(event, rawData)) {
|
||||
TELEPHONY_LOGE("rawData is nullptr within rcvMsg");
|
||||
return false;
|
||||
}
|
||||
std::vector<uint8_t> responseByte = Asn1Utils::HexStrToBytes(rawData.resultData);
|
||||
uint32_t byteLen = responseByte.size();
|
||||
std::shared_ptr<Asn1Node> root = Asn1ParseResponse(responseByte, byteLen);
|
||||
if(root == nullptr) {
|
||||
TELEPHONY_LOGE("Asn1ParseResponse error!");
|
||||
return false;
|
||||
}
|
||||
if (!ObtainEuiccInfo1ParseTagCtx2(root)) {
|
||||
TELEPHONY_LOGE("ObtainEuiccInfo1ParseTagCtx2 error!");
|
||||
return false;
|
||||
}
|
||||
std::unique_ptr<IccFromRilMsg> rcvMsg = event->GetUniqueObject<IccFromRilMsg>();
|
||||
if (rcvMsg == nullptr) {
|
||||
TELEPHONY_LOGE("rcvMsg is nullptr");
|
||||
return false;
|
||||
}
|
||||
IccFileData *result = &(rcvMsg->fileData);
|
||||
eUiccInfo_.response_ = Str8ToStr16(result->resultData);
|
||||
std::string responseHexStr = rawData.resultData;
|
||||
eUiccInfo_.response_ = Str8ToStr16(responseHexStr);
|
||||
{
|
||||
std::lock_guard<std::mutex> lock(euiccInfo1Mutex_);
|
||||
isEuiccInfo1Ready_ = true;
|
||||
@ -461,6 +468,7 @@ bool EsimFile::RequestAllProfilesParseProfileInfo(std::shared_ptr<Asn1Node> &roo
|
||||
profileRoot->Asn1GetChildren(TAG_ESIM_PROFILE_INFO, profileNodes);
|
||||
std::shared_ptr<Asn1Node> curNode = nullptr;
|
||||
EuiccProfileInfo euiccProfileInfo = {{0}};
|
||||
euiccProfileInfoList_.profiles_.clear();
|
||||
for (auto it = profileNodes.begin(); it != profileNodes.end(); ++it) {
|
||||
curNode = *it;
|
||||
if (!curNode->Asn1HasChild(TAG_ESIM_ICCID)) {
|
||||
@ -546,7 +554,9 @@ void EsimFile::BuildBasicProfileInfo(EuiccProfileInfo *eProfileInfo, std::shared
|
||||
TELEPHONY_LOGE("serviceProviderNameNode is nullptr");
|
||||
return;
|
||||
}
|
||||
serviceProviderNameNode->Asn1AsString(eProfileInfo->serviceProviderName);
|
||||
std::vector<uint8_t> serviceProviderNameBytes;
|
||||
serviceProviderNameNode->Asn1AsBytes(serviceProviderNameBytes);
|
||||
eProfileInfo->serviceProviderName = Asn1Utils::BytesToString(serviceProviderNameBytes);
|
||||
}
|
||||
if (profileNode->Asn1HasChild(TAG_ESIM_PROFILE_NAME)) {
|
||||
std::shared_ptr<Asn1Node> profileNameNode = profileNode->Asn1GetChild(TAG_ESIM_PROFILE_NAME);
|
||||
@ -554,7 +564,9 @@ void EsimFile::BuildBasicProfileInfo(EuiccProfileInfo *eProfileInfo, std::shared
|
||||
TELEPHONY_LOGE("profileNameNode is nullptr");
|
||||
return;
|
||||
}
|
||||
profileNameNode->Asn1AsString(eProfileInfo->profileName);
|
||||
std::vector<uint8_t> profileNameBytes;
|
||||
profileNameNode->Asn1AsBytes(profileNameBytes);
|
||||
eProfileInfo->profileName = Asn1Utils::BytesToString(profileNameBytes);
|
||||
}
|
||||
if (profileNode->Asn1HasChild(TAG_ESIM_OPERATOR_ID)) {
|
||||
std::shared_ptr<Asn1Node> pOperatorId = profileNode->Asn1GetChild(TAG_ESIM_OPERATOR_ID);
|
||||
@ -853,13 +865,9 @@ bool EsimFile::ProcessObtainSmdsAddressDone(const AppExecFwk::InnerEvent::Pointe
|
||||
TELEPHONY_LOGE("profileRoot is nullptr!");
|
||||
return false;
|
||||
}
|
||||
std::string outPutBytes;
|
||||
uint32_t byteLen = profileRoot->Asn1AsString(outPutBytes);
|
||||
if (byteLen == 0) {
|
||||
TELEPHONY_LOGE("byteLen is zero!");
|
||||
return false;
|
||||
}
|
||||
smdsAddress_ = outPutBytes;
|
||||
std::vector<uint8_t> outPutBytes;
|
||||
profileRoot->Asn1AsBytes(outPutBytes);
|
||||
smdsAddress_ = Asn1Utils::BytesToString(outPutBytes);
|
||||
{
|
||||
std::lock_guard<std::mutex> lock(smdsAddressMutex_);
|
||||
isSmdsAddressReady_ = true;
|
||||
@ -872,17 +880,19 @@ struct CarrierIdentifier CarrierIdentifiers(const std::vector<uint8_t> &mccMncDa
|
||||
const std::u16string &gid1, const std::u16string &gid2)
|
||||
{
|
||||
std::string strResult = Asn1Utils::BytesToHexStr(mccMncData);
|
||||
std::string mMcc(NUMBER_THREE + NUMBER_ONE, '\0');
|
||||
std::string mMcc(NUMBER_THREE, '\0');
|
||||
mMcc[NUMBER_ZERO] = strResult[NUMBER_ONE];
|
||||
mMcc[NUMBER_ONE] = strResult[NUMBER_ZERO];
|
||||
mMcc[NUMBER_TWO] = strResult[NUMBER_THREE];
|
||||
std::string mMnc(NUMBER_THREE, '\0');
|
||||
mMnc[NUMBER_ZERO] = strResult[NUMBER_FIVE];
|
||||
mMnc[NUMBER_ONE] = strResult[NUMBER_FOUR];
|
||||
mMcc[NUMBER_TWO] = strResult[NUMBER_THREE];
|
||||
if (strResult[NUMBER_TWO] != 'F') {
|
||||
mMnc[NUMBER_TWO] = strResult[NUMBER_TWO];
|
||||
}
|
||||
CarrierIdentifier carrierId;
|
||||
carrierId.mcc_ = OHOS::Telephony::ToUtf16(mMcc);
|
||||
carrierId.mnc_ = OHOS::Telephony::ToUtf16(mMnc);
|
||||
carrierId.mcc_ = OHOS::Telephony::ToUtf16(std::string(mMcc.c_str()));
|
||||
carrierId.mnc_ = OHOS::Telephony::ToUtf16(std::string(mMnc.c_str()));
|
||||
carrierId.gid1_ = gid1;
|
||||
carrierId.gid2_ = gid2;
|
||||
return carrierId;
|
||||
@ -1363,26 +1373,40 @@ bool EsimFile::IsEsimSupported()
|
||||
return isSupported_;
|
||||
}
|
||||
|
||||
ResponseEsimResult EsimFile::SendApduData(const std::u16string &aid, const std::u16string &apduData)
|
||||
ResponseEsimResult EsimFile::SendApduData(const std::u16string &aid, const EsimApduData &apduData)
|
||||
{
|
||||
if (aid.empty() || apduData.empty()) {
|
||||
if (aid.empty()) {
|
||||
return ResponseEsimResult();
|
||||
}
|
||||
esimProfile_.aid = aid;
|
||||
if (esimProfile_.aid != aid) {
|
||||
SyncCloseChannel();
|
||||
esimProfile_.aid = aid;
|
||||
}
|
||||
esimProfile_.apduData = apduData;
|
||||
if (esimProfile_.apduData.closeChannelFlag_) {
|
||||
SyncCloseChannel();
|
||||
esimProfile_.apduData.instructionType_ = 0;
|
||||
esimProfile_.apduData.instruction_ = 0;
|
||||
esimProfile_.apduData.p1_ = 0;
|
||||
esimProfile_.apduData.p2_ = 0;
|
||||
esimProfile_.apduData.p3_ = 0;
|
||||
esimProfile_.apduData.unusedDefaultReqHeadFlag_ = false;
|
||||
return ResponseEsimResult();
|
||||
}
|
||||
|
||||
SyncOpenChannel(aid);
|
||||
AppExecFwk::InnerEvent::Pointer eventSendApduData = BuildCallerInfo(MSG_ESIM_SEND_APUD_DATA);
|
||||
if (!ProcessSendApduData(slotId_, eventSendApduData)) {
|
||||
TELEPHONY_LOGE("ProcessSendApduData encode failed");
|
||||
return ResponseEsimResult();
|
||||
}
|
||||
isSendApduDataReady_ = false
|
||||
std::unique_lock<std::mutex> lock(sendApduDataMutex_);
|
||||
if (!sendApduDataCv_.wait_for(lock, std::chrono::seconds(WAIT_TIME_LONG_SECOND_FOR_ESIM),
|
||||
[this]() { return isSendApduDataReady_; })) {
|
||||
SyncCloseChannel();
|
||||
return ResponseEsimResult();
|
||||
}
|
||||
SyncCloseChannel();
|
||||
return transApduDataResponse_;
|
||||
}
|
||||
|
||||
@ -1483,8 +1507,7 @@ bool EsimFile::ProcessSendApduData(int32_t slotId, const AppExecFwk::InnerEvent:
|
||||
if (!IsLogicChannelOpen()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
std::string hexStr = OHOS::Telephony::ToUtf8(esimProfile_.toBeSendApduDataHexStr);
|
||||
std::string hexStr = OHOS::Telephony::ToUtf8(esimProfile_.apduData.data_);
|
||||
RequestApduBuild codec(currentChannelId_);
|
||||
codec.BuildStoreData(hexStr);
|
||||
std::list<std::unique_ptr<ApduCommand>> list = codec.GetCommands();
|
||||
@ -1494,6 +1517,13 @@ bool EsimFile::ProcessSendApduData(int32_t slotId, const AppExecFwk::InnerEvent:
|
||||
}
|
||||
ApduSimIORequestInfo reqInfo;
|
||||
CopyApdCmdToReqInfo(&reqInfo, apdCmd.get());
|
||||
if (esimProfile_.apduData.unusedDefaultReqHeadFlag_) {
|
||||
reqInfo.type = esimProfile_.apduData.instructionType_;
|
||||
reqInfo.instruction = esimProfile_.apduData.instruction_;
|
||||
reqInfo.p1 = esimProfile_.apduData.p1_;
|
||||
reqInfo.p2 = esimProfile_.apduData.p2_;
|
||||
reqInfo.p3 = esimProfile_.apduData.p3_;
|
||||
}
|
||||
if (telRilManager_ == nullptr) {
|
||||
return false;
|
||||
}
|
||||
@ -1521,6 +1551,8 @@ bool EsimFile::ProcessSendApduDataDone(const AppExecFwk::InnerEvent::Pointer &ev
|
||||
}
|
||||
transApduDataResponse_.resultCode_ = ResultState::RESULT_OK;
|
||||
transApduDataResponse_.response_ = OHOS::Telephony::ToUtf16(result->resultData);
|
||||
transApduDataResponse_.sw1_ = result->sw1;
|
||||
transApduDataResponse_.sw2_ = result->sw2;
|
||||
|
||||
{
|
||||
std::lock_guard<std::mutex> lock(sendApduDataMutex_);
|
||||
@ -2361,6 +2393,10 @@ bool EsimFile::RetrieveNotificatioParseTagCtxComp0(std::shared_ptr<Asn1Node> &ro
|
||||
if (compNode->Asn1GetChildren(TAG_ESIM_SEQUENCE, nodes) != 0) {
|
||||
return false;
|
||||
}
|
||||
if (nodes.empty()) {
|
||||
TELEPHONY_LOGE("node is empty");
|
||||
return false;
|
||||
}
|
||||
EuiccNotification notification;
|
||||
std::shared_ptr<Asn1Node> firstNode = nodes.front();
|
||||
createNotification(firstNode, notification);
|
||||
@ -2778,9 +2814,7 @@ void EsimFile::GetImeiBytes(std::vector<uint8_t> &imeiBytes, const std::string &
|
||||
|
||||
void EsimFile::AddCtxParams1(std::shared_ptr<Asn1Builder> &ctxParams1Builder, Es9PlusInitAuthResp &pbytes)
|
||||
{
|
||||
std::string matchingId;
|
||||
ctxParams1Builder->Asn1AddChildAsString(TAG_ESIM_CTX_0, matchingId);
|
||||
pbytes.matchingId = matchingId;
|
||||
ctxParams1Builder->Asn1AddChildAsString(TAG_ESIM_CTX_0, pbytes.matchingId);
|
||||
std::shared_ptr<Asn1Node> subNode = nullptr;
|
||||
std::vector<uint8_t> tacBytes;
|
||||
std::vector<uint8_t> imeiBytes;
|
||||
@ -3161,23 +3195,29 @@ void EsimFile::ProcessEvent(const AppExecFwk::InnerEvent::Pointer &event)
|
||||
}
|
||||
}
|
||||
|
||||
std::shared_ptr<Asn1Node> EsimFile::ParseEvent(const AppExecFwk::InnerEvent::Pointer &event)
|
||||
bool EsimFile::GetRawDataFromEvent(const AppExecFwk::InnerEvent::Pointer &event, IccFileData &outRawData)
|
||||
{
|
||||
if (event == nullptr) {
|
||||
TELEPHONY_LOGE("event is nullptr!");
|
||||
return nullptr;
|
||||
return false;
|
||||
}
|
||||
std::unique_ptr<IccFromRilMsg> rcvMsg = event->GetUniqueObject<IccFromRilMsg>();
|
||||
if (rcvMsg == nullptr) {
|
||||
TELEPHONY_LOGE("rcvMsg is nullptr");
|
||||
return false;
|
||||
}
|
||||
outRawData = rcvMsg->fileData;
|
||||
return true;
|
||||
}
|
||||
|
||||
std::shared_ptr<Asn1Node> EsimFile::ParseEvent(const AppExecFwk::InnerEvent::Pointer &event)
|
||||
{
|
||||
IccFileData rawData;
|
||||
if (!GetRawDataFromEvent(event, rawData)) {
|
||||
TELEPHONY_LOGE("rawData is nullptr within rcvMsg");
|
||||
return nullptr;
|
||||
}
|
||||
IccFileData *resultDataPtr = &(rcvMsg->fileData);
|
||||
if (resultDataPtr == nullptr) {
|
||||
TELEPHONY_LOGE("resultDataPtr is nullptr within rcvMsg");
|
||||
return nullptr;
|
||||
}
|
||||
std::vector<uint8_t> responseByte = Asn1Utils::HexStrToBytes(resultDataPtr->resultData);
|
||||
std::vector<uint8_t> responseByte = Asn1Utils::HexStrToBytes(rawData.resultData);
|
||||
uint32_t byteLen = responseByte.size();
|
||||
return Asn1ParseResponse(responseByte, byteLen);
|
||||
}
|
||||
|
@ -1124,7 +1124,7 @@ bool SimFileManager::IsEsimSupported()
|
||||
return result;
|
||||
}
|
||||
|
||||
ResponseEsimResult SimFileManager::SendApduData(const std::u16string &aid, const std::u16string &apduData)
|
||||
ResponseEsimResult SimFileManager::SendApduData(const std::u16string &aid, const EsimApduData &apduData)
|
||||
{
|
||||
if (eSimFile_ == nullptr) {
|
||||
TELEPHONY_LOGE("esimFile is nullptr");
|
||||
|
@ -1402,7 +1402,7 @@ bool SimManager::IsEsimSupported(int32_t slotId)
|
||||
}
|
||||
|
||||
int32_t SimManager::SendApduData(
|
||||
int32_t slotId, const std::u16string &aid, const std::u16string &apduData, ResponseEsimResult &responseResult)
|
||||
int32_t slotId, const std::u16string &aid, const EsimApduData &apduData, ResponseEsimResult &responseResult)
|
||||
{
|
||||
if ((!IsValidSlotId(slotId, simFileManager_)) || (simFileManager_[slotId] == nullptr)) {
|
||||
TELEPHONY_LOGE("slotId is invalid or simFileManager_ is null!");
|
||||
|
@ -194,7 +194,7 @@ HWTEST_F(EsimCoreServiceClientBranchTest, SendApduData_0100, Function | MediumTe
|
||||
{
|
||||
int32_t slotId = 0;
|
||||
std::u16string aid = Str8ToStr16("aid test");
|
||||
std::u16string apduData = Str8ToStr16("apduData test");
|
||||
EsimApduData apduData;
|
||||
ResponseEsimResult responseResult;
|
||||
EXPECT_CALL(*samgr, CheckSystemAbility(testing::_)).WillOnce(testing::Return(nullptr));
|
||||
int32_t result = CoreServiceClient::GetInstance().SendApduData(slotId, aid, apduData, responseResult);
|
||||
|
@ -22,6 +22,7 @@ ohos_unittest("parcel_gtest") {
|
||||
|
||||
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",
|
||||
|
@ -302,8 +302,8 @@ uint32_t Asn1Node::Asn1AsString(std::string &output)
|
||||
return hexStrLen;
|
||||
}
|
||||
std::string hexStr = Asn1Utils::BytesToHexStr(dataBytes_);
|
||||
output = Asn1Utils::HexStrToString(hexStr);
|
||||
return static_cast<uint32_t>(Asn1Utils::HexStrToString(hexStr).length());
|
||||
output = hexStr;
|
||||
return static_cast<uint32_t>(hexStr.length());
|
||||
}
|
||||
|
||||
int32_t Asn1Node::Asn1AsBits()
|
||||
|
@ -117,8 +117,8 @@ void Asn1Utils::BcdToBytes(const std::string &bcd, std::vector<uint8_t> &bytes)
|
||||
|
||||
std::string Asn1Utils::BytesToHexStr(const std::vector<uint8_t> &bytes)
|
||||
{
|
||||
if (bytes.size() > MAX_UINT8) {
|
||||
return "";
|
||||
if (bytes.size() > MAX_UINT16) {
|
||||
return "";
|
||||
}
|
||||
std::ostringstream oss;
|
||||
for (size_t i = 0; i < bytes.size(); i++) {
|
||||
@ -138,7 +138,7 @@ uint32_t Asn1Utils::ByteToHexStr(uint8_t src, std::string &dest)
|
||||
std::vector<uint8_t> Asn1Utils::HexStrToBytes(const std::string& hexStr)
|
||||
{
|
||||
std::vector<uint8_t> ret = {};
|
||||
if (hexStr.length() > (MAX_UINT8 * BYTE_TO_HEX_LEN)) {
|
||||
if (hexStr.length() > (MAX_UINT16 * BYTE_TO_HEX_LEN)) {
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
@ -132,12 +132,11 @@ typedef struct TagEsimProfile {
|
||||
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"";
|
||||
EsimApduData apduData;
|
||||
} EsimProfile;
|
||||
|
||||
typedef struct TagEs9PlusInitAuthResp {
|
||||
|
Loading…
Reference in New Issue
Block a user