/**@class android.accessibilityservice.AccessibilityService @extends android.app.Service Accessibility services should only be used to assist users with disabilities in using Android devices and apps. They run in the background and receive callbacks by the system when {@link AccessibilityEvent}s are fired. Such events denote some state transition in the user interface, for example, the focus has changed, a button has been clicked, etc. Such a service can optionally request the capability for querying the content of the active window. Development of an accessibility service requires extending this class and implementing its abstract methods. <div class="special reference"> <h3>Developer Guides</h3> <p>For more information about creating AccessibilityServices, read the <a href="{@docRoot}guide/topics/ui/accessibility/index.html">Accessibility</a> developer guide.</p> </div> <h3>Lifecycle</h3> <p> The lifecycle of an accessibility service is managed exclusively by the system and follows the established service life cycle. Starting an accessibility service is triggered exclusively by the user explicitly turning the service on in device settings. After the system binds to a service, it calls {@link android.accessibilityservice.AccessibilityService#onServiceConnected()}. This method can be overridden by clients that want to perform post binding setup. </p> <p> An accessibility service stops either when the user turns it off in device settings or when it calls {@link android.accessibilityservice.AccessibilityService#disableSelf()}. </p> <h3>Declaration</h3> <p> An accessibility is declared as any other service in an AndroidManifest.xml, but it must do two things: <ul> <ol> Specify that it handles the "android.accessibilityservice.AccessibilityService" {@link android.content.Intent}. </ol> <ol> Request the {@link android.Manifest.permission#BIND_ACCESSIBILITY_SERVICE} permission to ensure that only the system can bind to it. </ol> </ul> If either of these items is missing, the system will ignore the accessibility service. Following is an example declaration: </p> <pre> <service android:name=".MyAccessibilityService" android:permission="android.permission.BIND_ACCESSIBILITY_SERVICE"> <intent-filter> <action android:name="android.accessibilityservice.AccessibilityService" /> </intent-filter> . . . </service></pre> <h3>Configuration</h3> <p> An accessibility service can be configured to receive specific types of accessibility events, listen only to specific packages, get events from each type only once in a given time frame, retrieve window content, specify a settings activity, etc. </p> <p> There are two approaches for configuring an accessibility service: </p> <ul> <li> Providing a {@link #SERVICE_META_DATA meta-data} entry in the manifest when declaring the service. A service declaration with a meta-data tag is presented below: <pre> <service android:name=".MyAccessibilityService"> <intent-filter> <action android:name="android.accessibilityservice.AccessibilityService" /> </intent-filter> <meta-data android:name="android.accessibilityservice" android:resource="@xml/accessibilityservice" /> </service></pre> <p class="note"> <strong>Note:</strong> This approach enables setting all properties. </p> <p> For more details refer to {@link #SERVICE_META_DATA} and <code><{@link android.R.styleable#AccessibilityService accessibility-service}></code>. </p> </li> <li> Calling {@link android.accessibilityservice.AccessibilityService#setServiceInfo(android.accessibilityservice.AccessibilityServiceInfo)}. Note that this method can be called any time to dynamically change the service configuration. <p class="note"> <strong>Note:</strong> This approach enables setting only dynamically configurable properties: {@link android.accessibilityservice.AccessibilityServiceInfo#eventTypes}, {@link android.accessibilityservice.AccessibilityServiceInfo#feedbackType}, {@link android.accessibilityservice.AccessibilityServiceInfo#flags}, {@link android.accessibilityservice.AccessibilityServiceInfo#notificationTimeout}, {@link android.accessibilityservice.AccessibilityServiceInfo#packageNames} </p> <p> For more details refer to {@link android.accessibilityservice.AccessibilityServiceInfo}. </p> </li> </ul> <h3>Retrieving window content</h3> <p> A service can specify in its declaration that it can retrieve window content which is represented as a tree of {@link AccessibilityWindowInfo} and {@link AccessibilityNodeInfo} objects. Note that declaring this capability requires that the service declares its configuration via an XML resource referenced by {@link #SERVICE_META_DATA}. </p> <p> Window content may be retrieved with {@link AccessibilityEvent#getSource() AccessibilityEvent.getSource()}, {@link android.accessibilityservice.AccessibilityService#findFocus(int)}, {@link android.accessibilityservice.AccessibilityService#getWindows()}, or {@link android.accessibilityservice.AccessibilityService#getRootInActiveWindow()}. </p> <p class="note"> <strong>Note</strong> An accessibility service may have requested to be notified for a subset of the event types, and thus be unaware when the node hierarchy has changed. It is also possible for a node to contain outdated information because the window content may change at any time. </p> <h3>Notification strategy</h3> <p> All accessibility services are notified of all events they have requested, regardless of their feedback type. </p> <p class="note"> <strong>Note:</strong> The event notification timeout is useful to avoid propagating events to the client too frequently since this is accomplished via an expensive interprocess call. One can think of the timeout as a criteria to determine when event generation has settled down.</p> <h3>Event types</h3> <ul> <li>{@link AccessibilityEvent#TYPE_VIEW_CLICKED}</li> <li>{@link AccessibilityEvent#TYPE_VIEW_LONG_CLICKED}</li> <li>{@link AccessibilityEvent#TYPE_VIEW_FOCUSED}</li> <li>{@link AccessibilityEvent#TYPE_VIEW_SELECTED}</li> <li>{@link AccessibilityEvent#TYPE_VIEW_TEXT_CHANGED}</li> <li>{@link AccessibilityEvent#TYPE_WINDOW_STATE_CHANGED}</li> <li>{@link AccessibilityEvent#TYPE_NOTIFICATION_STATE_CHANGED}</li> <li>{@link AccessibilityEvent#TYPE_TOUCH_EXPLORATION_GESTURE_START}</li> <li>{@link AccessibilityEvent#TYPE_TOUCH_EXPLORATION_GESTURE_END}</li> <li>{@link AccessibilityEvent#TYPE_VIEW_HOVER_ENTER}</li> <li>{@link AccessibilityEvent#TYPE_VIEW_HOVER_EXIT}</li> <li>{@link AccessibilityEvent#TYPE_VIEW_SCROLLED}</li> <li>{@link AccessibilityEvent#TYPE_VIEW_TEXT_SELECTION_CHANGED}</li> <li>{@link AccessibilityEvent#TYPE_WINDOW_CONTENT_CHANGED}</li> <li>{@link AccessibilityEvent#TYPE_ANNOUNCEMENT}</li> <li>{@link AccessibilityEvent#TYPE_GESTURE_DETECTION_START}</li> <li>{@link AccessibilityEvent#TYPE_GESTURE_DETECTION_END}</li> <li>{@link AccessibilityEvent#TYPE_TOUCH_INTERACTION_START}</li> <li>{@link AccessibilityEvent#TYPE_TOUCH_INTERACTION_END}</li> <li>{@link AccessibilityEvent#TYPE_VIEW_ACCESSIBILITY_FOCUSED}</li> <li>{@link AccessibilityEvent#TYPE_WINDOWS_CHANGED}</li> <li>{@link AccessibilityEvent#TYPE_VIEW_ACCESSIBILITY_FOCUS_CLEARED}</li> </ul> <h3>Feedback types</h3> <ul> <li>{@link android.accessibilityservice.AccessibilityServiceInfo#FEEDBACK_AUDIBLE}</li> <li>{@link android.accessibilityservice.AccessibilityServiceInfo#FEEDBACK_HAPTIC}</li> <li>{@link android.accessibilityservice.AccessibilityServiceInfo#FEEDBACK_AUDIBLE}</li> <li>{@link android.accessibilityservice.AccessibilityServiceInfo#FEEDBACK_VISUAL}</li> <li>{@link android.accessibilityservice.AccessibilityServiceInfo#FEEDBACK_GENERIC}</li> <li>{@link android.accessibilityservice.AccessibilityServiceInfo#FEEDBACK_BRAILLE}</li> </ul> @see AccessibilityEvent @see AccessibilityServiceInfo @see android.view.accessibility.AccessibilityManager */ var AccessibilityService = { /** The user has performed a swipe up gesture on the touch screen. */ GESTURE_SWIPE_UP : "1", /** The user has performed a swipe down gesture on the touch screen. */ GESTURE_SWIPE_DOWN : "2", /** The user has performed a swipe left gesture on the touch screen. */ GESTURE_SWIPE_LEFT : "3", /** The user has performed a swipe right gesture on the touch screen. */ GESTURE_SWIPE_RIGHT : "4", /** The user has performed a swipe left and right gesture on the touch screen. */ GESTURE_SWIPE_LEFT_AND_RIGHT : "5", /** The user has performed a swipe right and left gesture on the touch screen. */ GESTURE_SWIPE_RIGHT_AND_LEFT : "6", /** The user has performed a swipe up and down gesture on the touch screen. */ GESTURE_SWIPE_UP_AND_DOWN : "7", /** The user has performed a swipe down and up gesture on the touch screen. */ GESTURE_SWIPE_DOWN_AND_UP : "8", /** The user has performed a left and up gesture on the touch screen. */ GESTURE_SWIPE_LEFT_AND_UP : "9", /** The user has performed a left and down gesture on the touch screen. */ GESTURE_SWIPE_LEFT_AND_DOWN : "10", /** The user has performed a right and up gesture on the touch screen. */ GESTURE_SWIPE_RIGHT_AND_UP : "11", /** The user has performed a right and down gesture on the touch screen. */ GESTURE_SWIPE_RIGHT_AND_DOWN : "12", /** The user has performed an up and left gesture on the touch screen. */ GESTURE_SWIPE_UP_AND_LEFT : "13", /** The user has performed an up and right gesture on the touch screen. */ GESTURE_SWIPE_UP_AND_RIGHT : "14", /** The user has performed an down and left gesture on the touch screen. */ GESTURE_SWIPE_DOWN_AND_LEFT : "15", /** The user has performed an down and right gesture on the touch screen. */ GESTURE_SWIPE_DOWN_AND_RIGHT : "16", /** The {@link Intent} that must be declared as handled by the service. */ SERVICE_INTERFACE : "android.accessibilityservice.AccessibilityService", /** Name under which an AccessibilityService component publishes information about itself. This meta-data must reference an XML resource containing an <code><{@link android.R.styleable#AccessibilityService accessibility-service}></code> tag. This is a a sample XML file configuring an accessibility service: <pre> <accessibility-service android:accessibilityEventTypes="typeViewClicked|typeViewFocused" android:packageNames="foo.bar, foo.baz" android:accessibilityFeedbackType="feedbackSpoken" android:notificationTimeout="100" android:accessibilityFlags="flagDefault" android:settingsActivity="foo.bar.TestBackActivity" android:canRetrieveWindowContent="true" android:canRequestTouchExplorationMode="true" . . . /></pre> */ SERVICE_META_DATA : "android.accessibilityservice", /** Action to go back. */ GLOBAL_ACTION_BACK : "1", /** Action to go home. */ GLOBAL_ACTION_HOME : "2", /** Action to toggle showing the overview of recent apps. Will fail on platforms that don't show recent apps. */ GLOBAL_ACTION_RECENTS : "3", /** Action to open the notifications. */ GLOBAL_ACTION_NOTIFICATIONS : "4", /** Action to open the quick settings. */ GLOBAL_ACTION_QUICK_SETTINGS : "5", /** Action to open the power long-press dialog. */ GLOBAL_ACTION_POWER_DIALOG : "6", /** Action to toggle docking the current app's window */ GLOBAL_ACTION_TOGGLE_SPLIT_SCREEN : "7", /** Action to lock the screen */ GLOBAL_ACTION_LOCK_SCREEN : "8", /** Action to take a screenshot */ GLOBAL_ACTION_TAKE_SCREENSHOT : "9", /** Allow the system to control when the soft keyboard is shown. @see SoftKeyboardController */ SHOW_MODE_AUTO : "0", /** Never show the soft keyboard. @see SoftKeyboardController */ SHOW_MODE_HIDDEN : "1", /** Allow the soft keyboard to be shown, even if a hard keyboard is connected @see SoftKeyboardController */ SHOW_MODE_IGNORE_HARD_KEYBOARD : "2", /** Mask used to cover the show modes supported in public API @hide */ SHOW_MODE_MASK : "3", /** Bit used to hold the old value of the hard IME setting to restore when a service is shut down. @hide */ SHOW_MODE_HARD_KEYBOARD_ORIGINAL_VALUE : "536870912", /** Bit for show mode setting to indicate that the user has overridden the hard keyboard behavior. @hide */ SHOW_MODE_HARD_KEYBOARD_OVERRIDDEN : "1073741824", /**Callback for {@link android.view.accessibility.AccessibilityEvent}s. @param {Object {AccessibilityEvent}} event The new event. This event is owned by the caller and cannot be used after this method returns. Services wishing to use the event after this method returns should make a copy. */ onAccessibilityEvent : function( ) {}, /**Callback for interrupting the accessibility feedback. */ onInterrupt : function( ) {}, /**Gets the windows on the screen. This method returns only the windows that a sighted user can interact with, as opposed to all windows. For example, if there is a modal dialog shown and the user cannot touch anything behind it, then only the modal window will be reported (assuming it is the top one). For convenience the returned windows are ordered in a descending layer order, which is the windows that are on top are reported first. Since the user can always interact with the window that has input focus by typing, the focused window is always returned (even if covered by a modal window). <p> <strong>Note:</strong> In order to access the windows your service has to declare the capability to retrieve window content by setting the {@link android.R.styleable#AccessibilityService_canRetrieveWindowContent} property in its meta-data. For details refer to {@link #SERVICE_META_DATA}. Also the service has to opt-in to retrieve the interactive windows by setting the {@link android.accessibilityservice.AccessibilityServiceInfo#FLAG_RETRIEVE_INTERACTIVE_WINDOWS} flag. </p> @return {Object {java.util.List}} The windows if there are windows and the service is can retrieve them, otherwise an empty list. */ getWindows : function( ) {}, /**Gets the root node in the currently active window if this service can retrieve window content. The active window is the one that the user is currently touching or the window with input focus, if the user is not touching any window. <p> The currently active window is defined as the window that most recently fired one of the following events: {@link AccessibilityEvent#TYPE_WINDOW_STATE_CHANGED}, {@link AccessibilityEvent#TYPE_VIEW_HOVER_ENTER}, {@link AccessibilityEvent#TYPE_VIEW_HOVER_EXIT}. In other words, the last window shown that also has input focus. </p> <p> <strong>Note:</strong> In order to access the root node your service has to declare the capability to retrieve window content by setting the {@link android.R.styleable#AccessibilityService_canRetrieveWindowContent} property in its meta-data. For details refer to {@link #SERVICE_META_DATA}. </p> @return {Object {android.view.accessibility.AccessibilityNodeInfo}} The root node if this service can retrieve window content. */ getRootInActiveWindow : function( ) {}, /**Disables the service. After calling this method, the service will be disabled and settings will show that it is turned off. */ disableSelf : function( ) {}, /**Returns the magnification controller, which may be used to query and modify the state of display magnification. <p> <strong>Note:</strong> In order to control magnification, your service must declare the capability by setting the {@link android.R.styleable#AccessibilityService_canControlMagnification} property in its meta-data. For more information, see {@link #SERVICE_META_DATA}. @return {Object {android.accessibilityservice.AccessibilityService.MagnificationController}} the magnification controller */ getMagnificationController : function( ) {}, /**Returns the magnification controller of specified logical display, which may be used to query and modify the state of display magnification. <p> <strong>Note:</strong> In order to control magnification, your service must declare the capability by setting the {@link android.R.styleable#AccessibilityService_canControlMagnification} property in its meta-data. For more information, see {@link #SERVICE_META_DATA}. @param {Number} displayId The logic display id, use {@link Display#DEFAULT_DISPLAY} for default display. @return {Object {android.accessibilityservice.AccessibilityService.MagnificationController}} the magnification controller @hide */ getMagnificationController : function( ) {}, /**Get the controller for fingerprint gestures. This feature requires {@link android.accessibilityservice.AccessibilityServiceInfo#CAPABILITY_CAN_REQUEST_FINGERPRINT_GESTURES}. <strong>Note: </strong> The service must be connected before this method is called. @return {Object {android.accessibilityservice.FingerprintGestureController}} The controller for fingerprint gestures, or {@code null} if gestures are unavailable. */ getFingerprintGestureController : function( ) {}, /**Dispatch a gesture to the touch screen. Any gestures currently in progress, whether from the user, this service, or another service, will be cancelled. <p> The gesture will be dispatched as if it were performed directly on the screen by a user, so the events may be affected by features such as magnification and explore by touch. </p> <p> <strong>Note:</strong> In order to dispatch gestures, your service must declare the capability by setting the {@link android.R.styleable#AccessibilityService_canPerformGestures} property in its meta-data. For more information, see {@link #SERVICE_META_DATA}. </p> @param {Object {GestureDescription}} gesture The gesture to dispatch @param {Object {AccessibilityService.GestureResultCallback}} callback The object to call back when the status of the gesture is known. If {@code null}, no status is reported. @param {Object {Handler}} handler The handler on which to call back the {@code callback} object. If {@code null}, the object is called back on the service's main thread. @return {Boolean} {@code true} if the gesture is dispatched, {@code false} if not. */ dispatchGesture : function( ) {}, /**Returns the soft keyboard controller, which may be used to query and modify the soft keyboard show mode. @return {Object {android.accessibilityservice.AccessibilityService.SoftKeyboardController}} the soft keyboard controller */ getSoftKeyboardController : function( ) {}, /**Returns the controller for the accessibility button within the system's navigation area. This instance may be used to query the accessibility button's state and register listeners for interactions with and state changes for the accessibility button when {@link android.accessibilityservice.AccessibilityServiceInfo#FLAG_REQUEST_ACCESSIBILITY_BUTTON} is set. <p> <strong>Note:</strong> Not all devices are capable of displaying the accessibility button within a navigation area, and as such, use of this class should be considered only as an optional feature or shortcut on supported device implementations. </p> @return {Object {android.accessibilityservice.AccessibilityButtonController}} the accessibility button controller for this {@link AccessibilityService} */ getAccessibilityButtonController : function( ) {}, /**Performs a global action. Such an action can be performed at any moment regardless of the current application or user location in that application. For example going back, going home, opening recents, etc. @param {Number} action The action to perform. @return {Boolean} Whether the action was successfully performed. @see #GLOBAL_ACTION_BACK @see #GLOBAL_ACTION_HOME @see #GLOBAL_ACTION_NOTIFICATIONS @see #GLOBAL_ACTION_RECENTS */ performGlobalAction : function( ) {}, /**Find the view that has the specified focus type. The search is performed across all windows. <p> <strong>Note:</strong> In order to access the windows your service has to declare the capability to retrieve window content by setting the {@link android.R.styleable#AccessibilityService_canRetrieveWindowContent} property in its meta-data. For details refer to {@link #SERVICE_META_DATA}. Also the service has to opt-in to retrieve the interactive windows by setting the {@link android.accessibilityservice.AccessibilityServiceInfo#FLAG_RETRIEVE_INTERACTIVE_WINDOWS} flag. Otherwise, the search will be performed only in the active window. </p> @param {Number} focus The focus to find. One of {@link AccessibilityNodeInfo#FOCUS_INPUT} or {@link AccessibilityNodeInfo#FOCUS_ACCESSIBILITY}. @return {Object {android.view.accessibility.AccessibilityNodeInfo}} The node info of the focused view or null. @see AccessibilityNodeInfo#FOCUS_INPUT @see AccessibilityNodeInfo#FOCUS_ACCESSIBILITY */ findFocus : function( ) {}, /**Gets the an {@link android.accessibilityservice.AccessibilityServiceInfo} describing this {@link android.accessibilityservice.AccessibilityService}. This method is useful if one wants to change some of the dynamically configurable properties at runtime. @return {Object {android.accessibilityservice.AccessibilityServiceInfo}} The accessibility service info. @see AccessibilityServiceInfo */ getServiceInfo : function( ) {}, /**Sets the {@link android.accessibilityservice.AccessibilityServiceInfo} that describes this service. <p> Note: You can call this method any time but the info will be picked up after the system has bound to this service and when this method is called thereafter. @param {Object {AccessibilityServiceInfo}} info The info. */ setServiceInfo : function( ) {}, /** */ getSystemService : function( ) {}, /**Implement to return the implementation of the internal accessibility service interface. */ onBind : function( ) {}, };