AccessibilityService 服务配置文件的内容详解

配置文件

<?xml version="1.0" encoding="UTF-8"?>
<accessibility-service xmlns:android="http://schemas.android.com/apk/res/android"
    android:accessibilityEventTypes="typeAllMask"
    android:accessibilityFeedbackType="feedbackSpoken"
    android:accessibilityFlags="flagDefault"
    android:canRetrieveWindowContent="true"
    android:description="@string/accessibility_query_window_description"
    android:notificationTimeout="100"
    android:packageNames="com.example.android.apis" />

这里可以先参考:http://krelve.com/android/23.html  下面是详解


android:accessibilityEventTypes(可以接收的事件)  谷歌是这样描述的:

AccessibilityService_accessibilityEventTypes

int AccessibilityService_accessibilityEventTypes

The event types this serivce would like to receive as specified in AccessibilityEvent. This setting can be changed at runtime by callingandroid.accessibilityservice.AccessibilityService.setServiceInfo(android.accessibilityservice.AccessibilityServiceInfo).

Must be one or more (separated by '|') of the following constant values.

Constant Value Description
typeViewClicked 0x00000001 Receives TYPE_VIEW_CLICKED events.
typeViewLongClicked 0x00000002 Receives TYPE_VIEW_LONG_CLICKED events.
typeViewSelected 0x00000004 Receives TYPE_VIEW_SELECTED events.
typeViewFocused 0x00000008 Receives TYPE_VIEW_FOCUSED events.
typeViewTextChanged 0x00000010 Receives TYPE_VIEW_TEXT_CHANGED events.
typeWindowStateChanged 0x00000020 Receives TYPE_WINDOW_STATE_CHANGED events.
typeNotificationStateChanged 0x00000040 Receives TYPE_NOTIFICATION_STATE_CHANGED events.
typeViewHoverEnter 0x00000080 Receives TYPE_VIEW_HOVER_ENTER events.
typeViewHoverExit 0x00000100 Receives TYPE_VIEW_HOVER_EXIT events.
typeTouchExplorationGestureStart 0x00000200 Receives TYPE_TOUCH_EXPLORATION_GESTURE_START events.
typeTouchExplorationGestureEnd 0x00000400 Receives TYPE_TOUCH_EXPLORATION_GESTURE_END events.
typeWindowContentChanged 0x00000800 Receives TYPE_WINDOW_CONTENT_CHANGED events.
typeViewScrolled 0x000001000 Receives TYPE_VIEW_SCROLLED events.
typeViewTextSelectionChanged 0x000002000 Receives TYPE_VIEW_TEXT_SELECTION_CHANGED events.
typeAnnouncement 0x00004000 Receives TYPE_ANNOUNCEMENT events.
typeViewAccessibilityFocused 0x00008000 Receives TYPE_VIEW_ACCESSIBILITY_FOCUSED events.
typeViewAccessibilityFocusCleared 0x00010000 Receives TYPE_VIEW_ACCESSIBILITY_FOCUS_CLEARED events.
typeViewTextTraversedAtMovementGranularity 0x00020000 Receives TYPE_VIEW_TEXT_TRAVERSED_AT_MOVEMENT_GRANULARITY events.
typeGestureDetectionStart 0x00040000 Receives TYPE_GESTURE_DETECTION_START events.
typeGestureDetectionEnd 0x00080000 Receives TYPE_GESTURE_DETECTION_END events.
typeTouchInteractionStart 0x00100000 Receives TYPE_TOUCH_INTERACTION_START events.
typeTouchInteractionEnd 0x00200000 Receives TYPE_TOUCH_INTERACTION_END events.
typeWindowsChanged 0x00400000 Receives TYPE_WINDOWS_CHANGED events.
typeContextClicked 0x00800000 Receives TYPE_VIEW_CONTEXT_CLICKED events.
typeAssistReadingContext 0x01000000 Receives TYPE_ASSIST_READING_CONTEXT events.
typeAllMask 0xffffffff Receives TYPES_ALL_MASK i.e. all events.

This corresponds to the global attribute resource symbol accessibilityEventTypes.

Constant Value: 2 (0x00000002)

android:accessibilityFeedbackType( 反馈类型)

AccessibilityService_accessibilityFeedbackType

int AccessibilityService_accessibilityFeedbackType

The feedback types this serivce provides as specified in AccessibilityServiceInfo. This setting can be changed at runtime by callingandroid.accessibilityservice.AccessibilityService.setServiceInfo(android.accessibilityservice.AccessibilityServiceInfo).

Must be one or more (separated by '|') of the following constant values.

Constant Value Description
feedbackSpoken 0x00000001 Provides FEEDBACK_SPOKEN feedback.
feedbackHaptic 0x00000002 Provides FEEDBACK_HAPTIC feedback.
feedbackAudible 0x00000004 Provides FEEDBACK_AUDIBLE feedback.
feedbackVisual 0x00000008 Provides FEEDBACK_VISUAL feedback.
feedbackGeneric 0x00000010 Provides FEEDBACK_GENERIC feedback.
feedbackAllMask 0xffffffff Provides FEEDBACK_ALL_MASK feedback.

