mirror of
https://gitee.com/openharmony/ability_ability_runtime
synced 2024-11-23 23:30:44 +00:00
commit
3253838b43
@ -195,7 +195,7 @@ void FormJsInfo::ReadImageData(Parcel &parcel)
|
||||
auto picName = Str16ToStr8(parcel.ReadString16());
|
||||
HILOG_INFO("picName: %{public}s, fd: %{public}d, size: %{public}d", picName.c_str(), fd, len);
|
||||
std::pair<int, int32_t> imageDataPair = std::make_pair(fd, len);
|
||||
imageDataMap.emplace(picName, imageDataPair);
|
||||
imageDataMap[picName] = imageDataPair;
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
@ -128,6 +128,7 @@ void FormProviderData::AddImageData(std::string picName, int fd)
|
||||
{
|
||||
HILOG_INFO("%{public}s called. fd is %{public}d", __func__, fd);
|
||||
if (fd < 0) {
|
||||
HILOG_ERROR("fd is invalid.");
|
||||
return;
|
||||
}
|
||||
|
||||
@ -162,6 +163,8 @@ void FormProviderData::ParseImagesData()
|
||||
for (auto iter = jsonImages.begin(); iter != jsonImages.end(); iter++) {
|
||||
if (iter->is_number_integer()) {
|
||||
AddImageData(iter.key(), iter.value());
|
||||
} else {
|
||||
HILOG_ERROR("fd is not number integer.");
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -279,7 +282,8 @@ bool FormProviderData::ReadFromParcel(Parcel &parcel)
|
||||
|
||||
int32_t len = parcel.ReadInt32();
|
||||
std::pair<sptr<Ashmem>, int32_t> imageDataRecord = std::make_pair(ashmem, len);
|
||||
imageDataMap_.emplace(Str16ToStr8(parcel.ReadString16()), imageDataRecord);
|
||||
auto picName = Str16ToStr8(parcel.ReadString16());
|
||||
imageDataMap_[picName] = imageDataRecord;
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
@ -204,6 +204,18 @@ void FormDataMgr::CreateFormInfo(const int64_t formId, const FormRecord &record,
|
||||
formInfo.versionName = record.versionName;
|
||||
formInfo.compatibleVersion = record.compatibleVersion;
|
||||
formInfo.icon = record.icon;
|
||||
auto sharedImageMap = record.formProviderInfo.GetFormData().GetImageDataMap();
|
||||
if (sharedImageMap.size() > FormJsInfo::IMAGE_DATA_THRESHOLD) {
|
||||
return;
|
||||
}
|
||||
for (auto entry : sharedImageMap) {
|
||||
auto picName = entry.first;
|
||||
auto ashmem = entry.second.first;
|
||||
auto fd = ashmem->GetAshmemFd();
|
||||
auto len = ashmem->GetAshmemSize();
|
||||
std::pair<int, int32_t> imageDataPair = std::make_pair(fd, len);
|
||||
formInfo.imageDataMap[picName] = imageDataPair;
|
||||
}
|
||||
}
|
||||
/**
|
||||
* @brief Check temp form count is max.
|
||||
|
Loading…
Reference in New Issue
Block a user