简体   繁体   English

辅助功能服务:获取您可以即时互动的视图(与语音访问相同)?

[英]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. 当它展开时,下面的“沿着路线搜索”按钮仍然可见,但应用程序没有突出显示它。


So what do we have? 那么我们有什么?

  • There is a stream of AccessibilityEvent . 有一个AccessibilityEvent流。 The most useful is AccessibilityEvent.TYPE_WINDOW_CONTENT_CHANGED , so we can be notified when something is happening. 最有用的是AccessibilityEvent.TYPE_WINDOW_CONTENT_CHANGED ,因此我们可以在发生任何事情时收到通知。
  • With getSource() we can get an instance of AccessibilityNodeInfo that triggered the event. 使用getSource(),我们可以获得触发事件的AccessibilityNodeInfo实例。 Or we can get a root of a window with AccessibilityService.getRootInActiveWindow() . 或者我们可以使用AccessibilityService.getRootInActiveWindow()获取窗口的根。 And having that we are able to traverse the whole hierarchy within an app. 并且我们能够在应用程序中遍历整个层次结构。
  • AccessibilityNodeInfo doesn't provide any information about z-order of views, so it's not possible to understand what is above and what is beneath. AccessibilityNodeInfo不提供有关z顺序视图的任何信息,因此无法理解上面的内容和下面的内容。
  • The bottom menu is in the same window (it's not modal). 底部菜单位于同一窗口中(它不是模态的)。
  • If you try to click "Search along the route" button while the bottom menu is expanded, the bottom menu collapses. 如果在底部菜单展开时尝试单击“沿路径搜索”按钮,则底部菜单会折叠。 So you can't actually click it, it's beneath the menu. 因此,您无法实际点击它,它位于菜单下方。
  • 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.

相关问题 Android 无障碍服务同时与多个开关交互 - Android Accessibility service interact with numerous switches at once 如何使用语音访问应用程序等辅助功能服务执行其他应用程序列表项单击? - How to perform Other app list item click using accessibility service like Voice Access app? 如何创建可访问性服务的元数据引用的 XML 文件? - How can you create an XML file that is referenced by the metadata of an accessibility service? 您可以将Google地图嵌入具有语音提示的应用程序吗? - Can you embed a google map into an app with get voice directions? 是否可以停止或杀死无障碍服务? - Can accessibility service be stopped or killed? 使用辅助功能服务获取通知图标 - Get notification icon using an accessibility service 使用Android中的辅助功能获取应用名称 - Get the Name of the App using Accessibility Service in Android 如何使用Amazon Voice Service或Alexa对我的应用程序进行语音查询 - How to get voice query to my app with Amazon Voice Service or Alexa 可以与其他应用程序交互的Android服务 - Android service that can interact with other apps 如何在Android中使用Accessibility收听点击并获取视图? - How to listen to taps and get views using Accessibility in Android?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM