mirror of
https://gitee.com/openharmony/accessibility
synced 2024-11-27 00:51:07 +00:00
修复返回节点数量为0时,不能正常SetResult的问题
Signed-off-by: taojuncun <taojuncun@huawei.com>
This commit is contained in:
parent
e237e0fd42
commit
337b5f7d3c
@ -81,25 +81,27 @@ void AccessibilityElementOperatorCallbackProxy::SetSearchElementInfoByAccessibil
|
||||
return;
|
||||
}
|
||||
|
||||
MessageParcel tmpParcel;
|
||||
tmpParcel.SetMaxCapacity(MAX_RAWDATA_SIZE);
|
||||
// when set pracel's max capacity, it won't alloc memory immediately
|
||||
// MessageParcel will expand memory dynamiclly
|
||||
for (const auto &info : infos) {
|
||||
AccessibilityElementInfoParcel infoParcel(info);
|
||||
if (!tmpParcel.WriteParcelable(&infoParcel)) {
|
||||
HILOG_ERROR("write accessibilityElementInfoParcel failed");
|
||||
if (infos.size() != 0) {
|
||||
MessageParcel tmpParcel;
|
||||
tmpParcel.SetMaxCapacity(MAX_RAWDATA_SIZE);
|
||||
// when set pracel's max capacity, it won't alloc memory immediately
|
||||
// MessageParcel will expand memory dynamiclly
|
||||
for (const auto &info : infos) {
|
||||
AccessibilityElementInfoParcel infoParcel(info);
|
||||
if (!tmpParcel.WriteParcelable(&infoParcel)) {
|
||||
HILOG_ERROR("write accessibilityElementInfoParcel failed");
|
||||
return;
|
||||
}
|
||||
}
|
||||
size_t tmpParcelSize = tmpParcel.GetDataSize();
|
||||
if (!data.WriteUint32(tmpParcelSize)) {
|
||||
HILOG_ERROR("write rawData size failed");
|
||||
return;
|
||||
}
|
||||
if (!data.WriteRawData(reinterpret_cast<uint8_t *>(tmpParcel.GetData()), tmpParcelSize)) {
|
||||
HILOG_ERROR("write rawData failed");
|
||||
return;
|
||||
}
|
||||
}
|
||||
size_t tmpParcelSize = tmpParcel.GetDataSize();
|
||||
if (!data.WriteUint32(tmpParcelSize)) {
|
||||
HILOG_ERROR("write rawData size failed");
|
||||
return;
|
||||
}
|
||||
if (!data.WriteRawData(reinterpret_cast<uint8_t *>(tmpParcel.GetData()), tmpParcelSize)) {
|
||||
HILOG_ERROR("write rawData failed");
|
||||
return;
|
||||
}
|
||||
|
||||
if (!SendTransactCmd(AccessibilityInterfaceCode::SET_RESULT_BY_ACCESSIBILITY_ID, data, reply, option)) {
|
||||
|
@ -110,27 +110,30 @@ ErrCode AccessibilityElementOperatorCallbackStub::HandleSetSearchElementInfoByAc
|
||||
std::vector<AccessibilityElementInfo> storeData;
|
||||
int32_t requestId = data.ReadInt32();
|
||||
size_t infoSize = data.ReadUint32();
|
||||
size_t rawDataSize = data.ReadUint32();
|
||||
MessageParcel tmpParcel;
|
||||
void *buffer = nullptr;
|
||||
// memory alloced in GetData will be released when tmpParcel destruct
|
||||
if (!GetData(rawDataSize, data.ReadRawData(rawDataSize), buffer)) {
|
||||
reply.WriteInt32(RET_ERR_FAILED);
|
||||
return TRANSACTION_ERR;
|
||||
}
|
||||
|
||||
if (!tmpParcel.ParseFrom(reinterpret_cast<uintptr_t>(buffer), rawDataSize)) {
|
||||
reply.WriteInt32(RET_ERR_FAILED);
|
||||
return TRANSACTION_ERR;
|
||||
}
|
||||
|
||||
for (size_t i = 0; i < infoSize; i++) {
|
||||
sptr<AccessibilityElementInfoParcel> info = tmpParcel.ReadStrongParcelable<AccessibilityElementInfoParcel>();
|
||||
if (info == nullptr) {
|
||||
if (infoSize != 0) {
|
||||
size_t rawDataSize = data.ReadUint32();
|
||||
MessageParcel tmpParcel;
|
||||
void *buffer = nullptr;
|
||||
// memory alloced in GetData will be released when tmpParcel destruct
|
||||
if (!GetData(rawDataSize, data.ReadRawData(rawDataSize), buffer)) {
|
||||
reply.WriteInt32(RET_ERR_FAILED);
|
||||
return TRANSACTION_ERR;
|
||||
}
|
||||
storeData.emplace_back(*info);
|
||||
|
||||
if (!tmpParcel.ParseFrom(reinterpret_cast<uintptr_t>(buffer), rawDataSize)) {
|
||||
reply.WriteInt32(RET_ERR_FAILED);
|
||||
return TRANSACTION_ERR;
|
||||
}
|
||||
|
||||
for (size_t i = 0; i < infoSize; i++) {
|
||||
sptr<AccessibilityElementInfoParcel> info =
|
||||
tmpParcel.ReadStrongParcelable<AccessibilityElementInfoParcel>();
|
||||
if (info == nullptr) {
|
||||
reply.WriteInt32(RET_ERR_FAILED);
|
||||
return TRANSACTION_ERR;
|
||||
}
|
||||
storeData.emplace_back(*info);
|
||||
}
|
||||
}
|
||||
reply.WriteInt32(RET_OK);
|
||||
SetSearchElementInfoByAccessibilityIdResult(storeData, requestId);
|
||||
|
Loading…
Reference in New Issue
Block a user