175986cf9bc57ef11ad70f36fb77fbbf5d63af6ecsvetoslavganov/*
275986cf9bc57ef11ad70f36fb77fbbf5d63af6ecsvetoslavganov * Copyright (C) 2009 The Android Open Source Project
375986cf9bc57ef11ad70f36fb77fbbf5d63af6ecsvetoslavganov *
475986cf9bc57ef11ad70f36fb77fbbf5d63af6ecsvetoslavganov * Licensed under the Apache License, Version 2.0 (the "License");
575986cf9bc57ef11ad70f36fb77fbbf5d63af6ecsvetoslavganov * you may not use this file except in compliance with the License.
675986cf9bc57ef11ad70f36fb77fbbf5d63af6ecsvetoslavganov * You may obtain a copy of the License at
775986cf9bc57ef11ad70f36fb77fbbf5d63af6ecsvetoslavganov *
875986cf9bc57ef11ad70f36fb77fbbf5d63af6ecsvetoslavganov *      http://www.apache.org/licenses/LICENSE-2.0
975986cf9bc57ef11ad70f36fb77fbbf5d63af6ecsvetoslavganov *
1075986cf9bc57ef11ad70f36fb77fbbf5d63af6ecsvetoslavganov * Unless required by applicable law or agreed to in writing, software
1175986cf9bc57ef11ad70f36fb77fbbf5d63af6ecsvetoslavganov * distributed under the License is distributed on an "AS IS" BASIS,
1275986cf9bc57ef11ad70f36fb77fbbf5d63af6ecsvetoslavganov * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1375986cf9bc57ef11ad70f36fb77fbbf5d63af6ecsvetoslavganov * See the License for the specific language governing permissions and
1475986cf9bc57ef11ad70f36fb77fbbf5d63af6ecsvetoslavganov * limitations under the License.
1575986cf9bc57ef11ad70f36fb77fbbf5d63af6ecsvetoslavganov */
1675986cf9bc57ef11ad70f36fb77fbbf5d63af6ecsvetoslavganov
1775986cf9bc57ef11ad70f36fb77fbbf5d63af6ecsvetoslavganovpackage android.accessibilityservice;
1875986cf9bc57ef11ad70f36fb77fbbf5d63af6ecsvetoslavganov
19c09a02198718761e20e351f4bf0ee9e30a716d11Phil Weaverimport static android.content.pm.PackageManager.FEATURE_FINGERPRINT;
20c09a02198718761e20e351f4bf0ee9e30a716d11Phil Weaver
2124c90450fe3fe097a7bca51edd6a4cffd8fd13aaSvetoslav Ganovimport android.annotation.IntDef;
22cc4053e031371456fe54d51bbad1db721db4ae38Svetoslav Ganovimport android.content.ComponentName;
23cc4053e031371456fe54d51bbad1db721db4ae38Svetoslav Ganovimport android.content.Context;
24cc4053e031371456fe54d51bbad1db721db4ae38Svetoslav Ganovimport android.content.pm.PackageManager;
25cc4053e031371456fe54d51bbad1db721db4ae38Svetoslav Ganovimport android.content.pm.PackageManager.NameNotFoundException;
26cc4053e031371456fe54d51bbad1db721db4ae38Svetoslav Ganovimport android.content.pm.ResolveInfo;
27cc4053e031371456fe54d51bbad1db721db4ae38Svetoslav Ganovimport android.content.pm.ServiceInfo;
28cc4053e031371456fe54d51bbad1db721db4ae38Svetoslav Ganovimport android.content.res.Resources;
29cc4053e031371456fe54d51bbad1db721db4ae38Svetoslav Ganovimport android.content.res.TypedArray;
30cc4053e031371456fe54d51bbad1db721db4ae38Svetoslav Ganovimport android.content.res.XmlResourceParser;
3127fcd9c97a2ceb50bab026237390207e5ee9e290Phil Weaverimport android.hardware.fingerprint.FingerprintManager;
324213804541a8b05cd0587b138a2fd9a3b7fd9350Svetoslav Ganovimport android.os.Build;
3375986cf9bc57ef11ad70f36fb77fbbf5d63af6ecsvetoslavganovimport android.os.Parcel;
3475986cf9bc57ef11ad70f36fb77fbbf5d63af6ecsvetoslavganovimport android.os.Parcelable;
35cc4053e031371456fe54d51bbad1db721db4ae38Svetoslav Ganovimport android.util.AttributeSet;
36688a6977cf7673ed0542ab3d839053c4e38a4dbdSvetoslavimport android.util.SparseArray;
373d0edd31d8082b7b8b2cdee5efda216179f677b5Svetoslav Ganovimport android.util.TypedValue;
38cc4053e031371456fe54d51bbad1db721db4ae38Svetoslav Ganovimport android.util.Xml;
394213804541a8b05cd0587b138a2fd9a3b7fd9350Svetoslav Ganovimport android.view.View;
40cc4053e031371456fe54d51bbad1db721db4ae38Svetoslav Ganovimport android.view.accessibility.AccessibilityEvent;
4180943d8daa6ab31ab5c486d57aea406aa0730d58Svetoslav Ganovimport android.view.accessibility.AccessibilityNodeInfo;
42cc4053e031371456fe54d51bbad1db721db4ae38Svetoslav Ganov
43b5e89c6debca90be92bf5bc2e0e79d109de6d08fJeff Sharkeyimport com.android.internal.R;
44b5e89c6debca90be92bf5bc2e0e79d109de6d08fJeff Sharkey
45cc4053e031371456fe54d51bbad1db721db4ae38Svetoslav Ganovimport org.xmlpull.v1.XmlPullParser;
46cc4053e031371456fe54d51bbad1db721db4ae38Svetoslav Ganovimport org.xmlpull.v1.XmlPullParserException;
47cc4053e031371456fe54d51bbad1db721db4ae38Svetoslav Ganov
48cc4053e031371456fe54d51bbad1db721db4ae38Svetoslav Ganovimport java.io.IOException;
4924c90450fe3fe097a7bca51edd6a4cffd8fd13aaSvetoslav Ganovimport java.lang.annotation.Retention;
5024c90450fe3fe097a7bca51edd6a4cffd8fd13aaSvetoslav Ganovimport java.lang.annotation.RetentionPolicy;
51688a6977cf7673ed0542ab3d839053c4e38a4dbdSvetoslavimport java.util.ArrayList;
52688a6977cf7673ed0542ab3d839053c4e38a4dbdSvetoslavimport java.util.Collections;
53688a6977cf7673ed0542ab3d839053c4e38a4dbdSvetoslavimport java.util.List;
5475986cf9bc57ef11ad70f36fb77fbbf5d63af6ecsvetoslavganov
5575986cf9bc57ef11ad70f36fb77fbbf5d63af6ecsvetoslavganov/**
5638e8b4e5bc3c93affdffbc064fd9db5aeccc3e8eSvetoslav Ganov * This class describes an {@link AccessibilityService}. The system notifies an
5738e8b4e5bc3c93affdffbc064fd9db5aeccc3e8eSvetoslav Ganov * {@link AccessibilityService} for {@link android.view.accessibility.AccessibilityEvent}s
5875986cf9bc57ef11ad70f36fb77fbbf5d63af6ecsvetoslavganov * according to the information encapsulated in this class.
5975986cf9bc57ef11ad70f36fb77fbbf5d63af6ecsvetoslavganov *
60e1302edd40c5cc264f842e17e3796e0a11d6f045Joe Fernandez * <div class="special reference">
61e1302edd40c5cc264f842e17e3796e0a11d6f045Joe Fernandez * <h3>Developer Guides</h3>
62e1302edd40c5cc264f842e17e3796e0a11d6f045Joe Fernandez * <p>For more information about creating AccessibilityServices, read the
63e1302edd40c5cc264f842e17e3796e0a11d6f045Joe Fernandez * <a href="{@docRoot}guide/topics/ui/accessibility/index.html">Accessibility</a>
64e1302edd40c5cc264f842e17e3796e0a11d6f045Joe Fernandez * developer guide.</p>
65e1302edd40c5cc264f842e17e3796e0a11d6f045Joe Fernandez * </div>
66e1302edd40c5cc264f842e17e3796e0a11d6f045Joe Fernandez *
6700d17f7aab54ef055d35da603dab5a7bae751876Scott Main * @attr ref android.R.styleable#AccessibilityService_accessibilityEventTypes
6800d17f7aab54ef055d35da603dab5a7bae751876Scott Main * @attr ref android.R.styleable#AccessibilityService_accessibilityFeedbackType
6900d17f7aab54ef055d35da603dab5a7bae751876Scott Main * @attr ref android.R.styleable#AccessibilityService_accessibilityFlags
7000d17f7aab54ef055d35da603dab5a7bae751876Scott Main * @attr ref android.R.styleable#AccessibilityService_canRequestEnhancedWebAccessibility
7100d17f7aab54ef055d35da603dab5a7bae751876Scott Main * @attr ref android.R.styleable#AccessibilityService_canRequestFilterKeyEvents
7200d17f7aab54ef055d35da603dab5a7bae751876Scott Main * @attr ref android.R.styleable#AccessibilityService_canRequestTouchExplorationMode
7300d17f7aab54ef055d35da603dab5a7bae751876Scott Main * @attr ref android.R.styleable#AccessibilityService_canRetrieveWindowContent
7400d17f7aab54ef055d35da603dab5a7bae751876Scott Main * @attr ref android.R.styleable#AccessibilityService_description
7508c41bcf5fab665cebc820ea813be52f6ecc3154Saige McVea * @attr ref android.R.styleable#AccessibilityService_summary
7600d17f7aab54ef055d35da603dab5a7bae751876Scott Main * @attr ref android.R.styleable#AccessibilityService_notificationTimeout
7700d17f7aab54ef055d35da603dab5a7bae751876Scott Main * @attr ref android.R.styleable#AccessibilityService_packageNames
7800d17f7aab54ef055d35da603dab5a7bae751876Scott Main * @attr ref android.R.styleable#AccessibilityService_settingsActivity
7975986cf9bc57ef11ad70f36fb77fbbf5d63af6ecsvetoslavganov * @see AccessibilityService
8075986cf9bc57ef11ad70f36fb77fbbf5d63af6ecsvetoslavganov * @see android.view.accessibility.AccessibilityEvent
8138e8b4e5bc3c93affdffbc064fd9db5aeccc3e8eSvetoslav Ganov * @see android.view.accessibility.AccessibilityManager
8275986cf9bc57ef11ad70f36fb77fbbf5d63af6ecsvetoslavganov */
8375986cf9bc57ef11ad70f36fb77fbbf5d63af6ecsvetoslavganovpublic class AccessibilityServiceInfo implements Parcelable {
8475986cf9bc57ef11ad70f36fb77fbbf5d63af6ecsvetoslavganov
85cc4053e031371456fe54d51bbad1db721db4ae38Svetoslav Ganov    private static final String TAG_ACCESSIBILITY_SERVICE = "accessibility-service";
86cc4053e031371456fe54d51bbad1db721db4ae38Svetoslav Ganov
8775986cf9bc57ef11ad70f36fb77fbbf5d63af6ecsvetoslavganov    /**
88688a6977cf7673ed0542ab3d839053c4e38a4dbdSvetoslav     * Capability: This accessibility service can retrieve the active window content.
8900d17f7aab54ef055d35da603dab5a7bae751876Scott Main     * @see android.R.styleable#AccessibilityService_canRetrieveWindowContent
90688a6977cf7673ed0542ab3d839053c4e38a4dbdSvetoslav     */
91688a6977cf7673ed0542ab3d839053c4e38a4dbdSvetoslav    public static final int CAPABILITY_CAN_RETRIEVE_WINDOW_CONTENT = 0x00000001;
92688a6977cf7673ed0542ab3d839053c4e38a4dbdSvetoslav
93688a6977cf7673ed0542ab3d839053c4e38a4dbdSvetoslav    /**
94688a6977cf7673ed0542ab3d839053c4e38a4dbdSvetoslav     * Capability: This accessibility service can request touch exploration mode in which
95688a6977cf7673ed0542ab3d839053c4e38a4dbdSvetoslav     * touched items are spoken aloud and the UI can be explored via gestures.
9600d17f7aab54ef055d35da603dab5a7bae751876Scott Main     * @see android.R.styleable#AccessibilityService_canRequestTouchExplorationMode
97688a6977cf7673ed0542ab3d839053c4e38a4dbdSvetoslav     */
98688a6977cf7673ed0542ab3d839053c4e38a4dbdSvetoslav    public static final int CAPABILITY_CAN_REQUEST_TOUCH_EXPLORATION = 0x00000002;
99688a6977cf7673ed0542ab3d839053c4e38a4dbdSvetoslav
100688a6977cf7673ed0542ab3d839053c4e38a4dbdSvetoslav    /**
10109d4ff8960cd3d45988b0c3ff0835d281f0e16b5Phil Weaver     * @deprecated No longer used
102688a6977cf7673ed0542ab3d839053c4e38a4dbdSvetoslav     */
103688a6977cf7673ed0542ab3d839053c4e38a4dbdSvetoslav    public static final int CAPABILITY_CAN_REQUEST_ENHANCED_WEB_ACCESSIBILITY = 0x00000004;
104688a6977cf7673ed0542ab3d839053c4e38a4dbdSvetoslav
105688a6977cf7673ed0542ab3d839053c4e38a4dbdSvetoslav    /**
10600d17f7aab54ef055d35da603dab5a7bae751876Scott Main     * Capability: This accessibility service can request to filter the key event stream.
10700d17f7aab54ef055d35da603dab5a7bae751876Scott Main     * @see android.R.styleable#AccessibilityService_canRequestFilterKeyEvents
108688a6977cf7673ed0542ab3d839053c4e38a4dbdSvetoslav     */
109688a6977cf7673ed0542ab3d839053c4e38a4dbdSvetoslav    public static final int CAPABILITY_CAN_REQUEST_FILTER_KEY_EVENTS = 0x00000008;
110688a6977cf7673ed0542ab3d839053c4e38a4dbdSvetoslav
111214fb68767502f5fede643a062c1dc5975d75b27Alan Viverette    /**
112214fb68767502f5fede643a062c1dc5975d75b27Alan Viverette     * Capability: This accessibility service can control display magnification.
113214fb68767502f5fede643a062c1dc5975d75b27Alan Viverette     * @see android.R.styleable#AccessibilityService_canControlMagnification
114214fb68767502f5fede643a062c1dc5975d75b27Alan Viverette     */
115214fb68767502f5fede643a062c1dc5975d75b27Alan Viverette    public static final int CAPABILITY_CAN_CONTROL_MAGNIFICATION = 0x00000010;
116214fb68767502f5fede643a062c1dc5975d75b27Alan Viverette
117a6b64f5099b7be6e8384958d8bcddb97bb06ec93Phil Weaver    /**
118a6b64f5099b7be6e8384958d8bcddb97bb06ec93Phil Weaver     * Capability: This accessibility service can perform gestures.
119a6b64f5099b7be6e8384958d8bcddb97bb06ec93Phil Weaver     * @see android.R.styleable#AccessibilityService_canPerformGestures
120a6b64f5099b7be6e8384958d8bcddb97bb06ec93Phil Weaver     */
121a6b64f5099b7be6e8384958d8bcddb97bb06ec93Phil Weaver    public static final int CAPABILITY_CAN_PERFORM_GESTURES = 0x00000020;
122a6b64f5099b7be6e8384958d8bcddb97bb06ec93Phil Weaver
12327fcd9c97a2ceb50bab026237390207e5ee9e290Phil Weaver    /**
12427fcd9c97a2ceb50bab026237390207e5ee9e290Phil Weaver     * Capability: This accessibility service can capture gestures from the fingerprint sensor
125be2922ff34424cfb996d895cde0cb31c724d09dcPhil Weaver     * @see android.R.styleable#AccessibilityService_canRequestFingerprintGestures
12627fcd9c97a2ceb50bab026237390207e5ee9e290Phil Weaver     */
127be2922ff34424cfb996d895cde0cb31c724d09dcPhil Weaver    public static final int CAPABILITY_CAN_REQUEST_FINGERPRINT_GESTURES = 0x00000040;
12827fcd9c97a2ceb50bab026237390207e5ee9e290Phil Weaver
12927fcd9c97a2ceb50bab026237390207e5ee9e290Phil Weaver    private static SparseArray<CapabilityInfo> sAvailableCapabilityInfos;
130688a6977cf7673ed0542ab3d839053c4e38a4dbdSvetoslav
131688a6977cf7673ed0542ab3d839053c4e38a4dbdSvetoslav    /**
13275986cf9bc57ef11ad70f36fb77fbbf5d63af6ecsvetoslavganov     * Denotes spoken feedback.
13375986cf9bc57ef11ad70f36fb77fbbf5d63af6ecsvetoslavganov     */
13475986cf9bc57ef11ad70f36fb77fbbf5d63af6ecsvetoslavganov    public static final int FEEDBACK_SPOKEN = 0x0000001;
13575986cf9bc57ef11ad70f36fb77fbbf5d63af6ecsvetoslavganov
13675986cf9bc57ef11ad70f36fb77fbbf5d63af6ecsvetoslavganov    /**
13775986cf9bc57ef11ad70f36fb77fbbf5d63af6ecsvetoslavganov     * Denotes haptic feedback.
13875986cf9bc57ef11ad70f36fb77fbbf5d63af6ecsvetoslavganov     */
13975986cf9bc57ef11ad70f36fb77fbbf5d63af6ecsvetoslavganov    public static final int FEEDBACK_HAPTIC =  0x0000002;
14075986cf9bc57ef11ad70f36fb77fbbf5d63af6ecsvetoslavganov
14175986cf9bc57ef11ad70f36fb77fbbf5d63af6ecsvetoslavganov    /**
14275986cf9bc57ef11ad70f36fb77fbbf5d63af6ecsvetoslavganov     * Denotes audible (not spoken) feedback.
14375986cf9bc57ef11ad70f36fb77fbbf5d63af6ecsvetoslavganov     */
14475986cf9bc57ef11ad70f36fb77fbbf5d63af6ecsvetoslavganov    public static final int FEEDBACK_AUDIBLE = 0x0000004;
14575986cf9bc57ef11ad70f36fb77fbbf5d63af6ecsvetoslavganov
14675986cf9bc57ef11ad70f36fb77fbbf5d63af6ecsvetoslavganov    /**
14775986cf9bc57ef11ad70f36fb77fbbf5d63af6ecsvetoslavganov     * Denotes visual feedback.
14875986cf9bc57ef11ad70f36fb77fbbf5d63af6ecsvetoslavganov     */
14975986cf9bc57ef11ad70f36fb77fbbf5d63af6ecsvetoslavganov    public static final int FEEDBACK_VISUAL = 0x0000008;
15075986cf9bc57ef11ad70f36fb77fbbf5d63af6ecsvetoslavganov
15175986cf9bc57ef11ad70f36fb77fbbf5d63af6ecsvetoslavganov    /**
15275986cf9bc57ef11ad70f36fb77fbbf5d63af6ecsvetoslavganov     * Denotes generic feedback.
15375986cf9bc57ef11ad70f36fb77fbbf5d63af6ecsvetoslavganov     */
15475986cf9bc57ef11ad70f36fb77fbbf5d63af6ecsvetoslavganov    public static final int FEEDBACK_GENERIC = 0x0000010;
15575986cf9bc57ef11ad70f36fb77fbbf5d63af6ecsvetoslavganov
15675986cf9bc57ef11ad70f36fb77fbbf5d63af6ecsvetoslavganov    /**
157eb9862fd4c6ba1745a0f6c997e85643a4ded0643Svetoslav Ganov     * Denotes braille feedback.
158eb9862fd4c6ba1745a0f6c997e85643a4ded0643Svetoslav Ganov     */
159eb9862fd4c6ba1745a0f6c997e85643a4ded0643Svetoslav Ganov    public static final int FEEDBACK_BRAILLE = 0x0000020;
160eb9862fd4c6ba1745a0f6c997e85643a4ded0643Svetoslav Ganov
161eb9862fd4c6ba1745a0f6c997e85643a4ded0643Svetoslav Ganov    /**
16200aabf7d187bc05408199bd687a538b2e68bdc17Svetoslav Ganov     * Mask for all feedback types.
16300aabf7d187bc05408199bd687a538b2e68bdc17Svetoslav Ganov     *
16400aabf7d187bc05408199bd687a538b2e68bdc17Svetoslav Ganov     * @see #FEEDBACK_SPOKEN
16500aabf7d187bc05408199bd687a538b2e68bdc17Svetoslav Ganov     * @see #FEEDBACK_HAPTIC
16600aabf7d187bc05408199bd687a538b2e68bdc17Svetoslav Ganov     * @see #FEEDBACK_AUDIBLE
16700aabf7d187bc05408199bd687a538b2e68bdc17Svetoslav Ganov     * @see #FEEDBACK_VISUAL
16800aabf7d187bc05408199bd687a538b2e68bdc17Svetoslav Ganov     * @see #FEEDBACK_GENERIC
169eb9862fd4c6ba1745a0f6c997e85643a4ded0643Svetoslav Ganov     * @see #FEEDBACK_BRAILLE
17000aabf7d187bc05408199bd687a538b2e68bdc17Svetoslav Ganov     */
17100aabf7d187bc05408199bd687a538b2e68bdc17Svetoslav Ganov    public static final int FEEDBACK_ALL_MASK = 0xFFFFFFFF;
17200aabf7d187bc05408199bd687a538b2e68bdc17Svetoslav Ganov
17300aabf7d187bc05408199bd687a538b2e68bdc17Svetoslav Ganov    /**
17475986cf9bc57ef11ad70f36fb77fbbf5d63af6ecsvetoslavganov     * If an {@link AccessibilityService} is the default for a given type.
17575986cf9bc57ef11ad70f36fb77fbbf5d63af6ecsvetoslavganov     * Default service is invoked only if no package specific one exists. In case of
17675986cf9bc57ef11ad70f36fb77fbbf5d63af6ecsvetoslavganov     * more than one package specific service only the earlier registered is notified.
17775986cf9bc57ef11ad70f36fb77fbbf5d63af6ecsvetoslavganov     */
17875986cf9bc57ef11ad70f36fb77fbbf5d63af6ecsvetoslavganov    public static final int DEFAULT = 0x0000001;
17975986cf9bc57ef11ad70f36fb77fbbf5d63af6ecsvetoslavganov
18075986cf9bc57ef11ad70f36fb77fbbf5d63af6ecsvetoslavganov    /**
1814213804541a8b05cd0587b138a2fd9a3b7fd9350Svetoslav Ganov     * If this flag is set the system will regard views that are not important
1824213804541a8b05cd0587b138a2fd9a3b7fd9350Svetoslav Ganov     * for accessibility in addition to the ones that are important for accessibility.
1834213804541a8b05cd0587b138a2fd9a3b7fd9350Svetoslav Ganov     * That is, views that are marked as not important for accessibility via
18423be199171bedb05e81864f8941492af066fa667Alan Viverette     * {@link View#IMPORTANT_FOR_ACCESSIBILITY_NO} or
18523be199171bedb05e81864f8941492af066fa667Alan Viverette     * {@link View#IMPORTANT_FOR_ACCESSIBILITY_NO_HIDE_DESCENDANTS} and views that are
18623be199171bedb05e81864f8941492af066fa667Alan Viverette     * marked as potentially important for accessibility via
1874213804541a8b05cd0587b138a2fd9a3b7fd9350Svetoslav Ganov     * {@link View#IMPORTANT_FOR_ACCESSIBILITY_AUTO} for which the system has determined
18823be199171bedb05e81864f8941492af066fa667Alan Viverette     * that are not important for accessibility, are reported while querying the window
18923be199171bedb05e81864f8941492af066fa667Alan Viverette     * content and also the accessibility service will receive accessibility events from
19023be199171bedb05e81864f8941492af066fa667Alan Viverette     * them.
1914213804541a8b05cd0587b138a2fd9a3b7fd9350Svetoslav Ganov     * <p>
1924213804541a8b05cd0587b138a2fd9a3b7fd9350Svetoslav Ganov     * <strong>Note:</strong> For accessibility services targeting API version
1934213804541a8b05cd0587b138a2fd9a3b7fd9350Svetoslav Ganov     * {@link Build.VERSION_CODES#JELLY_BEAN} or higher this flag has to be explicitly
1944213804541a8b05cd0587b138a2fd9a3b7fd9350Svetoslav Ganov     * set for the system to regard views that are not important for accessibility. For
1954213804541a8b05cd0587b138a2fd9a3b7fd9350Svetoslav Ganov     * accessibility services targeting API version lower than
1964213804541a8b05cd0587b138a2fd9a3b7fd9350Svetoslav Ganov     * {@link Build.VERSION_CODES#JELLY_BEAN} this flag is ignored and all views are
1974213804541a8b05cd0587b138a2fd9a3b7fd9350Svetoslav Ganov     * regarded for accessibility purposes.
1984213804541a8b05cd0587b138a2fd9a3b7fd9350Svetoslav Ganov     * </p>
1994213804541a8b05cd0587b138a2fd9a3b7fd9350Svetoslav Ganov     * <p>
2004213804541a8b05cd0587b138a2fd9a3b7fd9350Svetoslav Ganov     * Usually views not important for accessibility are layout managers that do not
2014213804541a8b05cd0587b138a2fd9a3b7fd9350Svetoslav Ganov     * react to user actions, do not draw any content, and do not have any special
2024213804541a8b05cd0587b138a2fd9a3b7fd9350Svetoslav Ganov     * semantics in the context of the screen content. For example, a three by three
2034213804541a8b05cd0587b138a2fd9a3b7fd9350Svetoslav Ganov     * grid can be implemented as three horizontal linear layouts and one vertical,
2044213804541a8b05cd0587b138a2fd9a3b7fd9350Svetoslav Ganov     * or three vertical linear layouts and one horizontal, or one grid layout, etc.
2054213804541a8b05cd0587b138a2fd9a3b7fd9350Svetoslav Ganov     * In this context the actual layout mangers used to achieve the grid configuration
2064213804541a8b05cd0587b138a2fd9a3b7fd9350Svetoslav Ganov     * are not important, rather it is important that there are nine evenly distributed
2074213804541a8b05cd0587b138a2fd9a3b7fd9350Svetoslav Ganov     * elements.
2084213804541a8b05cd0587b138a2fd9a3b7fd9350Svetoslav Ganov     * </p>
2094213804541a8b05cd0587b138a2fd9a3b7fd9350Svetoslav Ganov     */
2103ec2e1b94ab502bfa8d5e8750716108f69aa18d2Svetoslav Ganov    public static final int FLAG_INCLUDE_NOT_IMPORTANT_VIEWS = 0x0000002;
2113ec2e1b94ab502bfa8d5e8750716108f69aa18d2Svetoslav Ganov
2123ec2e1b94ab502bfa8d5e8750716108f69aa18d2Svetoslav Ganov    /**
2133ec2e1b94ab502bfa8d5e8750716108f69aa18d2Svetoslav Ganov     * This flag requests that the system gets into touch exploration mode.
2143ec2e1b94ab502bfa8d5e8750716108f69aa18d2Svetoslav Ganov     * In this mode a single finger moving on the screen behaves as a mouse
2153ec2e1b94ab502bfa8d5e8750716108f69aa18d2Svetoslav Ganov     * pointer hovering over the user interface. The system will also detect
2163ec2e1b94ab502bfa8d5e8750716108f69aa18d2Svetoslav Ganov     * certain gestures performed on the touch screen and notify this service.
2173ec2e1b94ab502bfa8d5e8750716108f69aa18d2Svetoslav Ganov     * The system will enable touch exploration mode if there is at least one
2183ec2e1b94ab502bfa8d5e8750716108f69aa18d2Svetoslav Ganov     * accessibility service that has this flag set. Hence, clearing this
2193ec2e1b94ab502bfa8d5e8750716108f69aa18d2Svetoslav Ganov     * flag does not guarantee that the device will not be in touch exploration
2203ec2e1b94ab502bfa8d5e8750716108f69aa18d2Svetoslav Ganov     * mode since there may be another enabled service that requested it.
2210ec0418c6eac5076774a74855725d9df53141907Svetoslav     * <p>
222447d94684ee73046d769649d8247aacd581bd6e3Svetoslav Ganov     * For accessibility services targeting API version higher than
223447d94684ee73046d769649d8247aacd581bd6e3Svetoslav Ganov     * {@link Build.VERSION_CODES#JELLY_BEAN_MR1} that want to set
224688a6977cf7673ed0542ab3d839053c4e38a4dbdSvetoslav     * this flag have to declare this capability in their meta-data by setting
225688a6977cf7673ed0542ab3d839053c4e38a4dbdSvetoslav     * the attribute {@link android.R.attr#canRequestTouchExplorationMode
226688a6977cf7673ed0542ab3d839053c4e38a4dbdSvetoslav     * canRequestTouchExplorationMode} to true, otherwise this flag will
227688a6977cf7673ed0542ab3d839053c4e38a4dbdSvetoslav     * be ignored. For how to declare the meta-data of a service refer to
228688a6977cf7673ed0542ab3d839053c4e38a4dbdSvetoslav     * {@value AccessibilityService#SERVICE_META_DATA}.
2290ec0418c6eac5076774a74855725d9df53141907Svetoslav     * </p>
230447d94684ee73046d769649d8247aacd581bd6e3Svetoslav Ganov     * <p>
231447d94684ee73046d769649d8247aacd581bd6e3Svetoslav Ganov     * Services targeting API version equal to or lower than
232447d94684ee73046d769649d8247aacd581bd6e3Svetoslav Ganov     * {@link Build.VERSION_CODES#JELLY_BEAN_MR1} will work normally, i.e.
233447d94684ee73046d769649d8247aacd581bd6e3Svetoslav Ganov     * the first time they are run, if this flag is specified, a dialog is
234447d94684ee73046d769649d8247aacd581bd6e3Svetoslav Ganov     * shown to the user to confirm enabling explore by touch.
235447d94684ee73046d769649d8247aacd581bd6e3Svetoslav Ganov     * </p>
23600d17f7aab54ef055d35da603dab5a7bae751876Scott Main     * @see android.R.styleable#AccessibilityService_canRequestTouchExplorationMode
2373ec2e1b94ab502bfa8d5e8750716108f69aa18d2Svetoslav Ganov     */
2380ec0418c6eac5076774a74855725d9df53141907Svetoslav    public static final int FLAG_REQUEST_TOUCH_EXPLORATION_MODE = 0x0000004;
2394213804541a8b05cd0587b138a2fd9a3b7fd9350Svetoslav Ganov
2404213804541a8b05cd0587b138a2fd9a3b7fd9350Svetoslav Ganov    /**
24109d4ff8960cd3d45988b0c3ff0835d281f0e16b5Phil Weaver     * @deprecated No longer used
2423822896e226567c6cd3ef84518d318abd33a7624Svetoslav     */
2433822896e226567c6cd3ef84518d318abd33a7624Svetoslav    public static final int FLAG_REQUEST_ENHANCED_WEB_ACCESSIBILITY = 0x00000008;
2443822896e226567c6cd3ef84518d318abd33a7624Svetoslav
2453822896e226567c6cd3ef84518d318abd33a7624Svetoslav    /**
24680943d8daa6ab31ab5c486d57aea406aa0730d58Svetoslav Ganov     * This flag requests that the {@link AccessibilityNodeInfo}s obtained
24780943d8daa6ab31ab5c486d57aea406aa0730d58Svetoslav Ganov     * by an {@link AccessibilityService} contain the id of the source view.
24880943d8daa6ab31ab5c486d57aea406aa0730d58Svetoslav Ganov     * The source view id will be a fully qualified resource name of the
24980943d8daa6ab31ab5c486d57aea406aa0730d58Svetoslav Ganov     * form "package:id/name", for example "foo.bar:id/my_list", and it is
25080943d8daa6ab31ab5c486d57aea406aa0730d58Svetoslav Ganov     * useful for UI test automation. This flag is not set by default.
25180943d8daa6ab31ab5c486d57aea406aa0730d58Svetoslav Ganov     */
2523822896e226567c6cd3ef84518d318abd33a7624Svetoslav    public static final int FLAG_REPORT_VIEW_IDS = 0x00000010;
25380943d8daa6ab31ab5c486d57aea406aa0730d58Svetoslav Ganov
25480943d8daa6ab31ab5c486d57aea406aa0730d58Svetoslav Ganov    /**
255688a6977cf7673ed0542ab3d839053c4e38a4dbdSvetoslav     * This flag requests from the system to filter key events. If this flag
256688a6977cf7673ed0542ab3d839053c4e38a4dbdSvetoslav     * is set the accessibility service will receive the key events before
257a6b64f5099b7be6e8384958d8bcddb97bb06ec93Phil Weaver     * applications allowing it implement global shortcuts.
258688a6977cf7673ed0542ab3d839053c4e38a4dbdSvetoslav     * <p>
259688a6977cf7673ed0542ab3d839053c4e38a4dbdSvetoslav     * Services that want to set this flag have to declare this capability
260688a6977cf7673ed0542ab3d839053c4e38a4dbdSvetoslav     * in their meta-data by setting the attribute {@link android.R.attr
261688a6977cf7673ed0542ab3d839053c4e38a4dbdSvetoslav     * #canRequestFilterKeyEvents canRequestFilterKeyEvents} to true,
262688a6977cf7673ed0542ab3d839053c4e38a4dbdSvetoslav     * otherwise this flag will be ignored. For how to declare the meta-data
263688a6977cf7673ed0542ab3d839053c4e38a4dbdSvetoslav     * of a service refer to {@value AccessibilityService#SERVICE_META_DATA}.
264688a6977cf7673ed0542ab3d839053c4e38a4dbdSvetoslav     * </p>
26500d17f7aab54ef055d35da603dab5a7bae751876Scott Main     * @see android.R.styleable#AccessibilityService_canRequestFilterKeyEvents
266688a6977cf7673ed0542ab3d839053c4e38a4dbdSvetoslav     */
267688a6977cf7673ed0542ab3d839053c4e38a4dbdSvetoslav    public static final int FLAG_REQUEST_FILTER_KEY_EVENTS = 0x00000020;
268688a6977cf7673ed0542ab3d839053c4e38a4dbdSvetoslav
269688a6977cf7673ed0542ab3d839053c4e38a4dbdSvetoslav    /**
2708e3feb15c5aec2c72b0ef120a1da325e1e8f0ddaSvetoslav     * This flag indicates to the system that the accessibility service wants
2718e3feb15c5aec2c72b0ef120a1da325e1e8f0ddaSvetoslav     * to access content of all interactive windows. An interactive window is a
272f7174e87b6007000777b0124de9cef70d8618788Svetoslav     * window that has input focus or can be touched by a sighted user when explore
273f7174e87b6007000777b0124de9cef70d8618788Svetoslav     * by touch is not enabled. If this flag is not set your service will not receive
2748e3feb15c5aec2c72b0ef120a1da325e1e8f0ddaSvetoslav     * {@link android.view.accessibility.AccessibilityEvent#TYPE_WINDOWS_CHANGED}
2758e3feb15c5aec2c72b0ef120a1da325e1e8f0ddaSvetoslav     * events, calling AccessibilityService{@link AccessibilityService#getWindows()
2768e3feb15c5aec2c72b0ef120a1da325e1e8f0ddaSvetoslav     * AccessibilityService.getWindows()} will return an empty list, and {@link
2778e3feb15c5aec2c72b0ef120a1da325e1e8f0ddaSvetoslav     * AccessibilityNodeInfo#getWindow() AccessibilityNodeInfo.getWindow()} will
2788e3feb15c5aec2c72b0ef120a1da325e1e8f0ddaSvetoslav     * return null.
2798e3feb15c5aec2c72b0ef120a1da325e1e8f0ddaSvetoslav     * <p>
2808e3feb15c5aec2c72b0ef120a1da325e1e8f0ddaSvetoslav     * Services that want to set this flag have to declare the capability
2818e3feb15c5aec2c72b0ef120a1da325e1e8f0ddaSvetoslav     * to retrieve window content in their meta-data by setting the attribute
2828e3feb15c5aec2c72b0ef120a1da325e1e8f0ddaSvetoslav     * {@link android.R.attr#canRetrieveWindowContent canRetrieveWindowContent} to
2838e3feb15c5aec2c72b0ef120a1da325e1e8f0ddaSvetoslav     * true, otherwise this flag will be ignored. For how to declare the meta-data
2848e3feb15c5aec2c72b0ef120a1da325e1e8f0ddaSvetoslav     * of a service refer to {@value AccessibilityService#SERVICE_META_DATA}.
2858e3feb15c5aec2c72b0ef120a1da325e1e8f0ddaSvetoslav     * </p>
2868e3feb15c5aec2c72b0ef120a1da325e1e8f0ddaSvetoslav     * @see android.R.styleable#AccessibilityService_canRetrieveWindowContent
2878e3feb15c5aec2c72b0ef120a1da325e1e8f0ddaSvetoslav     */
2888e3feb15c5aec2c72b0ef120a1da325e1e8f0ddaSvetoslav    public static final int FLAG_RETRIEVE_INTERACTIVE_WINDOWS = 0x00000040;
2898e3feb15c5aec2c72b0ef120a1da325e1e8f0ddaSvetoslav
2904acc16d1b611074baa9eeb7ec5628350b7eb5fa5Phil Weaver    /**
2914acc16d1b611074baa9eeb7ec5628350b7eb5fa5Phil Weaver     * This flag requests that all audio tracks system-wide with
2924acc16d1b611074baa9eeb7ec5628350b7eb5fa5Phil Weaver     * {@link android.media.AudioAttributes#USAGE_ASSISTANCE_ACCESSIBILITY} be controlled by the
2934acc16d1b611074baa9eeb7ec5628350b7eb5fa5Phil Weaver     * {@link android.media.AudioManager#STREAM_ACCESSIBILITY} volume.
2944acc16d1b611074baa9eeb7ec5628350b7eb5fa5Phil Weaver     */
2954acc16d1b611074baa9eeb7ec5628350b7eb5fa5Phil Weaver    public static final int FLAG_ENABLE_ACCESSIBILITY_VOLUME = 0x00000080;
2964acc16d1b611074baa9eeb7ec5628350b7eb5fa5Phil Weaver
297048c2bc19af4cfcb5e959f1bc07fbfa03a72e330Casey Burkhardt     /**
298048c2bc19af4cfcb5e959f1bc07fbfa03a72e330Casey Burkhardt     * This flag indicates to the system that the accessibility service requests that an
299048c2bc19af4cfcb5e959f1bc07fbfa03a72e330Casey Burkhardt     * accessibility button be shown within the system's navigation area, if available.
300048c2bc19af4cfcb5e959f1bc07fbfa03a72e330Casey Burkhardt     */
301048c2bc19af4cfcb5e959f1bc07fbfa03a72e330Casey Burkhardt    public static final int FLAG_REQUEST_ACCESSIBILITY_BUTTON = 0x00000100;
302048c2bc19af4cfcb5e959f1bc07fbfa03a72e330Casey Burkhardt
30327fcd9c97a2ceb50bab026237390207e5ee9e290Phil Weaver    /**
30427fcd9c97a2ceb50bab026237390207e5ee9e290Phil Weaver     * This flag requests that all fingerprint gestures be sent to the accessibility service.
305466b71e1a287bd20560f1bf10db15e5fa7f2c8d1Phil Weaver     * <p>
306466b71e1a287bd20560f1bf10db15e5fa7f2c8d1Phil Weaver     * Services that want to set this flag have to declare the capability
307466b71e1a287bd20560f1bf10db15e5fa7f2c8d1Phil Weaver     * to retrieve window content in their meta-data by setting the attribute
308466b71e1a287bd20560f1bf10db15e5fa7f2c8d1Phil Weaver     * {@link android.R.attr#canRequestFingerprintGestures} to
309466b71e1a287bd20560f1bf10db15e5fa7f2c8d1Phil Weaver     * true, otherwise this flag will be ignored. For how to declare the meta-data
310466b71e1a287bd20560f1bf10db15e5fa7f2c8d1Phil Weaver     * of a service refer to {@value AccessibilityService#SERVICE_META_DATA}.
311466b71e1a287bd20560f1bf10db15e5fa7f2c8d1Phil Weaver     * </p>
312466b71e1a287bd20560f1bf10db15e5fa7f2c8d1Phil Weaver     *
313466b71e1a287bd20560f1bf10db15e5fa7f2c8d1Phil Weaver     * @see android.R.styleable#AccessibilityService_canRequestFingerprintGestures
314466b71e1a287bd20560f1bf10db15e5fa7f2c8d1Phil Weaver     * @see AccessibilityService#getFingerprintGestureController()
31527fcd9c97a2ceb50bab026237390207e5ee9e290Phil Weaver     */
316be2922ff34424cfb996d895cde0cb31c724d09dcPhil Weaver    public static final int FLAG_REQUEST_FINGERPRINT_GESTURES = 0x00000200;
31727fcd9c97a2ceb50bab026237390207e5ee9e290Phil Weaver
318b5e89c6debca90be92bf5bc2e0e79d109de6d08fJeff Sharkey    /** {@hide} */
319b5e89c6debca90be92bf5bc2e0e79d109de6d08fJeff Sharkey    public static final int FLAG_FORCE_DIRECT_BOOT_AWARE = 0x00010000;
320b5e89c6debca90be92bf5bc2e0e79d109de6d08fJeff Sharkey
3218e3feb15c5aec2c72b0ef120a1da325e1e8f0ddaSvetoslav    /**
32275986cf9bc57ef11ad70f36fb77fbbf5d63af6ecsvetoslavganov     * The event types an {@link AccessibilityService} is interested in.
323cc4053e031371456fe54d51bbad1db721db4ae38Svetoslav Ganov     * <p>
324cc4053e031371456fe54d51bbad1db721db4ae38Svetoslav Ganov     *   <strong>Can be dynamically set at runtime.</strong>
325cc4053e031371456fe54d51bbad1db721db4ae38Svetoslav Ganov     * </p>
32675986cf9bc57ef11ad70f36fb77fbbf5d63af6ecsvetoslavganov     * @see android.view.accessibility.AccessibilityEvent#TYPE_VIEW_CLICKED
3279b31779eab896bdcc0922473b183c979cc0b874fSvetoslav Ganov     * @see android.view.accessibility.AccessibilityEvent#TYPE_VIEW_LONG_CLICKED
32875986cf9bc57ef11ad70f36fb77fbbf5d63af6ecsvetoslavganov     * @see android.view.accessibility.AccessibilityEvent#TYPE_VIEW_FOCUSED
32975986cf9bc57ef11ad70f36fb77fbbf5d63af6ecsvetoslavganov     * @see android.view.accessibility.AccessibilityEvent#TYPE_VIEW_SELECTED
33075986cf9bc57ef11ad70f36fb77fbbf5d63af6ecsvetoslavganov     * @see android.view.accessibility.AccessibilityEvent#TYPE_VIEW_TEXT_CHANGED
33175986cf9bc57ef11ad70f36fb77fbbf5d63af6ecsvetoslavganov     * @see android.view.accessibility.AccessibilityEvent#TYPE_WINDOW_STATE_CHANGED
33275986cf9bc57ef11ad70f36fb77fbbf5d63af6ecsvetoslavganov     * @see android.view.accessibility.AccessibilityEvent#TYPE_NOTIFICATION_STATE_CHANGED
33338e8b4e5bc3c93affdffbc064fd9db5aeccc3e8eSvetoslav Ganov     * @see android.view.accessibility.AccessibilityEvent#TYPE_TOUCH_EXPLORATION_GESTURE_START
33438e8b4e5bc3c93affdffbc064fd9db5aeccc3e8eSvetoslav Ganov     * @see android.view.accessibility.AccessibilityEvent#TYPE_TOUCH_EXPLORATION_GESTURE_END
33538e8b4e5bc3c93affdffbc064fd9db5aeccc3e8eSvetoslav Ganov     * @see android.view.accessibility.AccessibilityEvent#TYPE_VIEW_HOVER_ENTER
33638e8b4e5bc3c93affdffbc064fd9db5aeccc3e8eSvetoslav Ganov     * @see android.view.accessibility.AccessibilityEvent#TYPE_VIEW_HOVER_EXIT
33738e8b4e5bc3c93affdffbc064fd9db5aeccc3e8eSvetoslav Ganov     * @see android.view.accessibility.AccessibilityEvent#TYPE_VIEW_SCROLLED
33838e8b4e5bc3c93affdffbc064fd9db5aeccc3e8eSvetoslav Ganov     * @see android.view.accessibility.AccessibilityEvent#TYPE_VIEW_TEXT_SELECTION_CHANGED
33938e8b4e5bc3c93affdffbc064fd9db5aeccc3e8eSvetoslav Ganov     * @see android.view.accessibility.AccessibilityEvent#TYPE_WINDOW_CONTENT_CHANGED
3408e3feb15c5aec2c72b0ef120a1da325e1e8f0ddaSvetoslav     * @see android.view.accessibility.AccessibilityEvent#TYPE_TOUCH_INTERACTION_START
3418e3feb15c5aec2c72b0ef120a1da325e1e8f0ddaSvetoslav     * @see android.view.accessibility.AccessibilityEvent#TYPE_TOUCH_INTERACTION_END
3428e3feb15c5aec2c72b0ef120a1da325e1e8f0ddaSvetoslav     * @see android.view.accessibility.AccessibilityEvent#TYPE_ANNOUNCEMENT
3438e3feb15c5aec2c72b0ef120a1da325e1e8f0ddaSvetoslav     * @see android.view.accessibility.AccessibilityEvent#TYPE_GESTURE_DETECTION_START
3448e3feb15c5aec2c72b0ef120a1da325e1e8f0ddaSvetoslav     * @see android.view.accessibility.AccessibilityEvent#TYPE_GESTURE_DETECTION_END
3458e3feb15c5aec2c72b0ef120a1da325e1e8f0ddaSvetoslav     * @see android.view.accessibility.AccessibilityEvent#TYPE_VIEW_ACCESSIBILITY_FOCUSED
3468e3feb15c5aec2c72b0ef120a1da325e1e8f0ddaSvetoslav     * @see android.view.accessibility.AccessibilityEvent#TYPE_VIEW_ACCESSIBILITY_FOCUS_CLEARED
3478e3feb15c5aec2c72b0ef120a1da325e1e8f0ddaSvetoslav     * @see android.view.accessibility.AccessibilityEvent#TYPE_VIEW_TEXT_TRAVERSED_AT_MOVEMENT_GRANULARITY
3488e3feb15c5aec2c72b0ef120a1da325e1e8f0ddaSvetoslav     * @see android.view.accessibility.AccessibilityEvent#TYPE_WINDOWS_CHANGED
34975986cf9bc57ef11ad70f36fb77fbbf5d63af6ecsvetoslavganov     */
35075986cf9bc57ef11ad70f36fb77fbbf5d63af6ecsvetoslavganov    public int eventTypes;
35175986cf9bc57ef11ad70f36fb77fbbf5d63af6ecsvetoslavganov
35275986cf9bc57ef11ad70f36fb77fbbf5d63af6ecsvetoslavganov    /**
35375986cf9bc57ef11ad70f36fb77fbbf5d63af6ecsvetoslavganov     * The package names an {@link AccessibilityService} is interested in. Setting
35438e8b4e5bc3c93affdffbc064fd9db5aeccc3e8eSvetoslav Ganov     * to <code>null</code> is equivalent to all packages.
355cc4053e031371456fe54d51bbad1db721db4ae38Svetoslav Ganov     * <p>
356cc4053e031371456fe54d51bbad1db721db4ae38Svetoslav Ganov     *   <strong>Can be dynamically set at runtime.</strong>
357cc4053e031371456fe54d51bbad1db721db4ae38Svetoslav Ganov     * </p>
35875986cf9bc57ef11ad70f36fb77fbbf5d63af6ecsvetoslavganov     */
35975986cf9bc57ef11ad70f36fb77fbbf5d63af6ecsvetoslavganov    public String[] packageNames;
36075986cf9bc57ef11ad70f36fb77fbbf5d63af6ecsvetoslavganov
36124c90450fe3fe097a7bca51edd6a4cffd8fd13aaSvetoslav Ganov
36224c90450fe3fe097a7bca51edd6a4cffd8fd13aaSvetoslav Ganov    /** @hide */
36324c90450fe3fe097a7bca51edd6a4cffd8fd13aaSvetoslav Ganov    @IntDef(flag = true, prefix = { "FEEDBACK_" }, value = {
36424c90450fe3fe097a7bca51edd6a4cffd8fd13aaSvetoslav Ganov            FEEDBACK_AUDIBLE,
36524c90450fe3fe097a7bca51edd6a4cffd8fd13aaSvetoslav Ganov            FEEDBACK_GENERIC,
36624c90450fe3fe097a7bca51edd6a4cffd8fd13aaSvetoslav Ganov            FEEDBACK_HAPTIC,
36724c90450fe3fe097a7bca51edd6a4cffd8fd13aaSvetoslav Ganov            FEEDBACK_SPOKEN,
36824c90450fe3fe097a7bca51edd6a4cffd8fd13aaSvetoslav Ganov            FEEDBACK_VISUAL,
36924c90450fe3fe097a7bca51edd6a4cffd8fd13aaSvetoslav Ganov            FEEDBACK_BRAILLE
37024c90450fe3fe097a7bca51edd6a4cffd8fd13aaSvetoslav Ganov    })
37124c90450fe3fe097a7bca51edd6a4cffd8fd13aaSvetoslav Ganov    @Retention(RetentionPolicy.SOURCE)
37224c90450fe3fe097a7bca51edd6a4cffd8fd13aaSvetoslav Ganov    public @interface FeedbackType {}
37324c90450fe3fe097a7bca51edd6a4cffd8fd13aaSvetoslav Ganov
37475986cf9bc57ef11ad70f36fb77fbbf5d63af6ecsvetoslavganov    /**
37575986cf9bc57ef11ad70f36fb77fbbf5d63af6ecsvetoslavganov     * The feedback type an {@link AccessibilityService} provides.
376cc4053e031371456fe54d51bbad1db721db4ae38Svetoslav Ganov     * <p>
377cc4053e031371456fe54d51bbad1db721db4ae38Svetoslav Ganov     *   <strong>Can be dynamically set at runtime.</strong>
378cc4053e031371456fe54d51bbad1db721db4ae38Svetoslav Ganov     * </p>
37975986cf9bc57ef11ad70f36fb77fbbf5d63af6ecsvetoslavganov     * @see #FEEDBACK_AUDIBLE
38075986cf9bc57ef11ad70f36fb77fbbf5d63af6ecsvetoslavganov     * @see #FEEDBACK_GENERIC
38175986cf9bc57ef11ad70f36fb77fbbf5d63af6ecsvetoslavganov     * @see #FEEDBACK_HAPTIC
38275986cf9bc57ef11ad70f36fb77fbbf5d63af6ecsvetoslavganov     * @see #FEEDBACK_SPOKEN
38375986cf9bc57ef11ad70f36fb77fbbf5d63af6ecsvetoslavganov     * @see #FEEDBACK_VISUAL
384eb9862fd4c6ba1745a0f6c997e85643a4ded0643Svetoslav Ganov     * @see #FEEDBACK_BRAILLE
38575986cf9bc57ef11ad70f36fb77fbbf5d63af6ecsvetoslavganov     */
38624c90450fe3fe097a7bca51edd6a4cffd8fd13aaSvetoslav Ganov    @FeedbackType
38775986cf9bc57ef11ad70f36fb77fbbf5d63af6ecsvetoslavganov    public int feedbackType;
38875986cf9bc57ef11ad70f36fb77fbbf5d63af6ecsvetoslavganov
38975986cf9bc57ef11ad70f36fb77fbbf5d63af6ecsvetoslavganov    /**
39075986cf9bc57ef11ad70f36fb77fbbf5d63af6ecsvetoslavganov     * The timeout after the most recent event of a given type before an
39175986cf9bc57ef11ad70f36fb77fbbf5d63af6ecsvetoslavganov     * {@link AccessibilityService} is notified.
39275986cf9bc57ef11ad70f36fb77fbbf5d63af6ecsvetoslavganov     * <p>
393cc4053e031371456fe54d51bbad1db721db4ae38Svetoslav Ganov     *   <strong>Can be dynamically set at runtime.</strong>.
394cc4053e031371456fe54d51bbad1db721db4ae38Svetoslav Ganov     * </p>
395cc4053e031371456fe54d51bbad1db721db4ae38Svetoslav Ganov     * <p>
39638e8b4e5bc3c93affdffbc064fd9db5aeccc3e8eSvetoslav Ganov     * <strong>Note:</strong> The event notification timeout is useful to avoid propagating
39738e8b4e5bc3c93affdffbc064fd9db5aeccc3e8eSvetoslav Ganov     *       events to the client too frequently since this is accomplished via an expensive
39838e8b4e5bc3c93affdffbc064fd9db5aeccc3e8eSvetoslav Ganov     *       interprocess call. One can think of the timeout as a criteria to determine when
39938e8b4e5bc3c93affdffbc064fd9db5aeccc3e8eSvetoslav Ganov     *       event generation has settled down.
40075986cf9bc57ef11ad70f36fb77fbbf5d63af6ecsvetoslavganov     */
40175986cf9bc57ef11ad70f36fb77fbbf5d63af6ecsvetoslavganov    public long notificationTimeout;
40275986cf9bc57ef11ad70f36fb77fbbf5d63af6ecsvetoslavganov
40375986cf9bc57ef11ad70f36fb77fbbf5d63af6ecsvetoslavganov    /**
40475986cf9bc57ef11ad70f36fb77fbbf5d63af6ecsvetoslavganov     * This field represents a set of flags used for configuring an
40575986cf9bc57ef11ad70f36fb77fbbf5d63af6ecsvetoslavganov     * {@link AccessibilityService}.
406cc4053e031371456fe54d51bbad1db721db4ae38Svetoslav Ganov     * <p>
407cc4053e031371456fe54d51bbad1db721db4ae38Svetoslav Ganov     *   <strong>Can be dynamically set at runtime.</strong>
408cc4053e031371456fe54d51bbad1db721db4ae38Svetoslav Ganov     * </p>
40975986cf9bc57ef11ad70f36fb77fbbf5d63af6ecsvetoslavganov     * @see #DEFAULT
4103ec2e1b94ab502bfa8d5e8750716108f69aa18d2Svetoslav Ganov     * @see #FLAG_INCLUDE_NOT_IMPORTANT_VIEWS
4113ec2e1b94ab502bfa8d5e8750716108f69aa18d2Svetoslav Ganov     * @see #FLAG_REQUEST_TOUCH_EXPLORATION_MODE
412688a6977cf7673ed0542ab3d839053c4e38a4dbdSvetoslav     * @see #FLAG_REQUEST_ENHANCED_WEB_ACCESSIBILITY
413688a6977cf7673ed0542ab3d839053c4e38a4dbdSvetoslav     * @see #FLAG_REQUEST_FILTER_KEY_EVENTS
414688a6977cf7673ed0542ab3d839053c4e38a4dbdSvetoslav     * @see #FLAG_REPORT_VIEW_IDS
4158e3feb15c5aec2c72b0ef120a1da325e1e8f0ddaSvetoslav     * @see #FLAG_RETRIEVE_INTERACTIVE_WINDOWS
416048c2bc19af4cfcb5e959f1bc07fbfa03a72e330Casey Burkhardt     * @see #FLAG_ENABLE_ACCESSIBILITY_VOLUME
417048c2bc19af4cfcb5e959f1bc07fbfa03a72e330Casey Burkhardt     * @see #FLAG_REQUEST_ACCESSIBILITY_BUTTON
41875986cf9bc57ef11ad70f36fb77fbbf5d63af6ecsvetoslavganov     */
41975986cf9bc57ef11ad70f36fb77fbbf5d63af6ecsvetoslavganov    public int flags;
42075986cf9bc57ef11ad70f36fb77fbbf5d63af6ecsvetoslavganov
421cc4053e031371456fe54d51bbad1db721db4ae38Svetoslav Ganov    /**
422c09a02198718761e20e351f4bf0ee9e30a716d11Phil Weaver     * Whether or not the service has crashed and is awaiting restart. Only valid from {@link
423c09a02198718761e20e351f4bf0ee9e30a716d11Phil Weaver     * android.view.accessibility.AccessibilityManager#getEnabledAccessibilityServiceList(int)},
424c09a02198718761e20e351f4bf0ee9e30a716d11Phil Weaver     * because that is populated from the internal list of running services.
425c09a02198718761e20e351f4bf0ee9e30a716d11Phil Weaver     *
426c09a02198718761e20e351f4bf0ee9e30a716d11Phil Weaver     * @hide
427c09a02198718761e20e351f4bf0ee9e30a716d11Phil Weaver     */
428c09a02198718761e20e351f4bf0ee9e30a716d11Phil Weaver    public boolean crashed;
429c09a02198718761e20e351f4bf0ee9e30a716d11Phil Weaver
430c09a02198718761e20e351f4bf0ee9e30a716d11Phil Weaver    /**
431106fe732050f3d75a08c3bc48fdbcf84cac20b41Phil Weaver     * The component name the accessibility service.
432cc4053e031371456fe54d51bbad1db721db4ae38Svetoslav Ganov     */
433106fe732050f3d75a08c3bc48fdbcf84cac20b41Phil Weaver    private ComponentName mComponentName;
434cc4053e031371456fe54d51bbad1db721db4ae38Svetoslav Ganov
435cc4053e031371456fe54d51bbad1db721db4ae38Svetoslav Ganov    /**
436cc4053e031371456fe54d51bbad1db721db4ae38Svetoslav Ganov     * The Service that implements this accessibility service component.
437cc4053e031371456fe54d51bbad1db721db4ae38Svetoslav Ganov     */
438cc4053e031371456fe54d51bbad1db721db4ae38Svetoslav Ganov    private ResolveInfo mResolveInfo;
439cc4053e031371456fe54d51bbad1db721db4ae38Svetoslav Ganov
440cc4053e031371456fe54d51bbad1db721db4ae38Svetoslav Ganov    /**
441cc4053e031371456fe54d51bbad1db721db4ae38Svetoslav Ganov     * The accessibility service setting activity's name, used by the system
442cc4053e031371456fe54d51bbad1db721db4ae38Svetoslav Ganov     * settings to launch the setting activity of this accessibility service.
443cc4053e031371456fe54d51bbad1db721db4ae38Svetoslav Ganov     */
444cc4053e031371456fe54d51bbad1db721db4ae38Svetoslav Ganov    private String mSettingsActivityName;
445cc4053e031371456fe54d51bbad1db721db4ae38Svetoslav Ganov
446cc4053e031371456fe54d51bbad1db721db4ae38Svetoslav Ganov    /**
447688a6977cf7673ed0542ab3d839053c4e38a4dbdSvetoslav     * Bit mask with capabilities of this service.
448cc4053e031371456fe54d51bbad1db721db4ae38Svetoslav Ganov     */
449688a6977cf7673ed0542ab3d839053c4e38a4dbdSvetoslav    private int mCapabilities;
450cc4053e031371456fe54d51bbad1db721db4ae38Svetoslav Ganov
451cc4053e031371456fe54d51bbad1db721db4ae38Svetoslav Ganov    /**
45208c41bcf5fab665cebc820ea813be52f6ecc3154Saige McVea     * Resource id of the summary of the accessibility service.
45308c41bcf5fab665cebc820ea813be52f6ecc3154Saige McVea     */
45408c41bcf5fab665cebc820ea813be52f6ecc3154Saige McVea    private int mSummaryResId;
45508c41bcf5fab665cebc820ea813be52f6ecc3154Saige McVea
45608c41bcf5fab665cebc820ea813be52f6ecc3154Saige McVea    /**
45708c41bcf5fab665cebc820ea813be52f6ecc3154Saige McVea     * Non-localized summary of the accessibility service.
45808c41bcf5fab665cebc820ea813be52f6ecc3154Saige McVea     */
45908c41bcf5fab665cebc820ea813be52f6ecc3154Saige McVea    private String mNonLocalizedSummary;
46008c41bcf5fab665cebc820ea813be52f6ecc3154Saige McVea
46108c41bcf5fab665cebc820ea813be52f6ecc3154Saige McVea    /**
4623d0edd31d8082b7b8b2cdee5efda216179f677b5Svetoslav Ganov     * Resource id of the description of the accessibility service.
46335bfedeaba724aeadc6f6c890269cb6bf7ef42f5Svetoslav Ganov     */
4643d0edd31d8082b7b8b2cdee5efda216179f677b5Svetoslav Ganov    private int mDescriptionResId;
4653d0edd31d8082b7b8b2cdee5efda216179f677b5Svetoslav Ganov
4663d0edd31d8082b7b8b2cdee5efda216179f677b5Svetoslav Ganov    /**
4673d0edd31d8082b7b8b2cdee5efda216179f677b5Svetoslav Ganov     * Non localized description of the accessibility service.
4683d0edd31d8082b7b8b2cdee5efda216179f677b5Svetoslav Ganov     */
4693d0edd31d8082b7b8b2cdee5efda216179f677b5Svetoslav Ganov    private String mNonLocalizedDescription;
47035bfedeaba724aeadc6f6c890269cb6bf7ef42f5Svetoslav Ganov
47135bfedeaba724aeadc6f6c890269cb6bf7ef42f5Svetoslav Ganov    /**
472cc4053e031371456fe54d51bbad1db721db4ae38Svetoslav Ganov     * Creates a new instance.
473cc4053e031371456fe54d51bbad1db721db4ae38Svetoslav Ganov     */
474cc4053e031371456fe54d51bbad1db721db4ae38Svetoslav Ganov    public AccessibilityServiceInfo() {
475cc4053e031371456fe54d51bbad1db721db4ae38Svetoslav Ganov        /* do nothing */
476cc4053e031371456fe54d51bbad1db721db4ae38Svetoslav Ganov    }
477cc4053e031371456fe54d51bbad1db721db4ae38Svetoslav Ganov
478cc4053e031371456fe54d51bbad1db721db4ae38Svetoslav Ganov    /**
479cc4053e031371456fe54d51bbad1db721db4ae38Svetoslav Ganov     * Creates a new instance.
480cc4053e031371456fe54d51bbad1db721db4ae38Svetoslav Ganov     *
481cc4053e031371456fe54d51bbad1db721db4ae38Svetoslav Ganov     * @param resolveInfo The service resolve info.
482cc4053e031371456fe54d51bbad1db721db4ae38Svetoslav Ganov     * @param context Context for accessing resources.
483cc4053e031371456fe54d51bbad1db721db4ae38Svetoslav Ganov     * @throws XmlPullParserException If a XML parsing error occurs.
484cc4053e031371456fe54d51bbad1db721db4ae38Svetoslav Ganov     * @throws IOException If a XML parsing error occurs.
485cc4053e031371456fe54d51bbad1db721db4ae38Svetoslav Ganov     *
486cc4053e031371456fe54d51bbad1db721db4ae38Svetoslav Ganov     * @hide
487cc4053e031371456fe54d51bbad1db721db4ae38Svetoslav Ganov     */
488cc4053e031371456fe54d51bbad1db721db4ae38Svetoslav Ganov    public AccessibilityServiceInfo(ResolveInfo resolveInfo, Context context)
489cc4053e031371456fe54d51bbad1db721db4ae38Svetoslav Ganov            throws XmlPullParserException, IOException {
490cc4053e031371456fe54d51bbad1db721db4ae38Svetoslav Ganov        ServiceInfo serviceInfo = resolveInfo.serviceInfo;
491106fe732050f3d75a08c3bc48fdbcf84cac20b41Phil Weaver        mComponentName = new ComponentName(serviceInfo.packageName, serviceInfo.name);
492cc4053e031371456fe54d51bbad1db721db4ae38Svetoslav Ganov        mResolveInfo = resolveInfo;
493cc4053e031371456fe54d51bbad1db721db4ae38Svetoslav Ganov
494cc4053e031371456fe54d51bbad1db721db4ae38Svetoslav Ganov        XmlResourceParser parser = null;
495cc4053e031371456fe54d51bbad1db721db4ae38Svetoslav Ganov
496cc4053e031371456fe54d51bbad1db721db4ae38Svetoslav Ganov        try {
497cc4053e031371456fe54d51bbad1db721db4ae38Svetoslav Ganov            PackageManager packageManager = context.getPackageManager();
498cc4053e031371456fe54d51bbad1db721db4ae38Svetoslav Ganov            parser = serviceInfo.loadXmlMetaData(packageManager,
499cc4053e031371456fe54d51bbad1db721db4ae38Svetoslav Ganov                    AccessibilityService.SERVICE_META_DATA);
500cc4053e031371456fe54d51bbad1db721db4ae38Svetoslav Ganov            if (parser == null) {
501cc4053e031371456fe54d51bbad1db721db4ae38Svetoslav Ganov                return;
502cc4053e031371456fe54d51bbad1db721db4ae38Svetoslav Ganov            }
503cc4053e031371456fe54d51bbad1db721db4ae38Svetoslav Ganov
504cc4053e031371456fe54d51bbad1db721db4ae38Svetoslav Ganov            int type = 0;
505cc4053e031371456fe54d51bbad1db721db4ae38Svetoslav Ganov            while (type != XmlPullParser.END_DOCUMENT && type != XmlPullParser.START_TAG) {
506cc4053e031371456fe54d51bbad1db721db4ae38Svetoslav Ganov                type = parser.next();
507cc4053e031371456fe54d51bbad1db721db4ae38Svetoslav Ganov            }
508cc4053e031371456fe54d51bbad1db721db4ae38Svetoslav Ganov
509cc4053e031371456fe54d51bbad1db721db4ae38Svetoslav Ganov            String nodeName = parser.getName();
510cc4053e031371456fe54d51bbad1db721db4ae38Svetoslav Ganov            if (!TAG_ACCESSIBILITY_SERVICE.equals(nodeName)) {
511cc4053e031371456fe54d51bbad1db721db4ae38Svetoslav Ganov                throw new XmlPullParserException( "Meta-data does not start with"
512cc4053e031371456fe54d51bbad1db721db4ae38Svetoslav Ganov                        + TAG_ACCESSIBILITY_SERVICE + " tag");
513cc4053e031371456fe54d51bbad1db721db4ae38Svetoslav Ganov            }
514cc4053e031371456fe54d51bbad1db721db4ae38Svetoslav Ganov
515cc4053e031371456fe54d51bbad1db721db4ae38Svetoslav Ganov            AttributeSet allAttributes = Xml.asAttributeSet(parser);
516cc4053e031371456fe54d51bbad1db721db4ae38Svetoslav Ganov            Resources resources = packageManager.getResourcesForApplication(
517cc4053e031371456fe54d51bbad1db721db4ae38Svetoslav Ganov                    serviceInfo.applicationInfo);
518cc4053e031371456fe54d51bbad1db721db4ae38Svetoslav Ganov            TypedArray asAttributes = resources.obtainAttributes(allAttributes,
519cc4053e031371456fe54d51bbad1db721db4ae38Svetoslav Ganov                    com.android.internal.R.styleable.AccessibilityService);
520cc4053e031371456fe54d51bbad1db721db4ae38Svetoslav Ganov            eventTypes = asAttributes.getInt(
521cc4053e031371456fe54d51bbad1db721db4ae38Svetoslav Ganov                    com.android.internal.R.styleable.AccessibilityService_accessibilityEventTypes,
522cc4053e031371456fe54d51bbad1db721db4ae38Svetoslav Ganov                    0);
523cc4053e031371456fe54d51bbad1db721db4ae38Svetoslav Ganov            String packageNamez = asAttributes.getString(
524cc4053e031371456fe54d51bbad1db721db4ae38Svetoslav Ganov                    com.android.internal.R.styleable.AccessibilityService_packageNames);
525cc4053e031371456fe54d51bbad1db721db4ae38Svetoslav Ganov            if (packageNamez != null) {
526cc4053e031371456fe54d51bbad1db721db4ae38Svetoslav Ganov                packageNames = packageNamez.split("(\\s)*,(\\s)*");
527cc4053e031371456fe54d51bbad1db721db4ae38Svetoslav Ganov            }
528cc4053e031371456fe54d51bbad1db721db4ae38Svetoslav Ganov            feedbackType = asAttributes.getInt(
529cc4053e031371456fe54d51bbad1db721db4ae38Svetoslav Ganov                    com.android.internal.R.styleable.AccessibilityService_accessibilityFeedbackType,
530cc4053e031371456fe54d51bbad1db721db4ae38Svetoslav Ganov                    0);
531cc4053e031371456fe54d51bbad1db721db4ae38Svetoslav Ganov            notificationTimeout = asAttributes.getInt(
5328e3feb15c5aec2c72b0ef120a1da325e1e8f0ddaSvetoslav                    com.android.internal.R.styleable.AccessibilityService_notificationTimeout,
533cc4053e031371456fe54d51bbad1db721db4ae38Svetoslav Ganov                    0);
534cc4053e031371456fe54d51bbad1db721db4ae38Svetoslav Ganov            flags = asAttributes.getInt(
535cc4053e031371456fe54d51bbad1db721db4ae38Svetoslav Ganov                    com.android.internal.R.styleable.AccessibilityService_accessibilityFlags, 0);
536cc4053e031371456fe54d51bbad1db721db4ae38Svetoslav Ganov            mSettingsActivityName = asAttributes.getString(
537cc4053e031371456fe54d51bbad1db721db4ae38Svetoslav Ganov                    com.android.internal.R.styleable.AccessibilityService_settingsActivity);
538688a6977cf7673ed0542ab3d839053c4e38a4dbdSvetoslav            if (asAttributes.getBoolean(com.android.internal.R.styleable
539688a6977cf7673ed0542ab3d839053c4e38a4dbdSvetoslav                    .AccessibilityService_canRetrieveWindowContent, false)) {
540688a6977cf7673ed0542ab3d839053c4e38a4dbdSvetoslav                mCapabilities |= CAPABILITY_CAN_RETRIEVE_WINDOW_CONTENT;
541688a6977cf7673ed0542ab3d839053c4e38a4dbdSvetoslav            }
542688a6977cf7673ed0542ab3d839053c4e38a4dbdSvetoslav            if (asAttributes.getBoolean(com.android.internal.R.styleable
543688a6977cf7673ed0542ab3d839053c4e38a4dbdSvetoslav                    .AccessibilityService_canRequestTouchExplorationMode, false)) {
544688a6977cf7673ed0542ab3d839053c4e38a4dbdSvetoslav                mCapabilities |= CAPABILITY_CAN_REQUEST_TOUCH_EXPLORATION;
545688a6977cf7673ed0542ab3d839053c4e38a4dbdSvetoslav            }
546688a6977cf7673ed0542ab3d839053c4e38a4dbdSvetoslav            if (asAttributes.getBoolean(com.android.internal.R.styleable
547688a6977cf7673ed0542ab3d839053c4e38a4dbdSvetoslav                    .AccessibilityService_canRequestFilterKeyEvents, false)) {
548688a6977cf7673ed0542ab3d839053c4e38a4dbdSvetoslav                mCapabilities |= CAPABILITY_CAN_REQUEST_FILTER_KEY_EVENTS;
549688a6977cf7673ed0542ab3d839053c4e38a4dbdSvetoslav            }
550214fb68767502f5fede643a062c1dc5975d75b27Alan Viverette            if (asAttributes.getBoolean(com.android.internal.R.styleable
551214fb68767502f5fede643a062c1dc5975d75b27Alan Viverette                    .AccessibilityService_canControlMagnification, false)) {
552214fb68767502f5fede643a062c1dc5975d75b27Alan Viverette                mCapabilities |= CAPABILITY_CAN_CONTROL_MAGNIFICATION;
553214fb68767502f5fede643a062c1dc5975d75b27Alan Viverette            }
554a6b64f5099b7be6e8384958d8bcddb97bb06ec93Phil Weaver            if (asAttributes.getBoolean(com.android.internal.R.styleable
555a6b64f5099b7be6e8384958d8bcddb97bb06ec93Phil Weaver                    .AccessibilityService_canPerformGestures, false)) {
556a6b64f5099b7be6e8384958d8bcddb97bb06ec93Phil Weaver                mCapabilities |= CAPABILITY_CAN_PERFORM_GESTURES;
557a6b64f5099b7be6e8384958d8bcddb97bb06ec93Phil Weaver            }
55827fcd9c97a2ceb50bab026237390207e5ee9e290Phil Weaver            if (asAttributes.getBoolean(com.android.internal.R.styleable
559be2922ff34424cfb996d895cde0cb31c724d09dcPhil Weaver                    .AccessibilityService_canRequestFingerprintGestures, false)) {
560be2922ff34424cfb996d895cde0cb31c724d09dcPhil Weaver                mCapabilities |= CAPABILITY_CAN_REQUEST_FINGERPRINT_GESTURES;
56127fcd9c97a2ceb50bab026237390207e5ee9e290Phil Weaver            }
5623d0edd31d8082b7b8b2cdee5efda216179f677b5Svetoslav Ganov            TypedValue peekedValue = asAttributes.peekValue(
56335bfedeaba724aeadc6f6c890269cb6bf7ef42f5Svetoslav Ganov                    com.android.internal.R.styleable.AccessibilityService_description);
5643d0edd31d8082b7b8b2cdee5efda216179f677b5Svetoslav Ganov            if (peekedValue != null) {
5653d0edd31d8082b7b8b2cdee5efda216179f677b5Svetoslav Ganov                mDescriptionResId = peekedValue.resourceId;
5663d0edd31d8082b7b8b2cdee5efda216179f677b5Svetoslav Ganov                CharSequence nonLocalizedDescription = peekedValue.coerceToString();
5673d0edd31d8082b7b8b2cdee5efda216179f677b5Svetoslav Ganov                if (nonLocalizedDescription != null) {
5683d0edd31d8082b7b8b2cdee5efda216179f677b5Svetoslav Ganov                    mNonLocalizedDescription = nonLocalizedDescription.toString().trim();
5693d0edd31d8082b7b8b2cdee5efda216179f677b5Svetoslav Ganov                }
5703d0edd31d8082b7b8b2cdee5efda216179f677b5Svetoslav Ganov            }
57108c41bcf5fab665cebc820ea813be52f6ecc3154Saige McVea            peekedValue = asAttributes.peekValue(
57208c41bcf5fab665cebc820ea813be52f6ecc3154Saige McVea                com.android.internal.R.styleable.AccessibilityService_summary);
57308c41bcf5fab665cebc820ea813be52f6ecc3154Saige McVea            if (peekedValue != null) {
57408c41bcf5fab665cebc820ea813be52f6ecc3154Saige McVea                mSummaryResId = peekedValue.resourceId;
57508c41bcf5fab665cebc820ea813be52f6ecc3154Saige McVea                CharSequence nonLocalizedSummary = peekedValue.coerceToString();
57608c41bcf5fab665cebc820ea813be52f6ecc3154Saige McVea                if (nonLocalizedSummary != null) {
57708c41bcf5fab665cebc820ea813be52f6ecc3154Saige McVea                    mNonLocalizedSummary = nonLocalizedSummary.toString().trim();
57808c41bcf5fab665cebc820ea813be52f6ecc3154Saige McVea                }
57908c41bcf5fab665cebc820ea813be52f6ecc3154Saige McVea            }
580cc4053e031371456fe54d51bbad1db721db4ae38Svetoslav Ganov            asAttributes.recycle();
581cc4053e031371456fe54d51bbad1db721db4ae38Svetoslav Ganov        } catch (NameNotFoundException e) {
582cc4053e031371456fe54d51bbad1db721db4ae38Svetoslav Ganov            throw new XmlPullParserException( "Unable to create context for: "
583cc4053e031371456fe54d51bbad1db721db4ae38Svetoslav Ganov                    + serviceInfo.packageName);
584cc4053e031371456fe54d51bbad1db721db4ae38Svetoslav Ganov        } finally {
585cc4053e031371456fe54d51bbad1db721db4ae38Svetoslav Ganov            if (parser != null) {
586cc4053e031371456fe54d51bbad1db721db4ae38Svetoslav Ganov                parser.close();
587cc4053e031371456fe54d51bbad1db721db4ae38Svetoslav Ganov            }
588cc4053e031371456fe54d51bbad1db721db4ae38Svetoslav Ganov        }
589cc4053e031371456fe54d51bbad1db721db4ae38Svetoslav Ganov    }
590cc4053e031371456fe54d51bbad1db721db4ae38Svetoslav Ganov
591cc4053e031371456fe54d51bbad1db721db4ae38Svetoslav Ganov    /**
592d4128ec0df2d40d46b4fa0ff6edae393f3bf67b9Eugene Susla     * Updates the properties that an AccessibilitySerivice can change dynamically.
593cc4053e031371456fe54d51bbad1db721db4ae38Svetoslav Ganov     *
594cc4053e031371456fe54d51bbad1db721db4ae38Svetoslav Ganov     * @param other The info from which to update the properties.
595cc4053e031371456fe54d51bbad1db721db4ae38Svetoslav Ganov     *
596cc4053e031371456fe54d51bbad1db721db4ae38Svetoslav Ganov     * @hide
597cc4053e031371456fe54d51bbad1db721db4ae38Svetoslav Ganov     */
598cc4053e031371456fe54d51bbad1db721db4ae38Svetoslav Ganov    public void updateDynamicallyConfigurableProperties(AccessibilityServiceInfo other) {
599cc4053e031371456fe54d51bbad1db721db4ae38Svetoslav Ganov        eventTypes = other.eventTypes;
600cc4053e031371456fe54d51bbad1db721db4ae38Svetoslav Ganov        packageNames = other.packageNames;
601cc4053e031371456fe54d51bbad1db721db4ae38Svetoslav Ganov        feedbackType = other.feedbackType;
602cc4053e031371456fe54d51bbad1db721db4ae38Svetoslav Ganov        notificationTimeout = other.notificationTimeout;
603cc4053e031371456fe54d51bbad1db721db4ae38Svetoslav Ganov        flags = other.flags;
604cc4053e031371456fe54d51bbad1db721db4ae38Svetoslav Ganov    }
605cc4053e031371456fe54d51bbad1db721db4ae38Svetoslav Ganov
606cc4053e031371456fe54d51bbad1db721db4ae38Svetoslav Ganov    /**
60757bf88508e0491caced22c4c592d33aba6d88129Svetoslav     * @hide
60857bf88508e0491caced22c4c592d33aba6d88129Svetoslav     */
60957bf88508e0491caced22c4c592d33aba6d88129Svetoslav    public void setComponentName(ComponentName component) {
610106fe732050f3d75a08c3bc48fdbcf84cac20b41Phil Weaver        mComponentName = component;
611106fe732050f3d75a08c3bc48fdbcf84cac20b41Phil Weaver    }
612106fe732050f3d75a08c3bc48fdbcf84cac20b41Phil Weaver
613106fe732050f3d75a08c3bc48fdbcf84cac20b41Phil Weaver    /**
614106fe732050f3d75a08c3bc48fdbcf84cac20b41Phil Weaver     * @hide
615106fe732050f3d75a08c3bc48fdbcf84cac20b41Phil Weaver     */
616106fe732050f3d75a08c3bc48fdbcf84cac20b41Phil Weaver    public ComponentName getComponentName() {
617106fe732050f3d75a08c3bc48fdbcf84cac20b41Phil Weaver        return mComponentName;
61857bf88508e0491caced22c4c592d33aba6d88129Svetoslav    }
61957bf88508e0491caced22c4c592d33aba6d88129Svetoslav
62057bf88508e0491caced22c4c592d33aba6d88129Svetoslav    /**
621cc4053e031371456fe54d51bbad1db721db4ae38Svetoslav Ganov     * The accessibility service id.
622cc4053e031371456fe54d51bbad1db721db4ae38Svetoslav Ganov     * <p>
623cc4053e031371456fe54d51bbad1db721db4ae38Svetoslav Ganov     *   <strong>Generated by the system.</strong>
624cc4053e031371456fe54d51bbad1db721db4ae38Svetoslav Ganov     * </p>
625cc4053e031371456fe54d51bbad1db721db4ae38Svetoslav Ganov     * @return The id.
626cc4053e031371456fe54d51bbad1db721db4ae38Svetoslav Ganov     */
627cc4053e031371456fe54d51bbad1db721db4ae38Svetoslav Ganov    public String getId() {
628106fe732050f3d75a08c3bc48fdbcf84cac20b41Phil Weaver        return mComponentName.flattenToShortString();
629cc4053e031371456fe54d51bbad1db721db4ae38Svetoslav Ganov    }
630cc4053e031371456fe54d51bbad1db721db4ae38Svetoslav Ganov
631cc4053e031371456fe54d51bbad1db721db4ae38Svetoslav Ganov    /**
632cc4053e031371456fe54d51bbad1db721db4ae38Svetoslav Ganov     * The service {@link ResolveInfo}.
633cc4053e031371456fe54d51bbad1db721db4ae38Svetoslav Ganov     * <p>
634cc4053e031371456fe54d51bbad1db721db4ae38Svetoslav Ganov     *   <strong>Generated by the system.</strong>
635cc4053e031371456fe54d51bbad1db721db4ae38Svetoslav Ganov     * </p>
636cc4053e031371456fe54d51bbad1db721db4ae38Svetoslav Ganov     * @return The info.
637cc4053e031371456fe54d51bbad1db721db4ae38Svetoslav Ganov     */
638cc4053e031371456fe54d51bbad1db721db4ae38Svetoslav Ganov    public ResolveInfo getResolveInfo() {
639cc4053e031371456fe54d51bbad1db721db4ae38Svetoslav Ganov        return mResolveInfo;
640cc4053e031371456fe54d51bbad1db721db4ae38Svetoslav Ganov    }
641cc4053e031371456fe54d51bbad1db721db4ae38Svetoslav Ganov
642cc4053e031371456fe54d51bbad1db721db4ae38Svetoslav Ganov    /**
643cc4053e031371456fe54d51bbad1db721db4ae38Svetoslav Ganov     * The settings activity name.
644cc4053e031371456fe54d51bbad1db721db4ae38Svetoslav Ganov     * <p>
645cc4053e031371456fe54d51bbad1db721db4ae38Svetoslav Ganov     *    <strong>Statically set from
646cc4053e031371456fe54d51bbad1db721db4ae38Svetoslav Ganov     *    {@link AccessibilityService#SERVICE_META_DATA meta-data}.</strong>
647cc4053e031371456fe54d51bbad1db721db4ae38Svetoslav Ganov     * </p>
648cc4053e031371456fe54d51bbad1db721db4ae38Svetoslav Ganov     * @return The settings activity name.
649cc4053e031371456fe54d51bbad1db721db4ae38Svetoslav Ganov     */
650cc4053e031371456fe54d51bbad1db721db4ae38Svetoslav Ganov    public String getSettingsActivityName() {
651cc4053e031371456fe54d51bbad1db721db4ae38Svetoslav Ganov        return mSettingsActivityName;
652cc4053e031371456fe54d51bbad1db721db4ae38Svetoslav Ganov    }
653cc4053e031371456fe54d51bbad1db721db4ae38Svetoslav Ganov
654cc4053e031371456fe54d51bbad1db721db4ae38Svetoslav Ganov    /**
65538e8b4e5bc3c93affdffbc064fd9db5aeccc3e8eSvetoslav Ganov     * Whether this service can retrieve the current window's content.
656cc4053e031371456fe54d51bbad1db721db4ae38Svetoslav Ganov     * <p>
657cc4053e031371456fe54d51bbad1db721db4ae38Svetoslav Ganov     *    <strong>Statically set from
658cc4053e031371456fe54d51bbad1db721db4ae38Svetoslav Ganov     *    {@link AccessibilityService#SERVICE_META_DATA meta-data}.</strong>
659cc4053e031371456fe54d51bbad1db721db4ae38Svetoslav Ganov     * </p>
660fefd20e927b7252d63acb7bb1852c5188e3c1b2eSvetoslav Ganov     * @return True if window content can be retrieved.
661688a6977cf7673ed0542ab3d839053c4e38a4dbdSvetoslav     *
662688a6977cf7673ed0542ab3d839053c4e38a4dbdSvetoslav     * @deprecated Use {@link #getCapabilities()}.
663cc4053e031371456fe54d51bbad1db721db4ae38Svetoslav Ganov     */
664cc4053e031371456fe54d51bbad1db721db4ae38Svetoslav Ganov    public boolean getCanRetrieveWindowContent() {
665688a6977cf7673ed0542ab3d839053c4e38a4dbdSvetoslav        return (mCapabilities & CAPABILITY_CAN_RETRIEVE_WINDOW_CONTENT) != 0;
666688a6977cf7673ed0542ab3d839053c4e38a4dbdSvetoslav    }
667688a6977cf7673ed0542ab3d839053c4e38a4dbdSvetoslav
668688a6977cf7673ed0542ab3d839053c4e38a4dbdSvetoslav    /**
669688a6977cf7673ed0542ab3d839053c4e38a4dbdSvetoslav     * Returns the bit mask of capabilities this accessibility service has such as
670688a6977cf7673ed0542ab3d839053c4e38a4dbdSvetoslav     * being able to retrieve the active window content, etc.
671688a6977cf7673ed0542ab3d839053c4e38a4dbdSvetoslav     *
672688a6977cf7673ed0542ab3d839053c4e38a4dbdSvetoslav     * @return The capability bit mask.
673688a6977cf7673ed0542ab3d839053c4e38a4dbdSvetoslav     *
674688a6977cf7673ed0542ab3d839053c4e38a4dbdSvetoslav     * @see #CAPABILITY_CAN_RETRIEVE_WINDOW_CONTENT
675688a6977cf7673ed0542ab3d839053c4e38a4dbdSvetoslav     * @see #CAPABILITY_CAN_REQUEST_TOUCH_EXPLORATION
676048c2bc19af4cfcb5e959f1bc07fbfa03a72e330Casey Burkhardt     * @see #CAPABILITY_CAN_REQUEST_FILTER_KEY_EVENTS
677a6b64f5099b7be6e8384958d8bcddb97bb06ec93Phil Weaver     * @see #CAPABILITY_CAN_CONTROL_MAGNIFICATION
678a6b64f5099b7be6e8384958d8bcddb97bb06ec93Phil Weaver     * @see #CAPABILITY_CAN_PERFORM_GESTURES
679688a6977cf7673ed0542ab3d839053c4e38a4dbdSvetoslav     */
680688a6977cf7673ed0542ab3d839053c4e38a4dbdSvetoslav    public int getCapabilities() {
681688a6977cf7673ed0542ab3d839053c4e38a4dbdSvetoslav        return mCapabilities;
682cc4053e031371456fe54d51bbad1db721db4ae38Svetoslav Ganov    }
683cc4053e031371456fe54d51bbad1db721db4ae38Svetoslav Ganov
684cc4053e031371456fe54d51bbad1db721db4ae38Svetoslav Ganov    /**
68511adf6dc2438260c3e0d79cc189bcb4f6f15e9f4Svetoslav     * Sets the bit mask of capabilities this accessibility service has such as
68611adf6dc2438260c3e0d79cc189bcb4f6f15e9f4Svetoslav     * being able to retrieve the active window content, etc.
68711adf6dc2438260c3e0d79cc189bcb4f6f15e9f4Svetoslav     *
68811adf6dc2438260c3e0d79cc189bcb4f6f15e9f4Svetoslav     * @param capabilities The capability bit mask.
68911adf6dc2438260c3e0d79cc189bcb4f6f15e9f4Svetoslav     *
69011adf6dc2438260c3e0d79cc189bcb4f6f15e9f4Svetoslav     * @see #CAPABILITY_CAN_RETRIEVE_WINDOW_CONTENT
69111adf6dc2438260c3e0d79cc189bcb4f6f15e9f4Svetoslav     * @see #CAPABILITY_CAN_REQUEST_TOUCH_EXPLORATION
692048c2bc19af4cfcb5e959f1bc07fbfa03a72e330Casey Burkhardt     * @see #CAPABILITY_CAN_REQUEST_FILTER_KEY_EVENTS
693a6b64f5099b7be6e8384958d8bcddb97bb06ec93Phil Weaver     * @see #CAPABILITY_CAN_CONTROL_MAGNIFICATION
694a6b64f5099b7be6e8384958d8bcddb97bb06ec93Phil Weaver     * @see #CAPABILITY_CAN_PERFORM_GESTURES
69511adf6dc2438260c3e0d79cc189bcb4f6f15e9f4Svetoslav     *
69611adf6dc2438260c3e0d79cc189bcb4f6f15e9f4Svetoslav     * @hide
69711adf6dc2438260c3e0d79cc189bcb4f6f15e9f4Svetoslav     */
69811adf6dc2438260c3e0d79cc189bcb4f6f15e9f4Svetoslav    public void setCapabilities(int capabilities) {
69911adf6dc2438260c3e0d79cc189bcb4f6f15e9f4Svetoslav        mCapabilities = capabilities;
70011adf6dc2438260c3e0d79cc189bcb4f6f15e9f4Svetoslav    }
70111adf6dc2438260c3e0d79cc189bcb4f6f15e9f4Svetoslav
70211adf6dc2438260c3e0d79cc189bcb4f6f15e9f4Svetoslav    /**
70308c41bcf5fab665cebc820ea813be52f6ecc3154Saige McVea     * The localized summary of the accessibility service.
70408c41bcf5fab665cebc820ea813be52f6ecc3154Saige McVea     * <p>
70508c41bcf5fab665cebc820ea813be52f6ecc3154Saige McVea     *    <strong>Statically set from
70608c41bcf5fab665cebc820ea813be52f6ecc3154Saige McVea     *    {@link AccessibilityService#SERVICE_META_DATA meta-data}.</strong>
70708c41bcf5fab665cebc820ea813be52f6ecc3154Saige McVea     * </p>
708cb75b5454b54f7d443f1552adb7813ca139d22e3Saige McVea     * @return The localized summary if available, and {@code null} if a summary
709cb75b5454b54f7d443f1552adb7813ca139d22e3Saige McVea     * has not been provided.
71008c41bcf5fab665cebc820ea813be52f6ecc3154Saige McVea     */
711cb75b5454b54f7d443f1552adb7813ca139d22e3Saige McVea    public CharSequence loadSummary(PackageManager packageManager) {
71208c41bcf5fab665cebc820ea813be52f6ecc3154Saige McVea        if (mSummaryResId == 0) {
71308c41bcf5fab665cebc820ea813be52f6ecc3154Saige McVea            return mNonLocalizedSummary;
71408c41bcf5fab665cebc820ea813be52f6ecc3154Saige McVea        }
71508c41bcf5fab665cebc820ea813be52f6ecc3154Saige McVea        ServiceInfo serviceInfo = mResolveInfo.serviceInfo;
71608c41bcf5fab665cebc820ea813be52f6ecc3154Saige McVea        CharSequence summary = packageManager.getText(serviceInfo.packageName,
71708c41bcf5fab665cebc820ea813be52f6ecc3154Saige McVea                mSummaryResId, serviceInfo.applicationInfo);
71808c41bcf5fab665cebc820ea813be52f6ecc3154Saige McVea        if (summary != null) {
71908c41bcf5fab665cebc820ea813be52f6ecc3154Saige McVea            return summary.toString().trim();
72008c41bcf5fab665cebc820ea813be52f6ecc3154Saige McVea        }
72108c41bcf5fab665cebc820ea813be52f6ecc3154Saige McVea        return null;
72208c41bcf5fab665cebc820ea813be52f6ecc3154Saige McVea    }
72308c41bcf5fab665cebc820ea813be52f6ecc3154Saige McVea
72408c41bcf5fab665cebc820ea813be52f6ecc3154Saige McVea    /**
7253d0edd31d8082b7b8b2cdee5efda216179f677b5Svetoslav Ganov     * Gets the non-localized description of the accessibility service.
72635bfedeaba724aeadc6f6c890269cb6bf7ef42f5Svetoslav Ganov     * <p>
72735bfedeaba724aeadc6f6c890269cb6bf7ef42f5Svetoslav Ganov     *    <strong>Statically set from
72835bfedeaba724aeadc6f6c890269cb6bf7ef42f5Svetoslav Ganov     *    {@link AccessibilityService#SERVICE_META_DATA meta-data}.</strong>
72935bfedeaba724aeadc6f6c890269cb6bf7ef42f5Svetoslav Ganov     * </p>
73035bfedeaba724aeadc6f6c890269cb6bf7ef42f5Svetoslav Ganov     * @return The description.
7313d0edd31d8082b7b8b2cdee5efda216179f677b5Svetoslav Ganov     *
7323d0edd31d8082b7b8b2cdee5efda216179f677b5Svetoslav Ganov     * @deprecated Use {@link #loadDescription(PackageManager)}.
73335bfedeaba724aeadc6f6c890269cb6bf7ef42f5Svetoslav Ganov     */
73435bfedeaba724aeadc6f6c890269cb6bf7ef42f5Svetoslav Ganov    public String getDescription() {
7353d0edd31d8082b7b8b2cdee5efda216179f677b5Svetoslav Ganov        return mNonLocalizedDescription;
7363d0edd31d8082b7b8b2cdee5efda216179f677b5Svetoslav Ganov    }
7373d0edd31d8082b7b8b2cdee5efda216179f677b5Svetoslav Ganov
7383d0edd31d8082b7b8b2cdee5efda216179f677b5Svetoslav Ganov    /**
7393d0edd31d8082b7b8b2cdee5efda216179f677b5Svetoslav Ganov     * The localized description of the accessibility service.
7403d0edd31d8082b7b8b2cdee5efda216179f677b5Svetoslav Ganov     * <p>
7413d0edd31d8082b7b8b2cdee5efda216179f677b5Svetoslav Ganov     *    <strong>Statically set from
7423d0edd31d8082b7b8b2cdee5efda216179f677b5Svetoslav Ganov     *    {@link AccessibilityService#SERVICE_META_DATA meta-data}.</strong>
7433d0edd31d8082b7b8b2cdee5efda216179f677b5Svetoslav Ganov     * </p>
7443d0edd31d8082b7b8b2cdee5efda216179f677b5Svetoslav Ganov     * @return The localized description.
7453d0edd31d8082b7b8b2cdee5efda216179f677b5Svetoslav Ganov     */
7463d0edd31d8082b7b8b2cdee5efda216179f677b5Svetoslav Ganov    public String loadDescription(PackageManager packageManager) {
7473d0edd31d8082b7b8b2cdee5efda216179f677b5Svetoslav Ganov        if (mDescriptionResId == 0) {
7483d0edd31d8082b7b8b2cdee5efda216179f677b5Svetoslav Ganov            return mNonLocalizedDescription;
7493d0edd31d8082b7b8b2cdee5efda216179f677b5Svetoslav Ganov        }
7503d0edd31d8082b7b8b2cdee5efda216179f677b5Svetoslav Ganov        ServiceInfo serviceInfo = mResolveInfo.serviceInfo;
7513d0edd31d8082b7b8b2cdee5efda216179f677b5Svetoslav Ganov        CharSequence description = packageManager.getText(serviceInfo.packageName,
7523d0edd31d8082b7b8b2cdee5efda216179f677b5Svetoslav Ganov                mDescriptionResId, serviceInfo.applicationInfo);
7533d0edd31d8082b7b8b2cdee5efda216179f677b5Svetoslav Ganov        if (description != null) {
7543d0edd31d8082b7b8b2cdee5efda216179f677b5Svetoslav Ganov            return description.toString().trim();
7553d0edd31d8082b7b8b2cdee5efda216179f677b5Svetoslav Ganov        }
7563d0edd31d8082b7b8b2cdee5efda216179f677b5Svetoslav Ganov        return null;
75735bfedeaba724aeadc6f6c890269cb6bf7ef42f5Svetoslav Ganov    }
75835bfedeaba724aeadc6f6c890269cb6bf7ef42f5Svetoslav Ganov
759e88e2665471c7b620fd3b1baca024fc9e705ee32Jeff Sharkey    /** {@hide} */
760b5e89c6debca90be92bf5bc2e0e79d109de6d08fJeff Sharkey    public boolean isDirectBootAware() {
761b5e89c6debca90be92bf5bc2e0e79d109de6d08fJeff Sharkey        return ((flags & FLAG_FORCE_DIRECT_BOOT_AWARE) != 0)
762b5e89c6debca90be92bf5bc2e0e79d109de6d08fJeff Sharkey                || mResolveInfo.serviceInfo.directBootAware;
763e88e2665471c7b620fd3b1baca024fc9e705ee32Jeff Sharkey    }
764e88e2665471c7b620fd3b1baca024fc9e705ee32Jeff Sharkey
76535bfedeaba724aeadc6f6c890269cb6bf7ef42f5Svetoslav Ganov    /**
766cc4053e031371456fe54d51bbad1db721db4ae38Svetoslav Ganov     * {@inheritDoc}
767cc4053e031371456fe54d51bbad1db721db4ae38Svetoslav Ganov     */
76875986cf9bc57ef11ad70f36fb77fbbf5d63af6ecsvetoslavganov    public int describeContents() {
76975986cf9bc57ef11ad70f36fb77fbbf5d63af6ecsvetoslavganov        return 0;
77075986cf9bc57ef11ad70f36fb77fbbf5d63af6ecsvetoslavganov    }
77175986cf9bc57ef11ad70f36fb77fbbf5d63af6ecsvetoslavganov
7729b31779eab896bdcc0922473b183c979cc0b874fSvetoslav Ganov    public void writeToParcel(Parcel parcel, int flagz) {
77375986cf9bc57ef11ad70f36fb77fbbf5d63af6ecsvetoslavganov        parcel.writeInt(eventTypes);
77475986cf9bc57ef11ad70f36fb77fbbf5d63af6ecsvetoslavganov        parcel.writeStringArray(packageNames);
77575986cf9bc57ef11ad70f36fb77fbbf5d63af6ecsvetoslavganov        parcel.writeInt(feedbackType);
77675986cf9bc57ef11ad70f36fb77fbbf5d63af6ecsvetoslavganov        parcel.writeLong(notificationTimeout);
77775986cf9bc57ef11ad70f36fb77fbbf5d63af6ecsvetoslavganov        parcel.writeInt(flags);
778c09a02198718761e20e351f4bf0ee9e30a716d11Phil Weaver        parcel.writeInt(crashed ? 1 : 0);
779106fe732050f3d75a08c3bc48fdbcf84cac20b41Phil Weaver        parcel.writeParcelable(mComponentName, flagz);
780cc4053e031371456fe54d51bbad1db721db4ae38Svetoslav Ganov        parcel.writeParcelable(mResolveInfo, 0);
781cc4053e031371456fe54d51bbad1db721db4ae38Svetoslav Ganov        parcel.writeString(mSettingsActivityName);
782688a6977cf7673ed0542ab3d839053c4e38a4dbdSvetoslav        parcel.writeInt(mCapabilities);
78308c41bcf5fab665cebc820ea813be52f6ecc3154Saige McVea        parcel.writeInt(mSummaryResId);
78408c41bcf5fab665cebc820ea813be52f6ecc3154Saige McVea        parcel.writeString(mNonLocalizedSummary);
7853d0edd31d8082b7b8b2cdee5efda216179f677b5Svetoslav Ganov        parcel.writeInt(mDescriptionResId);
7863d0edd31d8082b7b8b2cdee5efda216179f677b5Svetoslav Ganov        parcel.writeString(mNonLocalizedDescription);
787cc4053e031371456fe54d51bbad1db721db4ae38Svetoslav Ganov    }
788cc4053e031371456fe54d51bbad1db721db4ae38Svetoslav Ganov
789cc4053e031371456fe54d51bbad1db721db4ae38Svetoslav Ganov    private void initFromParcel(Parcel parcel) {
790cc4053e031371456fe54d51bbad1db721db4ae38Svetoslav Ganov        eventTypes = parcel.readInt();
791cc4053e031371456fe54d51bbad1db721db4ae38Svetoslav Ganov        packageNames = parcel.readStringArray();
792cc4053e031371456fe54d51bbad1db721db4ae38Svetoslav Ganov        feedbackType = parcel.readInt();
793cc4053e031371456fe54d51bbad1db721db4ae38Svetoslav Ganov        notificationTimeout = parcel.readLong();
794cc4053e031371456fe54d51bbad1db721db4ae38Svetoslav Ganov        flags = parcel.readInt();
795c09a02198718761e20e351f4bf0ee9e30a716d11Phil Weaver        crashed = parcel.readInt() != 0;
796106fe732050f3d75a08c3bc48fdbcf84cac20b41Phil Weaver        mComponentName = parcel.readParcelable(this.getClass().getClassLoader());
797cc4053e031371456fe54d51bbad1db721db4ae38Svetoslav Ganov        mResolveInfo = parcel.readParcelable(null);
798cc4053e031371456fe54d51bbad1db721db4ae38Svetoslav Ganov        mSettingsActivityName = parcel.readString();
799688a6977cf7673ed0542ab3d839053c4e38a4dbdSvetoslav        mCapabilities = parcel.readInt();
80008c41bcf5fab665cebc820ea813be52f6ecc3154Saige McVea        mSummaryResId = parcel.readInt();
80108c41bcf5fab665cebc820ea813be52f6ecc3154Saige McVea        mNonLocalizedSummary = parcel.readString();
8023d0edd31d8082b7b8b2cdee5efda216179f677b5Svetoslav Ganov        mDescriptionResId = parcel.readInt();
8033d0edd31d8082b7b8b2cdee5efda216179f677b5Svetoslav Ganov        mNonLocalizedDescription = parcel.readString();
804cc4053e031371456fe54d51bbad1db721db4ae38Svetoslav Ganov    }
805cc4053e031371456fe54d51bbad1db721db4ae38Svetoslav Ganov
806cc4053e031371456fe54d51bbad1db721db4ae38Svetoslav Ganov    @Override
80757bf88508e0491caced22c4c592d33aba6d88129Svetoslav    public int hashCode() {
808106fe732050f3d75a08c3bc48fdbcf84cac20b41Phil Weaver        return 31 * 1 + ((mComponentName == null) ? 0 : mComponentName.hashCode());
80957bf88508e0491caced22c4c592d33aba6d88129Svetoslav    }
81057bf88508e0491caced22c4c592d33aba6d88129Svetoslav
81157bf88508e0491caced22c4c592d33aba6d88129Svetoslav    @Override
81257bf88508e0491caced22c4c592d33aba6d88129Svetoslav    public boolean equals(Object obj) {
81357bf88508e0491caced22c4c592d33aba6d88129Svetoslav        if (this == obj) {
81457bf88508e0491caced22c4c592d33aba6d88129Svetoslav            return true;
81557bf88508e0491caced22c4c592d33aba6d88129Svetoslav        }
81657bf88508e0491caced22c4c592d33aba6d88129Svetoslav        if (obj == null) {
81757bf88508e0491caced22c4c592d33aba6d88129Svetoslav            return false;
81857bf88508e0491caced22c4c592d33aba6d88129Svetoslav        }
81957bf88508e0491caced22c4c592d33aba6d88129Svetoslav        if (getClass() != obj.getClass()) {
82057bf88508e0491caced22c4c592d33aba6d88129Svetoslav            return false;
82157bf88508e0491caced22c4c592d33aba6d88129Svetoslav        }
82257bf88508e0491caced22c4c592d33aba6d88129Svetoslav        AccessibilityServiceInfo other = (AccessibilityServiceInfo) obj;
823106fe732050f3d75a08c3bc48fdbcf84cac20b41Phil Weaver        if (mComponentName == null) {
824106fe732050f3d75a08c3bc48fdbcf84cac20b41Phil Weaver            if (other.mComponentName != null) {
82557bf88508e0491caced22c4c592d33aba6d88129Svetoslav                return false;
82657bf88508e0491caced22c4c592d33aba6d88129Svetoslav            }
827106fe732050f3d75a08c3bc48fdbcf84cac20b41Phil Weaver        } else if (!mComponentName.equals(other.mComponentName)) {
82857bf88508e0491caced22c4c592d33aba6d88129Svetoslav            return false;
82957bf88508e0491caced22c4c592d33aba6d88129Svetoslav        }
83057bf88508e0491caced22c4c592d33aba6d88129Svetoslav        return true;
83157bf88508e0491caced22c4c592d33aba6d88129Svetoslav    }
83257bf88508e0491caced22c4c592d33aba6d88129Svetoslav
83357bf88508e0491caced22c4c592d33aba6d88129Svetoslav    @Override
834cc4053e031371456fe54d51bbad1db721db4ae38Svetoslav Ganov    public String toString() {
835cc4053e031371456fe54d51bbad1db721db4ae38Svetoslav Ganov        StringBuilder stringBuilder = new StringBuilder();
836cc4053e031371456fe54d51bbad1db721db4ae38Svetoslav Ganov        appendEventTypes(stringBuilder, eventTypes);
837cc4053e031371456fe54d51bbad1db721db4ae38Svetoslav Ganov        stringBuilder.append(", ");
838cc4053e031371456fe54d51bbad1db721db4ae38Svetoslav Ganov        appendPackageNames(stringBuilder, packageNames);
839cc4053e031371456fe54d51bbad1db721db4ae38Svetoslav Ganov        stringBuilder.append(", ");
840cc4053e031371456fe54d51bbad1db721db4ae38Svetoslav Ganov        appendFeedbackTypes(stringBuilder, feedbackType);
841cc4053e031371456fe54d51bbad1db721db4ae38Svetoslav Ganov        stringBuilder.append(", ");
842cc4053e031371456fe54d51bbad1db721db4ae38Svetoslav Ganov        stringBuilder.append("notificationTimeout: ").append(notificationTimeout);
843cc4053e031371456fe54d51bbad1db721db4ae38Svetoslav Ganov        stringBuilder.append(", ");
844cc4053e031371456fe54d51bbad1db721db4ae38Svetoslav Ganov        appendFlags(stringBuilder, flags);
845cc4053e031371456fe54d51bbad1db721db4ae38Svetoslav Ganov        stringBuilder.append(", ");
846106fe732050f3d75a08c3bc48fdbcf84cac20b41Phil Weaver        stringBuilder.append("id: ").append(getId());
847cc4053e031371456fe54d51bbad1db721db4ae38Svetoslav Ganov        stringBuilder.append(", ");
848cc4053e031371456fe54d51bbad1db721db4ae38Svetoslav Ganov        stringBuilder.append("resolveInfo: ").append(mResolveInfo);
849cc4053e031371456fe54d51bbad1db721db4ae38Svetoslav Ganov        stringBuilder.append(", ");
850cc4053e031371456fe54d51bbad1db721db4ae38Svetoslav Ganov        stringBuilder.append("settingsActivityName: ").append(mSettingsActivityName);
851cc4053e031371456fe54d51bbad1db721db4ae38Svetoslav Ganov        stringBuilder.append(", ");
85208c41bcf5fab665cebc820ea813be52f6ecc3154Saige McVea        stringBuilder.append("summary: ").append(mNonLocalizedSummary);
85308c41bcf5fab665cebc820ea813be52f6ecc3154Saige McVea        stringBuilder.append(", ");
854688a6977cf7673ed0542ab3d839053c4e38a4dbdSvetoslav        appendCapabilities(stringBuilder, mCapabilities);
855cc4053e031371456fe54d51bbad1db721db4ae38Svetoslav Ganov        return stringBuilder.toString();
856cc4053e031371456fe54d51bbad1db721db4ae38Svetoslav Ganov    }
857cc4053e031371456fe54d51bbad1db721db4ae38Svetoslav Ganov
85824c90450fe3fe097a7bca51edd6a4cffd8fd13aaSvetoslav Ganov    private static void appendFeedbackTypes(StringBuilder stringBuilder,
85924c90450fe3fe097a7bca51edd6a4cffd8fd13aaSvetoslav Ganov            @FeedbackType int feedbackTypes) {
860cc4053e031371456fe54d51bbad1db721db4ae38Svetoslav Ganov        stringBuilder.append("feedbackTypes:");
861cc4053e031371456fe54d51bbad1db721db4ae38Svetoslav Ganov        stringBuilder.append("[");
862cc4053e031371456fe54d51bbad1db721db4ae38Svetoslav Ganov        while (feedbackTypes != 0) {
863cc4053e031371456fe54d51bbad1db721db4ae38Svetoslav Ganov            final int feedbackTypeBit = (1 << Integer.numberOfTrailingZeros(feedbackTypes));
864cc4053e031371456fe54d51bbad1db721db4ae38Svetoslav Ganov            stringBuilder.append(feedbackTypeToString(feedbackTypeBit));
865cc4053e031371456fe54d51bbad1db721db4ae38Svetoslav Ganov            feedbackTypes &= ~feedbackTypeBit;
866cc4053e031371456fe54d51bbad1db721db4ae38Svetoslav Ganov            if (feedbackTypes != 0) {
867cc4053e031371456fe54d51bbad1db721db4ae38Svetoslav Ganov                stringBuilder.append(", ");
868cc4053e031371456fe54d51bbad1db721db4ae38Svetoslav Ganov            }
869cc4053e031371456fe54d51bbad1db721db4ae38Svetoslav Ganov        }
870cc4053e031371456fe54d51bbad1db721db4ae38Svetoslav Ganov        stringBuilder.append("]");
871cc4053e031371456fe54d51bbad1db721db4ae38Svetoslav Ganov    }
872cc4053e031371456fe54d51bbad1db721db4ae38Svetoslav Ganov
873cc4053e031371456fe54d51bbad1db721db4ae38Svetoslav Ganov    private static void appendPackageNames(StringBuilder stringBuilder, String[] packageNames) {
874cc4053e031371456fe54d51bbad1db721db4ae38Svetoslav Ganov        stringBuilder.append("packageNames:");
875cc4053e031371456fe54d51bbad1db721db4ae38Svetoslav Ganov        stringBuilder.append("[");
876cc4053e031371456fe54d51bbad1db721db4ae38Svetoslav Ganov        if (packageNames != null) {
877cc4053e031371456fe54d51bbad1db721db4ae38Svetoslav Ganov            final int packageNameCount = packageNames.length;
878cc4053e031371456fe54d51bbad1db721db4ae38Svetoslav Ganov            for (int i = 0; i < packageNameCount; i++) {
879cc4053e031371456fe54d51bbad1db721db4ae38Svetoslav Ganov                stringBuilder.append(packageNames[i]);
880cc4053e031371456fe54d51bbad1db721db4ae38Svetoslav Ganov                if (i < packageNameCount - 1) {
881cc4053e031371456fe54d51bbad1db721db4ae38Svetoslav Ganov                    stringBuilder.append(", ");
882cc4053e031371456fe54d51bbad1db721db4ae38Svetoslav Ganov                }
883cc4053e031371456fe54d51bbad1db721db4ae38Svetoslav Ganov            }
884cc4053e031371456fe54d51bbad1db721db4ae38Svetoslav Ganov        }
885cc4053e031371456fe54d51bbad1db721db4ae38Svetoslav Ganov        stringBuilder.append("]");
886cc4053e031371456fe54d51bbad1db721db4ae38Svetoslav Ganov    }
887cc4053e031371456fe54d51bbad1db721db4ae38Svetoslav Ganov
888cc4053e031371456fe54d51bbad1db721db4ae38Svetoslav Ganov    private static void appendEventTypes(StringBuilder stringBuilder, int eventTypes) {
889cc4053e031371456fe54d51bbad1db721db4ae38Svetoslav Ganov        stringBuilder.append("eventTypes:");
890cc4053e031371456fe54d51bbad1db721db4ae38Svetoslav Ganov        stringBuilder.append("[");
891cc4053e031371456fe54d51bbad1db721db4ae38Svetoslav Ganov        while (eventTypes != 0) {
892cc4053e031371456fe54d51bbad1db721db4ae38Svetoslav Ganov            final int eventTypeBit = (1 << Integer.numberOfTrailingZeros(eventTypes));
893cc4053e031371456fe54d51bbad1db721db4ae38Svetoslav Ganov            stringBuilder.append(AccessibilityEvent.eventTypeToString(eventTypeBit));
894cc4053e031371456fe54d51bbad1db721db4ae38Svetoslav Ganov            eventTypes &= ~eventTypeBit;
895cc4053e031371456fe54d51bbad1db721db4ae38Svetoslav Ganov            if (eventTypes != 0) {
896cc4053e031371456fe54d51bbad1db721db4ae38Svetoslav Ganov                stringBuilder.append(", ");
897cc4053e031371456fe54d51bbad1db721db4ae38Svetoslav Ganov            }
898cc4053e031371456fe54d51bbad1db721db4ae38Svetoslav Ganov        }
899cc4053e031371456fe54d51bbad1db721db4ae38Svetoslav Ganov        stringBuilder.append("]");
900cc4053e031371456fe54d51bbad1db721db4ae38Svetoslav Ganov    }
901cc4053e031371456fe54d51bbad1db721db4ae38Svetoslav Ganov
902cc4053e031371456fe54d51bbad1db721db4ae38Svetoslav Ganov    private static void appendFlags(StringBuilder stringBuilder, int flags) {
903cc4053e031371456fe54d51bbad1db721db4ae38Svetoslav Ganov        stringBuilder.append("flags:");
904cc4053e031371456fe54d51bbad1db721db4ae38Svetoslav Ganov        stringBuilder.append("[");
905cc4053e031371456fe54d51bbad1db721db4ae38Svetoslav Ganov        while (flags != 0) {
906cc4053e031371456fe54d51bbad1db721db4ae38Svetoslav Ganov            final int flagBit = (1 << Integer.numberOfTrailingZeros(flags));
907cc4053e031371456fe54d51bbad1db721db4ae38Svetoslav Ganov            stringBuilder.append(flagToString(flagBit));
908cc4053e031371456fe54d51bbad1db721db4ae38Svetoslav Ganov            flags &= ~flagBit;
909cc4053e031371456fe54d51bbad1db721db4ae38Svetoslav Ganov            if (flags != 0) {
910cc4053e031371456fe54d51bbad1db721db4ae38Svetoslav Ganov                stringBuilder.append(", ");
911cc4053e031371456fe54d51bbad1db721db4ae38Svetoslav Ganov            }
912cc4053e031371456fe54d51bbad1db721db4ae38Svetoslav Ganov        }
913cc4053e031371456fe54d51bbad1db721db4ae38Svetoslav Ganov        stringBuilder.append("]");
914cc4053e031371456fe54d51bbad1db721db4ae38Svetoslav Ganov    }
915cc4053e031371456fe54d51bbad1db721db4ae38Svetoslav Ganov
916688a6977cf7673ed0542ab3d839053c4e38a4dbdSvetoslav    private static void appendCapabilities(StringBuilder stringBuilder, int capabilities) {
917688a6977cf7673ed0542ab3d839053c4e38a4dbdSvetoslav        stringBuilder.append("capabilities:");
918688a6977cf7673ed0542ab3d839053c4e38a4dbdSvetoslav        stringBuilder.append("[");
919688a6977cf7673ed0542ab3d839053c4e38a4dbdSvetoslav        while (capabilities != 0) {
920688a6977cf7673ed0542ab3d839053c4e38a4dbdSvetoslav            final int capabilityBit = (1 << Integer.numberOfTrailingZeros(capabilities));
921688a6977cf7673ed0542ab3d839053c4e38a4dbdSvetoslav            stringBuilder.append(capabilityToString(capabilityBit));
922688a6977cf7673ed0542ab3d839053c4e38a4dbdSvetoslav            capabilities &= ~capabilityBit;
923688a6977cf7673ed0542ab3d839053c4e38a4dbdSvetoslav            if (capabilities != 0) {
924688a6977cf7673ed0542ab3d839053c4e38a4dbdSvetoslav                stringBuilder.append(", ");
925688a6977cf7673ed0542ab3d839053c4e38a4dbdSvetoslav            }
926688a6977cf7673ed0542ab3d839053c4e38a4dbdSvetoslav        }
927688a6977cf7673ed0542ab3d839053c4e38a4dbdSvetoslav        stringBuilder.append("]");
928688a6977cf7673ed0542ab3d839053c4e38a4dbdSvetoslav    }
929688a6977cf7673ed0542ab3d839053c4e38a4dbdSvetoslav
930cc4053e031371456fe54d51bbad1db721db4ae38Svetoslav Ganov    /**
931cc4053e031371456fe54d51bbad1db721db4ae38Svetoslav Ganov     * Returns the string representation of a feedback type. For example,
932cc4053e031371456fe54d51bbad1db721db4ae38Svetoslav Ganov     * {@link #FEEDBACK_SPOKEN} is represented by the string FEEDBACK_SPOKEN.
933cc4053e031371456fe54d51bbad1db721db4ae38Svetoslav Ganov     *
934cc4053e031371456fe54d51bbad1db721db4ae38Svetoslav Ganov     * @param feedbackType The feedback type.
935cc4053e031371456fe54d51bbad1db721db4ae38Svetoslav Ganov     * @return The string representation.
936cc4053e031371456fe54d51bbad1db721db4ae38Svetoslav Ganov     */
937cc4053e031371456fe54d51bbad1db721db4ae38Svetoslav Ganov    public static String feedbackTypeToString(int feedbackType) {
938bb1b9ea8a488eec833b0be18c45dae8505876042Svetoslav Ganov        StringBuilder builder = new StringBuilder();
939bb1b9ea8a488eec833b0be18c45dae8505876042Svetoslav Ganov        builder.append("[");
940c6c25f9e28a4de73261106a80ae098347524dd2aSvetoslav Ganov        while (feedbackType != 0) {
941bb1b9ea8a488eec833b0be18c45dae8505876042Svetoslav Ganov            final int feedbackTypeFlag = 1 << Integer.numberOfTrailingZeros(feedbackType);
942bb1b9ea8a488eec833b0be18c45dae8505876042Svetoslav Ganov            feedbackType &= ~feedbackTypeFlag;
943bb1b9ea8a488eec833b0be18c45dae8505876042Svetoslav Ganov            switch (feedbackTypeFlag) {
944bb1b9ea8a488eec833b0be18c45dae8505876042Svetoslav Ganov                case FEEDBACK_AUDIBLE:
945c6c25f9e28a4de73261106a80ae098347524dd2aSvetoslav Ganov                    if (builder.length() > 1) {
946c6c25f9e28a4de73261106a80ae098347524dd2aSvetoslav Ganov                        builder.append(", ");
947c6c25f9e28a4de73261106a80ae098347524dd2aSvetoslav Ganov                    }
948bb1b9ea8a488eec833b0be18c45dae8505876042Svetoslav Ganov                    builder.append("FEEDBACK_AUDIBLE");
949bb1b9ea8a488eec833b0be18c45dae8505876042Svetoslav Ganov                    break;
950bb1b9ea8a488eec833b0be18c45dae8505876042Svetoslav Ganov                case FEEDBACK_HAPTIC:
951c6c25f9e28a4de73261106a80ae098347524dd2aSvetoslav Ganov                    if (builder.length() > 1) {
952c6c25f9e28a4de73261106a80ae098347524dd2aSvetoslav Ganov                        builder.append(", ");
953c6c25f9e28a4de73261106a80ae098347524dd2aSvetoslav Ganov                    }
954bb1b9ea8a488eec833b0be18c45dae8505876042Svetoslav Ganov                    builder.append("FEEDBACK_HAPTIC");
955bb1b9ea8a488eec833b0be18c45dae8505876042Svetoslav Ganov                    break;
956bb1b9ea8a488eec833b0be18c45dae8505876042Svetoslav Ganov                case FEEDBACK_GENERIC:
957c6c25f9e28a4de73261106a80ae098347524dd2aSvetoslav Ganov                    if (builder.length() > 1) {
958c6c25f9e28a4de73261106a80ae098347524dd2aSvetoslav Ganov                        builder.append(", ");
959c6c25f9e28a4de73261106a80ae098347524dd2aSvetoslav Ganov                    }
960bb1b9ea8a488eec833b0be18c45dae8505876042Svetoslav Ganov                    builder.append("FEEDBACK_GENERIC");
961bb1b9ea8a488eec833b0be18c45dae8505876042Svetoslav Ganov                    break;
962bb1b9ea8a488eec833b0be18c45dae8505876042Svetoslav Ganov                case FEEDBACK_SPOKEN:
963c6c25f9e28a4de73261106a80ae098347524dd2aSvetoslav Ganov                    if (builder.length() > 1) {
964c6c25f9e28a4de73261106a80ae098347524dd2aSvetoslav Ganov                        builder.append(", ");
965c6c25f9e28a4de73261106a80ae098347524dd2aSvetoslav Ganov                    }
966bb1b9ea8a488eec833b0be18c45dae8505876042Svetoslav Ganov                    builder.append("FEEDBACK_SPOKEN");
967bb1b9ea8a488eec833b0be18c45dae8505876042Svetoslav Ganov                    break;
968bb1b9ea8a488eec833b0be18c45dae8505876042Svetoslav Ganov                case FEEDBACK_VISUAL:
969c6c25f9e28a4de73261106a80ae098347524dd2aSvetoslav Ganov                    if (builder.length() > 1) {
970c6c25f9e28a4de73261106a80ae098347524dd2aSvetoslav Ganov                        builder.append(", ");
971c6c25f9e28a4de73261106a80ae098347524dd2aSvetoslav Ganov                    }
972bb1b9ea8a488eec833b0be18c45dae8505876042Svetoslav Ganov                    builder.append("FEEDBACK_VISUAL");
973bb1b9ea8a488eec833b0be18c45dae8505876042Svetoslav Ganov                    break;
974eb9862fd4c6ba1745a0f6c997e85643a4ded0643Svetoslav Ganov                case FEEDBACK_BRAILLE:
975eb9862fd4c6ba1745a0f6c997e85643a4ded0643Svetoslav Ganov                    if (builder.length() > 1) {
976eb9862fd4c6ba1745a0f6c997e85643a4ded0643Svetoslav Ganov                        builder.append(", ");
977eb9862fd4c6ba1745a0f6c997e85643a4ded0643Svetoslav Ganov                    }
978eb9862fd4c6ba1745a0f6c997e85643a4ded0643Svetoslav Ganov                    builder.append("FEEDBACK_BRAILLE");
979eb9862fd4c6ba1745a0f6c997e85643a4ded0643Svetoslav Ganov                    break;
980bb1b9ea8a488eec833b0be18c45dae8505876042Svetoslav Ganov            }
981cc4053e031371456fe54d51bbad1db721db4ae38Svetoslav Ganov        }
982bb1b9ea8a488eec833b0be18c45dae8505876042Svetoslav Ganov        builder.append("]");
983bb1b9ea8a488eec833b0be18c45dae8505876042Svetoslav Ganov        return builder.toString();
984cc4053e031371456fe54d51bbad1db721db4ae38Svetoslav Ganov    }
985cc4053e031371456fe54d51bbad1db721db4ae38Svetoslav Ganov
986cc4053e031371456fe54d51bbad1db721db4ae38Svetoslav Ganov    /**
987cc4053e031371456fe54d51bbad1db721db4ae38Svetoslav Ganov     * Returns the string representation of a flag. For example,
988cc4053e031371456fe54d51bbad1db721db4ae38Svetoslav Ganov     * {@link #DEFAULT} is represented by the string DEFAULT.
989cc4053e031371456fe54d51bbad1db721db4ae38Svetoslav Ganov     *
990cc4053e031371456fe54d51bbad1db721db4ae38Svetoslav Ganov     * @param flag The flag.
991cc4053e031371456fe54d51bbad1db721db4ae38Svetoslav Ganov     * @return The string representation.
992cc4053e031371456fe54d51bbad1db721db4ae38Svetoslav Ganov     */
993cc4053e031371456fe54d51bbad1db721db4ae38Svetoslav Ganov    public static String flagToString(int flag) {
994cc4053e031371456fe54d51bbad1db721db4ae38Svetoslav Ganov        switch (flag) {
995cc4053e031371456fe54d51bbad1db721db4ae38Svetoslav Ganov            case DEFAULT:
996cc4053e031371456fe54d51bbad1db721db4ae38Svetoslav Ganov                return "DEFAULT";
9973ec2e1b94ab502bfa8d5e8750716108f69aa18d2Svetoslav Ganov            case FLAG_INCLUDE_NOT_IMPORTANT_VIEWS:
9983ec2e1b94ab502bfa8d5e8750716108f69aa18d2Svetoslav Ganov                return "FLAG_INCLUDE_NOT_IMPORTANT_VIEWS";
9993ec2e1b94ab502bfa8d5e8750716108f69aa18d2Svetoslav Ganov            case FLAG_REQUEST_TOUCH_EXPLORATION_MODE:
10003ec2e1b94ab502bfa8d5e8750716108f69aa18d2Svetoslav Ganov                return "FLAG_REQUEST_TOUCH_EXPLORATION_MODE";
1001688a6977cf7673ed0542ab3d839053c4e38a4dbdSvetoslav            case FLAG_REQUEST_ENHANCED_WEB_ACCESSIBILITY:
1002688a6977cf7673ed0542ab3d839053c4e38a4dbdSvetoslav                return "FLAG_REQUEST_ENHANCED_WEB_ACCESSIBILITY";
1003688a6977cf7673ed0542ab3d839053c4e38a4dbdSvetoslav            case FLAG_REPORT_VIEW_IDS:
1004688a6977cf7673ed0542ab3d839053c4e38a4dbdSvetoslav                return "FLAG_REPORT_VIEW_IDS";
1005688a6977cf7673ed0542ab3d839053c4e38a4dbdSvetoslav            case FLAG_REQUEST_FILTER_KEY_EVENTS:
1006688a6977cf7673ed0542ab3d839053c4e38a4dbdSvetoslav                return "FLAG_REQUEST_FILTER_KEY_EVENTS";
10078e3feb15c5aec2c72b0ef120a1da325e1e8f0ddaSvetoslav            case FLAG_RETRIEVE_INTERACTIVE_WINDOWS:
10088e3feb15c5aec2c72b0ef120a1da325e1e8f0ddaSvetoslav                return "FLAG_RETRIEVE_INTERACTIVE_WINDOWS";
10094acc16d1b611074baa9eeb7ec5628350b7eb5fa5Phil Weaver            case FLAG_ENABLE_ACCESSIBILITY_VOLUME:
10104acc16d1b611074baa9eeb7ec5628350b7eb5fa5Phil Weaver                return "FLAG_ENABLE_ACCESSIBILITY_VOLUME";
1011048c2bc19af4cfcb5e959f1bc07fbfa03a72e330Casey Burkhardt            case FLAG_REQUEST_ACCESSIBILITY_BUTTON:
1012048c2bc19af4cfcb5e959f1bc07fbfa03a72e330Casey Burkhardt                return "FLAG_REQUEST_ACCESSIBILITY_BUTTON";
1013be2922ff34424cfb996d895cde0cb31c724d09dcPhil Weaver            case FLAG_REQUEST_FINGERPRINT_GESTURES:
1014be2922ff34424cfb996d895cde0cb31c724d09dcPhil Weaver                return "FLAG_REQUEST_FINGERPRINT_GESTURES";
1015cc4053e031371456fe54d51bbad1db721db4ae38Svetoslav Ganov            default:
1016cc4053e031371456fe54d51bbad1db721db4ae38Svetoslav Ganov                return null;
1017cc4053e031371456fe54d51bbad1db721db4ae38Svetoslav Ganov        }
101875986cf9bc57ef11ad70f36fb77fbbf5d63af6ecsvetoslavganov    }
101975986cf9bc57ef11ad70f36fb77fbbf5d63af6ecsvetoslavganov
102075986cf9bc57ef11ad70f36fb77fbbf5d63af6ecsvetoslavganov    /**
1021688a6977cf7673ed0542ab3d839053c4e38a4dbdSvetoslav     * Returns the string representation of a capability. For example,
1022688a6977cf7673ed0542ab3d839053c4e38a4dbdSvetoslav     * {@link #CAPABILITY_CAN_RETRIEVE_WINDOW_CONTENT} is represented
1023688a6977cf7673ed0542ab3d839053c4e38a4dbdSvetoslav     * by the string CAPABILITY_CAN_RETRIEVE_WINDOW_CONTENT.
1024688a6977cf7673ed0542ab3d839053c4e38a4dbdSvetoslav     *
1025688a6977cf7673ed0542ab3d839053c4e38a4dbdSvetoslav     * @param capability The capability.
1026688a6977cf7673ed0542ab3d839053c4e38a4dbdSvetoslav     * @return The string representation.
1027688a6977cf7673ed0542ab3d839053c4e38a4dbdSvetoslav     */
1028688a6977cf7673ed0542ab3d839053c4e38a4dbdSvetoslav    public static String capabilityToString(int capability) {
1029688a6977cf7673ed0542ab3d839053c4e38a4dbdSvetoslav        switch (capability) {
1030688a6977cf7673ed0542ab3d839053c4e38a4dbdSvetoslav            case CAPABILITY_CAN_RETRIEVE_WINDOW_CONTENT:
1031688a6977cf7673ed0542ab3d839053c4e38a4dbdSvetoslav                return "CAPABILITY_CAN_RETRIEVE_WINDOW_CONTENT";
1032688a6977cf7673ed0542ab3d839053c4e38a4dbdSvetoslav            case CAPABILITY_CAN_REQUEST_TOUCH_EXPLORATION:
1033688a6977cf7673ed0542ab3d839053c4e38a4dbdSvetoslav                return "CAPABILITY_CAN_REQUEST_TOUCH_EXPLORATION";
1034688a6977cf7673ed0542ab3d839053c4e38a4dbdSvetoslav            case CAPABILITY_CAN_REQUEST_ENHANCED_WEB_ACCESSIBILITY:
1035688a6977cf7673ed0542ab3d839053c4e38a4dbdSvetoslav                return "CAPABILITY_CAN_REQUEST_ENHANCED_WEB_ACCESSIBILITY";
1036688a6977cf7673ed0542ab3d839053c4e38a4dbdSvetoslav            case CAPABILITY_CAN_REQUEST_FILTER_KEY_EVENTS:
1037048c2bc19af4cfcb5e959f1bc07fbfa03a72e330Casey Burkhardt                return "CAPABILITY_CAN_REQUEST_FILTER_KEY_EVENTS";
1038214fb68767502f5fede643a062c1dc5975d75b27Alan Viverette            case CAPABILITY_CAN_CONTROL_MAGNIFICATION:
1039214fb68767502f5fede643a062c1dc5975d75b27Alan Viverette                return "CAPABILITY_CAN_CONTROL_MAGNIFICATION";
1040a6b64f5099b7be6e8384958d8bcddb97bb06ec93Phil Weaver            case CAPABILITY_CAN_PERFORM_GESTURES:
1041a6b64f5099b7be6e8384958d8bcddb97bb06ec93Phil Weaver                return "CAPABILITY_CAN_PERFORM_GESTURES";
1042be2922ff34424cfb996d895cde0cb31c724d09dcPhil Weaver            case CAPABILITY_CAN_REQUEST_FINGERPRINT_GESTURES:
1043be2922ff34424cfb996d895cde0cb31c724d09dcPhil Weaver                return "CAPABILITY_CAN_REQUEST_FINGERPRINT_GESTURES";
1044688a6977cf7673ed0542ab3d839053c4e38a4dbdSvetoslav            default:
1045688a6977cf7673ed0542ab3d839053c4e38a4dbdSvetoslav                return "UNKNOWN";
1046688a6977cf7673ed0542ab3d839053c4e38a4dbdSvetoslav        }
1047688a6977cf7673ed0542ab3d839053c4e38a4dbdSvetoslav    }
1048688a6977cf7673ed0542ab3d839053c4e38a4dbdSvetoslav
1049688a6977cf7673ed0542ab3d839053c4e38a4dbdSvetoslav    /**
1050688a6977cf7673ed0542ab3d839053c4e38a4dbdSvetoslav     * @hide
1051688a6977cf7673ed0542ab3d839053c4e38a4dbdSvetoslav     * @return The list of {@link CapabilityInfo} objects.
105227fcd9c97a2ceb50bab026237390207e5ee9e290Phil Weaver     * @deprecated The version that takes a context works better.
1053688a6977cf7673ed0542ab3d839053c4e38a4dbdSvetoslav     */
1054688a6977cf7673ed0542ab3d839053c4e38a4dbdSvetoslav    public List<CapabilityInfo> getCapabilityInfos() {
105527fcd9c97a2ceb50bab026237390207e5ee9e290Phil Weaver        return getCapabilityInfos(null);
105627fcd9c97a2ceb50bab026237390207e5ee9e290Phil Weaver    }
105727fcd9c97a2ceb50bab026237390207e5ee9e290Phil Weaver
105827fcd9c97a2ceb50bab026237390207e5ee9e290Phil Weaver    /**
105927fcd9c97a2ceb50bab026237390207e5ee9e290Phil Weaver     * @hide
106027fcd9c97a2ceb50bab026237390207e5ee9e290Phil Weaver     * @param context A valid context
106127fcd9c97a2ceb50bab026237390207e5ee9e290Phil Weaver     * @return The list of {@link CapabilityInfo} objects.
106227fcd9c97a2ceb50bab026237390207e5ee9e290Phil Weaver     */
106327fcd9c97a2ceb50bab026237390207e5ee9e290Phil Weaver    public List<CapabilityInfo> getCapabilityInfos(Context context) {
1064688a6977cf7673ed0542ab3d839053c4e38a4dbdSvetoslav        if (mCapabilities == 0) {
1065688a6977cf7673ed0542ab3d839053c4e38a4dbdSvetoslav            return Collections.emptyList();
1066688a6977cf7673ed0542ab3d839053c4e38a4dbdSvetoslav        }
1067688a6977cf7673ed0542ab3d839053c4e38a4dbdSvetoslav        int capabilities = mCapabilities;
1068688a6977cf7673ed0542ab3d839053c4e38a4dbdSvetoslav        List<CapabilityInfo> capabilityInfos = new ArrayList<CapabilityInfo>();
106927fcd9c97a2ceb50bab026237390207e5ee9e290Phil Weaver        SparseArray<CapabilityInfo> capabilityInfoSparseArray =
107027fcd9c97a2ceb50bab026237390207e5ee9e290Phil Weaver                getCapabilityInfoSparseArray(context);
1071688a6977cf7673ed0542ab3d839053c4e38a4dbdSvetoslav        while (capabilities != 0) {
1072688a6977cf7673ed0542ab3d839053c4e38a4dbdSvetoslav            final int capabilityBit = 1 << Integer.numberOfTrailingZeros(capabilities);
1073688a6977cf7673ed0542ab3d839053c4e38a4dbdSvetoslav            capabilities &= ~capabilityBit;
107427fcd9c97a2ceb50bab026237390207e5ee9e290Phil Weaver            CapabilityInfo capabilityInfo = capabilityInfoSparseArray.get(capabilityBit);
1075688a6977cf7673ed0542ab3d839053c4e38a4dbdSvetoslav            if (capabilityInfo != null) {
1076688a6977cf7673ed0542ab3d839053c4e38a4dbdSvetoslav                capabilityInfos.add(capabilityInfo);
1077688a6977cf7673ed0542ab3d839053c4e38a4dbdSvetoslav            }
1078688a6977cf7673ed0542ab3d839053c4e38a4dbdSvetoslav        }
1079688a6977cf7673ed0542ab3d839053c4e38a4dbdSvetoslav        return capabilityInfos;
1080688a6977cf7673ed0542ab3d839053c4e38a4dbdSvetoslav    }
1081688a6977cf7673ed0542ab3d839053c4e38a4dbdSvetoslav
108227fcd9c97a2ceb50bab026237390207e5ee9e290Phil Weaver    private static SparseArray<CapabilityInfo> getCapabilityInfoSparseArray(Context context) {
108327fcd9c97a2ceb50bab026237390207e5ee9e290Phil Weaver        if (sAvailableCapabilityInfos == null) {
108427fcd9c97a2ceb50bab026237390207e5ee9e290Phil Weaver            sAvailableCapabilityInfos = new SparseArray<CapabilityInfo>();
108527fcd9c97a2ceb50bab026237390207e5ee9e290Phil Weaver            sAvailableCapabilityInfos.put(CAPABILITY_CAN_RETRIEVE_WINDOW_CONTENT,
108627fcd9c97a2ceb50bab026237390207e5ee9e290Phil Weaver                    new CapabilityInfo(CAPABILITY_CAN_RETRIEVE_WINDOW_CONTENT,
108727fcd9c97a2ceb50bab026237390207e5ee9e290Phil Weaver                            R.string.capability_title_canRetrieveWindowContent,
108827fcd9c97a2ceb50bab026237390207e5ee9e290Phil Weaver                            R.string.capability_desc_canRetrieveWindowContent));
108927fcd9c97a2ceb50bab026237390207e5ee9e290Phil Weaver            sAvailableCapabilityInfos.put(CAPABILITY_CAN_REQUEST_TOUCH_EXPLORATION,
109027fcd9c97a2ceb50bab026237390207e5ee9e290Phil Weaver                    new CapabilityInfo(CAPABILITY_CAN_REQUEST_TOUCH_EXPLORATION,
109127fcd9c97a2ceb50bab026237390207e5ee9e290Phil Weaver                            R.string.capability_title_canRequestTouchExploration,
109227fcd9c97a2ceb50bab026237390207e5ee9e290Phil Weaver                            R.string.capability_desc_canRequestTouchExploration));
109327fcd9c97a2ceb50bab026237390207e5ee9e290Phil Weaver            sAvailableCapabilityInfos.put(CAPABILITY_CAN_REQUEST_FILTER_KEY_EVENTS,
109427fcd9c97a2ceb50bab026237390207e5ee9e290Phil Weaver                    new CapabilityInfo(CAPABILITY_CAN_REQUEST_FILTER_KEY_EVENTS,
109527fcd9c97a2ceb50bab026237390207e5ee9e290Phil Weaver                            R.string.capability_title_canRequestFilterKeyEvents,
109627fcd9c97a2ceb50bab026237390207e5ee9e290Phil Weaver                            R.string.capability_desc_canRequestFilterKeyEvents));
109727fcd9c97a2ceb50bab026237390207e5ee9e290Phil Weaver            sAvailableCapabilityInfos.put(CAPABILITY_CAN_CONTROL_MAGNIFICATION,
109827fcd9c97a2ceb50bab026237390207e5ee9e290Phil Weaver                    new CapabilityInfo(CAPABILITY_CAN_CONTROL_MAGNIFICATION,
109927fcd9c97a2ceb50bab026237390207e5ee9e290Phil Weaver                            R.string.capability_title_canControlMagnification,
110027fcd9c97a2ceb50bab026237390207e5ee9e290Phil Weaver                            R.string.capability_desc_canControlMagnification));
110127fcd9c97a2ceb50bab026237390207e5ee9e290Phil Weaver            sAvailableCapabilityInfos.put(CAPABILITY_CAN_PERFORM_GESTURES,
110227fcd9c97a2ceb50bab026237390207e5ee9e290Phil Weaver                    new CapabilityInfo(CAPABILITY_CAN_PERFORM_GESTURES,
110327fcd9c97a2ceb50bab026237390207e5ee9e290Phil Weaver                            R.string.capability_title_canPerformGestures,
110427fcd9c97a2ceb50bab026237390207e5ee9e290Phil Weaver                            R.string.capability_desc_canPerformGestures));
11057917a2f020b95a6372dd3c506183ea345ab5ae24Phil Weaver            if ((context == null) || fingerprintAvailable(context)) {
1106be2922ff34424cfb996d895cde0cb31c724d09dcPhil Weaver                sAvailableCapabilityInfos.put(CAPABILITY_CAN_REQUEST_FINGERPRINT_GESTURES,
1107be2922ff34424cfb996d895cde0cb31c724d09dcPhil Weaver                        new CapabilityInfo(CAPABILITY_CAN_REQUEST_FINGERPRINT_GESTURES,
110827fcd9c97a2ceb50bab026237390207e5ee9e290Phil Weaver                                R.string.capability_title_canCaptureFingerprintGestures,
110927fcd9c97a2ceb50bab026237390207e5ee9e290Phil Weaver                                R.string.capability_desc_canCaptureFingerprintGestures));
111027fcd9c97a2ceb50bab026237390207e5ee9e290Phil Weaver            }
111127fcd9c97a2ceb50bab026237390207e5ee9e290Phil Weaver        }
111227fcd9c97a2ceb50bab026237390207e5ee9e290Phil Weaver        return sAvailableCapabilityInfos;
111327fcd9c97a2ceb50bab026237390207e5ee9e290Phil Weaver    }
111427fcd9c97a2ceb50bab026237390207e5ee9e290Phil Weaver
11157917a2f020b95a6372dd3c506183ea345ab5ae24Phil Weaver    private static boolean fingerprintAvailable(Context context) {
11167917a2f020b95a6372dd3c506183ea345ab5ae24Phil Weaver        return context.getPackageManager().hasSystemFeature(FEATURE_FINGERPRINT)
11177917a2f020b95a6372dd3c506183ea345ab5ae24Phil Weaver                && context.getSystemService(FingerprintManager.class).isHardwareDetected();
11187917a2f020b95a6372dd3c506183ea345ab5ae24Phil Weaver    }
1119688a6977cf7673ed0542ab3d839053c4e38a4dbdSvetoslav    /**
1120688a6977cf7673ed0542ab3d839053c4e38a4dbdSvetoslav     * @hide
1121688a6977cf7673ed0542ab3d839053c4e38a4dbdSvetoslav     */
1122688a6977cf7673ed0542ab3d839053c4e38a4dbdSvetoslav    public static final class CapabilityInfo {
1123688a6977cf7673ed0542ab3d839053c4e38a4dbdSvetoslav        public final int capability;
1124688a6977cf7673ed0542ab3d839053c4e38a4dbdSvetoslav        public final int titleResId;
1125688a6977cf7673ed0542ab3d839053c4e38a4dbdSvetoslav        public final int descResId;
1126688a6977cf7673ed0542ab3d839053c4e38a4dbdSvetoslav
1127688a6977cf7673ed0542ab3d839053c4e38a4dbdSvetoslav        public CapabilityInfo(int capability, int titleResId, int descResId) {
1128688a6977cf7673ed0542ab3d839053c4e38a4dbdSvetoslav            this.capability = capability;
1129688a6977cf7673ed0542ab3d839053c4e38a4dbdSvetoslav            this.titleResId = titleResId;
1130688a6977cf7673ed0542ab3d839053c4e38a4dbdSvetoslav            this.descResId = descResId;
1131688a6977cf7673ed0542ab3d839053c4e38a4dbdSvetoslav        }
1132688a6977cf7673ed0542ab3d839053c4e38a4dbdSvetoslav    }
1133688a6977cf7673ed0542ab3d839053c4e38a4dbdSvetoslav
1134688a6977cf7673ed0542ab3d839053c4e38a4dbdSvetoslav    /**
113575986cf9bc57ef11ad70f36fb77fbbf5d63af6ecsvetoslavganov     * @see Parcelable.Creator
113675986cf9bc57ef11ad70f36fb77fbbf5d63af6ecsvetoslavganov     */
113775986cf9bc57ef11ad70f36fb77fbbf5d63af6ecsvetoslavganov    public static final Parcelable.Creator<AccessibilityServiceInfo> CREATOR =
113875986cf9bc57ef11ad70f36fb77fbbf5d63af6ecsvetoslavganov            new Parcelable.Creator<AccessibilityServiceInfo>() {
113975986cf9bc57ef11ad70f36fb77fbbf5d63af6ecsvetoslavganov        public AccessibilityServiceInfo createFromParcel(Parcel parcel) {
114075986cf9bc57ef11ad70f36fb77fbbf5d63af6ecsvetoslavganov            AccessibilityServiceInfo info = new AccessibilityServiceInfo();
1141cc4053e031371456fe54d51bbad1db721db4ae38Svetoslav Ganov            info.initFromParcel(parcel);
114275986cf9bc57ef11ad70f36fb77fbbf5d63af6ecsvetoslavganov            return info;
114375986cf9bc57ef11ad70f36fb77fbbf5d63af6ecsvetoslavganov        }
114475986cf9bc57ef11ad70f36fb77fbbf5d63af6ecsvetoslavganov
114575986cf9bc57ef11ad70f36fb77fbbf5d63af6ecsvetoslavganov        public AccessibilityServiceInfo[] newArray(int size) {
114675986cf9bc57ef11ad70f36fb77fbbf5d63af6ecsvetoslavganov            return new AccessibilityServiceInfo[size];
114775986cf9bc57ef11ad70f36fb77fbbf5d63af6ecsvetoslavganov        }
114875986cf9bc57ef11ad70f36fb77fbbf5d63af6ecsvetoslavganov    };
114975986cf9bc57ef11ad70f36fb77fbbf5d63af6ecsvetoslavganov}
1150