!2406 修复VCard导入导出一致性

Merge pull request !2406 from mayuecheng/vcard_1029
This commit is contained in:
openharmony_ci 2024-10-31 04:14:04 +00:00 committed by Gitee
commit 4779a68858
No known key found for this signature in database
GPG Key ID: 173E9B9CA92EEF8F
4 changed files with 17 additions and 10 deletions

View File

@ -46,7 +46,7 @@ bool NrSsbInformation::Marshalling(Parcel &parcel) const
if (!parcel.WriteInt32(timeAdvance_)) {
return false;
}
for (int32_t i = 0; i < SCELL_SSB_LIST && i < sCellSsbList_.size(); ++i) {
for (int32_t i = 0; i < SCELL_SSB_LIST && i < static_cast<int32_t>(sCellSsbList_.size()); ++i) {
if (!parcel.WriteInt32(sCellSsbList_[i].ssbId)) {
return false;
}

View File

@ -379,8 +379,12 @@ int32_t VCardConstructor::ConstructRelation(std::shared_ptr<VCardContact> contac
if (relationData == nullptr) {
continue;
}
std::string labelId = relationData->GetLabelId();
if (labelId == std::to_string(static_cast<int32_t>(RelationType::CUSTOM_LABEL))) {
labelId = std::to_string(VALUE_INDEX_ZERO);
}
AddCustomType(VCARD_TYPE_X_MOBILE_RELATION,
{ relationData->GetRelationName(), relationData->GetLabelId(), relationData->GetLabelName() });
{ relationData->GetRelationName(), labelId, relationData->GetLabelName() });
}
return TELEPHONY_SUCCESS;
}
@ -534,7 +538,7 @@ void VCardConstructor::AddPostalLine(
postalTypeStr = "X-" + labelName;
}
if (postalType == static_cast<int32_t>(PostalType::ADDR_OTHER)) {
postalTypeStr = "X-" + std::string(VCARD_PARAM_ADR_EXTRA_TYPE_OTHER);
postalTypeStr = "";
}
if (!postalTypeStr.empty()) {
paramTypes.push_back(postalTypeStr);
@ -704,7 +708,7 @@ int32_t VCardConstructor::ConstructEvents(std::shared_ptr<VCardContact> contact)
{static_cast<int32_t>(EventType::EVENT_ANNIVERSARY), static_cast<int32_t>(EventHM4Type::EVENT_HM4_ANNIVERSARY)},
{static_cast<int32_t>(EventType::EVENT_LUNAR_BIRTHDAY),
static_cast<int32_t>(EventHM4Type::EVENT_HM4_LUNAR_BIRTHDAY)},
{static_cast<int32_t>(EventType::EVENT_OTHER), static_cast<int32_t>(EventHM4Type::EVENT_HM4_OTHER)},
{static_cast<int32_t>(EventType::CUSTOM_LABEL), static_cast<int32_t>(EventHM4Type::EVENT_HM4_OTHER)},
{static_cast<int32_t>(EventType::EVENT_BIRTHDAY), static_cast<int32_t>(EventHM4Type::EVENT_HM4_BIRTHDAY)}
};
for (auto eventData : contact->GetEventDatas()) {
@ -821,6 +825,9 @@ void VCardConstructor::AddEmailLine(
if (emailType == static_cast<int32_t>(EmailType::CUSTOM_LABEL)) {
postalTypeStr = "X-" + labelName;
}
if (emailType == static_cast<int32_t>(EmailType::EMAIL_OTHER)) {
postalTypeStr = "";
}
if (!postalTypeStr.empty()) {
paramTypes.push_back(postalTypeStr);
}

View File

@ -966,8 +966,8 @@ void VCardContact::AddEmailsData(std::string rawValue, std::string propValue, st
std::vector<std::string> typeCollection;
std::map<std::string, std::vector<std::string>>::iterator it = parasMap.find(VCARD_PARAM_TYPE);
if (it == parasMap.end()) {
TELEPHONY_LOGE("Map does not contain this key, %{public}s", VCARD_PARAM_TYPE);
return;
TELEPHONY_LOGI("Map does not contain this key, %{public}s, use OTHER type", VCARD_PARAM_TYPE);
// contains no type info will fallback to OTHER type
} else {
typeCollection = it->second;
}
@ -1022,8 +1022,8 @@ void VCardContact::AddPostalDatas(std::string rawValue, std::string propValue, s
std::vector<std::string> typeCollection;
std::map<std::string, std::vector<std::string>>::iterator it = parasMap.find(VCARD_PARAM_TYPE);
if (it == parasMap.end()) {
TELEPHONY_LOGE("Map does not contain this key, %{public}s", VCARD_PARAM_TYPE);
return;
TELEPHONY_LOGI("Map does not contain this key, %{public}s, use OTHER type", VCARD_PARAM_TYPE);
// contains no type info will fallback to OTHER type
} else {
typeCollection = it->second;
}
@ -1054,7 +1054,7 @@ void VCardContact::AddPostalDatas(std::string rawValue, std::string propValue, s
TELEPHONY_LOGI("No need to do anything");
}
}
AddPostal(type < 0 ? static_cast<int32_t>(PostalType::ADDR_HOME) : type, values, label, isPrimary);
AddPostal(type < 0 ? static_cast<int32_t>(PostalType::ADDR_OTHER) : type, values, label, isPrimary);
}
void VCardContact::AddSoundDatas(std::string rawValue, std::string propValue, std::vector<std::string> values,

View File

@ -48,7 +48,7 @@ std::map<PhoneVcType, std::string> phoneLabelIdToType = { { PhoneVcType::NUM_HOM
{ PhoneVcType::NUM_RADIO, VCARD_PARAM_PHONE_EXTRA_TYPE_RADIO }, { PhoneVcType::NUM_TELEX, VCARD_PARAM_TYPE_TLX },
{ PhoneVcType::NUM_TTY_TDD, VCARD_PARAM_PHONE_EXTRA_TYPE_TTY_TDD },
{ PhoneVcType::NUM_ASSISTANT, VCARD_PARAM_PHONE_EXTRA_TYPE_ASSISTANT },
{ PhoneVcType::NUM_MMS, VCARD_PARAM_TYPE_MSG } };
{ PhoneVcType::NUM_MMS, VCARD_PARAM_TYPE_MSG }, { PhoneVcType::NUM_MAIN, VCARD_PARAM_TYPE_PREF }};
std::map<std::string, PhoneVcType> typeToPhoneTypeMap = { { VCARD_PARAM_TYPE_CAR, PhoneVcType::NUM_CAR },
{ VCARD_PARAM_TYPE_PAGER, PhoneVcType::NUM_PAGER }, { VCARD_PARAM_TYPE_ISDN, PhoneVcType::NUM_ISDN },
{ VCARD_PARAM_TYPE_HOME, PhoneVcType::NUM_MOBILE }, { VCARD_PARAM_TYPE_WORK, PhoneVcType::NUM_WORK },