19648c538bac4f04145c118cc41168d1d7a536312Svetoslav Ganov/* 29648c538bac4f04145c118cc41168d1d7a536312Svetoslav Ganov * Copyright (C) 2011 The Android Open Source Project 39648c538bac4f04145c118cc41168d1d7a536312Svetoslav Ganov * 49648c538bac4f04145c118cc41168d1d7a536312Svetoslav Ganov * Licensed under the Apache License, Version 2.0 (the "License"); 59648c538bac4f04145c118cc41168d1d7a536312Svetoslav Ganov * you may not use this file except in compliance with the License. 69648c538bac4f04145c118cc41168d1d7a536312Svetoslav Ganov * You may obtain a copy of the License at 79648c538bac4f04145c118cc41168d1d7a536312Svetoslav Ganov * 89648c538bac4f04145c118cc41168d1d7a536312Svetoslav Ganov * http://www.apache.org/licenses/LICENSE-2.0 99648c538bac4f04145c118cc41168d1d7a536312Svetoslav Ganov * 109648c538bac4f04145c118cc41168d1d7a536312Svetoslav Ganov * Unless required by applicable law or agreed to in writing, software 119648c538bac4f04145c118cc41168d1d7a536312Svetoslav Ganov * distributed under the License is distributed on an "AS IS" BASIS, 129648c538bac4f04145c118cc41168d1d7a536312Svetoslav Ganov * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 139648c538bac4f04145c118cc41168d1d7a536312Svetoslav Ganov * See the License for the specific language governing permissions and 149648c538bac4f04145c118cc41168d1d7a536312Svetoslav Ganov * limitations under the License. 159648c538bac4f04145c118cc41168d1d7a536312Svetoslav Ganov */ 169648c538bac4f04145c118cc41168d1d7a536312Svetoslav Ganov 170574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganovpackage android.support.v4.accessibilityservice; 189648c538bac4f04145c118cc41168d1d7a536312Svetoslav Ganov 199648c538bac4f04145c118cc41168d1d7a536312Svetoslav Ganovimport android.accessibilityservice.AccessibilityService; 209648c538bac4f04145c118cc41168d1d7a536312Svetoslav Ganovimport android.accessibilityservice.AccessibilityServiceInfo; 219648c538bac4f04145c118cc41168d1d7a536312Svetoslav Ganovimport android.content.pm.ResolveInfo; 229648c538bac4f04145c118cc41168d1d7a536312Svetoslav Ganovimport android.os.Build; 230fc5bd7644f7563f7b59bd1017df9c938857e794Svetoslavimport android.view.View; 249648c538bac4f04145c118cc41168d1d7a536312Svetoslav Ganov 259648c538bac4f04145c118cc41168d1d7a536312Svetoslav Ganov/** 260574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov * Helper for accessing features in {@link android.accessibilityservice.AccessibilityService} 270574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov * introduced after API level 4 in a backwards compatible fashion. 289648c538bac4f04145c118cc41168d1d7a536312Svetoslav Ganov */ 299648c538bac4f04145c118cc41168d1d7a536312Svetoslav Ganovpublic class AccessibilityServiceInfoCompat { 309648c538bac4f04145c118cc41168d1d7a536312Svetoslav Ganov 319648c538bac4f04145c118cc41168d1d7a536312Svetoslav Ganov static interface AccessibilityServiceInfoVersionImpl { 329648c538bac4f04145c118cc41168d1d7a536312Svetoslav Ganov public String getId(AccessibilityServiceInfo info); 339648c538bac4f04145c118cc41168d1d7a536312Svetoslav Ganov public ResolveInfo getResolveInfo(AccessibilityServiceInfo info); 349648c538bac4f04145c118cc41168d1d7a536312Svetoslav Ganov public boolean getCanRetrieveWindowContent(AccessibilityServiceInfo info); 359648c538bac4f04145c118cc41168d1d7a536312Svetoslav Ganov public String getDescription(AccessibilityServiceInfo info); 369648c538bac4f04145c118cc41168d1d7a536312Svetoslav Ganov public String getSettingsActivityName(AccessibilityServiceInfo info); 37c7cb4862dbdb52c07ef82bd4fb29ca9efe7756faSvetoslav Ganov public int getCapabilities(AccessibilityServiceInfo info); 389648c538bac4f04145c118cc41168d1d7a536312Svetoslav Ganov } 399648c538bac4f04145c118cc41168d1d7a536312Svetoslav Ganov 409648c538bac4f04145c118cc41168d1d7a536312Svetoslav Ganov static class AccessibilityServiceInfoStubImpl implements AccessibilityServiceInfoVersionImpl { 419648c538bac4f04145c118cc41168d1d7a536312Svetoslav Ganov 429648c538bac4f04145c118cc41168d1d7a536312Svetoslav Ganov public boolean getCanRetrieveWindowContent(AccessibilityServiceInfo info) { 439648c538bac4f04145c118cc41168d1d7a536312Svetoslav Ganov return false; 449648c538bac4f04145c118cc41168d1d7a536312Svetoslav Ganov } 459648c538bac4f04145c118cc41168d1d7a536312Svetoslav Ganov 469648c538bac4f04145c118cc41168d1d7a536312Svetoslav Ganov public String getDescription(AccessibilityServiceInfo info) { 479648c538bac4f04145c118cc41168d1d7a536312Svetoslav Ganov return null; 489648c538bac4f04145c118cc41168d1d7a536312Svetoslav Ganov } 499648c538bac4f04145c118cc41168d1d7a536312Svetoslav Ganov 509648c538bac4f04145c118cc41168d1d7a536312Svetoslav Ganov public String getId(AccessibilityServiceInfo info) { 519648c538bac4f04145c118cc41168d1d7a536312Svetoslav Ganov return null; 529648c538bac4f04145c118cc41168d1d7a536312Svetoslav Ganov } 539648c538bac4f04145c118cc41168d1d7a536312Svetoslav Ganov 549648c538bac4f04145c118cc41168d1d7a536312Svetoslav Ganov public ResolveInfo getResolveInfo(AccessibilityServiceInfo info) { 559648c538bac4f04145c118cc41168d1d7a536312Svetoslav Ganov return null; 569648c538bac4f04145c118cc41168d1d7a536312Svetoslav Ganov } 579648c538bac4f04145c118cc41168d1d7a536312Svetoslav Ganov 589648c538bac4f04145c118cc41168d1d7a536312Svetoslav Ganov public String getSettingsActivityName(AccessibilityServiceInfo info) { 599648c538bac4f04145c118cc41168d1d7a536312Svetoslav Ganov return null; 609648c538bac4f04145c118cc41168d1d7a536312Svetoslav Ganov } 61c7cb4862dbdb52c07ef82bd4fb29ca9efe7756faSvetoslav Ganov 62c7cb4862dbdb52c07ef82bd4fb29ca9efe7756faSvetoslav Ganov public int getCapabilities(AccessibilityServiceInfo info) { 63c7cb4862dbdb52c07ef82bd4fb29ca9efe7756faSvetoslav Ganov return 0; 64c7cb4862dbdb52c07ef82bd4fb29ca9efe7756faSvetoslav Ganov } 659648c538bac4f04145c118cc41168d1d7a536312Svetoslav Ganov } 669648c538bac4f04145c118cc41168d1d7a536312Svetoslav Ganov 679648c538bac4f04145c118cc41168d1d7a536312Svetoslav Ganov static class AccessibilityServiceInfoIcsImpl extends AccessibilityServiceInfoStubImpl { 689648c538bac4f04145c118cc41168d1d7a536312Svetoslav Ganov 699648c538bac4f04145c118cc41168d1d7a536312Svetoslav Ganov @Override 709648c538bac4f04145c118cc41168d1d7a536312Svetoslav Ganov public boolean getCanRetrieveWindowContent(AccessibilityServiceInfo info) { 719648c538bac4f04145c118cc41168d1d7a536312Svetoslav Ganov return AccessibilityServiceInfoCompatIcs.getCanRetrieveWindowContent(info); 729648c538bac4f04145c118cc41168d1d7a536312Svetoslav Ganov } 739648c538bac4f04145c118cc41168d1d7a536312Svetoslav Ganov 749648c538bac4f04145c118cc41168d1d7a536312Svetoslav Ganov @Override 759648c538bac4f04145c118cc41168d1d7a536312Svetoslav Ganov public String getDescription(AccessibilityServiceInfo info) { 769648c538bac4f04145c118cc41168d1d7a536312Svetoslav Ganov return AccessibilityServiceInfoCompatIcs.getDescription(info); 779648c538bac4f04145c118cc41168d1d7a536312Svetoslav Ganov } 789648c538bac4f04145c118cc41168d1d7a536312Svetoslav Ganov 799648c538bac4f04145c118cc41168d1d7a536312Svetoslav Ganov @Override 809648c538bac4f04145c118cc41168d1d7a536312Svetoslav Ganov public String getId(AccessibilityServiceInfo info) { 819648c538bac4f04145c118cc41168d1d7a536312Svetoslav Ganov return AccessibilityServiceInfoCompatIcs.getId(info); 829648c538bac4f04145c118cc41168d1d7a536312Svetoslav Ganov } 839648c538bac4f04145c118cc41168d1d7a536312Svetoslav Ganov 849648c538bac4f04145c118cc41168d1d7a536312Svetoslav Ganov @Override 859648c538bac4f04145c118cc41168d1d7a536312Svetoslav Ganov public ResolveInfo getResolveInfo(AccessibilityServiceInfo info) { 869648c538bac4f04145c118cc41168d1d7a536312Svetoslav Ganov return AccessibilityServiceInfoCompatIcs.getResolveInfo(info); 879648c538bac4f04145c118cc41168d1d7a536312Svetoslav Ganov } 889648c538bac4f04145c118cc41168d1d7a536312Svetoslav Ganov 899648c538bac4f04145c118cc41168d1d7a536312Svetoslav Ganov @Override 909648c538bac4f04145c118cc41168d1d7a536312Svetoslav Ganov public String getSettingsActivityName(AccessibilityServiceInfo info) { 919648c538bac4f04145c118cc41168d1d7a536312Svetoslav Ganov return AccessibilityServiceInfoCompatIcs.getSettingsActivityName(info); 929648c538bac4f04145c118cc41168d1d7a536312Svetoslav Ganov } 93c7cb4862dbdb52c07ef82bd4fb29ca9efe7756faSvetoslav Ganov 94c7cb4862dbdb52c07ef82bd4fb29ca9efe7756faSvetoslav Ganov @Override 95c7cb4862dbdb52c07ef82bd4fb29ca9efe7756faSvetoslav Ganov public int getCapabilities(AccessibilityServiceInfo info) { 96c7cb4862dbdb52c07ef82bd4fb29ca9efe7756faSvetoslav Ganov if (getCanRetrieveWindowContent(info)) { 97c7cb4862dbdb52c07ef82bd4fb29ca9efe7756faSvetoslav Ganov return CAPABILITY_CAN_RETRIEVE_WINDOW_CONTENT; 98c7cb4862dbdb52c07ef82bd4fb29ca9efe7756faSvetoslav Ganov } 99c7cb4862dbdb52c07ef82bd4fb29ca9efe7756faSvetoslav Ganov return 0; 100c7cb4862dbdb52c07ef82bd4fb29ca9efe7756faSvetoslav Ganov } 101c7cb4862dbdb52c07ef82bd4fb29ca9efe7756faSvetoslav Ganov } 102c7cb4862dbdb52c07ef82bd4fb29ca9efe7756faSvetoslav Ganov 103c7cb4862dbdb52c07ef82bd4fb29ca9efe7756faSvetoslav Ganov static class AccessibilityServiceInfoJellyBeanMr2 extends AccessibilityServiceInfoIcsImpl { 104c7cb4862dbdb52c07ef82bd4fb29ca9efe7756faSvetoslav Ganov @Override 105c7cb4862dbdb52c07ef82bd4fb29ca9efe7756faSvetoslav Ganov public int getCapabilities(AccessibilityServiceInfo info) { 106c7cb4862dbdb52c07ef82bd4fb29ca9efe7756faSvetoslav Ganov return AccessibilityServiceInfoCompatJellyBeanMr2.getCapabilities(info); 107c7cb4862dbdb52c07ef82bd4fb29ca9efe7756faSvetoslav Ganov } 1089648c538bac4f04145c118cc41168d1d7a536312Svetoslav Ganov } 1099648c538bac4f04145c118cc41168d1d7a536312Svetoslav Ganov 1109648c538bac4f04145c118cc41168d1d7a536312Svetoslav Ganov static { 1114d7f4a43baed40212e282fb4312875feaf0de55eSvetoslav if (Build.VERSION.SDK_INT >= 18) { // JellyBean MR2 112c7cb4862dbdb52c07ef82bd4fb29ca9efe7756faSvetoslav Ganov IMPL = new AccessibilityServiceInfoJellyBeanMr2(); 113c7cb4862dbdb52c07ef82bd4fb29ca9efe7756faSvetoslav Ganov } else if (Build.VERSION.SDK_INT >= 14) { // ICS 1149648c538bac4f04145c118cc41168d1d7a536312Svetoslav Ganov IMPL = new AccessibilityServiceInfoIcsImpl(); 1159648c538bac4f04145c118cc41168d1d7a536312Svetoslav Ganov } else { 1169648c538bac4f04145c118cc41168d1d7a536312Svetoslav Ganov IMPL = new AccessibilityServiceInfoStubImpl(); 1179648c538bac4f04145c118cc41168d1d7a536312Svetoslav Ganov } 1189648c538bac4f04145c118cc41168d1d7a536312Svetoslav Ganov } 1199648c538bac4f04145c118cc41168d1d7a536312Svetoslav Ganov 120c7cb4862dbdb52c07ef82bd4fb29ca9efe7756faSvetoslav Ganov // Capabilities 121c7cb4862dbdb52c07ef82bd4fb29ca9efe7756faSvetoslav Ganov 1229648c538bac4f04145c118cc41168d1d7a536312Svetoslav Ganov private static final AccessibilityServiceInfoVersionImpl IMPL; 1239648c538bac4f04145c118cc41168d1d7a536312Svetoslav Ganov 124c7cb4862dbdb52c07ef82bd4fb29ca9efe7756faSvetoslav Ganov /** 125c7cb4862dbdb52c07ef82bd4fb29ca9efe7756faSvetoslav Ganov * Capability: This accessibility service can retrieve the active window content. 126c7cb4862dbdb52c07ef82bd4fb29ca9efe7756faSvetoslav Ganov */ 127c7cb4862dbdb52c07ef82bd4fb29ca9efe7756faSvetoslav Ganov public static final int CAPABILITY_CAN_RETRIEVE_WINDOW_CONTENT = 0x00000001; 128c7cb4862dbdb52c07ef82bd4fb29ca9efe7756faSvetoslav Ganov 129c7cb4862dbdb52c07ef82bd4fb29ca9efe7756faSvetoslav Ganov /** 130c7cb4862dbdb52c07ef82bd4fb29ca9efe7756faSvetoslav Ganov * Capability: This accessibility service can request touch exploration mode in which 131c7cb4862dbdb52c07ef82bd4fb29ca9efe7756faSvetoslav Ganov * touched items are spoken aloud and the UI can be explored via gestures. 132c7cb4862dbdb52c07ef82bd4fb29ca9efe7756faSvetoslav Ganov */ 133c7cb4862dbdb52c07ef82bd4fb29ca9efe7756faSvetoslav Ganov public static final int CAPABILITY_CAN_REQUEST_TOUCH_EXPLORATION = 0x00000002; 134c7cb4862dbdb52c07ef82bd4fb29ca9efe7756faSvetoslav Ganov 135c7cb4862dbdb52c07ef82bd4fb29ca9efe7756faSvetoslav Ganov /** 136c7cb4862dbdb52c07ef82bd4fb29ca9efe7756faSvetoslav Ganov * Capability: This accessibility service can request enhanced web accessibility 137c7cb4862dbdb52c07ef82bd4fb29ca9efe7756faSvetoslav Ganov * enhancements. For example, installing scripts to make app content more accessible. 138c7cb4862dbdb52c07ef82bd4fb29ca9efe7756faSvetoslav Ganov */ 139c7cb4862dbdb52c07ef82bd4fb29ca9efe7756faSvetoslav Ganov public static final int CAPABILITY_CAN_REQUEST_ENHANCED_WEB_ACCESSIBILITY = 0x00000004; 140c7cb4862dbdb52c07ef82bd4fb29ca9efe7756faSvetoslav Ganov 141c7cb4862dbdb52c07ef82bd4fb29ca9efe7756faSvetoslav Ganov /** 142c7cb4862dbdb52c07ef82bd4fb29ca9efe7756faSvetoslav Ganov * Capability: This accessibility service can filter the key event stream. 143c7cb4862dbdb52c07ef82bd4fb29ca9efe7756faSvetoslav Ganov */ 144c7cb4862dbdb52c07ef82bd4fb29ca9efe7756faSvetoslav Ganov public static final int CAPABILITY_CAN_FILTER_KEY_EVENTS = 0x00000008; 145c7cb4862dbdb52c07ef82bd4fb29ca9efe7756faSvetoslav Ganov 1460fc5bd7644f7563f7b59bd1017df9c938857e794Svetoslav // Feedback types 1470fc5bd7644f7563f7b59bd1017df9c938857e794Svetoslav 1480fc5bd7644f7563f7b59bd1017df9c938857e794Svetoslav /** 1490fc5bd7644f7563f7b59bd1017df9c938857e794Svetoslav * Denotes braille feedback. 1500fc5bd7644f7563f7b59bd1017df9c938857e794Svetoslav */ 1510fc5bd7644f7563f7b59bd1017df9c938857e794Svetoslav public static final int FEEDBACK_BRAILLE = 0x0000020; 1520fc5bd7644f7563f7b59bd1017df9c938857e794Svetoslav 1539648c538bac4f04145c118cc41168d1d7a536312Svetoslav Ganov /** 1549648c538bac4f04145c118cc41168d1d7a536312Svetoslav Ganov * Mask for all feedback types. 1559648c538bac4f04145c118cc41168d1d7a536312Svetoslav Ganov * 1569648c538bac4f04145c118cc41168d1d7a536312Svetoslav Ganov * @see AccessibilityServiceInfo#FEEDBACK_SPOKEN 1579648c538bac4f04145c118cc41168d1d7a536312Svetoslav Ganov * @see AccessibilityServiceInfo#FEEDBACK_HAPTIC 1589648c538bac4f04145c118cc41168d1d7a536312Svetoslav Ganov * @see AccessibilityServiceInfo#FEEDBACK_AUDIBLE 1599648c538bac4f04145c118cc41168d1d7a536312Svetoslav Ganov * @see AccessibilityServiceInfo#FEEDBACK_VISUAL 1609648c538bac4f04145c118cc41168d1d7a536312Svetoslav Ganov * @see AccessibilityServiceInfo#FEEDBACK_GENERIC 1610fc5bd7644f7563f7b59bd1017df9c938857e794Svetoslav * @see FEEDBACK_BRAILLE 1629648c538bac4f04145c118cc41168d1d7a536312Svetoslav Ganov */ 1639648c538bac4f04145c118cc41168d1d7a536312Svetoslav Ganov public static final int FEEDBACK_ALL_MASK = 0xFFFFFFFF; 1649648c538bac4f04145c118cc41168d1d7a536312Svetoslav Ganov 1650fc5bd7644f7563f7b59bd1017df9c938857e794Svetoslav // Flags 1660fc5bd7644f7563f7b59bd1017df9c938857e794Svetoslav 1670fc5bd7644f7563f7b59bd1017df9c938857e794Svetoslav /** 168c7cb4862dbdb52c07ef82bd4fb29ca9efe7756faSvetoslav Ganov * If an {@link AccessibilityService} is the default for a given type. 169c7cb4862dbdb52c07ef82bd4fb29ca9efe7756faSvetoslav Ganov * Default service is invoked only if no package specific one exists. In case of 170c7cb4862dbdb52c07ef82bd4fb29ca9efe7756faSvetoslav Ganov * more than one package specific service only the earlier registered is notified. 171c7cb4862dbdb52c07ef82bd4fb29ca9efe7756faSvetoslav Ganov */ 172c7cb4862dbdb52c07ef82bd4fb29ca9efe7756faSvetoslav Ganov public static final int DEFAULT = 0x0000001; 173c7cb4862dbdb52c07ef82bd4fb29ca9efe7756faSvetoslav Ganov 174c7cb4862dbdb52c07ef82bd4fb29ca9efe7756faSvetoslav Ganov /** 1750fc5bd7644f7563f7b59bd1017df9c938857e794Svetoslav * If this flag is set the system will regard views that are not important 1760fc5bd7644f7563f7b59bd1017df9c938857e794Svetoslav * for accessibility in addition to the ones that are important for accessibility. 1770fc5bd7644f7563f7b59bd1017df9c938857e794Svetoslav * That is, views that are marked as not important for accessibility via 178b5b909e4544fd4d1d0bdf445b8588a7233d5c71fAlan Viverette * {@link View#IMPORTANT_FOR_ACCESSIBILITY_NO} or 179b5b909e4544fd4d1d0bdf445b8588a7233d5c71fAlan Viverette * {@link View#IMPORTANT_FOR_ACCESSIBILITY_NO_HIDE_DESCENDANTS} and views that are 180b5b909e4544fd4d1d0bdf445b8588a7233d5c71fAlan Viverette * marked as potentially important for accessibility via 1810fc5bd7644f7563f7b59bd1017df9c938857e794Svetoslav * {@link View#IMPORTANT_FOR_ACCESSIBILITY_AUTO} for which the system has determined 1820fc5bd7644f7563f7b59bd1017df9c938857e794Svetoslav * that are not important for accessibility, are both reported while querying the 1830fc5bd7644f7563f7b59bd1017df9c938857e794Svetoslav * window content and also the accessibility service will receive accessibility events 1840fc5bd7644f7563f7b59bd1017df9c938857e794Svetoslav * from them. 1850fc5bd7644f7563f7b59bd1017df9c938857e794Svetoslav * <p> 1860fc5bd7644f7563f7b59bd1017df9c938857e794Svetoslav * <strong>Note:</strong> For accessibility services targeting API version 1870fc5bd7644f7563f7b59bd1017df9c938857e794Svetoslav * {@link Build.VERSION_CODES#JELLY_BEAN} or higher this flag has to be explicitly 1880fc5bd7644f7563f7b59bd1017df9c938857e794Svetoslav * set for the system to regard views that are not important for accessibility. For 1890fc5bd7644f7563f7b59bd1017df9c938857e794Svetoslav * accessibility services targeting API version lower than 1900fc5bd7644f7563f7b59bd1017df9c938857e794Svetoslav * {@link Build.VERSION_CODES#JELLY_BEAN} this flag is ignored and all views are 1910fc5bd7644f7563f7b59bd1017df9c938857e794Svetoslav * regarded for accessibility purposes. 1920fc5bd7644f7563f7b59bd1017df9c938857e794Svetoslav * </p> 1930fc5bd7644f7563f7b59bd1017df9c938857e794Svetoslav * <p> 1940fc5bd7644f7563f7b59bd1017df9c938857e794Svetoslav * Usually views not important for accessibility are layout managers that do not 1950fc5bd7644f7563f7b59bd1017df9c938857e794Svetoslav * react to user actions, do not draw any content, and do not have any special 1960fc5bd7644f7563f7b59bd1017df9c938857e794Svetoslav * semantics in the context of the screen content. For example, a three by three 1970fc5bd7644f7563f7b59bd1017df9c938857e794Svetoslav * grid can be implemented as three horizontal linear layouts and one vertical, 1980fc5bd7644f7563f7b59bd1017df9c938857e794Svetoslav * or three vertical linear layouts and one horizontal, or one grid layout, etc. 1990fc5bd7644f7563f7b59bd1017df9c938857e794Svetoslav * In this context the actual layout mangers used to achieve the grid configuration 2000fc5bd7644f7563f7b59bd1017df9c938857e794Svetoslav * are not important, rather it is important that there are nine evenly distributed 2010fc5bd7644f7563f7b59bd1017df9c938857e794Svetoslav * elements. 2020fc5bd7644f7563f7b59bd1017df9c938857e794Svetoslav * </p> 2030fc5bd7644f7563f7b59bd1017df9c938857e794Svetoslav */ 2040fc5bd7644f7563f7b59bd1017df9c938857e794Svetoslav public static final int FLAG_INCLUDE_NOT_IMPORTANT_VIEWS = 0x0000002; 2050fc5bd7644f7563f7b59bd1017df9c938857e794Svetoslav 2060fc5bd7644f7563f7b59bd1017df9c938857e794Svetoslav /** 2070fc5bd7644f7563f7b59bd1017df9c938857e794Svetoslav * This flag requests that the system gets into touch exploration mode. 2080fc5bd7644f7563f7b59bd1017df9c938857e794Svetoslav * In this mode a single finger moving on the screen behaves as a mouse 2090fc5bd7644f7563f7b59bd1017df9c938857e794Svetoslav * pointer hovering over the user interface. The system will also detect 2100fc5bd7644f7563f7b59bd1017df9c938857e794Svetoslav * certain gestures performed on the touch screen and notify this service. 2110fc5bd7644f7563f7b59bd1017df9c938857e794Svetoslav * The system will enable touch exploration mode if there is at least one 2120fc5bd7644f7563f7b59bd1017df9c938857e794Svetoslav * accessibility service that has this flag set. Hence, clearing this 2130fc5bd7644f7563f7b59bd1017df9c938857e794Svetoslav * flag does not guarantee that the device will not be in touch exploration 2140fc5bd7644f7563f7b59bd1017df9c938857e794Svetoslav * mode since there may be another enabled service that requested it. 2150fc5bd7644f7563f7b59bd1017df9c938857e794Svetoslav * <p> 2160fc5bd7644f7563f7b59bd1017df9c938857e794Svetoslav * For accessibility services targeting API version higher than 2170fc5bd7644f7563f7b59bd1017df9c938857e794Svetoslav * {@link Build.VERSION_CODES#JELLY_BEAN_MR1} that want to set 218c7cb4862dbdb52c07ef82bd4fb29ca9efe7756faSvetoslav Ganov * this flag have to declare this capability in their meta-data by setting 219c7cb4862dbdb52c07ef82bd4fb29ca9efe7756faSvetoslav Ganov * the attribute canRequestTouchExplorationMode to true, otherwise this flag 220c7cb4862dbdb52c07ef82bd4fb29ca9efe7756faSvetoslav Ganov * will be ignored. For how to declare the meta-data of a service refer to 221c7cb4862dbdb52c07ef82bd4fb29ca9efe7756faSvetoslav Ganov * {@value AccessibilityService#SERVICE_META_DATA}. 2220fc5bd7644f7563f7b59bd1017df9c938857e794Svetoslav * </p> 2230fc5bd7644f7563f7b59bd1017df9c938857e794Svetoslav * <p> 2240fc5bd7644f7563f7b59bd1017df9c938857e794Svetoslav * Services targeting API version equal to or lower than 2250fc5bd7644f7563f7b59bd1017df9c938857e794Svetoslav * {@link Build.VERSION_CODES#JELLY_BEAN_MR1} will work normally, i.e. 2260fc5bd7644f7563f7b59bd1017df9c938857e794Svetoslav * the first time they are run, if this flag is specified, a dialog is 2270fc5bd7644f7563f7b59bd1017df9c938857e794Svetoslav * shown to the user to confirm enabling explore by touch. 2280fc5bd7644f7563f7b59bd1017df9c938857e794Svetoslav * </p> 2290fc5bd7644f7563f7b59bd1017df9c938857e794Svetoslav */ 2300fc5bd7644f7563f7b59bd1017df9c938857e794Svetoslav public static final int FLAG_REQUEST_TOUCH_EXPLORATION_MODE = 0x0000004; 2310fc5bd7644f7563f7b59bd1017df9c938857e794Svetoslav 2320fc5bd7644f7563f7b59bd1017df9c938857e794Svetoslav /** 2330fc5bd7644f7563f7b59bd1017df9c938857e794Svetoslav * This flag requests from the system to enable web accessibility enhancing 2340fc5bd7644f7563f7b59bd1017df9c938857e794Svetoslav * extensions. Such extensions aim to provide improved accessibility support 2350fc5bd7644f7563f7b59bd1017df9c938857e794Svetoslav * for content presented in a {@link android.webkit.WebView}. An example of such 2360fc5bd7644f7563f7b59bd1017df9c938857e794Svetoslav * an extension is injecting JavaScript from a secure source. The system will enable 2370fc5bd7644f7563f7b59bd1017df9c938857e794Svetoslav * enhanced web accessibility if there is at least one accessibility service 2380fc5bd7644f7563f7b59bd1017df9c938857e794Svetoslav * that has this flag set. Hence, clearing this flag does not guarantee that the 2390fc5bd7644f7563f7b59bd1017df9c938857e794Svetoslav * device will not have enhanced web accessibility enabled since there may be 2400fc5bd7644f7563f7b59bd1017df9c938857e794Svetoslav * another enabled service that requested it. 2410fc5bd7644f7563f7b59bd1017df9c938857e794Svetoslav * <p> 242c7cb4862dbdb52c07ef82bd4fb29ca9efe7756faSvetoslav Ganov * Services that want to set this flag have to declare this capability 243c7cb4862dbdb52c07ef82bd4fb29ca9efe7756faSvetoslav Ganov * in their meta-data by setting the attribute canRequestEnhancedWebAccessibility 244c7cb4862dbdb52c07ef82bd4fb29ca9efe7756faSvetoslav Ganov * to true, otherwise this flag will be ignored. For how to declare the meta-data 245c7cb4862dbdb52c07ef82bd4fb29ca9efe7756faSvetoslav Ganov * of a service refer to {@value AccessibilityService#SERVICE_META_DATA}. 2460fc5bd7644f7563f7b59bd1017df9c938857e794Svetoslav * </p> 2470fc5bd7644f7563f7b59bd1017df9c938857e794Svetoslav */ 2480fc5bd7644f7563f7b59bd1017df9c938857e794Svetoslav public static final int FLAG_REQUEST_ENHANCED_WEB_ACCESSIBILITY = 0x00000008; 2490fc5bd7644f7563f7b59bd1017df9c938857e794Svetoslav 2500fc5bd7644f7563f7b59bd1017df9c938857e794Svetoslav /** 2510fc5bd7644f7563f7b59bd1017df9c938857e794Svetoslav * This flag requests that the AccessibilityNodeInfos obtained 2520fc5bd7644f7563f7b59bd1017df9c938857e794Svetoslav * by an {@link AccessibilityService} contain the id of the source view. 2530fc5bd7644f7563f7b59bd1017df9c938857e794Svetoslav * The source view id will be a fully qualified resource name of the 2540fc5bd7644f7563f7b59bd1017df9c938857e794Svetoslav * form "package:id/name", for example "foo.bar:id/my_list", and it is 2550fc5bd7644f7563f7b59bd1017df9c938857e794Svetoslav * useful for UI test automation. This flag is not set by default. 2560fc5bd7644f7563f7b59bd1017df9c938857e794Svetoslav */ 2570fc5bd7644f7563f7b59bd1017df9c938857e794Svetoslav public static final int FLAG_REPORT_VIEW_IDS = 0x00000010; 2580fc5bd7644f7563f7b59bd1017df9c938857e794Svetoslav 259c7cb4862dbdb52c07ef82bd4fb29ca9efe7756faSvetoslav Ganov /** 260c7cb4862dbdb52c07ef82bd4fb29ca9efe7756faSvetoslav Ganov * This flag requests from the system to filter key events. If this flag 261c7cb4862dbdb52c07ef82bd4fb29ca9efe7756faSvetoslav Ganov * is set the accessibility service will receive the key events before 262c7cb4862dbdb52c07ef82bd4fb29ca9efe7756faSvetoslav Ganov * applications allowing it implement global shortcuts. Setting this flag 263c7cb4862dbdb52c07ef82bd4fb29ca9efe7756faSvetoslav Ganov * does not guarantee that this service will filter key events since only 264c7cb4862dbdb52c07ef82bd4fb29ca9efe7756faSvetoslav Ganov * one service can do so at any given time. This avoids user confusion due 265c7cb4862dbdb52c07ef82bd4fb29ca9efe7756faSvetoslav Ganov * to behavior change in case different key filtering services are enabled. 266c7cb4862dbdb52c07ef82bd4fb29ca9efe7756faSvetoslav Ganov * If there is already another key filtering service enabled, this one will 267c7cb4862dbdb52c07ef82bd4fb29ca9efe7756faSvetoslav Ganov * not receive key events. 268c7cb4862dbdb52c07ef82bd4fb29ca9efe7756faSvetoslav Ganov * <p> 269c7cb4862dbdb52c07ef82bd4fb29ca9efe7756faSvetoslav Ganov * Services that want to set this flag have to declare this capability 270c7cb4862dbdb52c07ef82bd4fb29ca9efe7756faSvetoslav Ganov * in their meta-data by setting the attribute canRequestFilterKeyEvents 271c7cb4862dbdb52c07ef82bd4fb29ca9efe7756faSvetoslav Ganov * to true, otherwise this flag will be ignored. For how to declare the meta 272c7cb4862dbdb52c07ef82bd4fb29ca9efe7756faSvetoslav Ganov * -data of a service refer to {@value AccessibilityService#SERVICE_META_DATA}. 273c7cb4862dbdb52c07ef82bd4fb29ca9efe7756faSvetoslav Ganov * </p> 274c7cb4862dbdb52c07ef82bd4fb29ca9efe7756faSvetoslav Ganov */ 275c7cb4862dbdb52c07ef82bd4fb29ca9efe7756faSvetoslav Ganov public static final int FLAG_REQUEST_FILTER_KEY_EVENTS = 0x00000020; 276c7cb4862dbdb52c07ef82bd4fb29ca9efe7756faSvetoslav Ganov 2779648c538bac4f04145c118cc41168d1d7a536312Svetoslav Ganov /* 2789648c538bac4f04145c118cc41168d1d7a536312Svetoslav Ganov * Hide constructor 2799648c538bac4f04145c118cc41168d1d7a536312Svetoslav Ganov */ 2809648c538bac4f04145c118cc41168d1d7a536312Svetoslav Ganov private AccessibilityServiceInfoCompat() { 2819648c538bac4f04145c118cc41168d1d7a536312Svetoslav Ganov 2829648c538bac4f04145c118cc41168d1d7a536312Svetoslav Ganov } 2839648c538bac4f04145c118cc41168d1d7a536312Svetoslav Ganov 2849648c538bac4f04145c118cc41168d1d7a536312Svetoslav Ganov /** 2859648c538bac4f04145c118cc41168d1d7a536312Svetoslav Ganov * The accessibility service id. 2869648c538bac4f04145c118cc41168d1d7a536312Svetoslav Ganov * <p> 2879648c538bac4f04145c118cc41168d1d7a536312Svetoslav Ganov * <strong>Generated by the system.</strong> 2889648c538bac4f04145c118cc41168d1d7a536312Svetoslav Ganov * </p> 2899648c538bac4f04145c118cc41168d1d7a536312Svetoslav Ganov * 2909648c538bac4f04145c118cc41168d1d7a536312Svetoslav Ganov * @return The id. 2919648c538bac4f04145c118cc41168d1d7a536312Svetoslav Ganov */ 2929648c538bac4f04145c118cc41168d1d7a536312Svetoslav Ganov public static String getId(AccessibilityServiceInfo info) { 2939648c538bac4f04145c118cc41168d1d7a536312Svetoslav Ganov return IMPL.getId(info); 2949648c538bac4f04145c118cc41168d1d7a536312Svetoslav Ganov } 2959648c538bac4f04145c118cc41168d1d7a536312Svetoslav Ganov 2969648c538bac4f04145c118cc41168d1d7a536312Svetoslav Ganov /** 2979648c538bac4f04145c118cc41168d1d7a536312Svetoslav Ganov * The service {@link ResolveInfo}. 2989648c538bac4f04145c118cc41168d1d7a536312Svetoslav Ganov * <p> 2999648c538bac4f04145c118cc41168d1d7a536312Svetoslav Ganov * <strong>Generated by the system.</strong> 3009648c538bac4f04145c118cc41168d1d7a536312Svetoslav Ganov * </p> 3019648c538bac4f04145c118cc41168d1d7a536312Svetoslav Ganov * 3029648c538bac4f04145c118cc41168d1d7a536312Svetoslav Ganov * @return The info. 3039648c538bac4f04145c118cc41168d1d7a536312Svetoslav Ganov */ 3049648c538bac4f04145c118cc41168d1d7a536312Svetoslav Ganov public static ResolveInfo getResolveInfo(AccessibilityServiceInfo info) { 3059648c538bac4f04145c118cc41168d1d7a536312Svetoslav Ganov return IMPL.getResolveInfo(info); 3069648c538bac4f04145c118cc41168d1d7a536312Svetoslav Ganov } 3079648c538bac4f04145c118cc41168d1d7a536312Svetoslav Ganov 3089648c538bac4f04145c118cc41168d1d7a536312Svetoslav Ganov /** 3099648c538bac4f04145c118cc41168d1d7a536312Svetoslav Ganov * The settings activity name. 3109648c538bac4f04145c118cc41168d1d7a536312Svetoslav Ganov * <p> 3119648c538bac4f04145c118cc41168d1d7a536312Svetoslav Ganov * <strong>Statically set from {@link AccessibilityService#SERVICE_META_DATA 3129648c538bac4f04145c118cc41168d1d7a536312Svetoslav Ganov * meta-data}.</strong> 3139648c538bac4f04145c118cc41168d1d7a536312Svetoslav Ganov * </p> 3149648c538bac4f04145c118cc41168d1d7a536312Svetoslav Ganov * 3159648c538bac4f04145c118cc41168d1d7a536312Svetoslav Ganov * @return The settings activity name. 3169648c538bac4f04145c118cc41168d1d7a536312Svetoslav Ganov */ 3179648c538bac4f04145c118cc41168d1d7a536312Svetoslav Ganov public static String getSettingsActivityName(AccessibilityServiceInfo info) { 3189648c538bac4f04145c118cc41168d1d7a536312Svetoslav Ganov return IMPL.getSettingsActivityName(info); 3199648c538bac4f04145c118cc41168d1d7a536312Svetoslav Ganov } 3209648c538bac4f04145c118cc41168d1d7a536312Svetoslav Ganov 3219648c538bac4f04145c118cc41168d1d7a536312Svetoslav Ganov /** 3229648c538bac4f04145c118cc41168d1d7a536312Svetoslav Ganov * Whether this service can retrieve the current window's content. 3239648c538bac4f04145c118cc41168d1d7a536312Svetoslav Ganov * <p> 3249648c538bac4f04145c118cc41168d1d7a536312Svetoslav Ganov * <strong>Statically set from {@link AccessibilityService#SERVICE_META_DATA 3259648c538bac4f04145c118cc41168d1d7a536312Svetoslav Ganov * meta-data}.</strong> 3269648c538bac4f04145c118cc41168d1d7a536312Svetoslav Ganov * </p> 3279648c538bac4f04145c118cc41168d1d7a536312Svetoslav Ganov * 3289648c538bac4f04145c118cc41168d1d7a536312Svetoslav Ganov * @return True window content can be retrieved. 3299648c538bac4f04145c118cc41168d1d7a536312Svetoslav Ganov */ 3309648c538bac4f04145c118cc41168d1d7a536312Svetoslav Ganov public static boolean getCanRetrieveWindowContent(AccessibilityServiceInfo info) { 3319648c538bac4f04145c118cc41168d1d7a536312Svetoslav Ganov return IMPL.getCanRetrieveWindowContent(info); 3329648c538bac4f04145c118cc41168d1d7a536312Svetoslav Ganov } 3339648c538bac4f04145c118cc41168d1d7a536312Svetoslav Ganov 3349648c538bac4f04145c118cc41168d1d7a536312Svetoslav Ganov /** 3359648c538bac4f04145c118cc41168d1d7a536312Svetoslav Ganov * Description of the accessibility service. 3369648c538bac4f04145c118cc41168d1d7a536312Svetoslav Ganov * <p> 3379648c538bac4f04145c118cc41168d1d7a536312Svetoslav Ganov * <strong>Statically set from {@link AccessibilityService#SERVICE_META_DATA 3389648c538bac4f04145c118cc41168d1d7a536312Svetoslav Ganov * meta-data}.</strong> 3399648c538bac4f04145c118cc41168d1d7a536312Svetoslav Ganov * </p> 3409648c538bac4f04145c118cc41168d1d7a536312Svetoslav Ganov * 3419648c538bac4f04145c118cc41168d1d7a536312Svetoslav Ganov * @return The description. 3429648c538bac4f04145c118cc41168d1d7a536312Svetoslav Ganov */ 3439648c538bac4f04145c118cc41168d1d7a536312Svetoslav Ganov public static String getDescription(AccessibilityServiceInfo info) { 3449648c538bac4f04145c118cc41168d1d7a536312Svetoslav Ganov return IMPL.getDescription(info); 3459648c538bac4f04145c118cc41168d1d7a536312Svetoslav Ganov } 3469648c538bac4f04145c118cc41168d1d7a536312Svetoslav Ganov 3479648c538bac4f04145c118cc41168d1d7a536312Svetoslav Ganov /** 3489648c538bac4f04145c118cc41168d1d7a536312Svetoslav Ganov * Returns the string representation of a feedback type. For example, 3499648c538bac4f04145c118cc41168d1d7a536312Svetoslav Ganov * {@link AccessibilityServiceInfo#FEEDBACK_SPOKEN} is represented by the 3509648c538bac4f04145c118cc41168d1d7a536312Svetoslav Ganov * string FEEDBACK_SPOKEN. 3519648c538bac4f04145c118cc41168d1d7a536312Svetoslav Ganov * 3529648c538bac4f04145c118cc41168d1d7a536312Svetoslav Ganov * @param feedbackType The feedback type. 3539648c538bac4f04145c118cc41168d1d7a536312Svetoslav Ganov * @return The string representation. 3549648c538bac4f04145c118cc41168d1d7a536312Svetoslav Ganov */ 3559648c538bac4f04145c118cc41168d1d7a536312Svetoslav Ganov public static String feedbackTypeToString(int feedbackType) { 3561295792da760a6baca24d95f2a7975eec1c2b08aSvetoslav Ganov StringBuilder builder = new StringBuilder(); 3571295792da760a6baca24d95f2a7975eec1c2b08aSvetoslav Ganov builder.append("["); 3581295792da760a6baca24d95f2a7975eec1c2b08aSvetoslav Ganov while (feedbackType > 0) { 3591295792da760a6baca24d95f2a7975eec1c2b08aSvetoslav Ganov final int feedbackTypeFlag = 1 << Integer.numberOfTrailingZeros(feedbackType); 3601295792da760a6baca24d95f2a7975eec1c2b08aSvetoslav Ganov feedbackType &= ~feedbackTypeFlag; 3611295792da760a6baca24d95f2a7975eec1c2b08aSvetoslav Ganov if (builder.length() > 1) { 3621295792da760a6baca24d95f2a7975eec1c2b08aSvetoslav Ganov builder.append(", "); 3631295792da760a6baca24d95f2a7975eec1c2b08aSvetoslav Ganov } 3641295792da760a6baca24d95f2a7975eec1c2b08aSvetoslav Ganov switch (feedbackTypeFlag) { 3651295792da760a6baca24d95f2a7975eec1c2b08aSvetoslav Ganov case AccessibilityServiceInfo.FEEDBACK_AUDIBLE: 3661295792da760a6baca24d95f2a7975eec1c2b08aSvetoslav Ganov builder.append("FEEDBACK_AUDIBLE"); 3671295792da760a6baca24d95f2a7975eec1c2b08aSvetoslav Ganov break; 3681295792da760a6baca24d95f2a7975eec1c2b08aSvetoslav Ganov case AccessibilityServiceInfo.FEEDBACK_HAPTIC: 3691295792da760a6baca24d95f2a7975eec1c2b08aSvetoslav Ganov builder.append("FEEDBACK_HAPTIC"); 3701295792da760a6baca24d95f2a7975eec1c2b08aSvetoslav Ganov break; 3711295792da760a6baca24d95f2a7975eec1c2b08aSvetoslav Ganov case AccessibilityServiceInfo.FEEDBACK_GENERIC: 3721295792da760a6baca24d95f2a7975eec1c2b08aSvetoslav Ganov builder.append("FEEDBACK_GENERIC"); 3731295792da760a6baca24d95f2a7975eec1c2b08aSvetoslav Ganov break; 3741295792da760a6baca24d95f2a7975eec1c2b08aSvetoslav Ganov case AccessibilityServiceInfo.FEEDBACK_SPOKEN: 3751295792da760a6baca24d95f2a7975eec1c2b08aSvetoslav Ganov builder.append("FEEDBACK_SPOKEN"); 3761295792da760a6baca24d95f2a7975eec1c2b08aSvetoslav Ganov break; 3771295792da760a6baca24d95f2a7975eec1c2b08aSvetoslav Ganov case AccessibilityServiceInfo.FEEDBACK_VISUAL: 3781295792da760a6baca24d95f2a7975eec1c2b08aSvetoslav Ganov builder.append("FEEDBACK_VISUAL"); 3791295792da760a6baca24d95f2a7975eec1c2b08aSvetoslav Ganov break; 3801295792da760a6baca24d95f2a7975eec1c2b08aSvetoslav Ganov } 3819648c538bac4f04145c118cc41168d1d7a536312Svetoslav Ganov } 3821295792da760a6baca24d95f2a7975eec1c2b08aSvetoslav Ganov builder.append("]"); 3831295792da760a6baca24d95f2a7975eec1c2b08aSvetoslav Ganov return builder.toString(); 3849648c538bac4f04145c118cc41168d1d7a536312Svetoslav Ganov } 3859648c538bac4f04145c118cc41168d1d7a536312Svetoslav Ganov 3869648c538bac4f04145c118cc41168d1d7a536312Svetoslav Ganov /** 3879648c538bac4f04145c118cc41168d1d7a536312Svetoslav Ganov * Returns the string representation of a flag. For example, 3889648c538bac4f04145c118cc41168d1d7a536312Svetoslav Ganov * {@link AccessibilityServiceInfo#DEFAULT} is represented by the 3899648c538bac4f04145c118cc41168d1d7a536312Svetoslav Ganov * string DEFAULT. 3909648c538bac4f04145c118cc41168d1d7a536312Svetoslav Ganov * 3919648c538bac4f04145c118cc41168d1d7a536312Svetoslav Ganov * @param flag The flag. 3929648c538bac4f04145c118cc41168d1d7a536312Svetoslav Ganov * @return The string representation. 3939648c538bac4f04145c118cc41168d1d7a536312Svetoslav Ganov */ 3949648c538bac4f04145c118cc41168d1d7a536312Svetoslav Ganov public static String flagToString(int flag) { 3959648c538bac4f04145c118cc41168d1d7a536312Svetoslav Ganov switch (flag) { 396c7cb4862dbdb52c07ef82bd4fb29ca9efe7756faSvetoslav Ganov case DEFAULT: 3979648c538bac4f04145c118cc41168d1d7a536312Svetoslav Ganov return "DEFAULT"; 398c7cb4862dbdb52c07ef82bd4fb29ca9efe7756faSvetoslav Ganov case FLAG_INCLUDE_NOT_IMPORTANT_VIEWS: 399c7cb4862dbdb52c07ef82bd4fb29ca9efe7756faSvetoslav Ganov return "FLAG_INCLUDE_NOT_IMPORTANT_VIEWS"; 400c7cb4862dbdb52c07ef82bd4fb29ca9efe7756faSvetoslav Ganov case FLAG_REQUEST_TOUCH_EXPLORATION_MODE: 401c7cb4862dbdb52c07ef82bd4fb29ca9efe7756faSvetoslav Ganov return "FLAG_REQUEST_TOUCH_EXPLORATION_MODE"; 402c7cb4862dbdb52c07ef82bd4fb29ca9efe7756faSvetoslav Ganov case FLAG_REQUEST_ENHANCED_WEB_ACCESSIBILITY: 403c7cb4862dbdb52c07ef82bd4fb29ca9efe7756faSvetoslav Ganov return "FLAG_REQUEST_ENHANCED_WEB_ACCESSIBILITY"; 404c7cb4862dbdb52c07ef82bd4fb29ca9efe7756faSvetoslav Ganov case FLAG_REPORT_VIEW_IDS: 405c7cb4862dbdb52c07ef82bd4fb29ca9efe7756faSvetoslav Ganov return "FLAG_REPORT_VIEW_IDS"; 406c7cb4862dbdb52c07ef82bd4fb29ca9efe7756faSvetoslav Ganov case FLAG_REQUEST_FILTER_KEY_EVENTS: 407c7cb4862dbdb52c07ef82bd4fb29ca9efe7756faSvetoslav Ganov return "FLAG_REQUEST_FILTER_KEY_EVENTS"; 4089648c538bac4f04145c118cc41168d1d7a536312Svetoslav Ganov default: 4099648c538bac4f04145c118cc41168d1d7a536312Svetoslav Ganov return null; 4109648c538bac4f04145c118cc41168d1d7a536312Svetoslav Ganov } 4119648c538bac4f04145c118cc41168d1d7a536312Svetoslav Ganov } 412c7cb4862dbdb52c07ef82bd4fb29ca9efe7756faSvetoslav Ganov 413c7cb4862dbdb52c07ef82bd4fb29ca9efe7756faSvetoslav Ganov /** 414c7cb4862dbdb52c07ef82bd4fb29ca9efe7756faSvetoslav Ganov * Returns the bit mask of capabilities this accessibility service has such as 415c7cb4862dbdb52c07ef82bd4fb29ca9efe7756faSvetoslav Ganov * being able to retrieve the active window content, etc. 416c7cb4862dbdb52c07ef82bd4fb29ca9efe7756faSvetoslav Ganov * 417c7cb4862dbdb52c07ef82bd4fb29ca9efe7756faSvetoslav Ganov * @param info The service info whose capabilities to get. 418c7cb4862dbdb52c07ef82bd4fb29ca9efe7756faSvetoslav Ganov * @return The capability bit mask. 419c7cb4862dbdb52c07ef82bd4fb29ca9efe7756faSvetoslav Ganov * 420c7cb4862dbdb52c07ef82bd4fb29ca9efe7756faSvetoslav Ganov * @see #CAPABILITY_CAN_RETRIEVE_WINDOW_CONTENT 421c7cb4862dbdb52c07ef82bd4fb29ca9efe7756faSvetoslav Ganov * @see #CAPABILITY_CAN_REQUEST_TOUCH_EXPLORATION 422c7cb4862dbdb52c07ef82bd4fb29ca9efe7756faSvetoslav Ganov * @see #CAPABILITY_CAN_REQUEST_ENHANCED_WEB_ACCESSIBILITY 423c7cb4862dbdb52c07ef82bd4fb29ca9efe7756faSvetoslav Ganov * @see #CAPABILITY_CAN_FILTER_KEY_EVENTS 424c7cb4862dbdb52c07ef82bd4fb29ca9efe7756faSvetoslav Ganov */ 425c7cb4862dbdb52c07ef82bd4fb29ca9efe7756faSvetoslav Ganov public static int getCapabilities(AccessibilityServiceInfo info) { 426c7cb4862dbdb52c07ef82bd4fb29ca9efe7756faSvetoslav Ganov return IMPL.getCapabilities(info); 427c7cb4862dbdb52c07ef82bd4fb29ca9efe7756faSvetoslav Ganov } 428c7cb4862dbdb52c07ef82bd4fb29ca9efe7756faSvetoslav Ganov 429c7cb4862dbdb52c07ef82bd4fb29ca9efe7756faSvetoslav Ganov /** 430c7cb4862dbdb52c07ef82bd4fb29ca9efe7756faSvetoslav Ganov * Returns the string representation of a capability. For example, 431c7cb4862dbdb52c07ef82bd4fb29ca9efe7756faSvetoslav Ganov * {@link #CAPABILITY_CAN_RETRIEVE_WINDOW_CONTENT} is represented 432c7cb4862dbdb52c07ef82bd4fb29ca9efe7756faSvetoslav Ganov * by the string CAPABILITY_CAN_RETRIEVE_WINDOW_CONTENT. 433c7cb4862dbdb52c07ef82bd4fb29ca9efe7756faSvetoslav Ganov * 434c7cb4862dbdb52c07ef82bd4fb29ca9efe7756faSvetoslav Ganov * @param capability The capability. 435c7cb4862dbdb52c07ef82bd4fb29ca9efe7756faSvetoslav Ganov * @return The string representation. 436c7cb4862dbdb52c07ef82bd4fb29ca9efe7756faSvetoslav Ganov */ 437c7cb4862dbdb52c07ef82bd4fb29ca9efe7756faSvetoslav Ganov public static String capabilityToString(int capability) { 438c7cb4862dbdb52c07ef82bd4fb29ca9efe7756faSvetoslav Ganov switch (capability) { 439c7cb4862dbdb52c07ef82bd4fb29ca9efe7756faSvetoslav Ganov case CAPABILITY_CAN_RETRIEVE_WINDOW_CONTENT: 440c7cb4862dbdb52c07ef82bd4fb29ca9efe7756faSvetoslav Ganov return "CAPABILITY_CAN_RETRIEVE_WINDOW_CONTENT"; 441c7cb4862dbdb52c07ef82bd4fb29ca9efe7756faSvetoslav Ganov case CAPABILITY_CAN_REQUEST_TOUCH_EXPLORATION: 442c7cb4862dbdb52c07ef82bd4fb29ca9efe7756faSvetoslav Ganov return "CAPABILITY_CAN_REQUEST_TOUCH_EXPLORATION"; 443c7cb4862dbdb52c07ef82bd4fb29ca9efe7756faSvetoslav Ganov case CAPABILITY_CAN_REQUEST_ENHANCED_WEB_ACCESSIBILITY: 444c7cb4862dbdb52c07ef82bd4fb29ca9efe7756faSvetoslav Ganov return "CAPABILITY_CAN_REQUEST_ENHANCED_WEB_ACCESSIBILITY"; 445c7cb4862dbdb52c07ef82bd4fb29ca9efe7756faSvetoslav Ganov case CAPABILITY_CAN_FILTER_KEY_EVENTS: 446c7cb4862dbdb52c07ef82bd4fb29ca9efe7756faSvetoslav Ganov return "CAPABILITY_CAN_FILTER_KEY_EVENTS"; 447c7cb4862dbdb52c07ef82bd4fb29ca9efe7756faSvetoslav Ganov default: 448c7cb4862dbdb52c07ef82bd4fb29ca9efe7756faSvetoslav Ganov return "UNKNOWN"; 449c7cb4862dbdb52c07ef82bd4fb29ca9efe7756faSvetoslav Ganov } 450c7cb4862dbdb52c07ef82bd4fb29ca9efe7756faSvetoslav Ganov } 4519648c538bac4f04145c118cc41168d1d7a536312Svetoslav Ganov} 452