This corresponds to the global attribute resource symbol accessibilityFeedbackType.

Constant Value: 4 (0x00000004)

android:accessibilityFlags( 缺省值)

AccessibilityService_accessibilityFlags

int AccessibilityService_accessibilityFlags

Additional flags as specified in AccessibilityServiceInfo. This setting can be changed at runtime by callingandroid.accessibilityservice.AccessibilityService.setServiceInfo(android.accessibilityservice.AccessibilityServiceInfo).

Must be one or more (separated by '|') of the following constant values.

Constant Value Description
flagDefault 0x00000001 Has flag DEFAULT
flagIncludeNotImportantViews 0x00000002 Has flag FLAG_INCLUDE_NOT_IMPORTANT_VIEWS
flagRequestTouchExplorationMode 0x00000004 Has flag FLAG_REQUEST_TOUCH_EXPLORATION_MODE
flagRequestEnhancedWebAccessibility 0x00000008 Has flag FLAG_REQUEST_ENHANCED_WEB_ACCESSIBILITY
flagReportViewIds 0x00000010 Has flag FLAG_REPORT_VIEW_IDS
flagRequestFilterKeyEvents 0x00000020 Has flag FLAG_REQUEST_FILTER_KEY_EVENTS
flagRetrieveInteractiveWindows 0x00000040 Has flag FLAG_RETRIEVE_INTERACTIVE_WINDOWS

This corresponds to the global attribute resource symbol accessibilityFlags.

Constant Value: 6 (0x00000006)

android:canRetrieveWindowContent( 表明此服务是否可以读取窗口中的内容,应该是最重要的属性了.在运行时不可修改

AccessibilityService_canRetrieveWindowContent

int AccessibilityService_canRetrieveWindowContent

Attribute whether the accessibility service wants to be able to retrieve the active window content. This setting cannot be changed at runtime.属性是否可访问性服务希望能够检索活动窗口的内容。这个设置在运行时不能改变。

Must be a boolean value, either "true" or "false".

This may also be a reference to a resource (in the form "@[package:]type:name") or theme attribute (in the form "?[package:][type:]name") containing a value of this type.

This corresponds to the global attribute resource symbol canRetrieveWindowContent.

Constant Value: 7 (0x00000007)

android:description( 用于描述此服务的信息,会显示在系统开启服务的设置界面)

AccessibilityService_description

int AccessibilityService_description

Short description of the accessibility service purpose or behavior.

Must be a reference to another resource, in the form "@[+][package:]type:name" or to a theme attribute in the form "?[package:][type:]name".

This corresponds to the global attribute resource symbol description.

Constant Value: 0 (0x00000000)

 android:notificationTimeout( 发送2次事件的时间间隔,超过后事件作废

AccessibilityService_notificationTimeout

int AccessibilityService_notificationTimeout

The minimal period in milliseconds between two accessibility events of the same type are sent to this serivce. This setting can be changed at runtime by calling android.accessibilityservice.AccessibilityService.setServiceInfo(android.accessibilityservice.AccessibilityServiceInfo).

Must be an integer value, such as "100".

This may also be a reference to a resource (in the form "@[package:]type:name") or theme attribute (in the form "?[package:][type:]name") containing a value of this type.

This corresponds to the global attribute resource symbol notificationTimeout.

Constant Value: 5 (0x00000005)


android:packageNames(接收EventTypes的包名,多个包名用,隔开

AccessibilityService_packageNames

int AccessibilityService_packageNames

Comma separated package names from which this serivce would like to receive events (leave out for all packages).android.accessibilityservice.AccessibilityService.setServiceInfo(android.accessibilityservice.AccessibilityServiceInfo).

Must be a string value, using '\\;' to escape characters such as '\\n' or '\\uxxxx' for a unicode character.

This may also be a reference to a resource (in the form "@[package:]type:name") or theme attribute (in the form "?[package:][type:]name") containing a value of this type.

This corresponds to the global attribute resource symbol packageNames.

Constant Value: 3 (0x00000003)


android:settingsActivity(设置界面,在系统的启动服务界面会出现一个设置按钮,用来打开这个Activity的

AccessibilityService_settingsActivity

int AccessibilityService_settingsActivity

Component name of an activity that allows the user to modify the settings for this service. This setting cannot be changed at runtime.组件名称的活动,该服务允许用户修改设置。这个设置在运行时不能改变。

Must be a string value, using '\\;' to escape characters such as '\\n' or '\\uxxxx' for a unicode character.

This may also be a reference to a resource (in the form "@[package:]type:name") or theme attribute (in the form "?[package:][type:]name") containing a value of this type.

This corresponds to the global attribute resource symbol settingsActivity.

Constant Value: 1 (0x00000001)

加了这个 android:settingsActivity在华为手机上面测试就在设置界面最下方多了一个设置


三星平板上面没有,很奇怪。。。。。

到时候我把我打源码放上来。点击打开链接

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值