[英]Accessibility service: get views you can interact with instantly (same as Voice Access)?
The goal is to obtain views that can be interacted with instantly (that can be clicked right now and something would happen). 我们的目标是获得可与瞬间 (可以单击现在有什么东西会发生)进行交互的意见。 If the view is visible and clickable in general but hovered by another view/menu/side panel, it should be omitted.
如果视图一般可见且可点击但由另一个视图/菜单/侧面板悬停,则应省略该视图。
Voice Access do that. Voice Access可以做到这一点。 And it seems to use Accessibility API.
它似乎使用Accessibility API。
The perfect example is the bottom menu in Google Maps. 完美的例子是谷歌地图的底部菜单。 When it expands, "Search along the route" button underneath is still visible but it's not highlighted by the app.
当它展开时,下面的“沿着路线搜索”按钮仍然可见,但应用程序没有突出显示它。
I've looked through all parameters of the AccessibilityNodeInfo , like isVisibleToUser()
, isClickable()
, isContextClickable()
, isSelected()
, isFocusable()
, isFocused()
, isAccessibilityFocused()
and the button has the same parameters when the bottom menu is collapsed/expanded. 我查看了AccessibilityNodeInfo的所有参数,如
isVisibleToUser()
, isClickable()
, isContextClickable()
, isSelected()
, isFocusable()
, isFocused()
, isAccessibilityFocused()
和底部菜单时按钮具有相同的参数折叠/展开。 It's visible to the user, focusable and clickable. 它对用户可见,可聚焦且可点击。
I've looked into hidden APIs and don't see anything that can be useful. 我查看了隐藏的API,但没有看到任何有用的东西。
What I'm missing? 我错过了什么?
The key point is that in an AccessibilityService.onAccessibilityEvent() the tree hierarchy is not final. 关键点在于,在AccessibilityService.onAccessibilityEvent()中 ,树层次结构不是最终的。 To get views that are interactable at the moment, AccessibilityService.getRootInActiveWindow() should be called with a delay.
要获取此时可交互的视图,应调用AccessibilityService.getRootInActiveWindow()并延迟。
AccessibilityNodeInfo#getDrawingOrder() will probably help you. AccessibilityNodeInfo#getDrawingOrder()可能会帮助你。 Note that you need to do tree traversal to determine what is on top of what.
请注意,您需要执行树遍历以确定最重要的内容。
There are still corner cases with transparent views that will give you trouble, but that should get you 95% of the way there. 仍然存在透明视图的角落案例会给你带来麻烦,但这应该可以让你获得95%的胜利。 We're working on a better answer for that case.
我们正在为这个案子找到更好的答案。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.