有没有一种方法可以使用AccessibilityService在对话框中单击超链接?

2020年3月16日 58点热度 0条评论

permission prompt image

我正在尝试使用可访问性通过我的应用程序的可访问性服务单击“允许设置”。我已经看过AccessibilityNode,但在TextView中看不到任何可交互的东西。这是节点的输出:

Event Type: TYPE_WINDOW_CONTENT_CHANGED com.google.android.permissioncontroller android.widget.FrameLayout
 Source: 
0 | class name: android.widget.FrameLayout text: null content description: null input type 0 actions: ACTION_SELECT, ACTION_CLEAR_SELECTION, ACTION_ACCESSIBILITY_FOCUS, ACTION_SHOW_ON_SCREEN  
1 | class name: android.widget.ScrollView text: null content description: null input type 0 actions: ACTION_FOCUS, ACTION_SELECT, ACTION_CLEAR_SELECTION, ACTION_ACCESSIBILITY_FOCUS, ACTION_SHOW_ON_SCREEN  
2 | class name: android.widget.TextView text: Change location access for AppName? content description: null input type 0 actions: ACTION_SELECT, ACTION_CLEAR_SELECTION, ACTION_ACCESSIBILITY_FOCUS, ACTION_NEXT_AT_MOVEMENT_GRANULARITY, ACTION_PREVIOUS_AT_MOVEMENT_GRANULARITY, ACTION_SET_SELECTION, ACTION_SHOW_ON_SCREEN  
2 | class name: android.widget.TextView text: This app wants to access your location all the time, even when you’re not using the app. Allow in settings. content description: null input type 0 actions: ACTION_FOCUS, ACTION_SELECT, ACTION_CLEAR_SELECTION, ACTION_ACCESSIBILITY_FOCUS, ACTION_NEXT_AT_MOVEMENT_GRANULARITY, ACTION_PREVIOUS_AT_MOVEMENT_GRANULARITY, ACTION_SET_SELECTION, ACTION_SHOW_ON_SCREEN  
2 | class name: android.widget.Button text: Keep “While the app is in use” content description: null input type 0 actions: ACTION_FOCUS, ACTION_SELECT, ACTION_CLEAR_SELECTION, ACTION_CLICK, ACTION_ACCESSIBILITY_FOCUS, ACTION_NEXT_AT_MOVEMENT_GRANULARITY, ACTION_PREVIOUS_AT_MOVEMENT_GRANULARITY, ACTION_SET_SELECTION, ACTION_SHOW_ON_SCREEN 

TextView只有很少的可用操作。我已尽我所能尝试了可用的操作,但没有成功。

我还探讨了直接意图“允许设置”部分的想法,但目前还没有。我们的应用要求位置始终保持打开状态。

解决方案如下:

从Android O开始,ClickableSpans一直传递到可访问性。您可以在文本中找到ClickableSpans,然后调用onClick。然后,系统将确保在应用程序过程中调用原始跨度的onClick方法。

如果您使用AccessibilityNodeInfoCompat,则将其反向移植,但该应用还必须调用ViewCompat#enableAccessibleClickableSpanSupport(view)。