!1398 焦点查询需判断window是否在窗口列表

Merge pull request !1398 from 姚子鹏/focusIsInWindow
This commit is contained in:
openharmony_ci 2024-09-05 06:11:46 +00:00 committed by Gitee
commit 6287e39880
No known key found for this signature in database
GPG Key ID: 173E9B9CA92EEF8F
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

@ -74,7 +74,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);
@ -717,5 +717,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