android - 使用辅助服务修改另一个应用程序的 View 层次结构

标签 android android-view android-windowmanager accessibility android-viewgroup

众所周知,我们可以使用 AccessibilityService观察查询任何应用的 View 层次结构:

Create your own accessibility service .

也可以代表用户执行操作:

Developing an Accessibility Service for Android .

我的问题是,我们可以使用AccessibilityService修改前台应用的 View 层次结构吗?

enter image description here

我已经提到了以下问题:

他们正在做的是使用 WindowManagerSYSTEM_ALERT_WINDOW 权限在前台的应用程序顶部覆盖 View 。这种方法的问题是,如果用户按 BACKHOME,应用程序将被关闭,但 View 在屏幕上仍然可见,即使应用程序消失后也是如此。该 View 位于 View 层次结构的TOP,而不是它的一部分。

  • 有没有办法添加/修改 AccessibilityNodeInfo 对象?
  • 这些与 ViewViewGroup 相同吗?
  • 我们是否可以使用 AccessibilityService 添加 View 或修改现有 View ?

My requirement is to display a small view within the app itself. It has to be part of the view hierarchy of the app, so that it stays or goes with the app. For this I need to modify the view hierarchy of the app, namely the AccessibilityNodeInfo objects retrieved from the service.

我想要的是类似于 addView() 的东西,但将 View 添加到应用程序本身的 View 层次结构中,而不是在其之上。

我们怎样才能做到这一点?这可能吗?

更新:

Apps that support Custom Views for Accessibility

最佳答案

不,您无法修改另一个应用程序的 View 层次结构,因为它存在于单独的进程中。

这类似于无法从辅助功能服务中修改辅助功能节点。

关于android - 使用辅助服务修改另一个应用程序的 View 层次结构,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/59248779/

相关文章:

android - 如何通过 gradle 风格更改 Dagger 模块的注入(inject)?

java - 尝试访问USB设备时libusb_open_device_with_vid_pid失败

android - 创建 Google 音乐专辑甲板自定义 ListView

android - 全屏 TYPE_SYSTEM_ALERT [无状态和导航栏]

android - Android 中的全屏服务

android - 在 google maps api 中,这个地址是什么意思

java - AES加密解密无法正常工作--Android

java - 什么是 WindowInsets?

java - 修复 android.view.InflateException

android - 从 Android 中 WindowManager 添加的 View 中捕获 onTouch 或 onClick 事件