sync code to release5.0.1

Signed-off-by: fanzexuan <fanzexuan@huawei.com>
This commit is contained in:
fanzexuan 2024-10-10 14:44:16 +08:00
parent 9dc686e41e
commit 3b3c3e38e7
2 changed files with 16 additions and 1 deletions

View File

@ -72,6 +72,7 @@ private:
static sptr<AccessibleAbilityConnection> GetConnection(int32_t accountId, const std::string &clientName);
static RetError GetElementOperator(int32_t accountId, int32_t windowId, int32_t focusType,
const std::string &clientName, sptr<IAccessibilityElementOperator> &elementOperator, const int32_t treeId);
static bool CheckWinFromAwm(const int32_t windowId);
RetError GetWindows(uint64_t displayId, std::vector<AccessibilityWindowInfo> &windows) const;
RetError TransmitActionToMmi(const int32_t action);
static void SetKeyCodeToMmi(std::shared_ptr<MMI::KeyEvent>& keyEvent, const bool isPress,

View File

@ -75,7 +75,7 @@ RetError AccessibleAbilityChannel::SearchElementInfoByAccessibilityId(const Elem
sptr<IAccessibilityElementOperator> elementOperator = nullptr;
RetError ret = GetElementOperator(accountId_, windowId, FOCUS_TYPE_INVALID, clientName_,
elementOperator, treeId);
if (ret != RET_OK) {
if (ret != RET_OK || !CheckWinFromAwm(windowId)) {
HILOG_ERROR("Get elementOperator failed! accessibilityWindowId[%{public}d]", windowId);
std::vector<AccessibilityElementInfo> infos = {};
callback->SetSearchElementInfoByAccessibilityIdResult(infos, requestId);
@ -714,5 +714,19 @@ RetError AccessibleAbilityChannel::GetElementOperator(
}
return RET_OK;
}
bool AccessibleAbilityChannel::CheckWinFromAwm(const int32_t windowId)
{
std::vector<AccessibilityWindowInfo> windowsFromAwm =
Singleton<AccessibilityWindowManager>::GetInstance().GetAccessibilityWindows();
if (!windowsFromAwm.empty()) {
for (const auto& window: windowsFromAwm) {
if (windowId == window.GetWindowId()) {
return true;
}
}
}
return false;
}
} // namespace Accessibility
} // namespace OHOS