18643aa0179e598e78d938c59035389054535a229Svetoslav Ganov/* 28643aa0179e598e78d938c59035389054535a229Svetoslav Ganov * Copyright (C) 2011 The Android Open Source Project 38643aa0179e598e78d938c59035389054535a229Svetoslav Ganov * 48643aa0179e598e78d938c59035389054535a229Svetoslav Ganov * Licensed under the Apache License, Version 2.0 (the "License"); 58643aa0179e598e78d938c59035389054535a229Svetoslav Ganov * you may not use this file except in compliance with the License. 68643aa0179e598e78d938c59035389054535a229Svetoslav Ganov * You may obtain a copy of the License at 78643aa0179e598e78d938c59035389054535a229Svetoslav Ganov * 88643aa0179e598e78d938c59035389054535a229Svetoslav Ganov * http://www.apache.org/licenses/LICENSE-2.0 98643aa0179e598e78d938c59035389054535a229Svetoslav Ganov * 108643aa0179e598e78d938c59035389054535a229Svetoslav Ganov * Unless required by applicable law or agreed to in writing, software 118643aa0179e598e78d938c59035389054535a229Svetoslav Ganov * distributed under the License is distributed on an "AS IS" BASIS, 128643aa0179e598e78d938c59035389054535a229Svetoslav Ganov * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 138643aa0179e598e78d938c59035389054535a229Svetoslav Ganov * See the License for the specific language governing permissions and 148643aa0179e598e78d938c59035389054535a229Svetoslav Ganov * limitations under the License. 158643aa0179e598e78d938c59035389054535a229Svetoslav Ganov */ 168643aa0179e598e78d938c59035389054535a229Svetoslav Ganov 178643aa0179e598e78d938c59035389054535a229Svetoslav Ganovpackage android.view.accessibility; 188643aa0179e598e78d938c59035389054535a229Svetoslav Ganov 198643aa0179e598e78d938c59035389054535a229Svetoslav Ganovimport android.graphics.Rect; 20aa780c110922148a6a4ba06734bb2b0bb8c98f93Svetoslav Ganovimport android.os.Bundle; 218643aa0179e598e78d938c59035389054535a229Svetoslav Ganovimport android.os.Parcel; 228643aa0179e598e78d938c59035389054535a229Svetoslav Ganovimport android.os.Parcelable; 23021078554b902179442a345a9d080a165c3b5139Svetoslav Ganovimport android.util.SparseLongArray; 248643aa0179e598e78d938c59035389054535a229Svetoslav Ganovimport android.view.View; 258643aa0179e598e78d938c59035389054535a229Svetoslav Ganov 26eeee4d2c01d3c4ed99e4891dbc75c7de69a803faSvetoslav Ganovimport java.util.Collections; 27eeee4d2c01d3c4ed99e4891dbc75c7de69a803faSvetoslav Ganovimport java.util.List; 28eeee4d2c01d3c4ed99e4891dbc75c7de69a803faSvetoslav Ganov 298643aa0179e598e78d938c59035389054535a229Svetoslav Ganov/** 3038e8b4e5bc3c93affdffbc064fd9db5aeccc3e8eSvetoslav Ganov * This class represents a node of the window content as well as actions that 3138e8b4e5bc3c93affdffbc064fd9db5aeccc3e8eSvetoslav Ganov * can be requested from its source. From the point of view of an 3238e8b4e5bc3c93affdffbc064fd9db5aeccc3e8eSvetoslav Ganov * {@link android.accessibilityservice.AccessibilityService} a window content is 3338e8b4e5bc3c93affdffbc064fd9db5aeccc3e8eSvetoslav Ganov * presented as tree of accessibility node info which may or may not map one-to-one 3438e8b4e5bc3c93affdffbc064fd9db5aeccc3e8eSvetoslav Ganov * to the view hierarchy. In other words, a custom view is free to report itself as 3538e8b4e5bc3c93affdffbc064fd9db5aeccc3e8eSvetoslav Ganov * a tree of accessibility node info. 3638e8b4e5bc3c93affdffbc064fd9db5aeccc3e8eSvetoslav Ganov * </p> 3738e8b4e5bc3c93affdffbc064fd9db5aeccc3e8eSvetoslav Ganov * <p> 3838e8b4e5bc3c93affdffbc064fd9db5aeccc3e8eSvetoslav Ganov * Once an accessibility node info is delivered to an accessibility service it is 3938e8b4e5bc3c93affdffbc064fd9db5aeccc3e8eSvetoslav Ganov * made immutable and calling a state mutation method generates an error. 4038e8b4e5bc3c93affdffbc064fd9db5aeccc3e8eSvetoslav Ganov * </p> 4138e8b4e5bc3c93affdffbc064fd9db5aeccc3e8eSvetoslav Ganov * <p> 4238e8b4e5bc3c93affdffbc064fd9db5aeccc3e8eSvetoslav Ganov * Please refer to {@link android.accessibilityservice.AccessibilityService} for 4338e8b4e5bc3c93affdffbc064fd9db5aeccc3e8eSvetoslav Ganov * details about how to obtain a handle to window content as a tree of accessibility 4438e8b4e5bc3c93affdffbc064fd9db5aeccc3e8eSvetoslav Ganov * node info as well as familiarizing with the security model. 4538e8b4e5bc3c93affdffbc064fd9db5aeccc3e8eSvetoslav Ganov * </p> 46e1302edd40c5cc264f842e17e3796e0a11d6f045Joe Fernandez * <div class="special reference"> 47e1302edd40c5cc264f842e17e3796e0a11d6f045Joe Fernandez * <h3>Developer Guides</h3> 48e1302edd40c5cc264f842e17e3796e0a11d6f045Joe Fernandez * <p>For more information about making applications accessible, read the 49e1302edd40c5cc264f842e17e3796e0a11d6f045Joe Fernandez * <a href="{@docRoot}guide/topics/ui/accessibility/index.html">Accessibility</a> 50e1302edd40c5cc264f842e17e3796e0a11d6f045Joe Fernandez * developer guide.</p> 51e1302edd40c5cc264f842e17e3796e0a11d6f045Joe Fernandez * </div> 528643aa0179e598e78d938c59035389054535a229Svetoslav Ganov * 5338e8b4e5bc3c93affdffbc064fd9db5aeccc3e8eSvetoslav Ganov * @see android.accessibilityservice.AccessibilityService 5438e8b4e5bc3c93affdffbc064fd9db5aeccc3e8eSvetoslav Ganov * @see AccessibilityEvent 5538e8b4e5bc3c93affdffbc064fd9db5aeccc3e8eSvetoslav Ganov * @see AccessibilityManager 568643aa0179e598e78d938c59035389054535a229Svetoslav Ganov */ 578643aa0179e598e78d938c59035389054535a229Svetoslav Ganovpublic class AccessibilityNodeInfo implements Parcelable { 588643aa0179e598e78d938c59035389054535a229Svetoslav Ganov 598643aa0179e598e78d938c59035389054535a229Svetoslav Ganov private static final boolean DEBUG = false; 608643aa0179e598e78d938c59035389054535a229Svetoslav Ganov 610d04e245534cf777dfaf16dce3c51553837c14ffSvetoslav Ganov /** @hide */ 620d04e245534cf777dfaf16dce3c51553837c14ffSvetoslav Ganov public static final int UNDEFINED = -1; 630d04e245534cf777dfaf16dce3c51553837c14ffSvetoslav Ganov 640d04e245534cf777dfaf16dce3c51553837c14ffSvetoslav Ganov /** @hide */ 650d04e245534cf777dfaf16dce3c51553837c14ffSvetoslav Ganov public static final long ROOT_NODE_ID = makeNodeId(UNDEFINED, UNDEFINED); 660d04e245534cf777dfaf16dce3c51553837c14ffSvetoslav Ganov 670d04e245534cf777dfaf16dce3c51553837c14ffSvetoslav Ganov /** @hide */ 680d04e245534cf777dfaf16dce3c51553837c14ffSvetoslav Ganov public static final int ACTIVE_WINDOW_ID = UNDEFINED; 69d116d7c78a9c53f30a73bf273bd7618312cf3847Svetoslav Ganov 7057c7fd5a43237afc5e8ef31a076e862c0c16c328Svetoslav Ganov /** @hide */ 7157c7fd5a43237afc5e8ef31a076e862c0c16c328Svetoslav Ganov public static final int FLAG_PREFETCH_PREDECESSORS = 0x00000001; 7257c7fd5a43237afc5e8ef31a076e862c0c16c328Svetoslav Ganov 7357c7fd5a43237afc5e8ef31a076e862c0c16c328Svetoslav Ganov /** @hide */ 7457c7fd5a43237afc5e8ef31a076e862c0c16c328Svetoslav Ganov public static final int FLAG_PREFETCH_SIBLINGS = 0x00000002; 7557c7fd5a43237afc5e8ef31a076e862c0c16c328Svetoslav Ganov 7657c7fd5a43237afc5e8ef31a076e862c0c16c328Svetoslav Ganov /** @hide */ 774213804541a8b05cd0587b138a2fd9a3b7fd9350Svetoslav Ganov public static final int FLAG_PREFETCH_DESCENDANTS = 0x00000004; 784213804541a8b05cd0587b138a2fd9a3b7fd9350Svetoslav Ganov 794213804541a8b05cd0587b138a2fd9a3b7fd9350Svetoslav Ganov /** @hide */ 804213804541a8b05cd0587b138a2fd9a3b7fd9350Svetoslav Ganov public static final int INCLUDE_NOT_IMPORTANT_VIEWS = 0x00000008; 8157c7fd5a43237afc5e8ef31a076e862c0c16c328Svetoslav Ganov 828643aa0179e598e78d938c59035389054535a229Svetoslav Ganov // Actions. 838643aa0179e598e78d938c59035389054535a229Svetoslav Ganov 848643aa0179e598e78d938c59035389054535a229Svetoslav Ganov /** 854213804541a8b05cd0587b138a2fd9a3b7fd9350Svetoslav Ganov * Action that gives input focus to the node. 868643aa0179e598e78d938c59035389054535a229Svetoslav Ganov */ 87005b83b0c62d3d0538f0d566b08bd457015ec661Svetoslav Ganov public static final int ACTION_FOCUS = 0x00000001; 888643aa0179e598e78d938c59035389054535a229Svetoslav Ganov 898643aa0179e598e78d938c59035389054535a229Svetoslav Ganov /** 904213804541a8b05cd0587b138a2fd9a3b7fd9350Svetoslav Ganov * Action that clears input focus of the node. 918643aa0179e598e78d938c59035389054535a229Svetoslav Ganov */ 924213804541a8b05cd0587b138a2fd9a3b7fd9350Svetoslav Ganov public static final int ACTION_CLEAR_FOCUS = 0x00000002; 938643aa0179e598e78d938c59035389054535a229Svetoslav Ganov 948643aa0179e598e78d938c59035389054535a229Svetoslav Ganov /** 958643aa0179e598e78d938c59035389054535a229Svetoslav Ganov * Action that selects the node. 968643aa0179e598e78d938c59035389054535a229Svetoslav Ganov */ 974213804541a8b05cd0587b138a2fd9a3b7fd9350Svetoslav Ganov public static final int ACTION_SELECT = 0x00000004; 988643aa0179e598e78d938c59035389054535a229Svetoslav Ganov 998643aa0179e598e78d938c59035389054535a229Svetoslav Ganov /** 1008643aa0179e598e78d938c59035389054535a229Svetoslav Ganov * Action that unselects the node. 1018643aa0179e598e78d938c59035389054535a229Svetoslav Ganov */ 1024213804541a8b05cd0587b138a2fd9a3b7fd9350Svetoslav Ganov public static final int ACTION_CLEAR_SELECTION = 0x00000008; 1034213804541a8b05cd0587b138a2fd9a3b7fd9350Svetoslav Ganov 1044213804541a8b05cd0587b138a2fd9a3b7fd9350Svetoslav Ganov /** 1056d17a936f73976971135aa1e6248662533343292Svetoslav Ganov * Action that clicks on the node info. 1064213804541a8b05cd0587b138a2fd9a3b7fd9350Svetoslav Ganov */ 107005b83b0c62d3d0538f0d566b08bd457015ec661Svetoslav Ganov public static final int ACTION_CLICK = 0x00000010; 1084213804541a8b05cd0587b138a2fd9a3b7fd9350Svetoslav Ganov 1094213804541a8b05cd0587b138a2fd9a3b7fd9350Svetoslav Ganov /** 1106d17a936f73976971135aa1e6248662533343292Svetoslav Ganov * Action that long clicks on the node. 111005b83b0c62d3d0538f0d566b08bd457015ec661Svetoslav Ganov */ 112005b83b0c62d3d0538f0d566b08bd457015ec661Svetoslav Ganov public static final int ACTION_LONG_CLICK = 0x00000020; 113005b83b0c62d3d0538f0d566b08bd457015ec661Svetoslav Ganov 114005b83b0c62d3d0538f0d566b08bd457015ec661Svetoslav Ganov /** 115005b83b0c62d3d0538f0d566b08bd457015ec661Svetoslav Ganov * Action that gives accessibility focus to the node. 1164213804541a8b05cd0587b138a2fd9a3b7fd9350Svetoslav Ganov */ 117005b83b0c62d3d0538f0d566b08bd457015ec661Svetoslav Ganov public static final int ACTION_ACCESSIBILITY_FOCUS = 0x00000040; 1184213804541a8b05cd0587b138a2fd9a3b7fd9350Svetoslav Ganov 1194213804541a8b05cd0587b138a2fd9a3b7fd9350Svetoslav Ganov /** 120005b83b0c62d3d0538f0d566b08bd457015ec661Svetoslav Ganov * Action that clears accessibility focus of the node. 1214213804541a8b05cd0587b138a2fd9a3b7fd9350Svetoslav Ganov */ 122005b83b0c62d3d0538f0d566b08bd457015ec661Svetoslav Ganov public static final int ACTION_CLEAR_ACCESSIBILITY_FOCUS = 0x00000080; 1234213804541a8b05cd0587b138a2fd9a3b7fd9350Svetoslav Ganov 1244213804541a8b05cd0587b138a2fd9a3b7fd9350Svetoslav Ganov /** 125b7ff3255c6d4e12f9d2334e3bbec0a125b7b09dcSvetoslav Ganov * Action that requests to go to the next entity in this node's text 1262b435aada3d274a9c08d334946fff1ab9ba15b48Svetoslav Ganov * at a given movement granularity. For example, move to the next character, 1272b435aada3d274a9c08d334946fff1ab9ba15b48Svetoslav Ganov * word, etc. 128aa780c110922148a6a4ba06734bb2b0bb8c98f93Svetoslav Ganov * <p> 1292b435aada3d274a9c08d334946fff1ab9ba15b48Svetoslav Ganov * <strong>Arguments:</strong> {@link #ACTION_ARGUMENT_MOVEMENT_GRANULARITY_INT}<br> 130aa780c110922148a6a4ba06734bb2b0bb8c98f93Svetoslav Ganov * <strong>Example:</strong> 131aa780c110922148a6a4ba06734bb2b0bb8c98f93Svetoslav Ganov * <code><pre><p> 132aa780c110922148a6a4ba06734bb2b0bb8c98f93Svetoslav Ganov * Bundle arguments = new Bundle(); 1332b435aada3d274a9c08d334946fff1ab9ba15b48Svetoslav Ganov * arguments.putInt(AccessibilityNodeInfo.ACTION_ARGUMENT_MOVEMENT_GRANULARITY_INT, 1342b435aada3d274a9c08d334946fff1ab9ba15b48Svetoslav Ganov * AccessibilityNodeInfo.MOVEMENT_GRANULARITY_CHARACTER); 1352b435aada3d274a9c08d334946fff1ab9ba15b48Svetoslav Ganov * info.performAction(AccessibilityNodeInfo.ACTION_NEXT_AT_MOVEMENT_GRANULARITY, arguments); 136aa780c110922148a6a4ba06734bb2b0bb8c98f93Svetoslav Ganov * </code></pre></p> 137aa780c110922148a6a4ba06734bb2b0bb8c98f93Svetoslav Ganov * </p> 138b7ff3255c6d4e12f9d2334e3bbec0a125b7b09dcSvetoslav Ganov * 1392b435aada3d274a9c08d334946fff1ab9ba15b48Svetoslav Ganov * @see #setMovementGranularities(int) 1402b435aada3d274a9c08d334946fff1ab9ba15b48Svetoslav Ganov * @see #getMovementGranularities() 141b7ff3255c6d4e12f9d2334e3bbec0a125b7b09dcSvetoslav Ganov * 1422b435aada3d274a9c08d334946fff1ab9ba15b48Svetoslav Ganov * @see #MOVEMENT_GRANULARITY_CHARACTER 1432b435aada3d274a9c08d334946fff1ab9ba15b48Svetoslav Ganov * @see #MOVEMENT_GRANULARITY_WORD 1442b435aada3d274a9c08d334946fff1ab9ba15b48Svetoslav Ganov * @see #MOVEMENT_GRANULARITY_LINE 1452b435aada3d274a9c08d334946fff1ab9ba15b48Svetoslav Ganov * @see #MOVEMENT_GRANULARITY_PARAGRAPH 1462b435aada3d274a9c08d334946fff1ab9ba15b48Svetoslav Ganov * @see #MOVEMENT_GRANULARITY_PAGE 147aa780c110922148a6a4ba06734bb2b0bb8c98f93Svetoslav Ganov */ 1482b435aada3d274a9c08d334946fff1ab9ba15b48Svetoslav Ganov public static final int ACTION_NEXT_AT_MOVEMENT_GRANULARITY = 0x00000100; 149aa780c110922148a6a4ba06734bb2b0bb8c98f93Svetoslav Ganov 150aa780c110922148a6a4ba06734bb2b0bb8c98f93Svetoslav Ganov /** 151b7ff3255c6d4e12f9d2334e3bbec0a125b7b09dcSvetoslav Ganov * Action that requests to go to the previous entity in this node's text 1522b435aada3d274a9c08d334946fff1ab9ba15b48Svetoslav Ganov * at a given movement granularity. For example, move to the next character, 1532b435aada3d274a9c08d334946fff1ab9ba15b48Svetoslav Ganov * word, etc. 154aa780c110922148a6a4ba06734bb2b0bb8c98f93Svetoslav Ganov * <p> 1552b435aada3d274a9c08d334946fff1ab9ba15b48Svetoslav Ganov * <strong>Arguments:</strong> {@link #ACTION_ARGUMENT_MOVEMENT_GRANULARITY_INT}<br> 156aa780c110922148a6a4ba06734bb2b0bb8c98f93Svetoslav Ganov * <strong>Example:</strong> 157aa780c110922148a6a4ba06734bb2b0bb8c98f93Svetoslav Ganov * <code><pre><p> 158aa780c110922148a6a4ba06734bb2b0bb8c98f93Svetoslav Ganov * Bundle arguments = new Bundle(); 1592b435aada3d274a9c08d334946fff1ab9ba15b48Svetoslav Ganov * arguments.putInt(AccessibilityNodeInfo.ACTION_ARGUMENT_MOVEMENT_GRANULARITY_INT, 1602b435aada3d274a9c08d334946fff1ab9ba15b48Svetoslav Ganov * AccessibilityNodeInfo.MOVEMENT_GRANULARITY_CHARACTER); 1612b435aada3d274a9c08d334946fff1ab9ba15b48Svetoslav Ganov * info.performAction(AccessibilityNodeInfo.ACTION_PREVIOUS_AT_MOVEMENT_GRANULARITY, 1622b435aada3d274a9c08d334946fff1ab9ba15b48Svetoslav Ganov * arguments); 163aa780c110922148a6a4ba06734bb2b0bb8c98f93Svetoslav Ganov * </code></pre></p> 164aa780c110922148a6a4ba06734bb2b0bb8c98f93Svetoslav Ganov * </p> 165b7ff3255c6d4e12f9d2334e3bbec0a125b7b09dcSvetoslav Ganov * 1662b435aada3d274a9c08d334946fff1ab9ba15b48Svetoslav Ganov * @see #setMovementGranularities(int) 1672b435aada3d274a9c08d334946fff1ab9ba15b48Svetoslav Ganov * @see #getMovementGranularities() 168b7ff3255c6d4e12f9d2334e3bbec0a125b7b09dcSvetoslav Ganov * 1692b435aada3d274a9c08d334946fff1ab9ba15b48Svetoslav Ganov * @see #MOVEMENT_GRANULARITY_CHARACTER 1702b435aada3d274a9c08d334946fff1ab9ba15b48Svetoslav Ganov * @see #MOVEMENT_GRANULARITY_WORD 1712b435aada3d274a9c08d334946fff1ab9ba15b48Svetoslav Ganov * @see #MOVEMENT_GRANULARITY_LINE 1722b435aada3d274a9c08d334946fff1ab9ba15b48Svetoslav Ganov * @see #MOVEMENT_GRANULARITY_PARAGRAPH 1732b435aada3d274a9c08d334946fff1ab9ba15b48Svetoslav Ganov * @see #MOVEMENT_GRANULARITY_PAGE 174aa780c110922148a6a4ba06734bb2b0bb8c98f93Svetoslav Ganov */ 1752b435aada3d274a9c08d334946fff1ab9ba15b48Svetoslav Ganov public static final int ACTION_PREVIOUS_AT_MOVEMENT_GRANULARITY = 0x00000200; 176aa780c110922148a6a4ba06734bb2b0bb8c98f93Svetoslav Ganov 177aa780c110922148a6a4ba06734bb2b0bb8c98f93Svetoslav Ganov /** 178b7ff3255c6d4e12f9d2334e3bbec0a125b7b09dcSvetoslav Ganov * Action to move to the next HTML element of a given type. For example, move 179b7ff3255c6d4e12f9d2334e3bbec0a125b7b09dcSvetoslav Ganov * to the BUTTON, INPUT, TABLE, etc. 180aa780c110922148a6a4ba06734bb2b0bb8c98f93Svetoslav Ganov * <p> 181b7ff3255c6d4e12f9d2334e3bbec0a125b7b09dcSvetoslav Ganov * <strong>Arguments:</strong> {@link #ACTION_ARGUMENT_HTML_ELEMENT_STRING}<br> 182b7ff3255c6d4e12f9d2334e3bbec0a125b7b09dcSvetoslav Ganov * <strong>Example:</strong> 183b7ff3255c6d4e12f9d2334e3bbec0a125b7b09dcSvetoslav Ganov * <code><pre><p> 184b7ff3255c6d4e12f9d2334e3bbec0a125b7b09dcSvetoslav Ganov * Bundle arguments = new Bundle(); 185b7ff3255c6d4e12f9d2334e3bbec0a125b7b09dcSvetoslav Ganov * arguments.putString(AccessibilityNodeInfo.ACTION_ARGUMENT_HTML_ELEMENT_STRING, "BUTTON"); 186b7ff3255c6d4e12f9d2334e3bbec0a125b7b09dcSvetoslav Ganov * info.performAction(AccessibilityNodeInfo.ACTION_NEXT_HTML_ELEMENT, arguments); 187b7ff3255c6d4e12f9d2334e3bbec0a125b7b09dcSvetoslav Ganov * </code></pre></p> 188b7ff3255c6d4e12f9d2334e3bbec0a125b7b09dcSvetoslav Ganov * </p> 189b7ff3255c6d4e12f9d2334e3bbec0a125b7b09dcSvetoslav Ganov */ 190b7ff3255c6d4e12f9d2334e3bbec0a125b7b09dcSvetoslav Ganov public static final int ACTION_NEXT_HTML_ELEMENT = 0x00000400; 191b7ff3255c6d4e12f9d2334e3bbec0a125b7b09dcSvetoslav Ganov 192b7ff3255c6d4e12f9d2334e3bbec0a125b7b09dcSvetoslav Ganov /** 193b7ff3255c6d4e12f9d2334e3bbec0a125b7b09dcSvetoslav Ganov * Action to move to the previous HTML element of a given type. For example, move 194b7ff3255c6d4e12f9d2334e3bbec0a125b7b09dcSvetoslav Ganov * to the BUTTON, INPUT, TABLE, etc. 195b7ff3255c6d4e12f9d2334e3bbec0a125b7b09dcSvetoslav Ganov * <p> 196b7ff3255c6d4e12f9d2334e3bbec0a125b7b09dcSvetoslav Ganov * <strong>Arguments:</strong> {@link #ACTION_ARGUMENT_HTML_ELEMENT_STRING}<br> 197b7ff3255c6d4e12f9d2334e3bbec0a125b7b09dcSvetoslav Ganov * <strong>Example:</strong> 198b7ff3255c6d4e12f9d2334e3bbec0a125b7b09dcSvetoslav Ganov * <code><pre><p> 199b7ff3255c6d4e12f9d2334e3bbec0a125b7b09dcSvetoslav Ganov * Bundle arguments = new Bundle(); 200b7ff3255c6d4e12f9d2334e3bbec0a125b7b09dcSvetoslav Ganov * arguments.putString(AccessibilityNodeInfo.ACTION_ARGUMENT_HTML_ELEMENT_STRING, "BUTTON"); 201b7ff3255c6d4e12f9d2334e3bbec0a125b7b09dcSvetoslav Ganov * info.performAction(AccessibilityNodeInfo.ACTION_PREVIOUS_HTML_ELEMENT, arguments); 202b7ff3255c6d4e12f9d2334e3bbec0a125b7b09dcSvetoslav Ganov * </code></pre></p> 203b7ff3255c6d4e12f9d2334e3bbec0a125b7b09dcSvetoslav Ganov * </p> 204b7ff3255c6d4e12f9d2334e3bbec0a125b7b09dcSvetoslav Ganov */ 205b7ff3255c6d4e12f9d2334e3bbec0a125b7b09dcSvetoslav Ganov public static final int ACTION_PREVIOUS_HTML_ELEMENT = 0x00000800; 206b7ff3255c6d4e12f9d2334e3bbec0a125b7b09dcSvetoslav Ganov 207b7ff3255c6d4e12f9d2334e3bbec0a125b7b09dcSvetoslav Ganov /** 208a1dc761c8322355eb1bb71d3d6c9c603c1d1fc0fSvetoslav Ganov * Action to scroll the node content forward. 209a1dc761c8322355eb1bb71d3d6c9c603c1d1fc0fSvetoslav Ganov */ 210a1dc761c8322355eb1bb71d3d6c9c603c1d1fc0fSvetoslav Ganov public static final int ACTION_SCROLL_FORWARD = 0x00001000; 211a1dc761c8322355eb1bb71d3d6c9c603c1d1fc0fSvetoslav Ganov 212a1dc761c8322355eb1bb71d3d6c9c603c1d1fc0fSvetoslav Ganov /** 213a1dc761c8322355eb1bb71d3d6c9c603c1d1fc0fSvetoslav Ganov * Action to scroll the node content backward. 214a1dc761c8322355eb1bb71d3d6c9c603c1d1fc0fSvetoslav Ganov */ 215a1dc761c8322355eb1bb71d3d6c9c603c1d1fc0fSvetoslav Ganov public static final int ACTION_SCROLL_BACKWARD = 0x00002000; 216a1dc761c8322355eb1bb71d3d6c9c603c1d1fc0fSvetoslav Ganov 217a1dc761c8322355eb1bb71d3d6c9c603c1d1fc0fSvetoslav Ganov /** 2182b435aada3d274a9c08d334946fff1ab9ba15b48Svetoslav Ganov * Argument for which movement granularity to be used when traversing the node text. 219b7ff3255c6d4e12f9d2334e3bbec0a125b7b09dcSvetoslav Ganov * <p> 220b7ff3255c6d4e12f9d2334e3bbec0a125b7b09dcSvetoslav Ganov * <strong>Type:</strong> int<br> 2212b435aada3d274a9c08d334946fff1ab9ba15b48Svetoslav Ganov * <strong>Actions:</strong> {@link #ACTION_NEXT_AT_MOVEMENT_GRANULARITY}, 2222b435aada3d274a9c08d334946fff1ab9ba15b48Svetoslav Ganov * {@link #ACTION_PREVIOUS_AT_MOVEMENT_GRANULARITY} 223aa780c110922148a6a4ba06734bb2b0bb8c98f93Svetoslav Ganov * </p> 224aa780c110922148a6a4ba06734bb2b0bb8c98f93Svetoslav Ganov */ 2252b435aada3d274a9c08d334946fff1ab9ba15b48Svetoslav Ganov public static final String ACTION_ARGUMENT_MOVEMENT_GRANULARITY_INT = 2262b435aada3d274a9c08d334946fff1ab9ba15b48Svetoslav Ganov "ACTION_ARGUMENT_MOVEMENT_GRANULARITY_INT"; 227b7ff3255c6d4e12f9d2334e3bbec0a125b7b09dcSvetoslav Ganov 228b7ff3255c6d4e12f9d2334e3bbec0a125b7b09dcSvetoslav Ganov /** 229b7ff3255c6d4e12f9d2334e3bbec0a125b7b09dcSvetoslav Ganov * Argument for which HTML element to get moving to the next/previous HTML element. 230b7ff3255c6d4e12f9d2334e3bbec0a125b7b09dcSvetoslav Ganov * <p> 231b7ff3255c6d4e12f9d2334e3bbec0a125b7b09dcSvetoslav Ganov * <strong>Type:</strong> String<br> 232b7ff3255c6d4e12f9d2334e3bbec0a125b7b09dcSvetoslav Ganov * <strong>Actions:</strong> {@link #ACTION_NEXT_HTML_ELEMENT}, 233b7ff3255c6d4e12f9d2334e3bbec0a125b7b09dcSvetoslav Ganov * {@link #ACTION_PREVIOUS_HTML_ELEMENT} 234b7ff3255c6d4e12f9d2334e3bbec0a125b7b09dcSvetoslav Ganov * </p> 235b7ff3255c6d4e12f9d2334e3bbec0a125b7b09dcSvetoslav Ganov */ 236b7ff3255c6d4e12f9d2334e3bbec0a125b7b09dcSvetoslav Ganov public static final String ACTION_ARGUMENT_HTML_ELEMENT_STRING = 237b7ff3255c6d4e12f9d2334e3bbec0a125b7b09dcSvetoslav Ganov "ACTION_ARGUMENT_HTML_ELEMENT_STRING"; 238aa780c110922148a6a4ba06734bb2b0bb8c98f93Svetoslav Ganov 239aa780c110922148a6a4ba06734bb2b0bb8c98f93Svetoslav Ganov /** 2404213804541a8b05cd0587b138a2fd9a3b7fd9350Svetoslav Ganov * The input focus. 2414213804541a8b05cd0587b138a2fd9a3b7fd9350Svetoslav Ganov */ 2424213804541a8b05cd0587b138a2fd9a3b7fd9350Svetoslav Ganov public static final int FOCUS_INPUT = 1; 2434213804541a8b05cd0587b138a2fd9a3b7fd9350Svetoslav Ganov 2444213804541a8b05cd0587b138a2fd9a3b7fd9350Svetoslav Ganov /** 2454213804541a8b05cd0587b138a2fd9a3b7fd9350Svetoslav Ganov * The accessibility focus. 2464213804541a8b05cd0587b138a2fd9a3b7fd9350Svetoslav Ganov */ 2474213804541a8b05cd0587b138a2fd9a3b7fd9350Svetoslav Ganov public static final int FOCUS_ACCESSIBILITY = 2; 2488643aa0179e598e78d938c59035389054535a229Svetoslav Ganov 2492b435aada3d274a9c08d334946fff1ab9ba15b48Svetoslav Ganov // Movement granularities 250b7ff3255c6d4e12f9d2334e3bbec0a125b7b09dcSvetoslav Ganov 251b7ff3255c6d4e12f9d2334e3bbec0a125b7b09dcSvetoslav Ganov /** 2522b435aada3d274a9c08d334946fff1ab9ba15b48Svetoslav Ganov * Movement granularity bit for traversing the text of a node by character. 253b7ff3255c6d4e12f9d2334e3bbec0a125b7b09dcSvetoslav Ganov */ 2542b435aada3d274a9c08d334946fff1ab9ba15b48Svetoslav Ganov public static final int MOVEMENT_GRANULARITY_CHARACTER = 0x00000001; 255b7ff3255c6d4e12f9d2334e3bbec0a125b7b09dcSvetoslav Ganov 256b7ff3255c6d4e12f9d2334e3bbec0a125b7b09dcSvetoslav Ganov /** 2572b435aada3d274a9c08d334946fff1ab9ba15b48Svetoslav Ganov * Movement granularity bit for traversing the text of a node by word. 258b7ff3255c6d4e12f9d2334e3bbec0a125b7b09dcSvetoslav Ganov */ 2592b435aada3d274a9c08d334946fff1ab9ba15b48Svetoslav Ganov public static final int MOVEMENT_GRANULARITY_WORD = 0x00000002; 260b7ff3255c6d4e12f9d2334e3bbec0a125b7b09dcSvetoslav Ganov 261b7ff3255c6d4e12f9d2334e3bbec0a125b7b09dcSvetoslav Ganov /** 2622b435aada3d274a9c08d334946fff1ab9ba15b48Svetoslav Ganov * Movement granularity bit for traversing the text of a node by line. 263b7ff3255c6d4e12f9d2334e3bbec0a125b7b09dcSvetoslav Ganov */ 2642b435aada3d274a9c08d334946fff1ab9ba15b48Svetoslav Ganov public static final int MOVEMENT_GRANULARITY_LINE = 0x00000004; 265b7ff3255c6d4e12f9d2334e3bbec0a125b7b09dcSvetoslav Ganov 266b7ff3255c6d4e12f9d2334e3bbec0a125b7b09dcSvetoslav Ganov /** 2672b435aada3d274a9c08d334946fff1ab9ba15b48Svetoslav Ganov * Movement granularity bit for traversing the text of a node by paragraph. 268b7ff3255c6d4e12f9d2334e3bbec0a125b7b09dcSvetoslav Ganov */ 2692b435aada3d274a9c08d334946fff1ab9ba15b48Svetoslav Ganov public static final int MOVEMENT_GRANULARITY_PARAGRAPH = 0x00000008; 270b7ff3255c6d4e12f9d2334e3bbec0a125b7b09dcSvetoslav Ganov 271b7ff3255c6d4e12f9d2334e3bbec0a125b7b09dcSvetoslav Ganov /** 2722b435aada3d274a9c08d334946fff1ab9ba15b48Svetoslav Ganov * Movement granularity bit for traversing the text of a node by page. 273b7ff3255c6d4e12f9d2334e3bbec0a125b7b09dcSvetoslav Ganov */ 2742b435aada3d274a9c08d334946fff1ab9ba15b48Svetoslav Ganov public static final int MOVEMENT_GRANULARITY_PAGE = 0x00000010; 275b7ff3255c6d4e12f9d2334e3bbec0a125b7b09dcSvetoslav Ganov 2768643aa0179e598e78d938c59035389054535a229Svetoslav Ganov // Boolean attributes. 2778643aa0179e598e78d938c59035389054535a229Svetoslav Ganov 2788643aa0179e598e78d938c59035389054535a229Svetoslav Ganov private static final int PROPERTY_CHECKABLE = 0x00000001; 2798643aa0179e598e78d938c59035389054535a229Svetoslav Ganov 2808643aa0179e598e78d938c59035389054535a229Svetoslav Ganov private static final int PROPERTY_CHECKED = 0x00000002; 2818643aa0179e598e78d938c59035389054535a229Svetoslav Ganov 2828643aa0179e598e78d938c59035389054535a229Svetoslav Ganov private static final int PROPERTY_FOCUSABLE = 0x00000004; 2838643aa0179e598e78d938c59035389054535a229Svetoslav Ganov 2848643aa0179e598e78d938c59035389054535a229Svetoslav Ganov private static final int PROPERTY_FOCUSED = 0x00000008; 2858643aa0179e598e78d938c59035389054535a229Svetoslav Ganov 2868643aa0179e598e78d938c59035389054535a229Svetoslav Ganov private static final int PROPERTY_SELECTED = 0x00000010; 2878643aa0179e598e78d938c59035389054535a229Svetoslav Ganov 2888643aa0179e598e78d938c59035389054535a229Svetoslav Ganov private static final int PROPERTY_CLICKABLE = 0x00000020; 2898643aa0179e598e78d938c59035389054535a229Svetoslav Ganov 2908643aa0179e598e78d938c59035389054535a229Svetoslav Ganov private static final int PROPERTY_LONG_CLICKABLE = 0x00000040; 2918643aa0179e598e78d938c59035389054535a229Svetoslav Ganov 2928643aa0179e598e78d938c59035389054535a229Svetoslav Ganov private static final int PROPERTY_ENABLED = 0x00000080; 2938643aa0179e598e78d938c59035389054535a229Svetoslav Ganov 2948643aa0179e598e78d938c59035389054535a229Svetoslav Ganov private static final int PROPERTY_PASSWORD = 0x00000100; 2958643aa0179e598e78d938c59035389054535a229Svetoslav Ganov 296a0156177cdc809795dd8bc5a19943dd2b6f82b66Svetoslav Ganov private static final int PROPERTY_SCROLLABLE = 0x00000200; 297a0156177cdc809795dd8bc5a19943dd2b6f82b66Svetoslav Ganov 2984213804541a8b05cd0587b138a2fd9a3b7fd9350Svetoslav Ganov private static final int PROPERTY_ACCESSIBILITY_FOCUSED = 0x00000400; 2994213804541a8b05cd0587b138a2fd9a3b7fd9350Svetoslav Ganov 3000a1bb6dffc358c01e10555c5c833edb7dba69659Svetoslav Ganov private static final int PROPERTY_VISIBLE_TO_USER = 0x00000800; 3010a1bb6dffc358c01e10555c5c833edb7dba69659Svetoslav Ganov 302021078554b902179442a345a9d080a165c3b5139Svetoslav Ganov /** 303021078554b902179442a345a9d080a165c3b5139Svetoslav Ganov * Bits that provide the id of a virtual descendant of a view. 304021078554b902179442a345a9d080a165c3b5139Svetoslav Ganov */ 305021078554b902179442a345a9d080a165c3b5139Svetoslav Ganov private static final long VIRTUAL_DESCENDANT_ID_MASK = 0xffffffff00000000L; 306021078554b902179442a345a9d080a165c3b5139Svetoslav Ganov 307021078554b902179442a345a9d080a165c3b5139Svetoslav Ganov /** 308021078554b902179442a345a9d080a165c3b5139Svetoslav Ganov * Bit shift of {@link #VIRTUAL_DESCENDANT_ID_MASK} to get to the id for a 309021078554b902179442a345a9d080a165c3b5139Svetoslav Ganov * virtual descendant of a view. Such a descendant does not exist in the view 310021078554b902179442a345a9d080a165c3b5139Svetoslav Ganov * hierarchy and is only reported via the accessibility APIs. 311021078554b902179442a345a9d080a165c3b5139Svetoslav Ganov */ 312021078554b902179442a345a9d080a165c3b5139Svetoslav Ganov private static final int VIRTUAL_DESCENDANT_ID_SHIFT = 32; 313021078554b902179442a345a9d080a165c3b5139Svetoslav Ganov 314021078554b902179442a345a9d080a165c3b5139Svetoslav Ganov /** 315021078554b902179442a345a9d080a165c3b5139Svetoslav Ganov * Gets the accessibility view id which identifies a View in the view three. 316021078554b902179442a345a9d080a165c3b5139Svetoslav Ganov * 317021078554b902179442a345a9d080a165c3b5139Svetoslav Ganov * @param accessibilityNodeId The id of an {@link AccessibilityNodeInfo}. 318021078554b902179442a345a9d080a165c3b5139Svetoslav Ganov * @return The accessibility view id part of the node id. 319021078554b902179442a345a9d080a165c3b5139Svetoslav Ganov * 320021078554b902179442a345a9d080a165c3b5139Svetoslav Ganov * @hide 321021078554b902179442a345a9d080a165c3b5139Svetoslav Ganov */ 322021078554b902179442a345a9d080a165c3b5139Svetoslav Ganov public static int getAccessibilityViewId(long accessibilityNodeId) { 323021078554b902179442a345a9d080a165c3b5139Svetoslav Ganov return (int) accessibilityNodeId; 324021078554b902179442a345a9d080a165c3b5139Svetoslav Ganov } 325021078554b902179442a345a9d080a165c3b5139Svetoslav Ganov 326021078554b902179442a345a9d080a165c3b5139Svetoslav Ganov /** 327021078554b902179442a345a9d080a165c3b5139Svetoslav Ganov * Gets the virtual descendant id which identifies an imaginary view in a 328021078554b902179442a345a9d080a165c3b5139Svetoslav Ganov * containing View. 329021078554b902179442a345a9d080a165c3b5139Svetoslav Ganov * 330021078554b902179442a345a9d080a165c3b5139Svetoslav Ganov * @param accessibilityNodeId The id of an {@link AccessibilityNodeInfo}. 331021078554b902179442a345a9d080a165c3b5139Svetoslav Ganov * @return The virtual view id part of the node id. 332021078554b902179442a345a9d080a165c3b5139Svetoslav Ganov * 333021078554b902179442a345a9d080a165c3b5139Svetoslav Ganov * @hide 334021078554b902179442a345a9d080a165c3b5139Svetoslav Ganov */ 335021078554b902179442a345a9d080a165c3b5139Svetoslav Ganov public static int getVirtualDescendantId(long accessibilityNodeId) { 336021078554b902179442a345a9d080a165c3b5139Svetoslav Ganov return (int) ((accessibilityNodeId & VIRTUAL_DESCENDANT_ID_MASK) 337021078554b902179442a345a9d080a165c3b5139Svetoslav Ganov >> VIRTUAL_DESCENDANT_ID_SHIFT); 338021078554b902179442a345a9d080a165c3b5139Svetoslav Ganov } 339021078554b902179442a345a9d080a165c3b5139Svetoslav Ganov 340021078554b902179442a345a9d080a165c3b5139Svetoslav Ganov /** 341021078554b902179442a345a9d080a165c3b5139Svetoslav Ganov * Makes a node id by shifting the <code>virtualDescendantId</code> 342021078554b902179442a345a9d080a165c3b5139Svetoslav Ganov * by {@link #VIRTUAL_DESCENDANT_ID_SHIFT} and taking 343021078554b902179442a345a9d080a165c3b5139Svetoslav Ganov * the bitwise or with the <code>accessibilityViewId</code>. 344021078554b902179442a345a9d080a165c3b5139Svetoslav Ganov * 345021078554b902179442a345a9d080a165c3b5139Svetoslav Ganov * @param accessibilityViewId A View accessibility id. 346021078554b902179442a345a9d080a165c3b5139Svetoslav Ganov * @param virtualDescendantId A virtual descendant id. 347021078554b902179442a345a9d080a165c3b5139Svetoslav Ganov * @return The node id. 348021078554b902179442a345a9d080a165c3b5139Svetoslav Ganov * 349021078554b902179442a345a9d080a165c3b5139Svetoslav Ganov * @hide 350021078554b902179442a345a9d080a165c3b5139Svetoslav Ganov */ 351021078554b902179442a345a9d080a165c3b5139Svetoslav Ganov public static long makeNodeId(int accessibilityViewId, int virtualDescendantId) { 352021078554b902179442a345a9d080a165c3b5139Svetoslav Ganov return (((long) virtualDescendantId) << VIRTUAL_DESCENDANT_ID_SHIFT) | accessibilityViewId; 353021078554b902179442a345a9d080a165c3b5139Svetoslav Ganov } 354021078554b902179442a345a9d080a165c3b5139Svetoslav Ganov 3558643aa0179e598e78d938c59035389054535a229Svetoslav Ganov // Housekeeping. 3568643aa0179e598e78d938c59035389054535a229Svetoslav Ganov private static final int MAX_POOL_SIZE = 50; 3578643aa0179e598e78d938c59035389054535a229Svetoslav Ganov private static final Object sPoolLock = new Object(); 3588643aa0179e598e78d938c59035389054535a229Svetoslav Ganov private static AccessibilityNodeInfo sPool; 3598643aa0179e598e78d938c59035389054535a229Svetoslav Ganov private static int sPoolSize; 3608643aa0179e598e78d938c59035389054535a229Svetoslav Ganov private AccessibilityNodeInfo mNext; 3618643aa0179e598e78d938c59035389054535a229Svetoslav Ganov private boolean mIsInPool; 3628643aa0179e598e78d938c59035389054535a229Svetoslav Ganov private boolean mSealed; 3638643aa0179e598e78d938c59035389054535a229Svetoslav Ganov 3648643aa0179e598e78d938c59035389054535a229Svetoslav Ganov // Data. 365f3b4f3163b5b4c0a54a2643f07c97c47b14a1eb7Svetoslav Ganov private int mWindowId = UNDEFINED; 3660d04e245534cf777dfaf16dce3c51553837c14ffSvetoslav Ganov private long mSourceNodeId = ROOT_NODE_ID; 3670d04e245534cf777dfaf16dce3c51553837c14ffSvetoslav Ganov private long mParentNodeId = ROOT_NODE_ID; 36833aef98fd28dcac0a2ad37e7329afd3e666f5e0aSvetoslav Ganov private long mLabelForId = ROOT_NODE_ID; 36933aef98fd28dcac0a2ad37e7329afd3e666f5e0aSvetoslav Ganov private long mLabeledById = ROOT_NODE_ID; 370f3b4f3163b5b4c0a54a2643f07c97c47b14a1eb7Svetoslav Ganov 3718643aa0179e598e78d938c59035389054535a229Svetoslav Ganov private int mBooleanProperties; 372eeee4d2c01d3c4ed99e4891dbc75c7de69a803faSvetoslav Ganov private final Rect mBoundsInParent = new Rect(); 373eeee4d2c01d3c4ed99e4891dbc75c7de69a803faSvetoslav Ganov private final Rect mBoundsInScreen = new Rect(); 3748643aa0179e598e78d938c59035389054535a229Svetoslav Ganov 3758643aa0179e598e78d938c59035389054535a229Svetoslav Ganov private CharSequence mPackageName; 3768643aa0179e598e78d938c59035389054535a229Svetoslav Ganov private CharSequence mClassName; 3778643aa0179e598e78d938c59035389054535a229Svetoslav Ganov private CharSequence mText; 3788643aa0179e598e78d938c59035389054535a229Svetoslav Ganov private CharSequence mContentDescription; 3798643aa0179e598e78d938c59035389054535a229Svetoslav Ganov 380aa780c110922148a6a4ba06734bb2b0bb8c98f93Svetoslav Ganov private final SparseLongArray mChildNodeIds = new SparseLongArray(); 3818643aa0179e598e78d938c59035389054535a229Svetoslav Ganov private int mActions; 3828643aa0179e598e78d938c59035389054535a229Svetoslav Ganov 3832b435aada3d274a9c08d334946fff1ab9ba15b48Svetoslav Ganov private int mMovementGranularities; 384aa780c110922148a6a4ba06734bb2b0bb8c98f93Svetoslav Ganov 385d116d7c78a9c53f30a73bf273bd7618312cf3847Svetoslav Ganov private int mConnectionId = UNDEFINED; 3868643aa0179e598e78d938c59035389054535a229Svetoslav Ganov 3878643aa0179e598e78d938c59035389054535a229Svetoslav Ganov /** 3888643aa0179e598e78d938c59035389054535a229Svetoslav Ganov * Hide constructor from clients. 3898643aa0179e598e78d938c59035389054535a229Svetoslav Ganov */ 3908643aa0179e598e78d938c59035389054535a229Svetoslav Ganov private AccessibilityNodeInfo() { 3918643aa0179e598e78d938c59035389054535a229Svetoslav Ganov /* do nothing */ 3928643aa0179e598e78d938c59035389054535a229Svetoslav Ganov } 3938643aa0179e598e78d938c59035389054535a229Svetoslav Ganov 3948643aa0179e598e78d938c59035389054535a229Svetoslav Ganov /** 3958643aa0179e598e78d938c59035389054535a229Svetoslav Ganov * Sets the source. 396021078554b902179442a345a9d080a165c3b5139Svetoslav Ganov * <p> 397021078554b902179442a345a9d080a165c3b5139Svetoslav Ganov * <strong>Note:</strong> Cannot be called from an 398021078554b902179442a345a9d080a165c3b5139Svetoslav Ganov * {@link android.accessibilityservice.AccessibilityService}. 399021078554b902179442a345a9d080a165c3b5139Svetoslav Ganov * This class is made immutable before being delivered to an AccessibilityService. 400021078554b902179442a345a9d080a165c3b5139Svetoslav Ganov * </p> 4018643aa0179e598e78d938c59035389054535a229Svetoslav Ganov * 4028643aa0179e598e78d938c59035389054535a229Svetoslav Ganov * @param source The info source. 4038643aa0179e598e78d938c59035389054535a229Svetoslav Ganov */ 4048643aa0179e598e78d938c59035389054535a229Svetoslav Ganov public void setSource(View source) { 405f3b4f3163b5b4c0a54a2643f07c97c47b14a1eb7Svetoslav Ganov setSource(source, UNDEFINED); 406021078554b902179442a345a9d080a165c3b5139Svetoslav Ganov } 407021078554b902179442a345a9d080a165c3b5139Svetoslav Ganov 408021078554b902179442a345a9d080a165c3b5139Svetoslav Ganov /** 409021078554b902179442a345a9d080a165c3b5139Svetoslav Ganov * Sets the source to be a virtual descendant of the given <code>root</code>. 41071b4e71c67df79f53b582fabb34b96ddbe23fe0fSvetoslav Ganov * If <code>virtualDescendantId</code> is {@link View#NO_ID} the root 411021078554b902179442a345a9d080a165c3b5139Svetoslav Ganov * is set as the source. 412021078554b902179442a345a9d080a165c3b5139Svetoslav Ganov * <p> 413021078554b902179442a345a9d080a165c3b5139Svetoslav Ganov * A virtual descendant is an imaginary View that is reported as a part of the view 414021078554b902179442a345a9d080a165c3b5139Svetoslav Ganov * hierarchy for accessibility purposes. This enables custom views that draw complex 41571b4e71c67df79f53b582fabb34b96ddbe23fe0fSvetoslav Ganov * content to report themselves as a tree of virtual views, thus conveying their 416021078554b902179442a345a9d080a165c3b5139Svetoslav Ganov * logical structure. 417021078554b902179442a345a9d080a165c3b5139Svetoslav Ganov * </p> 418021078554b902179442a345a9d080a165c3b5139Svetoslav Ganov * <p> 419021078554b902179442a345a9d080a165c3b5139Svetoslav Ganov * <strong>Note:</strong> Cannot be called from an 420021078554b902179442a345a9d080a165c3b5139Svetoslav Ganov * {@link android.accessibilityservice.AccessibilityService}. 421021078554b902179442a345a9d080a165c3b5139Svetoslav Ganov * This class is made immutable before being delivered to an AccessibilityService. 422021078554b902179442a345a9d080a165c3b5139Svetoslav Ganov * </p> 423021078554b902179442a345a9d080a165c3b5139Svetoslav Ganov * 424021078554b902179442a345a9d080a165c3b5139Svetoslav Ganov * @param root The root of the virtual subtree. 425021078554b902179442a345a9d080a165c3b5139Svetoslav Ganov * @param virtualDescendantId The id of the virtual descendant. 426021078554b902179442a345a9d080a165c3b5139Svetoslav Ganov */ 427021078554b902179442a345a9d080a165c3b5139Svetoslav Ganov public void setSource(View root, int virtualDescendantId) { 4288643aa0179e598e78d938c59035389054535a229Svetoslav Ganov enforceNotSealed(); 429f3b4f3163b5b4c0a54a2643f07c97c47b14a1eb7Svetoslav Ganov mWindowId = (root != null) ? root.getAccessibilityWindowId() : UNDEFINED; 430021078554b902179442a345a9d080a165c3b5139Svetoslav Ganov final int rootAccessibilityViewId = 431f3b4f3163b5b4c0a54a2643f07c97c47b14a1eb7Svetoslav Ganov (root != null) ? root.getAccessibilityViewId() : UNDEFINED; 432021078554b902179442a345a9d080a165c3b5139Svetoslav Ganov mSourceNodeId = makeNodeId(rootAccessibilityViewId, virtualDescendantId); 4338643aa0179e598e78d938c59035389054535a229Svetoslav Ganov } 434005b83b0c62d3d0538f0d566b08bd457015ec661Svetoslav Ganov 4354213804541a8b05cd0587b138a2fd9a3b7fd9350Svetoslav Ganov /** 436005b83b0c62d3d0538f0d566b08bd457015ec661Svetoslav Ganov * Find the view that has the specified focus type. The search starts from 4374213804541a8b05cd0587b138a2fd9a3b7fd9350Svetoslav Ganov * the view represented by this node info. 4384213804541a8b05cd0587b138a2fd9a3b7fd9350Svetoslav Ganov * 4394213804541a8b05cd0587b138a2fd9a3b7fd9350Svetoslav Ganov * @param focus The focus to find. One of {@link #FOCUS_INPUT} or 4404213804541a8b05cd0587b138a2fd9a3b7fd9350Svetoslav Ganov * {@link #FOCUS_ACCESSIBILITY}. 4414213804541a8b05cd0587b138a2fd9a3b7fd9350Svetoslav Ganov * @return The node info of the focused view or null. 4424213804541a8b05cd0587b138a2fd9a3b7fd9350Svetoslav Ganov * 4434213804541a8b05cd0587b138a2fd9a3b7fd9350Svetoslav Ganov * @see #FOCUS_INPUT 4444213804541a8b05cd0587b138a2fd9a3b7fd9350Svetoslav Ganov * @see #FOCUS_ACCESSIBILITY 4454213804541a8b05cd0587b138a2fd9a3b7fd9350Svetoslav Ganov */ 4464213804541a8b05cd0587b138a2fd9a3b7fd9350Svetoslav Ganov public AccessibilityNodeInfo findFocus(int focus) { 4474213804541a8b05cd0587b138a2fd9a3b7fd9350Svetoslav Ganov enforceSealed(); 4482ef6905003c20010032ee993dfcc5899ad9be6f8Svetoslav Ganov enforceValidFocusType(focus); 4494213804541a8b05cd0587b138a2fd9a3b7fd9350Svetoslav Ganov if (!canPerformRequestOverConnection(mSourceNodeId)) { 4504213804541a8b05cd0587b138a2fd9a3b7fd9350Svetoslav Ganov return null; 4514213804541a8b05cd0587b138a2fd9a3b7fd9350Svetoslav Ganov } 4524213804541a8b05cd0587b138a2fd9a3b7fd9350Svetoslav Ganov return AccessibilityInteractionClient.getInstance().findFocus(mConnectionId, mWindowId, 4534213804541a8b05cd0587b138a2fd9a3b7fd9350Svetoslav Ganov mSourceNodeId, focus); 4544213804541a8b05cd0587b138a2fd9a3b7fd9350Svetoslav Ganov } 4554213804541a8b05cd0587b138a2fd9a3b7fd9350Svetoslav Ganov 4564213804541a8b05cd0587b138a2fd9a3b7fd9350Svetoslav Ganov /** 4574213804541a8b05cd0587b138a2fd9a3b7fd9350Svetoslav Ganov * Searches for the nearest view in the specified direction that can take 4584213804541a8b05cd0587b138a2fd9a3b7fd9350Svetoslav Ganov * the input focus. 4594213804541a8b05cd0587b138a2fd9a3b7fd9350Svetoslav Ganov * 4604213804541a8b05cd0587b138a2fd9a3b7fd9350Svetoslav Ganov * @param direction The direction. Can be one of: 4614213804541a8b05cd0587b138a2fd9a3b7fd9350Svetoslav Ganov * {@link View#FOCUS_DOWN}, 4624213804541a8b05cd0587b138a2fd9a3b7fd9350Svetoslav Ganov * {@link View#FOCUS_UP}, 4634213804541a8b05cd0587b138a2fd9a3b7fd9350Svetoslav Ganov * {@link View#FOCUS_LEFT}, 4644213804541a8b05cd0587b138a2fd9a3b7fd9350Svetoslav Ganov * {@link View#FOCUS_RIGHT}, 4654213804541a8b05cd0587b138a2fd9a3b7fd9350Svetoslav Ganov * {@link View#FOCUS_FORWARD}, 4668ffe8b304e4778b3c95e57ad5a77cd41c9cf9f7bSvetoslav Ganov * {@link View#FOCUS_BACKWARD}. 4674213804541a8b05cd0587b138a2fd9a3b7fd9350Svetoslav Ganov * 4684213804541a8b05cd0587b138a2fd9a3b7fd9350Svetoslav Ganov * @return The node info for the view that can take accessibility focus. 4694213804541a8b05cd0587b138a2fd9a3b7fd9350Svetoslav Ganov */ 4704213804541a8b05cd0587b138a2fd9a3b7fd9350Svetoslav Ganov public AccessibilityNodeInfo focusSearch(int direction) { 4714213804541a8b05cd0587b138a2fd9a3b7fd9350Svetoslav Ganov enforceSealed(); 4722ef6905003c20010032ee993dfcc5899ad9be6f8Svetoslav Ganov enforceValidFocusDirection(direction); 4734213804541a8b05cd0587b138a2fd9a3b7fd9350Svetoslav Ganov if (!canPerformRequestOverConnection(mSourceNodeId)) { 4744213804541a8b05cd0587b138a2fd9a3b7fd9350Svetoslav Ganov return null; 4754213804541a8b05cd0587b138a2fd9a3b7fd9350Svetoslav Ganov } 4764213804541a8b05cd0587b138a2fd9a3b7fd9350Svetoslav Ganov return AccessibilityInteractionClient.getInstance().focusSearch(mConnectionId, mWindowId, 4774213804541a8b05cd0587b138a2fd9a3b7fd9350Svetoslav Ganov mSourceNodeId, direction); 4784213804541a8b05cd0587b138a2fd9a3b7fd9350Svetoslav Ganov } 4798643aa0179e598e78d938c59035389054535a229Svetoslav Ganov 4808643aa0179e598e78d938c59035389054535a229Svetoslav Ganov /** 4818643aa0179e598e78d938c59035389054535a229Svetoslav Ganov * Gets the id of the window from which the info comes from. 4828643aa0179e598e78d938c59035389054535a229Svetoslav Ganov * 4838643aa0179e598e78d938c59035389054535a229Svetoslav Ganov * @return The window id. 4848643aa0179e598e78d938c59035389054535a229Svetoslav Ganov */ 485eeee4d2c01d3c4ed99e4891dbc75c7de69a803faSvetoslav Ganov public int getWindowId() { 486021078554b902179442a345a9d080a165c3b5139Svetoslav Ganov return mWindowId; 4878643aa0179e598e78d938c59035389054535a229Svetoslav Ganov } 4888643aa0179e598e78d938c59035389054535a229Svetoslav Ganov 4898643aa0179e598e78d938c59035389054535a229Svetoslav Ganov /** 49057c7fd5a43237afc5e8ef31a076e862c0c16c328Svetoslav Ganov * @return The ids of the children. 49157c7fd5a43237afc5e8ef31a076e862c0c16c328Svetoslav Ganov * 49257c7fd5a43237afc5e8ef31a076e862c0c16c328Svetoslav Ganov * @hide 49357c7fd5a43237afc5e8ef31a076e862c0c16c328Svetoslav Ganov */ 49457c7fd5a43237afc5e8ef31a076e862c0c16c328Svetoslav Ganov public SparseLongArray getChildNodeIds() { 49557c7fd5a43237afc5e8ef31a076e862c0c16c328Svetoslav Ganov return mChildNodeIds; 49657c7fd5a43237afc5e8ef31a076e862c0c16c328Svetoslav Ganov } 49757c7fd5a43237afc5e8ef31a076e862c0c16c328Svetoslav Ganov 49857c7fd5a43237afc5e8ef31a076e862c0c16c328Svetoslav Ganov /** 4998643aa0179e598e78d938c59035389054535a229Svetoslav Ganov * Gets the number of children. 5008643aa0179e598e78d938c59035389054535a229Svetoslav Ganov * 5018643aa0179e598e78d938c59035389054535a229Svetoslav Ganov * @return The child count. 5028643aa0179e598e78d938c59035389054535a229Svetoslav Ganov */ 5038643aa0179e598e78d938c59035389054535a229Svetoslav Ganov public int getChildCount() { 50457c7fd5a43237afc5e8ef31a076e862c0c16c328Svetoslav Ganov return mChildNodeIds.size(); 5058643aa0179e598e78d938c59035389054535a229Svetoslav Ganov } 5068643aa0179e598e78d938c59035389054535a229Svetoslav Ganov 5078643aa0179e598e78d938c59035389054535a229Svetoslav Ganov /** 5088643aa0179e598e78d938c59035389054535a229Svetoslav Ganov * Get the child at given index. 5098643aa0179e598e78d938c59035389054535a229Svetoslav Ganov * <p> 51038e8b4e5bc3c93affdffbc064fd9db5aeccc3e8eSvetoslav Ganov * <strong>Note:</strong> It is a client responsibility to recycle the 51138e8b4e5bc3c93affdffbc064fd9db5aeccc3e8eSvetoslav Ganov * received info by calling {@link AccessibilityNodeInfo#recycle()} 51238e8b4e5bc3c93affdffbc064fd9db5aeccc3e8eSvetoslav Ganov * to avoid creating of multiple instances. 5138643aa0179e598e78d938c59035389054535a229Svetoslav Ganov * </p> 51438e8b4e5bc3c93affdffbc064fd9db5aeccc3e8eSvetoslav Ganov * 5158643aa0179e598e78d938c59035389054535a229Svetoslav Ganov * @param index The child index. 5168643aa0179e598e78d938c59035389054535a229Svetoslav Ganov * @return The child node. 5178643aa0179e598e78d938c59035389054535a229Svetoslav Ganov * 5188643aa0179e598e78d938c59035389054535a229Svetoslav Ganov * @throws IllegalStateException If called outside of an AccessibilityService. 5198643aa0179e598e78d938c59035389054535a229Svetoslav Ganov * 5208643aa0179e598e78d938c59035389054535a229Svetoslav Ganov */ 5218643aa0179e598e78d938c59035389054535a229Svetoslav Ganov public AccessibilityNodeInfo getChild(int index) { 5228643aa0179e598e78d938c59035389054535a229Svetoslav Ganov enforceSealed(); 523021078554b902179442a345a9d080a165c3b5139Svetoslav Ganov if (!canPerformRequestOverConnection(mSourceNodeId)) { 524eeee4d2c01d3c4ed99e4891dbc75c7de69a803faSvetoslav Ganov return null; 525eeee4d2c01d3c4ed99e4891dbc75c7de69a803faSvetoslav Ganov } 52657c7fd5a43237afc5e8ef31a076e862c0c16c328Svetoslav Ganov final long childId = mChildNodeIds.get(index); 5278bd69610aafc6995126965d1d23b771fe02a9084Svetoslav Ganov AccessibilityInteractionClient client = AccessibilityInteractionClient.getInstance(); 52857c7fd5a43237afc5e8ef31a076e862c0c16c328Svetoslav Ganov return client.findAccessibilityNodeInfoByAccessibilityId(mConnectionId, mWindowId, 52957c7fd5a43237afc5e8ef31a076e862c0c16c328Svetoslav Ganov childId, FLAG_PREFETCH_DESCENDANTS); 5308643aa0179e598e78d938c59035389054535a229Svetoslav Ganov } 5318643aa0179e598e78d938c59035389054535a229Svetoslav Ganov 5328643aa0179e598e78d938c59035389054535a229Svetoslav Ganov /** 5338643aa0179e598e78d938c59035389054535a229Svetoslav Ganov * Adds a child. 5348643aa0179e598e78d938c59035389054535a229Svetoslav Ganov * <p> 535021078554b902179442a345a9d080a165c3b5139Svetoslav Ganov * <strong>Note:</strong> Cannot be called from an 536021078554b902179442a345a9d080a165c3b5139Svetoslav Ganov * {@link android.accessibilityservice.AccessibilityService}. 537021078554b902179442a345a9d080a165c3b5139Svetoslav Ganov * This class is made immutable before being delivered to an AccessibilityService. 5388643aa0179e598e78d938c59035389054535a229Svetoslav Ganov * </p> 53938e8b4e5bc3c93affdffbc064fd9db5aeccc3e8eSvetoslav Ganov * 5408643aa0179e598e78d938c59035389054535a229Svetoslav Ganov * @param child The child. 5418643aa0179e598e78d938c59035389054535a229Svetoslav Ganov * 5428643aa0179e598e78d938c59035389054535a229Svetoslav Ganov * @throws IllegalStateException If called from an AccessibilityService. 5438643aa0179e598e78d938c59035389054535a229Svetoslav Ganov */ 5448643aa0179e598e78d938c59035389054535a229Svetoslav Ganov public void addChild(View child) { 545f3b4f3163b5b4c0a54a2643f07c97c47b14a1eb7Svetoslav Ganov addChild(child, UNDEFINED); 546021078554b902179442a345a9d080a165c3b5139Svetoslav Ganov } 547021078554b902179442a345a9d080a165c3b5139Svetoslav Ganov 548021078554b902179442a345a9d080a165c3b5139Svetoslav Ganov /** 549021078554b902179442a345a9d080a165c3b5139Svetoslav Ganov * Adds a virtual child which is a descendant of the given <code>root</code>. 55071b4e71c67df79f53b582fabb34b96ddbe23fe0fSvetoslav Ganov * If <code>virtualDescendantId</code> is {@link View#NO_ID} the root 551021078554b902179442a345a9d080a165c3b5139Svetoslav Ganov * is added as a child. 552021078554b902179442a345a9d080a165c3b5139Svetoslav Ganov * <p> 553021078554b902179442a345a9d080a165c3b5139Svetoslav Ganov * A virtual descendant is an imaginary View that is reported as a part of the view 554021078554b902179442a345a9d080a165c3b5139Svetoslav Ganov * hierarchy for accessibility purposes. This enables custom views that draw complex 555021078554b902179442a345a9d080a165c3b5139Svetoslav Ganov * content to report them selves as a tree of virtual views, thus conveying their 556021078554b902179442a345a9d080a165c3b5139Svetoslav Ganov * logical structure. 557021078554b902179442a345a9d080a165c3b5139Svetoslav Ganov * </p> 558021078554b902179442a345a9d080a165c3b5139Svetoslav Ganov * 559021078554b902179442a345a9d080a165c3b5139Svetoslav Ganov * @param root The root of the virtual subtree. 560021078554b902179442a345a9d080a165c3b5139Svetoslav Ganov * @param virtualDescendantId The id of the virtual child. 561021078554b902179442a345a9d080a165c3b5139Svetoslav Ganov */ 562021078554b902179442a345a9d080a165c3b5139Svetoslav Ganov public void addChild(View root, int virtualDescendantId) { 5638643aa0179e598e78d938c59035389054535a229Svetoslav Ganov enforceNotSealed(); 56457c7fd5a43237afc5e8ef31a076e862c0c16c328Svetoslav Ganov final int index = mChildNodeIds.size(); 565021078554b902179442a345a9d080a165c3b5139Svetoslav Ganov final int rootAccessibilityViewId = 566f3b4f3163b5b4c0a54a2643f07c97c47b14a1eb7Svetoslav Ganov (root != null) ? root.getAccessibilityViewId() : UNDEFINED; 567021078554b902179442a345a9d080a165c3b5139Svetoslav Ganov final long childNodeId = makeNodeId(rootAccessibilityViewId, virtualDescendantId); 56857c7fd5a43237afc5e8ef31a076e862c0c16c328Svetoslav Ganov mChildNodeIds.put(index, childNodeId); 5698643aa0179e598e78d938c59035389054535a229Svetoslav Ganov } 5708643aa0179e598e78d938c59035389054535a229Svetoslav Ganov 5718643aa0179e598e78d938c59035389054535a229Svetoslav Ganov /** 5728643aa0179e598e78d938c59035389054535a229Svetoslav Ganov * Gets the actions that can be performed on the node. 5738643aa0179e598e78d938c59035389054535a229Svetoslav Ganov * 5748643aa0179e598e78d938c59035389054535a229Svetoslav Ganov * @return The bit mask of with actions. 5758643aa0179e598e78d938c59035389054535a229Svetoslav Ganov * 5768643aa0179e598e78d938c59035389054535a229Svetoslav Ganov * @see AccessibilityNodeInfo#ACTION_FOCUS 5778643aa0179e598e78d938c59035389054535a229Svetoslav Ganov * @see AccessibilityNodeInfo#ACTION_CLEAR_FOCUS 5788643aa0179e598e78d938c59035389054535a229Svetoslav Ganov * @see AccessibilityNodeInfo#ACTION_SELECT 5798643aa0179e598e78d938c59035389054535a229Svetoslav Ganov * @see AccessibilityNodeInfo#ACTION_CLEAR_SELECTION 580a1dc761c8322355eb1bb71d3d6c9c603c1d1fc0fSvetoslav Ganov * @see AccessibilityNodeInfo#ACTION_ACCESSIBILITY_FOCUS 581a1dc761c8322355eb1bb71d3d6c9c603c1d1fc0fSvetoslav Ganov * @see AccessibilityNodeInfo#ACTION_CLEAR_ACCESSIBILITY_FOCUS 582a1dc761c8322355eb1bb71d3d6c9c603c1d1fc0fSvetoslav Ganov * @see AccessibilityNodeInfo#ACTION_CLICK 583a1dc761c8322355eb1bb71d3d6c9c603c1d1fc0fSvetoslav Ganov * @see AccessibilityNodeInfo#ACTION_LONG_CLICK 584a1dc761c8322355eb1bb71d3d6c9c603c1d1fc0fSvetoslav Ganov * @see AccessibilityNodeInfo#ACTION_NEXT_AT_MOVEMENT_GRANULARITY 585a1dc761c8322355eb1bb71d3d6c9c603c1d1fc0fSvetoslav Ganov * @see AccessibilityNodeInfo#ACTION_PREVIOUS_AT_MOVEMENT_GRANULARITY 586a1dc761c8322355eb1bb71d3d6c9c603c1d1fc0fSvetoslav Ganov * @see AccessibilityNodeInfo#ACTION_NEXT_HTML_ELEMENT 587a1dc761c8322355eb1bb71d3d6c9c603c1d1fc0fSvetoslav Ganov * @see AccessibilityNodeInfo#ACTION_PREVIOUS_HTML_ELEMENT 588a1dc761c8322355eb1bb71d3d6c9c603c1d1fc0fSvetoslav Ganov * @see AccessibilityNodeInfo#ACTION_SCROLL_FORWARD 589a1dc761c8322355eb1bb71d3d6c9c603c1d1fc0fSvetoslav Ganov * @see AccessibilityNodeInfo#ACTION_SCROLL_BACKWARD 5908643aa0179e598e78d938c59035389054535a229Svetoslav Ganov */ 5918643aa0179e598e78d938c59035389054535a229Svetoslav Ganov public int getActions() { 5928643aa0179e598e78d938c59035389054535a229Svetoslav Ganov return mActions; 5938643aa0179e598e78d938c59035389054535a229Svetoslav Ganov } 5948643aa0179e598e78d938c59035389054535a229Svetoslav Ganov 5958643aa0179e598e78d938c59035389054535a229Svetoslav Ganov /** 5968643aa0179e598e78d938c59035389054535a229Svetoslav Ganov * Adds an action that can be performed on the node. 5978643aa0179e598e78d938c59035389054535a229Svetoslav Ganov * <p> 59838e8b4e5bc3c93affdffbc064fd9db5aeccc3e8eSvetoslav Ganov * <strong>Note:</strong> Cannot be called from an 59938e8b4e5bc3c93affdffbc064fd9db5aeccc3e8eSvetoslav Ganov * {@link android.accessibilityservice.AccessibilityService}. 6008643aa0179e598e78d938c59035389054535a229Svetoslav Ganov * This class is made immutable before being delivered to an AccessibilityService. 6018643aa0179e598e78d938c59035389054535a229Svetoslav Ganov * </p> 60238e8b4e5bc3c93affdffbc064fd9db5aeccc3e8eSvetoslav Ganov * 6038643aa0179e598e78d938c59035389054535a229Svetoslav Ganov * @param action The action. 6048643aa0179e598e78d938c59035389054535a229Svetoslav Ganov * 6058643aa0179e598e78d938c59035389054535a229Svetoslav Ganov * @throws IllegalStateException If called from an AccessibilityService. 6068643aa0179e598e78d938c59035389054535a229Svetoslav Ganov */ 6078643aa0179e598e78d938c59035389054535a229Svetoslav Ganov public void addAction(int action) { 6088643aa0179e598e78d938c59035389054535a229Svetoslav Ganov enforceNotSealed(); 6098643aa0179e598e78d938c59035389054535a229Svetoslav Ganov mActions |= action; 6108643aa0179e598e78d938c59035389054535a229Svetoslav Ganov } 6118643aa0179e598e78d938c59035389054535a229Svetoslav Ganov 6128643aa0179e598e78d938c59035389054535a229Svetoslav Ganov /** 6132b435aada3d274a9c08d334946fff1ab9ba15b48Svetoslav Ganov * Sets the movement granularities for traversing the text of this node. 614aa780c110922148a6a4ba06734bb2b0bb8c98f93Svetoslav Ganov * <p> 615aa780c110922148a6a4ba06734bb2b0bb8c98f93Svetoslav Ganov * <strong>Note:</strong> Cannot be called from an 616aa780c110922148a6a4ba06734bb2b0bb8c98f93Svetoslav Ganov * {@link android.accessibilityservice.AccessibilityService}. 617aa780c110922148a6a4ba06734bb2b0bb8c98f93Svetoslav Ganov * This class is made immutable before being delivered to an AccessibilityService. 618aa780c110922148a6a4ba06734bb2b0bb8c98f93Svetoslav Ganov * </p> 619aa780c110922148a6a4ba06734bb2b0bb8c98f93Svetoslav Ganov * 620b7ff3255c6d4e12f9d2334e3bbec0a125b7b09dcSvetoslav Ganov * @param granularities The bit mask with granularities. 621aa780c110922148a6a4ba06734bb2b0bb8c98f93Svetoslav Ganov * 622aa780c110922148a6a4ba06734bb2b0bb8c98f93Svetoslav Ganov * @throws IllegalStateException If called from an AccessibilityService. 623aa780c110922148a6a4ba06734bb2b0bb8c98f93Svetoslav Ganov */ 6242b435aada3d274a9c08d334946fff1ab9ba15b48Svetoslav Ganov public void setMovementGranularities(int granularities) { 625aa780c110922148a6a4ba06734bb2b0bb8c98f93Svetoslav Ganov enforceNotSealed(); 6262b435aada3d274a9c08d334946fff1ab9ba15b48Svetoslav Ganov mMovementGranularities = granularities; 627aa780c110922148a6a4ba06734bb2b0bb8c98f93Svetoslav Ganov } 628aa780c110922148a6a4ba06734bb2b0bb8c98f93Svetoslav Ganov 629aa780c110922148a6a4ba06734bb2b0bb8c98f93Svetoslav Ganov /** 6302b435aada3d274a9c08d334946fff1ab9ba15b48Svetoslav Ganov * Gets the movement granularities for traversing the text of this node. 631aa780c110922148a6a4ba06734bb2b0bb8c98f93Svetoslav Ganov * 632b7ff3255c6d4e12f9d2334e3bbec0a125b7b09dcSvetoslav Ganov * @return The bit mask with granularities. 633aa780c110922148a6a4ba06734bb2b0bb8c98f93Svetoslav Ganov */ 6342b435aada3d274a9c08d334946fff1ab9ba15b48Svetoslav Ganov public int getMovementGranularities() { 6352b435aada3d274a9c08d334946fff1ab9ba15b48Svetoslav Ganov return mMovementGranularities; 636aa780c110922148a6a4ba06734bb2b0bb8c98f93Svetoslav Ganov } 637aa780c110922148a6a4ba06734bb2b0bb8c98f93Svetoslav Ganov 638aa780c110922148a6a4ba06734bb2b0bb8c98f93Svetoslav Ganov /** 6398643aa0179e598e78d938c59035389054535a229Svetoslav Ganov * Performs an action on the node. 6408643aa0179e598e78d938c59035389054535a229Svetoslav Ganov * <p> 64138e8b4e5bc3c93affdffbc064fd9db5aeccc3e8eSvetoslav Ganov * <strong>Note:</strong> An action can be performed only if the request is made 6428643aa0179e598e78d938c59035389054535a229Svetoslav Ganov * from an {@link android.accessibilityservice.AccessibilityService}. 6438643aa0179e598e78d938c59035389054535a229Svetoslav Ganov * </p> 64438e8b4e5bc3c93affdffbc064fd9db5aeccc3e8eSvetoslav Ganov * 6458643aa0179e598e78d938c59035389054535a229Svetoslav Ganov * @param action The action to perform. 6468643aa0179e598e78d938c59035389054535a229Svetoslav Ganov * @return True if the action was performed. 6478643aa0179e598e78d938c59035389054535a229Svetoslav Ganov * 6488643aa0179e598e78d938c59035389054535a229Svetoslav Ganov * @throws IllegalStateException If called outside of an AccessibilityService. 6498643aa0179e598e78d938c59035389054535a229Svetoslav Ganov */ 6508643aa0179e598e78d938c59035389054535a229Svetoslav Ganov public boolean performAction(int action) { 6518643aa0179e598e78d938c59035389054535a229Svetoslav Ganov enforceSealed(); 652021078554b902179442a345a9d080a165c3b5139Svetoslav Ganov if (!canPerformRequestOverConnection(mSourceNodeId)) { 653eeee4d2c01d3c4ed99e4891dbc75c7de69a803faSvetoslav Ganov return false; 654eeee4d2c01d3c4ed99e4891dbc75c7de69a803faSvetoslav Ganov } 6558bd69610aafc6995126965d1d23b771fe02a9084Svetoslav Ganov AccessibilityInteractionClient client = AccessibilityInteractionClient.getInstance(); 656aa780c110922148a6a4ba06734bb2b0bb8c98f93Svetoslav Ganov return client.performAccessibilityAction(mConnectionId, mWindowId, mSourceNodeId, 657aa780c110922148a6a4ba06734bb2b0bb8c98f93Svetoslav Ganov action, null); 658aa780c110922148a6a4ba06734bb2b0bb8c98f93Svetoslav Ganov } 659aa780c110922148a6a4ba06734bb2b0bb8c98f93Svetoslav Ganov 660aa780c110922148a6a4ba06734bb2b0bb8c98f93Svetoslav Ganov /** 661aa780c110922148a6a4ba06734bb2b0bb8c98f93Svetoslav Ganov * Performs an action on the node. 662aa780c110922148a6a4ba06734bb2b0bb8c98f93Svetoslav Ganov * <p> 663aa780c110922148a6a4ba06734bb2b0bb8c98f93Svetoslav Ganov * <strong>Note:</strong> An action can be performed only if the request is made 664aa780c110922148a6a4ba06734bb2b0bb8c98f93Svetoslav Ganov * from an {@link android.accessibilityservice.AccessibilityService}. 665aa780c110922148a6a4ba06734bb2b0bb8c98f93Svetoslav Ganov * </p> 666aa780c110922148a6a4ba06734bb2b0bb8c98f93Svetoslav Ganov * 667aa780c110922148a6a4ba06734bb2b0bb8c98f93Svetoslav Ganov * @param action The action to perform. 668aa780c110922148a6a4ba06734bb2b0bb8c98f93Svetoslav Ganov * @param arguments A bundle with additional arguments. 669aa780c110922148a6a4ba06734bb2b0bb8c98f93Svetoslav Ganov * @return True if the action was performed. 670aa780c110922148a6a4ba06734bb2b0bb8c98f93Svetoslav Ganov * 671aa780c110922148a6a4ba06734bb2b0bb8c98f93Svetoslav Ganov * @throws IllegalStateException If called outside of an AccessibilityService. 672aa780c110922148a6a4ba06734bb2b0bb8c98f93Svetoslav Ganov */ 673aa780c110922148a6a4ba06734bb2b0bb8c98f93Svetoslav Ganov public boolean performAction(int action, Bundle arguments) { 674aa780c110922148a6a4ba06734bb2b0bb8c98f93Svetoslav Ganov enforceSealed(); 675aa780c110922148a6a4ba06734bb2b0bb8c98f93Svetoslav Ganov if (!canPerformRequestOverConnection(mSourceNodeId)) { 676aa780c110922148a6a4ba06734bb2b0bb8c98f93Svetoslav Ganov return false; 677aa780c110922148a6a4ba06734bb2b0bb8c98f93Svetoslav Ganov } 678aa780c110922148a6a4ba06734bb2b0bb8c98f93Svetoslav Ganov AccessibilityInteractionClient client = AccessibilityInteractionClient.getInstance(); 679aa780c110922148a6a4ba06734bb2b0bb8c98f93Svetoslav Ganov return client.performAccessibilityAction(mConnectionId, mWindowId, mSourceNodeId, 680aa780c110922148a6a4ba06734bb2b0bb8c98f93Svetoslav Ganov action, arguments); 681eeee4d2c01d3c4ed99e4891dbc75c7de69a803faSvetoslav Ganov } 682eeee4d2c01d3c4ed99e4891dbc75c7de69a803faSvetoslav Ganov 683eeee4d2c01d3c4ed99e4891dbc75c7de69a803faSvetoslav Ganov /** 684eeee4d2c01d3c4ed99e4891dbc75c7de69a803faSvetoslav Ganov * Finds {@link AccessibilityNodeInfo}s by text. The match is case 68586398bda3dd869c67faa841a5d961316b5f4aa8aSvetoslav Ganov * insensitive containment. The search is relative to this info i.e. 68686398bda3dd869c67faa841a5d961316b5f4aa8aSvetoslav Ganov * this info is the root of the traversed tree. 687ea515aeafa01de6f50c854ee381b972ef2478284Svetoslav Ganov * 68838e8b4e5bc3c93affdffbc064fd9db5aeccc3e8eSvetoslav Ganov * <p> 68938e8b4e5bc3c93affdffbc064fd9db5aeccc3e8eSvetoslav Ganov * <strong>Note:</strong> It is a client responsibility to recycle the 69038e8b4e5bc3c93affdffbc064fd9db5aeccc3e8eSvetoslav Ganov * received info by calling {@link AccessibilityNodeInfo#recycle()} 69138e8b4e5bc3c93affdffbc064fd9db5aeccc3e8eSvetoslav Ganov * to avoid creating of multiple instances. 69238e8b4e5bc3c93affdffbc064fd9db5aeccc3e8eSvetoslav Ganov * </p> 693eeee4d2c01d3c4ed99e4891dbc75c7de69a803faSvetoslav Ganov * 694eeee4d2c01d3c4ed99e4891dbc75c7de69a803faSvetoslav Ganov * @param text The searched text. 695eeee4d2c01d3c4ed99e4891dbc75c7de69a803faSvetoslav Ganov * @return A list of node info. 696eeee4d2c01d3c4ed99e4891dbc75c7de69a803faSvetoslav Ganov */ 697eeee4d2c01d3c4ed99e4891dbc75c7de69a803faSvetoslav Ganov public List<AccessibilityNodeInfo> findAccessibilityNodeInfosByText(String text) { 698eeee4d2c01d3c4ed99e4891dbc75c7de69a803faSvetoslav Ganov enforceSealed(); 699021078554b902179442a345a9d080a165c3b5139Svetoslav Ganov if (!canPerformRequestOverConnection(mSourceNodeId)) { 70086398bda3dd869c67faa841a5d961316b5f4aa8aSvetoslav Ganov return Collections.emptyList(); 701eeee4d2c01d3c4ed99e4891dbc75c7de69a803faSvetoslav Ganov } 7028bd69610aafc6995126965d1d23b771fe02a9084Svetoslav Ganov AccessibilityInteractionClient client = AccessibilityInteractionClient.getInstance(); 70379311c4af8b54d3cd47ab37a120c648bfc990511Svetoslav Ganov return client.findAccessibilityNodeInfosByText(mConnectionId, mWindowId, mSourceNodeId, 70479311c4af8b54d3cd47ab37a120c648bfc990511Svetoslav Ganov text); 7058643aa0179e598e78d938c59035389054535a229Svetoslav Ganov } 7068643aa0179e598e78d938c59035389054535a229Svetoslav Ganov 7078643aa0179e598e78d938c59035389054535a229Svetoslav Ganov /** 70800aabf7d187bc05408199bd687a538b2e68bdc17Svetoslav Ganov * Gets the parent. 7098643aa0179e598e78d938c59035389054535a229Svetoslav Ganov * <p> 71038e8b4e5bc3c93affdffbc064fd9db5aeccc3e8eSvetoslav Ganov * <strong>Note:</strong> It is a client responsibility to recycle the 71138e8b4e5bc3c93affdffbc064fd9db5aeccc3e8eSvetoslav Ganov * received info by calling {@link AccessibilityNodeInfo#recycle()} 71238e8b4e5bc3c93affdffbc064fd9db5aeccc3e8eSvetoslav Ganov * to avoid creating of multiple instances. 7138643aa0179e598e78d938c59035389054535a229Svetoslav Ganov * </p> 71438e8b4e5bc3c93affdffbc064fd9db5aeccc3e8eSvetoslav Ganov * 71500aabf7d187bc05408199bd687a538b2e68bdc17Svetoslav Ganov * @return The parent. 7168643aa0179e598e78d938c59035389054535a229Svetoslav Ganov */ 7178643aa0179e598e78d938c59035389054535a229Svetoslav Ganov public AccessibilityNodeInfo getParent() { 7188643aa0179e598e78d938c59035389054535a229Svetoslav Ganov enforceSealed(); 719af0d984a5850666a374d6f7fc690664d33d57568Svetoslav Ganov if (!canPerformRequestOverConnection(mParentNodeId)) { 720eeee4d2c01d3c4ed99e4891dbc75c7de69a803faSvetoslav Ganov return null; 721eeee4d2c01d3c4ed99e4891dbc75c7de69a803faSvetoslav Ganov } 7228bd69610aafc6995126965d1d23b771fe02a9084Svetoslav Ganov AccessibilityInteractionClient client = AccessibilityInteractionClient.getInstance(); 723d116d7c78a9c53f30a73bf273bd7618312cf3847Svetoslav Ganov return client.findAccessibilityNodeInfoByAccessibilityId(mConnectionId, 72457c7fd5a43237afc5e8ef31a076e862c0c16c328Svetoslav Ganov mWindowId, mParentNodeId, FLAG_PREFETCH_DESCENDANTS | FLAG_PREFETCH_SIBLINGS); 72557c7fd5a43237afc5e8ef31a076e862c0c16c328Svetoslav Ganov } 72657c7fd5a43237afc5e8ef31a076e862c0c16c328Svetoslav Ganov 72757c7fd5a43237afc5e8ef31a076e862c0c16c328Svetoslav Ganov /** 72857c7fd5a43237afc5e8ef31a076e862c0c16c328Svetoslav Ganov * @return The parent node id. 72957c7fd5a43237afc5e8ef31a076e862c0c16c328Svetoslav Ganov * 73057c7fd5a43237afc5e8ef31a076e862c0c16c328Svetoslav Ganov * @hide 73157c7fd5a43237afc5e8ef31a076e862c0c16c328Svetoslav Ganov */ 73257c7fd5a43237afc5e8ef31a076e862c0c16c328Svetoslav Ganov public long getParentNodeId() { 73357c7fd5a43237afc5e8ef31a076e862c0c16c328Svetoslav Ganov return mParentNodeId; 7348643aa0179e598e78d938c59035389054535a229Svetoslav Ganov } 7358643aa0179e598e78d938c59035389054535a229Svetoslav Ganov 7368643aa0179e598e78d938c59035389054535a229Svetoslav Ganov /** 7378643aa0179e598e78d938c59035389054535a229Svetoslav Ganov * Sets the parent. 7388643aa0179e598e78d938c59035389054535a229Svetoslav Ganov * <p> 73938e8b4e5bc3c93affdffbc064fd9db5aeccc3e8eSvetoslav Ganov * <strong>Note:</strong> Cannot be called from an 74038e8b4e5bc3c93affdffbc064fd9db5aeccc3e8eSvetoslav Ganov * {@link android.accessibilityservice.AccessibilityService}. 7418643aa0179e598e78d938c59035389054535a229Svetoslav Ganov * This class is made immutable before being delivered to an AccessibilityService. 7428643aa0179e598e78d938c59035389054535a229Svetoslav Ganov * </p> 74338e8b4e5bc3c93affdffbc064fd9db5aeccc3e8eSvetoslav Ganov * 7448643aa0179e598e78d938c59035389054535a229Svetoslav Ganov * @param parent The parent. 7458643aa0179e598e78d938c59035389054535a229Svetoslav Ganov * 7468643aa0179e598e78d938c59035389054535a229Svetoslav Ganov * @throws IllegalStateException If called from an AccessibilityService. 7478643aa0179e598e78d938c59035389054535a229Svetoslav Ganov */ 7488643aa0179e598e78d938c59035389054535a229Svetoslav Ganov public void setParent(View parent) { 749f3b4f3163b5b4c0a54a2643f07c97c47b14a1eb7Svetoslav Ganov setParent(parent, UNDEFINED); 750021078554b902179442a345a9d080a165c3b5139Svetoslav Ganov } 751021078554b902179442a345a9d080a165c3b5139Svetoslav Ganov 752021078554b902179442a345a9d080a165c3b5139Svetoslav Ganov /** 753021078554b902179442a345a9d080a165c3b5139Svetoslav Ganov * Sets the parent to be a virtual descendant of the given <code>root</code>. 754021078554b902179442a345a9d080a165c3b5139Svetoslav Ganov * If <code>virtualDescendantId</code> equals to {@link View#NO_ID} the root 755021078554b902179442a345a9d080a165c3b5139Svetoslav Ganov * is set as the parent. 756021078554b902179442a345a9d080a165c3b5139Svetoslav Ganov * <p> 757021078554b902179442a345a9d080a165c3b5139Svetoslav Ganov * A virtual descendant is an imaginary View that is reported as a part of the view 758021078554b902179442a345a9d080a165c3b5139Svetoslav Ganov * hierarchy for accessibility purposes. This enables custom views that draw complex 759021078554b902179442a345a9d080a165c3b5139Svetoslav Ganov * content to report them selves as a tree of virtual views, thus conveying their 760021078554b902179442a345a9d080a165c3b5139Svetoslav Ganov * logical structure. 761021078554b902179442a345a9d080a165c3b5139Svetoslav Ganov * </p> 762021078554b902179442a345a9d080a165c3b5139Svetoslav Ganov * <p> 763021078554b902179442a345a9d080a165c3b5139Svetoslav Ganov * <strong>Note:</strong> Cannot be called from an 764021078554b902179442a345a9d080a165c3b5139Svetoslav Ganov * {@link android.accessibilityservice.AccessibilityService}. 765021078554b902179442a345a9d080a165c3b5139Svetoslav Ganov * This class is made immutable before being delivered to an AccessibilityService. 766021078554b902179442a345a9d080a165c3b5139Svetoslav Ganov * </p> 767021078554b902179442a345a9d080a165c3b5139Svetoslav Ganov * 768021078554b902179442a345a9d080a165c3b5139Svetoslav Ganov * @param root The root of the virtual subtree. 769021078554b902179442a345a9d080a165c3b5139Svetoslav Ganov * @param virtualDescendantId The id of the virtual descendant. 770021078554b902179442a345a9d080a165c3b5139Svetoslav Ganov */ 771021078554b902179442a345a9d080a165c3b5139Svetoslav Ganov public void setParent(View root, int virtualDescendantId) { 7728643aa0179e598e78d938c59035389054535a229Svetoslav Ganov enforceNotSealed(); 773021078554b902179442a345a9d080a165c3b5139Svetoslav Ganov final int rootAccessibilityViewId = 774f3b4f3163b5b4c0a54a2643f07c97c47b14a1eb7Svetoslav Ganov (root != null) ? root.getAccessibilityViewId() : UNDEFINED; 775021078554b902179442a345a9d080a165c3b5139Svetoslav Ganov mParentNodeId = makeNodeId(rootAccessibilityViewId, virtualDescendantId); 7768643aa0179e598e78d938c59035389054535a229Svetoslav Ganov } 7778643aa0179e598e78d938c59035389054535a229Svetoslav Ganov 7788643aa0179e598e78d938c59035389054535a229Svetoslav Ganov /** 7798643aa0179e598e78d938c59035389054535a229Svetoslav Ganov * Gets the node bounds in parent coordinates. 7808643aa0179e598e78d938c59035389054535a229Svetoslav Ganov * 7818643aa0179e598e78d938c59035389054535a229Svetoslav Ganov * @param outBounds The output node bounds. 7828643aa0179e598e78d938c59035389054535a229Svetoslav Ganov */ 783eeee4d2c01d3c4ed99e4891dbc75c7de69a803faSvetoslav Ganov public void getBoundsInParent(Rect outBounds) { 784eeee4d2c01d3c4ed99e4891dbc75c7de69a803faSvetoslav Ganov outBounds.set(mBoundsInParent.left, mBoundsInParent.top, 785eeee4d2c01d3c4ed99e4891dbc75c7de69a803faSvetoslav Ganov mBoundsInParent.right, mBoundsInParent.bottom); 7868643aa0179e598e78d938c59035389054535a229Svetoslav Ganov } 7878643aa0179e598e78d938c59035389054535a229Svetoslav Ganov 7888643aa0179e598e78d938c59035389054535a229Svetoslav Ganov /** 7898643aa0179e598e78d938c59035389054535a229Svetoslav Ganov * Sets the node bounds in parent coordinates. 7908643aa0179e598e78d938c59035389054535a229Svetoslav Ganov * <p> 79138e8b4e5bc3c93affdffbc064fd9db5aeccc3e8eSvetoslav Ganov * <strong>Note:</strong> Cannot be called from an 79238e8b4e5bc3c93affdffbc064fd9db5aeccc3e8eSvetoslav Ganov * {@link android.accessibilityservice.AccessibilityService}. 7938643aa0179e598e78d938c59035389054535a229Svetoslav Ganov * This class is made immutable before being delivered to an AccessibilityService. 7948643aa0179e598e78d938c59035389054535a229Svetoslav Ganov * </p> 79538e8b4e5bc3c93affdffbc064fd9db5aeccc3e8eSvetoslav Ganov * 7968643aa0179e598e78d938c59035389054535a229Svetoslav Ganov * @param bounds The node bounds. 7978643aa0179e598e78d938c59035389054535a229Svetoslav Ganov * 7988643aa0179e598e78d938c59035389054535a229Svetoslav Ganov * @throws IllegalStateException If called from an AccessibilityService. 7998643aa0179e598e78d938c59035389054535a229Svetoslav Ganov */ 800eeee4d2c01d3c4ed99e4891dbc75c7de69a803faSvetoslav Ganov public void setBoundsInParent(Rect bounds) { 8018643aa0179e598e78d938c59035389054535a229Svetoslav Ganov enforceNotSealed(); 802eeee4d2c01d3c4ed99e4891dbc75c7de69a803faSvetoslav Ganov mBoundsInParent.set(bounds.left, bounds.top, bounds.right, bounds.bottom); 803eeee4d2c01d3c4ed99e4891dbc75c7de69a803faSvetoslav Ganov } 804eeee4d2c01d3c4ed99e4891dbc75c7de69a803faSvetoslav Ganov 805eeee4d2c01d3c4ed99e4891dbc75c7de69a803faSvetoslav Ganov /** 806eeee4d2c01d3c4ed99e4891dbc75c7de69a803faSvetoslav Ganov * Gets the node bounds in screen coordinates. 807eeee4d2c01d3c4ed99e4891dbc75c7de69a803faSvetoslav Ganov * 808eeee4d2c01d3c4ed99e4891dbc75c7de69a803faSvetoslav Ganov * @param outBounds The output node bounds. 809eeee4d2c01d3c4ed99e4891dbc75c7de69a803faSvetoslav Ganov */ 810eeee4d2c01d3c4ed99e4891dbc75c7de69a803faSvetoslav Ganov public void getBoundsInScreen(Rect outBounds) { 811eeee4d2c01d3c4ed99e4891dbc75c7de69a803faSvetoslav Ganov outBounds.set(mBoundsInScreen.left, mBoundsInScreen.top, 812eeee4d2c01d3c4ed99e4891dbc75c7de69a803faSvetoslav Ganov mBoundsInScreen.right, mBoundsInScreen.bottom); 813eeee4d2c01d3c4ed99e4891dbc75c7de69a803faSvetoslav Ganov } 814eeee4d2c01d3c4ed99e4891dbc75c7de69a803faSvetoslav Ganov 815eeee4d2c01d3c4ed99e4891dbc75c7de69a803faSvetoslav Ganov /** 816eeee4d2c01d3c4ed99e4891dbc75c7de69a803faSvetoslav Ganov * Sets the node bounds in screen coordinates. 817eeee4d2c01d3c4ed99e4891dbc75c7de69a803faSvetoslav Ganov * <p> 81838e8b4e5bc3c93affdffbc064fd9db5aeccc3e8eSvetoslav Ganov * <strong>Note:</strong> Cannot be called from an 81938e8b4e5bc3c93affdffbc064fd9db5aeccc3e8eSvetoslav Ganov * {@link android.accessibilityservice.AccessibilityService}. 820eeee4d2c01d3c4ed99e4891dbc75c7de69a803faSvetoslav Ganov * This class is made immutable before being delivered to an AccessibilityService. 821eeee4d2c01d3c4ed99e4891dbc75c7de69a803faSvetoslav Ganov * </p> 82238e8b4e5bc3c93affdffbc064fd9db5aeccc3e8eSvetoslav Ganov * 823eeee4d2c01d3c4ed99e4891dbc75c7de69a803faSvetoslav Ganov * @param bounds The node bounds. 824eeee4d2c01d3c4ed99e4891dbc75c7de69a803faSvetoslav Ganov * 825eeee4d2c01d3c4ed99e4891dbc75c7de69a803faSvetoslav Ganov * @throws IllegalStateException If called from an AccessibilityService. 826eeee4d2c01d3c4ed99e4891dbc75c7de69a803faSvetoslav Ganov */ 827eeee4d2c01d3c4ed99e4891dbc75c7de69a803faSvetoslav Ganov public void setBoundsInScreen(Rect bounds) { 828eeee4d2c01d3c4ed99e4891dbc75c7de69a803faSvetoslav Ganov enforceNotSealed(); 829eeee4d2c01d3c4ed99e4891dbc75c7de69a803faSvetoslav Ganov mBoundsInScreen.set(bounds.left, bounds.top, bounds.right, bounds.bottom); 8308643aa0179e598e78d938c59035389054535a229Svetoslav Ganov } 8318643aa0179e598e78d938c59035389054535a229Svetoslav Ganov 8328643aa0179e598e78d938c59035389054535a229Svetoslav Ganov /** 8338643aa0179e598e78d938c59035389054535a229Svetoslav Ganov * Gets whether this node is checkable. 8348643aa0179e598e78d938c59035389054535a229Svetoslav Ganov * 8358643aa0179e598e78d938c59035389054535a229Svetoslav Ganov * @return True if the node is checkable. 8368643aa0179e598e78d938c59035389054535a229Svetoslav Ganov */ 8378643aa0179e598e78d938c59035389054535a229Svetoslav Ganov public boolean isCheckable() { 8388643aa0179e598e78d938c59035389054535a229Svetoslav Ganov return getBooleanProperty(PROPERTY_CHECKABLE); 8398643aa0179e598e78d938c59035389054535a229Svetoslav Ganov } 8408643aa0179e598e78d938c59035389054535a229Svetoslav Ganov 8418643aa0179e598e78d938c59035389054535a229Svetoslav Ganov /** 8428643aa0179e598e78d938c59035389054535a229Svetoslav Ganov * Sets whether this node is checkable. 8438643aa0179e598e78d938c59035389054535a229Svetoslav Ganov * <p> 84438e8b4e5bc3c93affdffbc064fd9db5aeccc3e8eSvetoslav Ganov * <strong>Note:</strong> Cannot be called from an 84538e8b4e5bc3c93affdffbc064fd9db5aeccc3e8eSvetoslav Ganov * {@link android.accessibilityservice.AccessibilityService}. 8468643aa0179e598e78d938c59035389054535a229Svetoslav Ganov * This class is made immutable before being delivered to an AccessibilityService. 8478643aa0179e598e78d938c59035389054535a229Svetoslav Ganov * </p> 84838e8b4e5bc3c93affdffbc064fd9db5aeccc3e8eSvetoslav Ganov * 8498643aa0179e598e78d938c59035389054535a229Svetoslav Ganov * @param checkable True if the node is checkable. 8508643aa0179e598e78d938c59035389054535a229Svetoslav Ganov * 8518643aa0179e598e78d938c59035389054535a229Svetoslav Ganov * @throws IllegalStateException If called from an AccessibilityService. 8528643aa0179e598e78d938c59035389054535a229Svetoslav Ganov */ 8538643aa0179e598e78d938c59035389054535a229Svetoslav Ganov public void setCheckable(boolean checkable) { 8548643aa0179e598e78d938c59035389054535a229Svetoslav Ganov setBooleanProperty(PROPERTY_CHECKABLE, checkable); 8558643aa0179e598e78d938c59035389054535a229Svetoslav Ganov } 8568643aa0179e598e78d938c59035389054535a229Svetoslav Ganov 8578643aa0179e598e78d938c59035389054535a229Svetoslav Ganov /** 8588643aa0179e598e78d938c59035389054535a229Svetoslav Ganov * Gets whether this node is checked. 8598643aa0179e598e78d938c59035389054535a229Svetoslav Ganov * 8608643aa0179e598e78d938c59035389054535a229Svetoslav Ganov * @return True if the node is checked. 8618643aa0179e598e78d938c59035389054535a229Svetoslav Ganov */ 8628643aa0179e598e78d938c59035389054535a229Svetoslav Ganov public boolean isChecked() { 8638643aa0179e598e78d938c59035389054535a229Svetoslav Ganov return getBooleanProperty(PROPERTY_CHECKED); 8648643aa0179e598e78d938c59035389054535a229Svetoslav Ganov } 8658643aa0179e598e78d938c59035389054535a229Svetoslav Ganov 8668643aa0179e598e78d938c59035389054535a229Svetoslav Ganov /** 8678643aa0179e598e78d938c59035389054535a229Svetoslav Ganov * Sets whether this node is checked. 8688643aa0179e598e78d938c59035389054535a229Svetoslav Ganov * <p> 86938e8b4e5bc3c93affdffbc064fd9db5aeccc3e8eSvetoslav Ganov * <strong>Note:</strong> Cannot be called from an 87038e8b4e5bc3c93affdffbc064fd9db5aeccc3e8eSvetoslav Ganov * {@link android.accessibilityservice.AccessibilityService}. 8718643aa0179e598e78d938c59035389054535a229Svetoslav Ganov * This class is made immutable before being delivered to an AccessibilityService. 8728643aa0179e598e78d938c59035389054535a229Svetoslav Ganov * </p> 87338e8b4e5bc3c93affdffbc064fd9db5aeccc3e8eSvetoslav Ganov * 8748643aa0179e598e78d938c59035389054535a229Svetoslav Ganov * @param checked True if the node is checked. 8758643aa0179e598e78d938c59035389054535a229Svetoslav Ganov * 8768643aa0179e598e78d938c59035389054535a229Svetoslav Ganov * @throws IllegalStateException If called from an AccessibilityService. 8778643aa0179e598e78d938c59035389054535a229Svetoslav Ganov */ 8788643aa0179e598e78d938c59035389054535a229Svetoslav Ganov public void setChecked(boolean checked) { 8798643aa0179e598e78d938c59035389054535a229Svetoslav Ganov setBooleanProperty(PROPERTY_CHECKED, checked); 8808643aa0179e598e78d938c59035389054535a229Svetoslav Ganov } 8818643aa0179e598e78d938c59035389054535a229Svetoslav Ganov 8828643aa0179e598e78d938c59035389054535a229Svetoslav Ganov /** 8838643aa0179e598e78d938c59035389054535a229Svetoslav Ganov * Gets whether this node is focusable. 8848643aa0179e598e78d938c59035389054535a229Svetoslav Ganov * 8858643aa0179e598e78d938c59035389054535a229Svetoslav Ganov * @return True if the node is focusable. 8868643aa0179e598e78d938c59035389054535a229Svetoslav Ganov */ 8878643aa0179e598e78d938c59035389054535a229Svetoslav Ganov public boolean isFocusable() { 8888643aa0179e598e78d938c59035389054535a229Svetoslav Ganov return getBooleanProperty(PROPERTY_FOCUSABLE); 8898643aa0179e598e78d938c59035389054535a229Svetoslav Ganov } 8908643aa0179e598e78d938c59035389054535a229Svetoslav Ganov 8918643aa0179e598e78d938c59035389054535a229Svetoslav Ganov /** 8928643aa0179e598e78d938c59035389054535a229Svetoslav Ganov * Sets whether this node is focusable. 8938643aa0179e598e78d938c59035389054535a229Svetoslav Ganov * <p> 89438e8b4e5bc3c93affdffbc064fd9db5aeccc3e8eSvetoslav Ganov * <strong>Note:</strong> Cannot be called from an 89538e8b4e5bc3c93affdffbc064fd9db5aeccc3e8eSvetoslav Ganov * {@link android.accessibilityservice.AccessibilityService}. 8968643aa0179e598e78d938c59035389054535a229Svetoslav Ganov * This class is made immutable before being delivered to an AccessibilityService. 8978643aa0179e598e78d938c59035389054535a229Svetoslav Ganov * </p> 89838e8b4e5bc3c93affdffbc064fd9db5aeccc3e8eSvetoslav Ganov * 8998643aa0179e598e78d938c59035389054535a229Svetoslav Ganov * @param focusable True if the node is focusable. 9008643aa0179e598e78d938c59035389054535a229Svetoslav Ganov * 9018643aa0179e598e78d938c59035389054535a229Svetoslav Ganov * @throws IllegalStateException If called from an AccessibilityService. 9028643aa0179e598e78d938c59035389054535a229Svetoslav Ganov */ 9038643aa0179e598e78d938c59035389054535a229Svetoslav Ganov public void setFocusable(boolean focusable) { 9048643aa0179e598e78d938c59035389054535a229Svetoslav Ganov setBooleanProperty(PROPERTY_FOCUSABLE, focusable); 9058643aa0179e598e78d938c59035389054535a229Svetoslav Ganov } 9068643aa0179e598e78d938c59035389054535a229Svetoslav Ganov 9078643aa0179e598e78d938c59035389054535a229Svetoslav Ganov /** 9088643aa0179e598e78d938c59035389054535a229Svetoslav Ganov * Gets whether this node is focused. 9098643aa0179e598e78d938c59035389054535a229Svetoslav Ganov * 9108643aa0179e598e78d938c59035389054535a229Svetoslav Ganov * @return True if the node is focused. 9118643aa0179e598e78d938c59035389054535a229Svetoslav Ganov */ 9128643aa0179e598e78d938c59035389054535a229Svetoslav Ganov public boolean isFocused() { 9138643aa0179e598e78d938c59035389054535a229Svetoslav Ganov return getBooleanProperty(PROPERTY_FOCUSED); 9148643aa0179e598e78d938c59035389054535a229Svetoslav Ganov } 9158643aa0179e598e78d938c59035389054535a229Svetoslav Ganov 9168643aa0179e598e78d938c59035389054535a229Svetoslav Ganov /** 9178643aa0179e598e78d938c59035389054535a229Svetoslav Ganov * Sets whether this node is focused. 9188643aa0179e598e78d938c59035389054535a229Svetoslav Ganov * <p> 91938e8b4e5bc3c93affdffbc064fd9db5aeccc3e8eSvetoslav Ganov * <strong>Note:</strong> Cannot be called from an 92038e8b4e5bc3c93affdffbc064fd9db5aeccc3e8eSvetoslav Ganov * {@link android.accessibilityservice.AccessibilityService}. 9218643aa0179e598e78d938c59035389054535a229Svetoslav Ganov * This class is made immutable before being delivered to an AccessibilityService. 9228643aa0179e598e78d938c59035389054535a229Svetoslav Ganov * </p> 92338e8b4e5bc3c93affdffbc064fd9db5aeccc3e8eSvetoslav Ganov * 9248643aa0179e598e78d938c59035389054535a229Svetoslav Ganov * @param focused True if the node is focused. 9258643aa0179e598e78d938c59035389054535a229Svetoslav Ganov * 9268643aa0179e598e78d938c59035389054535a229Svetoslav Ganov * @throws IllegalStateException If called from an AccessibilityService. 9278643aa0179e598e78d938c59035389054535a229Svetoslav Ganov */ 9288643aa0179e598e78d938c59035389054535a229Svetoslav Ganov public void setFocused(boolean focused) { 9298643aa0179e598e78d938c59035389054535a229Svetoslav Ganov setBooleanProperty(PROPERTY_FOCUSED, focused); 9308643aa0179e598e78d938c59035389054535a229Svetoslav Ganov } 9318643aa0179e598e78d938c59035389054535a229Svetoslav Ganov 9328643aa0179e598e78d938c59035389054535a229Svetoslav Ganov /** 9330a1bb6dffc358c01e10555c5c833edb7dba69659Svetoslav Ganov * Sets whether this node is visible to the user. 9340a1bb6dffc358c01e10555c5c833edb7dba69659Svetoslav Ganov * 9350a1bb6dffc358c01e10555c5c833edb7dba69659Svetoslav Ganov * @return Whether the node is visible to the user. 9360a1bb6dffc358c01e10555c5c833edb7dba69659Svetoslav Ganov */ 9370a1bb6dffc358c01e10555c5c833edb7dba69659Svetoslav Ganov public boolean isVisibleToUser() { 9380a1bb6dffc358c01e10555c5c833edb7dba69659Svetoslav Ganov return getBooleanProperty(PROPERTY_VISIBLE_TO_USER); 9390a1bb6dffc358c01e10555c5c833edb7dba69659Svetoslav Ganov } 9400a1bb6dffc358c01e10555c5c833edb7dba69659Svetoslav Ganov 9410a1bb6dffc358c01e10555c5c833edb7dba69659Svetoslav Ganov /** 9420a1bb6dffc358c01e10555c5c833edb7dba69659Svetoslav Ganov * Sets whether this node is visible to the user. 9430a1bb6dffc358c01e10555c5c833edb7dba69659Svetoslav Ganov * <p> 9440a1bb6dffc358c01e10555c5c833edb7dba69659Svetoslav Ganov * <strong>Note:</strong> Cannot be called from an 9450a1bb6dffc358c01e10555c5c833edb7dba69659Svetoslav Ganov * {@link android.accessibilityservice.AccessibilityService}. 9460a1bb6dffc358c01e10555c5c833edb7dba69659Svetoslav Ganov * This class is made immutable before being delivered to an AccessibilityService. 9470a1bb6dffc358c01e10555c5c833edb7dba69659Svetoslav Ganov * </p> 9480a1bb6dffc358c01e10555c5c833edb7dba69659Svetoslav Ganov * 9490a1bb6dffc358c01e10555c5c833edb7dba69659Svetoslav Ganov * @param visibleToUser Whether the node is visible to the user. 9500a1bb6dffc358c01e10555c5c833edb7dba69659Svetoslav Ganov * 9510a1bb6dffc358c01e10555c5c833edb7dba69659Svetoslav Ganov * @throws IllegalStateException If called from an AccessibilityService. 9520a1bb6dffc358c01e10555c5c833edb7dba69659Svetoslav Ganov */ 9530a1bb6dffc358c01e10555c5c833edb7dba69659Svetoslav Ganov public void setVisibleToUser(boolean visibleToUser) { 9540a1bb6dffc358c01e10555c5c833edb7dba69659Svetoslav Ganov setBooleanProperty(PROPERTY_VISIBLE_TO_USER, visibleToUser); 9550a1bb6dffc358c01e10555c5c833edb7dba69659Svetoslav Ganov } 9560a1bb6dffc358c01e10555c5c833edb7dba69659Svetoslav Ganov 9570a1bb6dffc358c01e10555c5c833edb7dba69659Svetoslav Ganov /** 9584213804541a8b05cd0587b138a2fd9a3b7fd9350Svetoslav Ganov * Gets whether this node is accessibility focused. 9594213804541a8b05cd0587b138a2fd9a3b7fd9350Svetoslav Ganov * 9604213804541a8b05cd0587b138a2fd9a3b7fd9350Svetoslav Ganov * @return True if the node is accessibility focused. 9614213804541a8b05cd0587b138a2fd9a3b7fd9350Svetoslav Ganov */ 9624213804541a8b05cd0587b138a2fd9a3b7fd9350Svetoslav Ganov public boolean isAccessibilityFocused() { 9634213804541a8b05cd0587b138a2fd9a3b7fd9350Svetoslav Ganov return getBooleanProperty(PROPERTY_ACCESSIBILITY_FOCUSED); 9644213804541a8b05cd0587b138a2fd9a3b7fd9350Svetoslav Ganov } 9654213804541a8b05cd0587b138a2fd9a3b7fd9350Svetoslav Ganov 9664213804541a8b05cd0587b138a2fd9a3b7fd9350Svetoslav Ganov /** 9674213804541a8b05cd0587b138a2fd9a3b7fd9350Svetoslav Ganov * Sets whether this node is accessibility focused. 9684213804541a8b05cd0587b138a2fd9a3b7fd9350Svetoslav Ganov * <p> 9694213804541a8b05cd0587b138a2fd9a3b7fd9350Svetoslav Ganov * <strong>Note:</strong> Cannot be called from an 9704213804541a8b05cd0587b138a2fd9a3b7fd9350Svetoslav Ganov * {@link android.accessibilityservice.AccessibilityService}. 9714213804541a8b05cd0587b138a2fd9a3b7fd9350Svetoslav Ganov * This class is made immutable before being delivered to an AccessibilityService. 9724213804541a8b05cd0587b138a2fd9a3b7fd9350Svetoslav Ganov * </p> 9734213804541a8b05cd0587b138a2fd9a3b7fd9350Svetoslav Ganov * 9744213804541a8b05cd0587b138a2fd9a3b7fd9350Svetoslav Ganov * @param focused True if the node is accessibility focused. 9754213804541a8b05cd0587b138a2fd9a3b7fd9350Svetoslav Ganov * 9764213804541a8b05cd0587b138a2fd9a3b7fd9350Svetoslav Ganov * @throws IllegalStateException If called from an AccessibilityService. 9774213804541a8b05cd0587b138a2fd9a3b7fd9350Svetoslav Ganov */ 9784213804541a8b05cd0587b138a2fd9a3b7fd9350Svetoslav Ganov public void setAccessibilityFocused(boolean focused) { 9794213804541a8b05cd0587b138a2fd9a3b7fd9350Svetoslav Ganov setBooleanProperty(PROPERTY_ACCESSIBILITY_FOCUSED, focused); 9804213804541a8b05cd0587b138a2fd9a3b7fd9350Svetoslav Ganov } 9814213804541a8b05cd0587b138a2fd9a3b7fd9350Svetoslav Ganov 9824213804541a8b05cd0587b138a2fd9a3b7fd9350Svetoslav Ganov /** 9838643aa0179e598e78d938c59035389054535a229Svetoslav Ganov * Gets whether this node is selected. 9848643aa0179e598e78d938c59035389054535a229Svetoslav Ganov * 9858643aa0179e598e78d938c59035389054535a229Svetoslav Ganov * @return True if the node is selected. 9868643aa0179e598e78d938c59035389054535a229Svetoslav Ganov */ 9878643aa0179e598e78d938c59035389054535a229Svetoslav Ganov public boolean isSelected() { 9888643aa0179e598e78d938c59035389054535a229Svetoslav Ganov return getBooleanProperty(PROPERTY_SELECTED); 9898643aa0179e598e78d938c59035389054535a229Svetoslav Ganov } 9908643aa0179e598e78d938c59035389054535a229Svetoslav Ganov 9918643aa0179e598e78d938c59035389054535a229Svetoslav Ganov /** 9928643aa0179e598e78d938c59035389054535a229Svetoslav Ganov * Sets whether this node is selected. 9938643aa0179e598e78d938c59035389054535a229Svetoslav Ganov * <p> 99438e8b4e5bc3c93affdffbc064fd9db5aeccc3e8eSvetoslav Ganov * <strong>Note:</strong> Cannot be called from an 99538e8b4e5bc3c93affdffbc064fd9db5aeccc3e8eSvetoslav Ganov * {@link android.accessibilityservice.AccessibilityService}. 9968643aa0179e598e78d938c59035389054535a229Svetoslav Ganov * This class is made immutable before being delivered to an AccessibilityService. 9978643aa0179e598e78d938c59035389054535a229Svetoslav Ganov * </p> 99838e8b4e5bc3c93affdffbc064fd9db5aeccc3e8eSvetoslav Ganov * 9998643aa0179e598e78d938c59035389054535a229Svetoslav Ganov * @param selected True if the node is selected. 10008643aa0179e598e78d938c59035389054535a229Svetoslav Ganov * 10018643aa0179e598e78d938c59035389054535a229Svetoslav Ganov * @throws IllegalStateException If called from an AccessibilityService. 10028643aa0179e598e78d938c59035389054535a229Svetoslav Ganov */ 10038643aa0179e598e78d938c59035389054535a229Svetoslav Ganov public void setSelected(boolean selected) { 10048643aa0179e598e78d938c59035389054535a229Svetoslav Ganov setBooleanProperty(PROPERTY_SELECTED, selected); 10058643aa0179e598e78d938c59035389054535a229Svetoslav Ganov } 10068643aa0179e598e78d938c59035389054535a229Svetoslav Ganov 10078643aa0179e598e78d938c59035389054535a229Svetoslav Ganov /** 10088643aa0179e598e78d938c59035389054535a229Svetoslav Ganov * Gets whether this node is clickable. 10098643aa0179e598e78d938c59035389054535a229Svetoslav Ganov * 10108643aa0179e598e78d938c59035389054535a229Svetoslav Ganov * @return True if the node is clickable. 10118643aa0179e598e78d938c59035389054535a229Svetoslav Ganov */ 10128643aa0179e598e78d938c59035389054535a229Svetoslav Ganov public boolean isClickable() { 10138643aa0179e598e78d938c59035389054535a229Svetoslav Ganov return getBooleanProperty(PROPERTY_CLICKABLE); 10148643aa0179e598e78d938c59035389054535a229Svetoslav Ganov } 10158643aa0179e598e78d938c59035389054535a229Svetoslav Ganov 10168643aa0179e598e78d938c59035389054535a229Svetoslav Ganov /** 10178643aa0179e598e78d938c59035389054535a229Svetoslav Ganov * Sets whether this node is clickable. 10188643aa0179e598e78d938c59035389054535a229Svetoslav Ganov * <p> 101938e8b4e5bc3c93affdffbc064fd9db5aeccc3e8eSvetoslav Ganov * <strong>Note:</strong> Cannot be called from an 102038e8b4e5bc3c93affdffbc064fd9db5aeccc3e8eSvetoslav Ganov * {@link android.accessibilityservice.AccessibilityService}. 10218643aa0179e598e78d938c59035389054535a229Svetoslav Ganov * This class is made immutable before being delivered to an AccessibilityService. 10228643aa0179e598e78d938c59035389054535a229Svetoslav Ganov * </p> 102338e8b4e5bc3c93affdffbc064fd9db5aeccc3e8eSvetoslav Ganov * 10248643aa0179e598e78d938c59035389054535a229Svetoslav Ganov * @param clickable True if the node is clickable. 10258643aa0179e598e78d938c59035389054535a229Svetoslav Ganov * 10268643aa0179e598e78d938c59035389054535a229Svetoslav Ganov * @throws IllegalStateException If called from an AccessibilityService. 10278643aa0179e598e78d938c59035389054535a229Svetoslav Ganov */ 10288643aa0179e598e78d938c59035389054535a229Svetoslav Ganov public void setClickable(boolean clickable) { 10298643aa0179e598e78d938c59035389054535a229Svetoslav Ganov setBooleanProperty(PROPERTY_CLICKABLE, clickable); 10308643aa0179e598e78d938c59035389054535a229Svetoslav Ganov } 10318643aa0179e598e78d938c59035389054535a229Svetoslav Ganov 10328643aa0179e598e78d938c59035389054535a229Svetoslav Ganov /** 10338643aa0179e598e78d938c59035389054535a229Svetoslav Ganov * Gets whether this node is long clickable. 10348643aa0179e598e78d938c59035389054535a229Svetoslav Ganov * 10358643aa0179e598e78d938c59035389054535a229Svetoslav Ganov * @return True if the node is long clickable. 10368643aa0179e598e78d938c59035389054535a229Svetoslav Ganov */ 10378643aa0179e598e78d938c59035389054535a229Svetoslav Ganov public boolean isLongClickable() { 10388643aa0179e598e78d938c59035389054535a229Svetoslav Ganov return getBooleanProperty(PROPERTY_LONG_CLICKABLE); 10398643aa0179e598e78d938c59035389054535a229Svetoslav Ganov } 10408643aa0179e598e78d938c59035389054535a229Svetoslav Ganov 10418643aa0179e598e78d938c59035389054535a229Svetoslav Ganov /** 10428643aa0179e598e78d938c59035389054535a229Svetoslav Ganov * Sets whether this node is long clickable. 10438643aa0179e598e78d938c59035389054535a229Svetoslav Ganov * <p> 104438e8b4e5bc3c93affdffbc064fd9db5aeccc3e8eSvetoslav Ganov * <strong>Note:</strong> Cannot be called from an 104538e8b4e5bc3c93affdffbc064fd9db5aeccc3e8eSvetoslav Ganov * {@link android.accessibilityservice.AccessibilityService}. 10468643aa0179e598e78d938c59035389054535a229Svetoslav Ganov * This class is made immutable before being delivered to an AccessibilityService. 10478643aa0179e598e78d938c59035389054535a229Svetoslav Ganov * </p> 104838e8b4e5bc3c93affdffbc064fd9db5aeccc3e8eSvetoslav Ganov * 10498643aa0179e598e78d938c59035389054535a229Svetoslav Ganov * @param longClickable True if the node is long clickable. 10508643aa0179e598e78d938c59035389054535a229Svetoslav Ganov * 10518643aa0179e598e78d938c59035389054535a229Svetoslav Ganov * @throws IllegalStateException If called from an AccessibilityService. 10528643aa0179e598e78d938c59035389054535a229Svetoslav Ganov */ 10538643aa0179e598e78d938c59035389054535a229Svetoslav Ganov public void setLongClickable(boolean longClickable) { 10548643aa0179e598e78d938c59035389054535a229Svetoslav Ganov setBooleanProperty(PROPERTY_LONG_CLICKABLE, longClickable); 10558643aa0179e598e78d938c59035389054535a229Svetoslav Ganov } 10568643aa0179e598e78d938c59035389054535a229Svetoslav Ganov 10578643aa0179e598e78d938c59035389054535a229Svetoslav Ganov /** 10588643aa0179e598e78d938c59035389054535a229Svetoslav Ganov * Gets whether this node is enabled. 10598643aa0179e598e78d938c59035389054535a229Svetoslav Ganov * 10608643aa0179e598e78d938c59035389054535a229Svetoslav Ganov * @return True if the node is enabled. 10618643aa0179e598e78d938c59035389054535a229Svetoslav Ganov */ 10628643aa0179e598e78d938c59035389054535a229Svetoslav Ganov public boolean isEnabled() { 10638643aa0179e598e78d938c59035389054535a229Svetoslav Ganov return getBooleanProperty(PROPERTY_ENABLED); 10648643aa0179e598e78d938c59035389054535a229Svetoslav Ganov } 10658643aa0179e598e78d938c59035389054535a229Svetoslav Ganov 10668643aa0179e598e78d938c59035389054535a229Svetoslav Ganov /** 10678643aa0179e598e78d938c59035389054535a229Svetoslav Ganov * Sets whether this node is enabled. 10688643aa0179e598e78d938c59035389054535a229Svetoslav Ganov * <p> 106938e8b4e5bc3c93affdffbc064fd9db5aeccc3e8eSvetoslav Ganov * <strong>Note:</strong> Cannot be called from an 107038e8b4e5bc3c93affdffbc064fd9db5aeccc3e8eSvetoslav Ganov * {@link android.accessibilityservice.AccessibilityService}. 10718643aa0179e598e78d938c59035389054535a229Svetoslav Ganov * This class is made immutable before being delivered to an AccessibilityService. 10728643aa0179e598e78d938c59035389054535a229Svetoslav Ganov * </p> 107338e8b4e5bc3c93affdffbc064fd9db5aeccc3e8eSvetoslav Ganov * 10748643aa0179e598e78d938c59035389054535a229Svetoslav Ganov * @param enabled True if the node is enabled. 10758643aa0179e598e78d938c59035389054535a229Svetoslav Ganov * 10768643aa0179e598e78d938c59035389054535a229Svetoslav Ganov * @throws IllegalStateException If called from an AccessibilityService. 10778643aa0179e598e78d938c59035389054535a229Svetoslav Ganov */ 10788643aa0179e598e78d938c59035389054535a229Svetoslav Ganov public void setEnabled(boolean enabled) { 10798643aa0179e598e78d938c59035389054535a229Svetoslav Ganov setBooleanProperty(PROPERTY_ENABLED, enabled); 10808643aa0179e598e78d938c59035389054535a229Svetoslav Ganov } 10818643aa0179e598e78d938c59035389054535a229Svetoslav Ganov 10828643aa0179e598e78d938c59035389054535a229Svetoslav Ganov /** 10838643aa0179e598e78d938c59035389054535a229Svetoslav Ganov * Gets whether this node is a password. 10848643aa0179e598e78d938c59035389054535a229Svetoslav Ganov * 10858643aa0179e598e78d938c59035389054535a229Svetoslav Ganov * @return True if the node is a password. 10868643aa0179e598e78d938c59035389054535a229Svetoslav Ganov */ 10878643aa0179e598e78d938c59035389054535a229Svetoslav Ganov public boolean isPassword() { 10888643aa0179e598e78d938c59035389054535a229Svetoslav Ganov return getBooleanProperty(PROPERTY_PASSWORD); 10898643aa0179e598e78d938c59035389054535a229Svetoslav Ganov } 10908643aa0179e598e78d938c59035389054535a229Svetoslav Ganov 10918643aa0179e598e78d938c59035389054535a229Svetoslav Ganov /** 10928643aa0179e598e78d938c59035389054535a229Svetoslav Ganov * Sets whether this node is a password. 10938643aa0179e598e78d938c59035389054535a229Svetoslav Ganov * <p> 109438e8b4e5bc3c93affdffbc064fd9db5aeccc3e8eSvetoslav Ganov * <strong>Note:</strong> Cannot be called from an 109538e8b4e5bc3c93affdffbc064fd9db5aeccc3e8eSvetoslav Ganov * {@link android.accessibilityservice.AccessibilityService}. 10968643aa0179e598e78d938c59035389054535a229Svetoslav Ganov * This class is made immutable before being delivered to an AccessibilityService. 10978643aa0179e598e78d938c59035389054535a229Svetoslav Ganov * </p> 109838e8b4e5bc3c93affdffbc064fd9db5aeccc3e8eSvetoslav Ganov * 10998643aa0179e598e78d938c59035389054535a229Svetoslav Ganov * @param password True if the node is a password. 11008643aa0179e598e78d938c59035389054535a229Svetoslav Ganov * 11018643aa0179e598e78d938c59035389054535a229Svetoslav Ganov * @throws IllegalStateException If called from an AccessibilityService. 11028643aa0179e598e78d938c59035389054535a229Svetoslav Ganov */ 11038643aa0179e598e78d938c59035389054535a229Svetoslav Ganov public void setPassword(boolean password) { 11048643aa0179e598e78d938c59035389054535a229Svetoslav Ganov setBooleanProperty(PROPERTY_PASSWORD, password); 11058643aa0179e598e78d938c59035389054535a229Svetoslav Ganov } 11068643aa0179e598e78d938c59035389054535a229Svetoslav Ganov 11078643aa0179e598e78d938c59035389054535a229Svetoslav Ganov /** 1108a0156177cdc809795dd8bc5a19943dd2b6f82b66Svetoslav Ganov * Gets if the node is scrollable. 1109a0156177cdc809795dd8bc5a19943dd2b6f82b66Svetoslav Ganov * 1110a0156177cdc809795dd8bc5a19943dd2b6f82b66Svetoslav Ganov * @return True if the node is scrollable, false otherwise. 1111a0156177cdc809795dd8bc5a19943dd2b6f82b66Svetoslav Ganov */ 1112a0156177cdc809795dd8bc5a19943dd2b6f82b66Svetoslav Ganov public boolean isScrollable() { 1113a0156177cdc809795dd8bc5a19943dd2b6f82b66Svetoslav Ganov return getBooleanProperty(PROPERTY_SCROLLABLE); 1114a0156177cdc809795dd8bc5a19943dd2b6f82b66Svetoslav Ganov } 1115a0156177cdc809795dd8bc5a19943dd2b6f82b66Svetoslav Ganov 1116a0156177cdc809795dd8bc5a19943dd2b6f82b66Svetoslav Ganov /** 1117a0156177cdc809795dd8bc5a19943dd2b6f82b66Svetoslav Ganov * Sets if the node is scrollable. 111838e8b4e5bc3c93affdffbc064fd9db5aeccc3e8eSvetoslav Ganov * <p> 111938e8b4e5bc3c93affdffbc064fd9db5aeccc3e8eSvetoslav Ganov * <strong>Note:</strong> Cannot be called from an 112038e8b4e5bc3c93affdffbc064fd9db5aeccc3e8eSvetoslav Ganov * {@link android.accessibilityservice.AccessibilityService}. 112138e8b4e5bc3c93affdffbc064fd9db5aeccc3e8eSvetoslav Ganov * This class is made immutable before being delivered to an AccessibilityService. 112238e8b4e5bc3c93affdffbc064fd9db5aeccc3e8eSvetoslav Ganov * </p> 1123a0156177cdc809795dd8bc5a19943dd2b6f82b66Svetoslav Ganov * 1124a0156177cdc809795dd8bc5a19943dd2b6f82b66Svetoslav Ganov * @param scrollable True if the node is scrollable, false otherwise. 1125a0156177cdc809795dd8bc5a19943dd2b6f82b66Svetoslav Ganov * 1126a0156177cdc809795dd8bc5a19943dd2b6f82b66Svetoslav Ganov * @throws IllegalStateException If called from an AccessibilityService. 1127a0156177cdc809795dd8bc5a19943dd2b6f82b66Svetoslav Ganov */ 1128a0156177cdc809795dd8bc5a19943dd2b6f82b66Svetoslav Ganov public void setScrollable(boolean scrollable) { 1129a0156177cdc809795dd8bc5a19943dd2b6f82b66Svetoslav Ganov enforceNotSealed(); 1130a0156177cdc809795dd8bc5a19943dd2b6f82b66Svetoslav Ganov setBooleanProperty(PROPERTY_SCROLLABLE, scrollable); 1131a0156177cdc809795dd8bc5a19943dd2b6f82b66Svetoslav Ganov } 1132a0156177cdc809795dd8bc5a19943dd2b6f82b66Svetoslav Ganov 1133a0156177cdc809795dd8bc5a19943dd2b6f82b66Svetoslav Ganov /** 11348643aa0179e598e78d938c59035389054535a229Svetoslav Ganov * Gets the package this node comes from. 11358643aa0179e598e78d938c59035389054535a229Svetoslav Ganov * 11368643aa0179e598e78d938c59035389054535a229Svetoslav Ganov * @return The package name. 11378643aa0179e598e78d938c59035389054535a229Svetoslav Ganov */ 11388643aa0179e598e78d938c59035389054535a229Svetoslav Ganov public CharSequence getPackageName() { 11398643aa0179e598e78d938c59035389054535a229Svetoslav Ganov return mPackageName; 11408643aa0179e598e78d938c59035389054535a229Svetoslav Ganov } 11418643aa0179e598e78d938c59035389054535a229Svetoslav Ganov 11428643aa0179e598e78d938c59035389054535a229Svetoslav Ganov /** 11438643aa0179e598e78d938c59035389054535a229Svetoslav Ganov * Sets the package this node comes from. 11448643aa0179e598e78d938c59035389054535a229Svetoslav Ganov * <p> 114538e8b4e5bc3c93affdffbc064fd9db5aeccc3e8eSvetoslav Ganov * <strong>Note:</strong> Cannot be called from an 114638e8b4e5bc3c93affdffbc064fd9db5aeccc3e8eSvetoslav Ganov * {@link android.accessibilityservice.AccessibilityService}. 11478643aa0179e598e78d938c59035389054535a229Svetoslav Ganov * This class is made immutable before being delivered to an AccessibilityService. 11488643aa0179e598e78d938c59035389054535a229Svetoslav Ganov * </p> 114938e8b4e5bc3c93affdffbc064fd9db5aeccc3e8eSvetoslav Ganov * 11508643aa0179e598e78d938c59035389054535a229Svetoslav Ganov * @param packageName The package name. 11518643aa0179e598e78d938c59035389054535a229Svetoslav Ganov * 11528643aa0179e598e78d938c59035389054535a229Svetoslav Ganov * @throws IllegalStateException If called from an AccessibilityService. 11538643aa0179e598e78d938c59035389054535a229Svetoslav Ganov */ 11548643aa0179e598e78d938c59035389054535a229Svetoslav Ganov public void setPackageName(CharSequence packageName) { 11558643aa0179e598e78d938c59035389054535a229Svetoslav Ganov enforceNotSealed(); 11568643aa0179e598e78d938c59035389054535a229Svetoslav Ganov mPackageName = packageName; 11578643aa0179e598e78d938c59035389054535a229Svetoslav Ganov } 11588643aa0179e598e78d938c59035389054535a229Svetoslav Ganov 11598643aa0179e598e78d938c59035389054535a229Svetoslav Ganov /** 11608643aa0179e598e78d938c59035389054535a229Svetoslav Ganov * Gets the class this node comes from. 11618643aa0179e598e78d938c59035389054535a229Svetoslav Ganov * 11628643aa0179e598e78d938c59035389054535a229Svetoslav Ganov * @return The class name. 11638643aa0179e598e78d938c59035389054535a229Svetoslav Ganov */ 11648643aa0179e598e78d938c59035389054535a229Svetoslav Ganov public CharSequence getClassName() { 11658643aa0179e598e78d938c59035389054535a229Svetoslav Ganov return mClassName; 11668643aa0179e598e78d938c59035389054535a229Svetoslav Ganov } 11678643aa0179e598e78d938c59035389054535a229Svetoslav Ganov 11688643aa0179e598e78d938c59035389054535a229Svetoslav Ganov /** 11698643aa0179e598e78d938c59035389054535a229Svetoslav Ganov * Sets the class this node comes from. 11708643aa0179e598e78d938c59035389054535a229Svetoslav Ganov * <p> 117138e8b4e5bc3c93affdffbc064fd9db5aeccc3e8eSvetoslav Ganov * <strong>Note:</strong> Cannot be called from an 117238e8b4e5bc3c93affdffbc064fd9db5aeccc3e8eSvetoslav Ganov * {@link android.accessibilityservice.AccessibilityService}. 11738643aa0179e598e78d938c59035389054535a229Svetoslav Ganov * This class is made immutable before being delivered to an AccessibilityService. 11748643aa0179e598e78d938c59035389054535a229Svetoslav Ganov * </p> 117538e8b4e5bc3c93affdffbc064fd9db5aeccc3e8eSvetoslav Ganov * 11768643aa0179e598e78d938c59035389054535a229Svetoslav Ganov * @param className The class name. 11778643aa0179e598e78d938c59035389054535a229Svetoslav Ganov * 11788643aa0179e598e78d938c59035389054535a229Svetoslav Ganov * @throws IllegalStateException If called from an AccessibilityService. 11798643aa0179e598e78d938c59035389054535a229Svetoslav Ganov */ 11808643aa0179e598e78d938c59035389054535a229Svetoslav Ganov public void setClassName(CharSequence className) { 11818643aa0179e598e78d938c59035389054535a229Svetoslav Ganov enforceNotSealed(); 11828643aa0179e598e78d938c59035389054535a229Svetoslav Ganov mClassName = className; 11838643aa0179e598e78d938c59035389054535a229Svetoslav Ganov } 11848643aa0179e598e78d938c59035389054535a229Svetoslav Ganov 11858643aa0179e598e78d938c59035389054535a229Svetoslav Ganov /** 11868643aa0179e598e78d938c59035389054535a229Svetoslav Ganov * Gets the text of this node. 11878643aa0179e598e78d938c59035389054535a229Svetoslav Ganov * 11888643aa0179e598e78d938c59035389054535a229Svetoslav Ganov * @return The text. 11898643aa0179e598e78d938c59035389054535a229Svetoslav Ganov */ 11908643aa0179e598e78d938c59035389054535a229Svetoslav Ganov public CharSequence getText() { 11918643aa0179e598e78d938c59035389054535a229Svetoslav Ganov return mText; 11928643aa0179e598e78d938c59035389054535a229Svetoslav Ganov } 11938643aa0179e598e78d938c59035389054535a229Svetoslav Ganov 11948643aa0179e598e78d938c59035389054535a229Svetoslav Ganov /** 11958643aa0179e598e78d938c59035389054535a229Svetoslav Ganov * Sets the text of this node. 11968643aa0179e598e78d938c59035389054535a229Svetoslav Ganov * <p> 119738e8b4e5bc3c93affdffbc064fd9db5aeccc3e8eSvetoslav Ganov * <strong>Note:</strong> Cannot be called from an 119838e8b4e5bc3c93affdffbc064fd9db5aeccc3e8eSvetoslav Ganov * {@link android.accessibilityservice.AccessibilityService}. 11998643aa0179e598e78d938c59035389054535a229Svetoslav Ganov * This class is made immutable before being delivered to an AccessibilityService. 12008643aa0179e598e78d938c59035389054535a229Svetoslav Ganov * </p> 120138e8b4e5bc3c93affdffbc064fd9db5aeccc3e8eSvetoslav Ganov * 12028643aa0179e598e78d938c59035389054535a229Svetoslav Ganov * @param text The text. 12038643aa0179e598e78d938c59035389054535a229Svetoslav Ganov * 12048643aa0179e598e78d938c59035389054535a229Svetoslav Ganov * @throws IllegalStateException If called from an AccessibilityService. 12058643aa0179e598e78d938c59035389054535a229Svetoslav Ganov */ 12068643aa0179e598e78d938c59035389054535a229Svetoslav Ganov public void setText(CharSequence text) { 12078643aa0179e598e78d938c59035389054535a229Svetoslav Ganov enforceNotSealed(); 12088643aa0179e598e78d938c59035389054535a229Svetoslav Ganov mText = text; 12098643aa0179e598e78d938c59035389054535a229Svetoslav Ganov } 12108643aa0179e598e78d938c59035389054535a229Svetoslav Ganov 12118643aa0179e598e78d938c59035389054535a229Svetoslav Ganov /** 12128643aa0179e598e78d938c59035389054535a229Svetoslav Ganov * Gets the content description of this node. 12138643aa0179e598e78d938c59035389054535a229Svetoslav Ganov * 12148643aa0179e598e78d938c59035389054535a229Svetoslav Ganov * @return The content description. 12158643aa0179e598e78d938c59035389054535a229Svetoslav Ganov */ 12168643aa0179e598e78d938c59035389054535a229Svetoslav Ganov public CharSequence getContentDescription() { 12178643aa0179e598e78d938c59035389054535a229Svetoslav Ganov return mContentDescription; 12188643aa0179e598e78d938c59035389054535a229Svetoslav Ganov } 12198643aa0179e598e78d938c59035389054535a229Svetoslav Ganov 12208643aa0179e598e78d938c59035389054535a229Svetoslav Ganov /** 12218643aa0179e598e78d938c59035389054535a229Svetoslav Ganov * Sets the content description of this node. 12228643aa0179e598e78d938c59035389054535a229Svetoslav Ganov * <p> 122338e8b4e5bc3c93affdffbc064fd9db5aeccc3e8eSvetoslav Ganov * <strong>Note:</strong> Cannot be called from an 122438e8b4e5bc3c93affdffbc064fd9db5aeccc3e8eSvetoslav Ganov * {@link android.accessibilityservice.AccessibilityService}. 12258643aa0179e598e78d938c59035389054535a229Svetoslav Ganov * This class is made immutable before being delivered to an AccessibilityService. 12268643aa0179e598e78d938c59035389054535a229Svetoslav Ganov * </p> 122738e8b4e5bc3c93affdffbc064fd9db5aeccc3e8eSvetoslav Ganov * 12288643aa0179e598e78d938c59035389054535a229Svetoslav Ganov * @param contentDescription The content description. 12298643aa0179e598e78d938c59035389054535a229Svetoslav Ganov * 12308643aa0179e598e78d938c59035389054535a229Svetoslav Ganov * @throws IllegalStateException If called from an AccessibilityService. 12318643aa0179e598e78d938c59035389054535a229Svetoslav Ganov */ 12328643aa0179e598e78d938c59035389054535a229Svetoslav Ganov public void setContentDescription(CharSequence contentDescription) { 12338643aa0179e598e78d938c59035389054535a229Svetoslav Ganov enforceNotSealed(); 12348643aa0179e598e78d938c59035389054535a229Svetoslav Ganov mContentDescription = contentDescription; 12358643aa0179e598e78d938c59035389054535a229Svetoslav Ganov } 12368643aa0179e598e78d938c59035389054535a229Svetoslav Ganov 12378643aa0179e598e78d938c59035389054535a229Svetoslav Ganov /** 123833aef98fd28dcac0a2ad37e7329afd3e666f5e0aSvetoslav Ganov * Sets the view for which the view represented by this info serves as a 123933aef98fd28dcac0a2ad37e7329afd3e666f5e0aSvetoslav Ganov * label for accessibility purposes. 124033aef98fd28dcac0a2ad37e7329afd3e666f5e0aSvetoslav Ganov * 124133aef98fd28dcac0a2ad37e7329afd3e666f5e0aSvetoslav Ganov * @param labeled The view for which this info serves as a label. 124233aef98fd28dcac0a2ad37e7329afd3e666f5e0aSvetoslav Ganov */ 124333aef98fd28dcac0a2ad37e7329afd3e666f5e0aSvetoslav Ganov public void setLabelFor(View labeled) { 124433aef98fd28dcac0a2ad37e7329afd3e666f5e0aSvetoslav Ganov setLabelFor(labeled, UNDEFINED); 124533aef98fd28dcac0a2ad37e7329afd3e666f5e0aSvetoslav Ganov } 124633aef98fd28dcac0a2ad37e7329afd3e666f5e0aSvetoslav Ganov 124733aef98fd28dcac0a2ad37e7329afd3e666f5e0aSvetoslav Ganov /** 124833aef98fd28dcac0a2ad37e7329afd3e666f5e0aSvetoslav Ganov * Sets the view for which the view represented by this info serves as a 124933aef98fd28dcac0a2ad37e7329afd3e666f5e0aSvetoslav Ganov * label for accessibility purposes. If <code>virtualDescendantId</code> 125033aef98fd28dcac0a2ad37e7329afd3e666f5e0aSvetoslav Ganov * is {@link View#NO_ID} the root is set as the labeled. 125133aef98fd28dcac0a2ad37e7329afd3e666f5e0aSvetoslav Ganov * <p> 125233aef98fd28dcac0a2ad37e7329afd3e666f5e0aSvetoslav Ganov * A virtual descendant is an imaginary View that is reported as a part of the view 125333aef98fd28dcac0a2ad37e7329afd3e666f5e0aSvetoslav Ganov * hierarchy for accessibility purposes. This enables custom views that draw complex 125433aef98fd28dcac0a2ad37e7329afd3e666f5e0aSvetoslav Ganov * content to report themselves as a tree of virtual views, thus conveying their 125533aef98fd28dcac0a2ad37e7329afd3e666f5e0aSvetoslav Ganov * logical structure. 125633aef98fd28dcac0a2ad37e7329afd3e666f5e0aSvetoslav Ganov * </p> 125733aef98fd28dcac0a2ad37e7329afd3e666f5e0aSvetoslav Ganov * <p> 125833aef98fd28dcac0a2ad37e7329afd3e666f5e0aSvetoslav Ganov * <strong>Note:</strong> Cannot be called from an 125933aef98fd28dcac0a2ad37e7329afd3e666f5e0aSvetoslav Ganov * {@link android.accessibilityservice.AccessibilityService}. 126033aef98fd28dcac0a2ad37e7329afd3e666f5e0aSvetoslav Ganov * This class is made immutable before being delivered to an AccessibilityService. 126133aef98fd28dcac0a2ad37e7329afd3e666f5e0aSvetoslav Ganov * </p> 126233aef98fd28dcac0a2ad37e7329afd3e666f5e0aSvetoslav Ganov * 126333aef98fd28dcac0a2ad37e7329afd3e666f5e0aSvetoslav Ganov * @param root The root whose virtual descendant serves as a label. 126433aef98fd28dcac0a2ad37e7329afd3e666f5e0aSvetoslav Ganov * @param virtualDescendantId The id of the virtual descendant. 126533aef98fd28dcac0a2ad37e7329afd3e666f5e0aSvetoslav Ganov */ 126633aef98fd28dcac0a2ad37e7329afd3e666f5e0aSvetoslav Ganov public void setLabelFor(View root, int virtualDescendantId) { 126733aef98fd28dcac0a2ad37e7329afd3e666f5e0aSvetoslav Ganov enforceNotSealed(); 126833aef98fd28dcac0a2ad37e7329afd3e666f5e0aSvetoslav Ganov final int rootAccessibilityViewId = (root != null) 126933aef98fd28dcac0a2ad37e7329afd3e666f5e0aSvetoslav Ganov ? root.getAccessibilityViewId() : UNDEFINED; 127033aef98fd28dcac0a2ad37e7329afd3e666f5e0aSvetoslav Ganov mLabelForId = makeNodeId(rootAccessibilityViewId, virtualDescendantId); 127133aef98fd28dcac0a2ad37e7329afd3e666f5e0aSvetoslav Ganov } 127233aef98fd28dcac0a2ad37e7329afd3e666f5e0aSvetoslav Ganov 127333aef98fd28dcac0a2ad37e7329afd3e666f5e0aSvetoslav Ganov /** 127433aef98fd28dcac0a2ad37e7329afd3e666f5e0aSvetoslav Ganov * Gets the node info for which the view represented by this info serves as 127533aef98fd28dcac0a2ad37e7329afd3e666f5e0aSvetoslav Ganov * a label for accessibility purposes. 127633aef98fd28dcac0a2ad37e7329afd3e666f5e0aSvetoslav Ganov * <p> 127733aef98fd28dcac0a2ad37e7329afd3e666f5e0aSvetoslav Ganov * <strong>Note:</strong> It is a client responsibility to recycle the 127833aef98fd28dcac0a2ad37e7329afd3e666f5e0aSvetoslav Ganov * received info by calling {@link AccessibilityNodeInfo#recycle()} 127933aef98fd28dcac0a2ad37e7329afd3e666f5e0aSvetoslav Ganov * to avoid creating of multiple instances. 128033aef98fd28dcac0a2ad37e7329afd3e666f5e0aSvetoslav Ganov * </p> 128133aef98fd28dcac0a2ad37e7329afd3e666f5e0aSvetoslav Ganov * 128233aef98fd28dcac0a2ad37e7329afd3e666f5e0aSvetoslav Ganov * @return The labeled info. 128333aef98fd28dcac0a2ad37e7329afd3e666f5e0aSvetoslav Ganov */ 128433aef98fd28dcac0a2ad37e7329afd3e666f5e0aSvetoslav Ganov public AccessibilityNodeInfo getLabelFor() { 128533aef98fd28dcac0a2ad37e7329afd3e666f5e0aSvetoslav Ganov enforceSealed(); 128633aef98fd28dcac0a2ad37e7329afd3e666f5e0aSvetoslav Ganov if (!canPerformRequestOverConnection(mLabelForId)) { 128733aef98fd28dcac0a2ad37e7329afd3e666f5e0aSvetoslav Ganov return null; 128833aef98fd28dcac0a2ad37e7329afd3e666f5e0aSvetoslav Ganov } 128933aef98fd28dcac0a2ad37e7329afd3e666f5e0aSvetoslav Ganov AccessibilityInteractionClient client = AccessibilityInteractionClient.getInstance(); 129033aef98fd28dcac0a2ad37e7329afd3e666f5e0aSvetoslav Ganov return client.findAccessibilityNodeInfoByAccessibilityId(mConnectionId, 129133aef98fd28dcac0a2ad37e7329afd3e666f5e0aSvetoslav Ganov mWindowId, mLabelForId, FLAG_PREFETCH_DESCENDANTS | FLAG_PREFETCH_SIBLINGS); 129233aef98fd28dcac0a2ad37e7329afd3e666f5e0aSvetoslav Ganov } 129333aef98fd28dcac0a2ad37e7329afd3e666f5e0aSvetoslav Ganov 129433aef98fd28dcac0a2ad37e7329afd3e666f5e0aSvetoslav Ganov /** 129533aef98fd28dcac0a2ad37e7329afd3e666f5e0aSvetoslav Ganov * Sets the view which serves as the label of the view represented by 129633aef98fd28dcac0a2ad37e7329afd3e666f5e0aSvetoslav Ganov * this info for accessibility purposes. 129733aef98fd28dcac0a2ad37e7329afd3e666f5e0aSvetoslav Ganov * 129833aef98fd28dcac0a2ad37e7329afd3e666f5e0aSvetoslav Ganov * @param label The view that labels this node's source. 129933aef98fd28dcac0a2ad37e7329afd3e666f5e0aSvetoslav Ganov */ 130033aef98fd28dcac0a2ad37e7329afd3e666f5e0aSvetoslav Ganov public void setLabeledBy(View label) { 130133aef98fd28dcac0a2ad37e7329afd3e666f5e0aSvetoslav Ganov setLabeledBy(label, UNDEFINED); 130233aef98fd28dcac0a2ad37e7329afd3e666f5e0aSvetoslav Ganov } 130333aef98fd28dcac0a2ad37e7329afd3e666f5e0aSvetoslav Ganov 130433aef98fd28dcac0a2ad37e7329afd3e666f5e0aSvetoslav Ganov /** 130533aef98fd28dcac0a2ad37e7329afd3e666f5e0aSvetoslav Ganov * Sets the view which serves as the label of the view represented by 130633aef98fd28dcac0a2ad37e7329afd3e666f5e0aSvetoslav Ganov * this info for accessibility purposes. If <code>virtualDescendantId</code> 130733aef98fd28dcac0a2ad37e7329afd3e666f5e0aSvetoslav Ganov * is {@link View#NO_ID} the root is set as the label. 130833aef98fd28dcac0a2ad37e7329afd3e666f5e0aSvetoslav Ganov * <p> 130933aef98fd28dcac0a2ad37e7329afd3e666f5e0aSvetoslav Ganov * A virtual descendant is an imaginary View that is reported as a part of the view 131033aef98fd28dcac0a2ad37e7329afd3e666f5e0aSvetoslav Ganov * hierarchy for accessibility purposes. This enables custom views that draw complex 131133aef98fd28dcac0a2ad37e7329afd3e666f5e0aSvetoslav Ganov * content to report themselves as a tree of virtual views, thus conveying their 131233aef98fd28dcac0a2ad37e7329afd3e666f5e0aSvetoslav Ganov * logical structure. 131333aef98fd28dcac0a2ad37e7329afd3e666f5e0aSvetoslav Ganov * </p> 131433aef98fd28dcac0a2ad37e7329afd3e666f5e0aSvetoslav Ganov * <p> 131533aef98fd28dcac0a2ad37e7329afd3e666f5e0aSvetoslav Ganov * <strong>Note:</strong> Cannot be called from an 131633aef98fd28dcac0a2ad37e7329afd3e666f5e0aSvetoslav Ganov * {@link android.accessibilityservice.AccessibilityService}. 131733aef98fd28dcac0a2ad37e7329afd3e666f5e0aSvetoslav Ganov * This class is made immutable before being delivered to an AccessibilityService. 131833aef98fd28dcac0a2ad37e7329afd3e666f5e0aSvetoslav Ganov * </p> 131933aef98fd28dcac0a2ad37e7329afd3e666f5e0aSvetoslav Ganov * 132033aef98fd28dcac0a2ad37e7329afd3e666f5e0aSvetoslav Ganov * @param root The root whose virtual descendant labels this node's source. 132133aef98fd28dcac0a2ad37e7329afd3e666f5e0aSvetoslav Ganov * @param virtualDescendantId The id of the virtual descendant. 132233aef98fd28dcac0a2ad37e7329afd3e666f5e0aSvetoslav Ganov */ 132333aef98fd28dcac0a2ad37e7329afd3e666f5e0aSvetoslav Ganov public void setLabeledBy(View root, int virtualDescendantId) { 132433aef98fd28dcac0a2ad37e7329afd3e666f5e0aSvetoslav Ganov enforceNotSealed(); 132533aef98fd28dcac0a2ad37e7329afd3e666f5e0aSvetoslav Ganov final int rootAccessibilityViewId = (root != null) 132633aef98fd28dcac0a2ad37e7329afd3e666f5e0aSvetoslav Ganov ? root.getAccessibilityViewId() : UNDEFINED; 132733aef98fd28dcac0a2ad37e7329afd3e666f5e0aSvetoslav Ganov mLabeledById = makeNodeId(rootAccessibilityViewId, virtualDescendantId); 132833aef98fd28dcac0a2ad37e7329afd3e666f5e0aSvetoslav Ganov } 132933aef98fd28dcac0a2ad37e7329afd3e666f5e0aSvetoslav Ganov 133033aef98fd28dcac0a2ad37e7329afd3e666f5e0aSvetoslav Ganov /** 133133aef98fd28dcac0a2ad37e7329afd3e666f5e0aSvetoslav Ganov * Gets the node info which serves as the label of the view represented by 133233aef98fd28dcac0a2ad37e7329afd3e666f5e0aSvetoslav Ganov * this info for accessibility purposes. 133333aef98fd28dcac0a2ad37e7329afd3e666f5e0aSvetoslav Ganov * <p> 133433aef98fd28dcac0a2ad37e7329afd3e666f5e0aSvetoslav Ganov * <strong>Note:</strong> It is a client responsibility to recycle the 133533aef98fd28dcac0a2ad37e7329afd3e666f5e0aSvetoslav Ganov * received info by calling {@link AccessibilityNodeInfo#recycle()} 133633aef98fd28dcac0a2ad37e7329afd3e666f5e0aSvetoslav Ganov * to avoid creating of multiple instances. 133733aef98fd28dcac0a2ad37e7329afd3e666f5e0aSvetoslav Ganov * </p> 133833aef98fd28dcac0a2ad37e7329afd3e666f5e0aSvetoslav Ganov * 133933aef98fd28dcac0a2ad37e7329afd3e666f5e0aSvetoslav Ganov * @return The label. 134033aef98fd28dcac0a2ad37e7329afd3e666f5e0aSvetoslav Ganov */ 134133aef98fd28dcac0a2ad37e7329afd3e666f5e0aSvetoslav Ganov public AccessibilityNodeInfo getLabeledBy() { 134233aef98fd28dcac0a2ad37e7329afd3e666f5e0aSvetoslav Ganov enforceSealed(); 134333aef98fd28dcac0a2ad37e7329afd3e666f5e0aSvetoslav Ganov if (!canPerformRequestOverConnection(mLabeledById)) { 134433aef98fd28dcac0a2ad37e7329afd3e666f5e0aSvetoslav Ganov return null; 134533aef98fd28dcac0a2ad37e7329afd3e666f5e0aSvetoslav Ganov } 134633aef98fd28dcac0a2ad37e7329afd3e666f5e0aSvetoslav Ganov AccessibilityInteractionClient client = AccessibilityInteractionClient.getInstance(); 134733aef98fd28dcac0a2ad37e7329afd3e666f5e0aSvetoslav Ganov return client.findAccessibilityNodeInfoByAccessibilityId(mConnectionId, 134833aef98fd28dcac0a2ad37e7329afd3e666f5e0aSvetoslav Ganov mWindowId, mLabeledById, FLAG_PREFETCH_DESCENDANTS | FLAG_PREFETCH_SIBLINGS); 134933aef98fd28dcac0a2ad37e7329afd3e666f5e0aSvetoslav Ganov } 135033aef98fd28dcac0a2ad37e7329afd3e666f5e0aSvetoslav Ganov 135133aef98fd28dcac0a2ad37e7329afd3e666f5e0aSvetoslav Ganov /** 13528643aa0179e598e78d938c59035389054535a229Svetoslav Ganov * Gets the value of a boolean property. 13538643aa0179e598e78d938c59035389054535a229Svetoslav Ganov * 13548643aa0179e598e78d938c59035389054535a229Svetoslav Ganov * @param property The property. 13558643aa0179e598e78d938c59035389054535a229Svetoslav Ganov * @return The value. 13568643aa0179e598e78d938c59035389054535a229Svetoslav Ganov */ 13578643aa0179e598e78d938c59035389054535a229Svetoslav Ganov private boolean getBooleanProperty(int property) { 13588643aa0179e598e78d938c59035389054535a229Svetoslav Ganov return (mBooleanProperties & property) != 0; 13598643aa0179e598e78d938c59035389054535a229Svetoslav Ganov } 13608643aa0179e598e78d938c59035389054535a229Svetoslav Ganov 13618643aa0179e598e78d938c59035389054535a229Svetoslav Ganov /** 13628643aa0179e598e78d938c59035389054535a229Svetoslav Ganov * Sets a boolean property. 13638643aa0179e598e78d938c59035389054535a229Svetoslav Ganov * 13648643aa0179e598e78d938c59035389054535a229Svetoslav Ganov * @param property The property. 13658643aa0179e598e78d938c59035389054535a229Svetoslav Ganov * @param value The value. 13668643aa0179e598e78d938c59035389054535a229Svetoslav Ganov * 13678643aa0179e598e78d938c59035389054535a229Svetoslav Ganov * @throws IllegalStateException If called from an AccessibilityService. 13688643aa0179e598e78d938c59035389054535a229Svetoslav Ganov */ 13698643aa0179e598e78d938c59035389054535a229Svetoslav Ganov private void setBooleanProperty(int property, boolean value) { 13708643aa0179e598e78d938c59035389054535a229Svetoslav Ganov enforceNotSealed(); 13718643aa0179e598e78d938c59035389054535a229Svetoslav Ganov if (value) { 13728643aa0179e598e78d938c59035389054535a229Svetoslav Ganov mBooleanProperties |= property; 13738643aa0179e598e78d938c59035389054535a229Svetoslav Ganov } else { 13748643aa0179e598e78d938c59035389054535a229Svetoslav Ganov mBooleanProperties &= ~property; 13758643aa0179e598e78d938c59035389054535a229Svetoslav Ganov } 13768643aa0179e598e78d938c59035389054535a229Svetoslav Ganov } 13778643aa0179e598e78d938c59035389054535a229Svetoslav Ganov 13788643aa0179e598e78d938c59035389054535a229Svetoslav Ganov /** 1379d116d7c78a9c53f30a73bf273bd7618312cf3847Svetoslav Ganov * Sets the unique id of the IAccessibilityServiceConnection over which 1380d116d7c78a9c53f30a73bf273bd7618312cf3847Svetoslav Ganov * this instance can send requests to the system. 13818643aa0179e598e78d938c59035389054535a229Svetoslav Ganov * 1382d116d7c78a9c53f30a73bf273bd7618312cf3847Svetoslav Ganov * @param connectionId The connection id. 13838643aa0179e598e78d938c59035389054535a229Svetoslav Ganov * 13848643aa0179e598e78d938c59035389054535a229Svetoslav Ganov * @hide 13858643aa0179e598e78d938c59035389054535a229Svetoslav Ganov */ 1386d116d7c78a9c53f30a73bf273bd7618312cf3847Svetoslav Ganov public void setConnectionId(int connectionId) { 1387eeee4d2c01d3c4ed99e4891dbc75c7de69a803faSvetoslav Ganov enforceNotSealed(); 1388d116d7c78a9c53f30a73bf273bd7618312cf3847Svetoslav Ganov mConnectionId = connectionId; 13898643aa0179e598e78d938c59035389054535a229Svetoslav Ganov } 13908643aa0179e598e78d938c59035389054535a229Svetoslav Ganov 13918643aa0179e598e78d938c59035389054535a229Svetoslav Ganov /** 13928643aa0179e598e78d938c59035389054535a229Svetoslav Ganov * {@inheritDoc} 13938643aa0179e598e78d938c59035389054535a229Svetoslav Ganov */ 13948643aa0179e598e78d938c59035389054535a229Svetoslav Ganov public int describeContents() { 13958643aa0179e598e78d938c59035389054535a229Svetoslav Ganov return 0; 13968643aa0179e598e78d938c59035389054535a229Svetoslav Ganov } 13978643aa0179e598e78d938c59035389054535a229Svetoslav Ganov 13988643aa0179e598e78d938c59035389054535a229Svetoslav Ganov /** 139979311c4af8b54d3cd47ab37a120c648bfc990511Svetoslav Ganov * Gets the id of the source node. 140079311c4af8b54d3cd47ab37a120c648bfc990511Svetoslav Ganov * 140179311c4af8b54d3cd47ab37a120c648bfc990511Svetoslav Ganov * @return The id. 140279311c4af8b54d3cd47ab37a120c648bfc990511Svetoslav Ganov * 140379311c4af8b54d3cd47ab37a120c648bfc990511Svetoslav Ganov * @hide 140479311c4af8b54d3cd47ab37a120c648bfc990511Svetoslav Ganov */ 140579311c4af8b54d3cd47ab37a120c648bfc990511Svetoslav Ganov public long getSourceNodeId() { 140679311c4af8b54d3cd47ab37a120c648bfc990511Svetoslav Ganov return mSourceNodeId; 140779311c4af8b54d3cd47ab37a120c648bfc990511Svetoslav Ganov } 140879311c4af8b54d3cd47ab37a120c648bfc990511Svetoslav Ganov 140979311c4af8b54d3cd47ab37a120c648bfc990511Svetoslav Ganov /** 14108643aa0179e598e78d938c59035389054535a229Svetoslav Ganov * Sets if this instance is sealed. 14118643aa0179e598e78d938c59035389054535a229Svetoslav Ganov * 14128643aa0179e598e78d938c59035389054535a229Svetoslav Ganov * @param sealed Whether is sealed. 14138643aa0179e598e78d938c59035389054535a229Svetoslav Ganov * 14148643aa0179e598e78d938c59035389054535a229Svetoslav Ganov * @hide 14158643aa0179e598e78d938c59035389054535a229Svetoslav Ganov */ 14168643aa0179e598e78d938c59035389054535a229Svetoslav Ganov public void setSealed(boolean sealed) { 14178643aa0179e598e78d938c59035389054535a229Svetoslav Ganov mSealed = sealed; 14188643aa0179e598e78d938c59035389054535a229Svetoslav Ganov } 14198643aa0179e598e78d938c59035389054535a229Svetoslav Ganov 14208643aa0179e598e78d938c59035389054535a229Svetoslav Ganov /** 14218643aa0179e598e78d938c59035389054535a229Svetoslav Ganov * Gets if this instance is sealed. 14228643aa0179e598e78d938c59035389054535a229Svetoslav Ganov * 14238643aa0179e598e78d938c59035389054535a229Svetoslav Ganov * @return Whether is sealed. 14248643aa0179e598e78d938c59035389054535a229Svetoslav Ganov * 14258643aa0179e598e78d938c59035389054535a229Svetoslav Ganov * @hide 14268643aa0179e598e78d938c59035389054535a229Svetoslav Ganov */ 14278643aa0179e598e78d938c59035389054535a229Svetoslav Ganov public boolean isSealed() { 14288643aa0179e598e78d938c59035389054535a229Svetoslav Ganov return mSealed; 14298643aa0179e598e78d938c59035389054535a229Svetoslav Ganov } 14308643aa0179e598e78d938c59035389054535a229Svetoslav Ganov 14318643aa0179e598e78d938c59035389054535a229Svetoslav Ganov /** 14328643aa0179e598e78d938c59035389054535a229Svetoslav Ganov * Enforces that this instance is sealed. 14338643aa0179e598e78d938c59035389054535a229Svetoslav Ganov * 14348643aa0179e598e78d938c59035389054535a229Svetoslav Ganov * @throws IllegalStateException If this instance is not sealed. 14358643aa0179e598e78d938c59035389054535a229Svetoslav Ganov * 14368643aa0179e598e78d938c59035389054535a229Svetoslav Ganov * @hide 14378643aa0179e598e78d938c59035389054535a229Svetoslav Ganov */ 14388643aa0179e598e78d938c59035389054535a229Svetoslav Ganov protected void enforceSealed() { 14398643aa0179e598e78d938c59035389054535a229Svetoslav Ganov if (!isSealed()) { 14408643aa0179e598e78d938c59035389054535a229Svetoslav Ganov throw new IllegalStateException("Cannot perform this " 14418643aa0179e598e78d938c59035389054535a229Svetoslav Ganov + "action on a not sealed instance."); 14428643aa0179e598e78d938c59035389054535a229Svetoslav Ganov } 14438643aa0179e598e78d938c59035389054535a229Svetoslav Ganov } 14448643aa0179e598e78d938c59035389054535a229Svetoslav Ganov 14452ef6905003c20010032ee993dfcc5899ad9be6f8Svetoslav Ganov private void enforceValidFocusDirection(int direction) { 14462ef6905003c20010032ee993dfcc5899ad9be6f8Svetoslav Ganov switch (direction) { 14472ef6905003c20010032ee993dfcc5899ad9be6f8Svetoslav Ganov case View.FOCUS_DOWN: 14482ef6905003c20010032ee993dfcc5899ad9be6f8Svetoslav Ganov case View.FOCUS_UP: 14492ef6905003c20010032ee993dfcc5899ad9be6f8Svetoslav Ganov case View.FOCUS_LEFT: 14502ef6905003c20010032ee993dfcc5899ad9be6f8Svetoslav Ganov case View.FOCUS_RIGHT: 14512ef6905003c20010032ee993dfcc5899ad9be6f8Svetoslav Ganov case View.FOCUS_FORWARD: 14522ef6905003c20010032ee993dfcc5899ad9be6f8Svetoslav Ganov case View.FOCUS_BACKWARD: 14532ef6905003c20010032ee993dfcc5899ad9be6f8Svetoslav Ganov return; 14542ef6905003c20010032ee993dfcc5899ad9be6f8Svetoslav Ganov default: 14552ef6905003c20010032ee993dfcc5899ad9be6f8Svetoslav Ganov throw new IllegalArgumentException("Unknown direction: " + direction); 14562ef6905003c20010032ee993dfcc5899ad9be6f8Svetoslav Ganov } 14572ef6905003c20010032ee993dfcc5899ad9be6f8Svetoslav Ganov } 14582ef6905003c20010032ee993dfcc5899ad9be6f8Svetoslav Ganov 14592ef6905003c20010032ee993dfcc5899ad9be6f8Svetoslav Ganov private void enforceValidFocusType(int focusType) { 14602ef6905003c20010032ee993dfcc5899ad9be6f8Svetoslav Ganov switch (focusType) { 14612ef6905003c20010032ee993dfcc5899ad9be6f8Svetoslav Ganov case FOCUS_INPUT: 14622ef6905003c20010032ee993dfcc5899ad9be6f8Svetoslav Ganov case FOCUS_ACCESSIBILITY: 14632ef6905003c20010032ee993dfcc5899ad9be6f8Svetoslav Ganov return; 14642ef6905003c20010032ee993dfcc5899ad9be6f8Svetoslav Ganov default: 14652ef6905003c20010032ee993dfcc5899ad9be6f8Svetoslav Ganov throw new IllegalArgumentException("Unknown focus type: " + focusType); 14662ef6905003c20010032ee993dfcc5899ad9be6f8Svetoslav Ganov } 14672ef6905003c20010032ee993dfcc5899ad9be6f8Svetoslav Ganov } 14682ef6905003c20010032ee993dfcc5899ad9be6f8Svetoslav Ganov 14698643aa0179e598e78d938c59035389054535a229Svetoslav Ganov /** 14708643aa0179e598e78d938c59035389054535a229Svetoslav Ganov * Enforces that this instance is not sealed. 14718643aa0179e598e78d938c59035389054535a229Svetoslav Ganov * 14728643aa0179e598e78d938c59035389054535a229Svetoslav Ganov * @throws IllegalStateException If this instance is sealed. 14738643aa0179e598e78d938c59035389054535a229Svetoslav Ganov * 14748643aa0179e598e78d938c59035389054535a229Svetoslav Ganov * @hide 14758643aa0179e598e78d938c59035389054535a229Svetoslav Ganov */ 14768643aa0179e598e78d938c59035389054535a229Svetoslav Ganov protected void enforceNotSealed() { 14778643aa0179e598e78d938c59035389054535a229Svetoslav Ganov if (isSealed()) { 14788643aa0179e598e78d938c59035389054535a229Svetoslav Ganov throw new IllegalStateException("Cannot perform this " 1479f76a50ce8fdc6aea22cabc77b2977a1a15a79630Ken Wakasa + "action on a sealed instance."); 14808643aa0179e598e78d938c59035389054535a229Svetoslav Ganov } 14818643aa0179e598e78d938c59035389054535a229Svetoslav Ganov } 14828643aa0179e598e78d938c59035389054535a229Svetoslav Ganov 14838643aa0179e598e78d938c59035389054535a229Svetoslav Ganov /** 14848643aa0179e598e78d938c59035389054535a229Svetoslav Ganov * Returns a cached instance if such is available otherwise a new one 14858643aa0179e598e78d938c59035389054535a229Svetoslav Ganov * and sets the source. 14868643aa0179e598e78d938c59035389054535a229Svetoslav Ganov * 1487021078554b902179442a345a9d080a165c3b5139Svetoslav Ganov * @param source The source view. 14888643aa0179e598e78d938c59035389054535a229Svetoslav Ganov * @return An instance. 14898643aa0179e598e78d938c59035389054535a229Svetoslav Ganov * 14908643aa0179e598e78d938c59035389054535a229Svetoslav Ganov * @see #setSource(View) 14918643aa0179e598e78d938c59035389054535a229Svetoslav Ganov */ 14928643aa0179e598e78d938c59035389054535a229Svetoslav Ganov public static AccessibilityNodeInfo obtain(View source) { 14938643aa0179e598e78d938c59035389054535a229Svetoslav Ganov AccessibilityNodeInfo info = AccessibilityNodeInfo.obtain(); 14948643aa0179e598e78d938c59035389054535a229Svetoslav Ganov info.setSource(source); 14958643aa0179e598e78d938c59035389054535a229Svetoslav Ganov return info; 14968643aa0179e598e78d938c59035389054535a229Svetoslav Ganov } 14978643aa0179e598e78d938c59035389054535a229Svetoslav Ganov 14988643aa0179e598e78d938c59035389054535a229Svetoslav Ganov /** 1499021078554b902179442a345a9d080a165c3b5139Svetoslav Ganov * Returns a cached instance if such is available otherwise a new one 1500021078554b902179442a345a9d080a165c3b5139Svetoslav Ganov * and sets the source. 1501021078554b902179442a345a9d080a165c3b5139Svetoslav Ganov * 1502021078554b902179442a345a9d080a165c3b5139Svetoslav Ganov * @param root The root of the virtual subtree. 1503021078554b902179442a345a9d080a165c3b5139Svetoslav Ganov * @param virtualDescendantId The id of the virtual descendant. 1504021078554b902179442a345a9d080a165c3b5139Svetoslav Ganov * @return An instance. 1505021078554b902179442a345a9d080a165c3b5139Svetoslav Ganov * 1506021078554b902179442a345a9d080a165c3b5139Svetoslav Ganov * @see #setSource(View, int) 1507021078554b902179442a345a9d080a165c3b5139Svetoslav Ganov */ 1508021078554b902179442a345a9d080a165c3b5139Svetoslav Ganov public static AccessibilityNodeInfo obtain(View root, int virtualDescendantId) { 1509021078554b902179442a345a9d080a165c3b5139Svetoslav Ganov AccessibilityNodeInfo info = AccessibilityNodeInfo.obtain(); 1510021078554b902179442a345a9d080a165c3b5139Svetoslav Ganov info.setSource(root, virtualDescendantId); 1511021078554b902179442a345a9d080a165c3b5139Svetoslav Ganov return info; 1512021078554b902179442a345a9d080a165c3b5139Svetoslav Ganov } 1513021078554b902179442a345a9d080a165c3b5139Svetoslav Ganov 1514021078554b902179442a345a9d080a165c3b5139Svetoslav Ganov /** 15158643aa0179e598e78d938c59035389054535a229Svetoslav Ganov * Returns a cached instance if such is available otherwise a new one. 15168643aa0179e598e78d938c59035389054535a229Svetoslav Ganov * 15178643aa0179e598e78d938c59035389054535a229Svetoslav Ganov * @return An instance. 15188643aa0179e598e78d938c59035389054535a229Svetoslav Ganov */ 15198643aa0179e598e78d938c59035389054535a229Svetoslav Ganov public static AccessibilityNodeInfo obtain() { 15208643aa0179e598e78d938c59035389054535a229Svetoslav Ganov synchronized (sPoolLock) { 15218643aa0179e598e78d938c59035389054535a229Svetoslav Ganov if (sPool != null) { 15228643aa0179e598e78d938c59035389054535a229Svetoslav Ganov AccessibilityNodeInfo info = sPool; 15238643aa0179e598e78d938c59035389054535a229Svetoslav Ganov sPool = sPool.mNext; 15248643aa0179e598e78d938c59035389054535a229Svetoslav Ganov sPoolSize--; 15258643aa0179e598e78d938c59035389054535a229Svetoslav Ganov info.mNext = null; 15268643aa0179e598e78d938c59035389054535a229Svetoslav Ganov info.mIsInPool = false; 15279210ccbdc3629cead65a822d729e1783a773118cSvetoslav Ganov return info; 15288643aa0179e598e78d938c59035389054535a229Svetoslav Ganov } 15298643aa0179e598e78d938c59035389054535a229Svetoslav Ganov return new AccessibilityNodeInfo(); 15308643aa0179e598e78d938c59035389054535a229Svetoslav Ganov } 15318643aa0179e598e78d938c59035389054535a229Svetoslav Ganov } 15328643aa0179e598e78d938c59035389054535a229Svetoslav Ganov 15338643aa0179e598e78d938c59035389054535a229Svetoslav Ganov /** 153435bfedeaba724aeadc6f6c890269cb6bf7ef42f5Svetoslav Ganov * Returns a cached instance if such is available or a new one is 153535bfedeaba724aeadc6f6c890269cb6bf7ef42f5Svetoslav Ganov * create. The returned instance is initialized from the given 153635bfedeaba724aeadc6f6c890269cb6bf7ef42f5Svetoslav Ganov * <code>info</code>. 153735bfedeaba724aeadc6f6c890269cb6bf7ef42f5Svetoslav Ganov * 153835bfedeaba724aeadc6f6c890269cb6bf7ef42f5Svetoslav Ganov * @param info The other info. 153935bfedeaba724aeadc6f6c890269cb6bf7ef42f5Svetoslav Ganov * @return An instance. 154035bfedeaba724aeadc6f6c890269cb6bf7ef42f5Svetoslav Ganov */ 154135bfedeaba724aeadc6f6c890269cb6bf7ef42f5Svetoslav Ganov public static AccessibilityNodeInfo obtain(AccessibilityNodeInfo info) { 154235bfedeaba724aeadc6f6c890269cb6bf7ef42f5Svetoslav Ganov AccessibilityNodeInfo infoClone = AccessibilityNodeInfo.obtain(); 154335bfedeaba724aeadc6f6c890269cb6bf7ef42f5Svetoslav Ganov infoClone.init(info); 154435bfedeaba724aeadc6f6c890269cb6bf7ef42f5Svetoslav Ganov return infoClone; 154535bfedeaba724aeadc6f6c890269cb6bf7ef42f5Svetoslav Ganov } 154635bfedeaba724aeadc6f6c890269cb6bf7ef42f5Svetoslav Ganov 154735bfedeaba724aeadc6f6c890269cb6bf7ef42f5Svetoslav Ganov /** 15488643aa0179e598e78d938c59035389054535a229Svetoslav Ganov * Return an instance back to be reused. 15498643aa0179e598e78d938c59035389054535a229Svetoslav Ganov * <p> 155038e8b4e5bc3c93affdffbc064fd9db5aeccc3e8eSvetoslav Ganov * <strong>Note:</strong> You must not touch the object after calling this function. 15518643aa0179e598e78d938c59035389054535a229Svetoslav Ganov * 15528643aa0179e598e78d938c59035389054535a229Svetoslav Ganov * @throws IllegalStateException If the info is already recycled. 15538643aa0179e598e78d938c59035389054535a229Svetoslav Ganov */ 15548643aa0179e598e78d938c59035389054535a229Svetoslav Ganov public void recycle() { 15558643aa0179e598e78d938c59035389054535a229Svetoslav Ganov if (mIsInPool) { 15568643aa0179e598e78d938c59035389054535a229Svetoslav Ganov throw new IllegalStateException("Info already recycled!"); 15578643aa0179e598e78d938c59035389054535a229Svetoslav Ganov } 15588643aa0179e598e78d938c59035389054535a229Svetoslav Ganov clear(); 15598643aa0179e598e78d938c59035389054535a229Svetoslav Ganov synchronized (sPoolLock) { 15608643aa0179e598e78d938c59035389054535a229Svetoslav Ganov if (sPoolSize <= MAX_POOL_SIZE) { 15618643aa0179e598e78d938c59035389054535a229Svetoslav Ganov mNext = sPool; 15628643aa0179e598e78d938c59035389054535a229Svetoslav Ganov sPool = this; 15638643aa0179e598e78d938c59035389054535a229Svetoslav Ganov mIsInPool = true; 15648643aa0179e598e78d938c59035389054535a229Svetoslav Ganov sPoolSize++; 15658643aa0179e598e78d938c59035389054535a229Svetoslav Ganov } 15668643aa0179e598e78d938c59035389054535a229Svetoslav Ganov } 15678643aa0179e598e78d938c59035389054535a229Svetoslav Ganov } 15688643aa0179e598e78d938c59035389054535a229Svetoslav Ganov 15698643aa0179e598e78d938c59035389054535a229Svetoslav Ganov /** 15708643aa0179e598e78d938c59035389054535a229Svetoslav Ganov * {@inheritDoc} 15718643aa0179e598e78d938c59035389054535a229Svetoslav Ganov * <p> 157238e8b4e5bc3c93affdffbc064fd9db5aeccc3e8eSvetoslav Ganov * <strong>Note:</strong> After the instance is written to a parcel it 157338e8b4e5bc3c93affdffbc064fd9db5aeccc3e8eSvetoslav Ganov * is recycled. You must not touch the object after calling this function. 15748643aa0179e598e78d938c59035389054535a229Svetoslav Ganov * </p> 15758643aa0179e598e78d938c59035389054535a229Svetoslav Ganov */ 15768643aa0179e598e78d938c59035389054535a229Svetoslav Ganov public void writeToParcel(Parcel parcel, int flags) { 15778643aa0179e598e78d938c59035389054535a229Svetoslav Ganov parcel.writeInt(isSealed() ? 1 : 0); 1578021078554b902179442a345a9d080a165c3b5139Svetoslav Ganov parcel.writeLong(mSourceNodeId); 1579021078554b902179442a345a9d080a165c3b5139Svetoslav Ganov parcel.writeInt(mWindowId); 1580021078554b902179442a345a9d080a165c3b5139Svetoslav Ganov parcel.writeLong(mParentNodeId); 158133aef98fd28dcac0a2ad37e7329afd3e666f5e0aSvetoslav Ganov parcel.writeLong(mLabelForId); 158233aef98fd28dcac0a2ad37e7329afd3e666f5e0aSvetoslav Ganov parcel.writeLong(mLabeledById); 1583d116d7c78a9c53f30a73bf273bd7618312cf3847Svetoslav Ganov parcel.writeInt(mConnectionId); 15848643aa0179e598e78d938c59035389054535a229Svetoslav Ganov 158557c7fd5a43237afc5e8ef31a076e862c0c16c328Svetoslav Ganov SparseLongArray childIds = mChildNodeIds; 15868643aa0179e598e78d938c59035389054535a229Svetoslav Ganov final int childIdsSize = childIds.size(); 15878643aa0179e598e78d938c59035389054535a229Svetoslav Ganov parcel.writeInt(childIdsSize); 15888643aa0179e598e78d938c59035389054535a229Svetoslav Ganov for (int i = 0; i < childIdsSize; i++) { 1589021078554b902179442a345a9d080a165c3b5139Svetoslav Ganov parcel.writeLong(childIds.valueAt(i)); 15908643aa0179e598e78d938c59035389054535a229Svetoslav Ganov } 15918643aa0179e598e78d938c59035389054535a229Svetoslav Ganov 1592eeee4d2c01d3c4ed99e4891dbc75c7de69a803faSvetoslav Ganov parcel.writeInt(mBoundsInParent.top); 1593eeee4d2c01d3c4ed99e4891dbc75c7de69a803faSvetoslav Ganov parcel.writeInt(mBoundsInParent.bottom); 1594eeee4d2c01d3c4ed99e4891dbc75c7de69a803faSvetoslav Ganov parcel.writeInt(mBoundsInParent.left); 1595eeee4d2c01d3c4ed99e4891dbc75c7de69a803faSvetoslav Ganov parcel.writeInt(mBoundsInParent.right); 1596eeee4d2c01d3c4ed99e4891dbc75c7de69a803faSvetoslav Ganov 1597eeee4d2c01d3c4ed99e4891dbc75c7de69a803faSvetoslav Ganov parcel.writeInt(mBoundsInScreen.top); 1598eeee4d2c01d3c4ed99e4891dbc75c7de69a803faSvetoslav Ganov parcel.writeInt(mBoundsInScreen.bottom); 1599eeee4d2c01d3c4ed99e4891dbc75c7de69a803faSvetoslav Ganov parcel.writeInt(mBoundsInScreen.left); 1600eeee4d2c01d3c4ed99e4891dbc75c7de69a803faSvetoslav Ganov parcel.writeInt(mBoundsInScreen.right); 16018643aa0179e598e78d938c59035389054535a229Svetoslav Ganov 16028643aa0179e598e78d938c59035389054535a229Svetoslav Ganov parcel.writeInt(mActions); 16038643aa0179e598e78d938c59035389054535a229Svetoslav Ganov 16042b435aada3d274a9c08d334946fff1ab9ba15b48Svetoslav Ganov parcel.writeInt(mMovementGranularities); 1605b7ff3255c6d4e12f9d2334e3bbec0a125b7b09dcSvetoslav Ganov 16068643aa0179e598e78d938c59035389054535a229Svetoslav Ganov parcel.writeInt(mBooleanProperties); 16078643aa0179e598e78d938c59035389054535a229Svetoslav Ganov 1608aa780c110922148a6a4ba06734bb2b0bb8c98f93Svetoslav Ganov parcel.writeCharSequence(mPackageName); 1609aa780c110922148a6a4ba06734bb2b0bb8c98f93Svetoslav Ganov parcel.writeCharSequence(mClassName); 1610aa780c110922148a6a4ba06734bb2b0bb8c98f93Svetoslav Ganov parcel.writeCharSequence(mText); 1611aa780c110922148a6a4ba06734bb2b0bb8c98f93Svetoslav Ganov parcel.writeCharSequence(mContentDescription); 16128643aa0179e598e78d938c59035389054535a229Svetoslav Ganov 16138643aa0179e598e78d938c59035389054535a229Svetoslav Ganov // Since instances of this class are fetched via synchronous i.e. blocking 161438e8b4e5bc3c93affdffbc064fd9db5aeccc3e8eSvetoslav Ganov // calls in IPCs we always recycle as soon as the instance is marshaled. 16158643aa0179e598e78d938c59035389054535a229Svetoslav Ganov recycle(); 16168643aa0179e598e78d938c59035389054535a229Svetoslav Ganov } 16178643aa0179e598e78d938c59035389054535a229Svetoslav Ganov 16188643aa0179e598e78d938c59035389054535a229Svetoslav Ganov /** 161935bfedeaba724aeadc6f6c890269cb6bf7ef42f5Svetoslav Ganov * Initializes this instance from another one. 162035bfedeaba724aeadc6f6c890269cb6bf7ef42f5Svetoslav Ganov * 162135bfedeaba724aeadc6f6c890269cb6bf7ef42f5Svetoslav Ganov * @param other The other instance. 162235bfedeaba724aeadc6f6c890269cb6bf7ef42f5Svetoslav Ganov */ 1623aa780c110922148a6a4ba06734bb2b0bb8c98f93Svetoslav Ganov @SuppressWarnings("unchecked") 162435bfedeaba724aeadc6f6c890269cb6bf7ef42f5Svetoslav Ganov private void init(AccessibilityNodeInfo other) { 162535bfedeaba724aeadc6f6c890269cb6bf7ef42f5Svetoslav Ganov mSealed = other.mSealed; 1626021078554b902179442a345a9d080a165c3b5139Svetoslav Ganov mSourceNodeId = other.mSourceNodeId; 1627021078554b902179442a345a9d080a165c3b5139Svetoslav Ganov mParentNodeId = other.mParentNodeId; 162833aef98fd28dcac0a2ad37e7329afd3e666f5e0aSvetoslav Ganov mLabelForId = other.mLabelForId; 162933aef98fd28dcac0a2ad37e7329afd3e666f5e0aSvetoslav Ganov mLabeledById = other.mLabeledById; 1630021078554b902179442a345a9d080a165c3b5139Svetoslav Ganov mWindowId = other.mWindowId; 1631d116d7c78a9c53f30a73bf273bd7618312cf3847Svetoslav Ganov mConnectionId = other.mConnectionId; 163235bfedeaba724aeadc6f6c890269cb6bf7ef42f5Svetoslav Ganov mBoundsInParent.set(other.mBoundsInParent); 163335bfedeaba724aeadc6f6c890269cb6bf7ef42f5Svetoslav Ganov mBoundsInScreen.set(other.mBoundsInScreen); 163435bfedeaba724aeadc6f6c890269cb6bf7ef42f5Svetoslav Ganov mPackageName = other.mPackageName; 163535bfedeaba724aeadc6f6c890269cb6bf7ef42f5Svetoslav Ganov mClassName = other.mClassName; 163635bfedeaba724aeadc6f6c890269cb6bf7ef42f5Svetoslav Ganov mText = other.mText; 163735bfedeaba724aeadc6f6c890269cb6bf7ef42f5Svetoslav Ganov mContentDescription = other.mContentDescription; 163835bfedeaba724aeadc6f6c890269cb6bf7ef42f5Svetoslav Ganov mActions= other.mActions; 163935bfedeaba724aeadc6f6c890269cb6bf7ef42f5Svetoslav Ganov mBooleanProperties = other.mBooleanProperties; 16402b435aada3d274a9c08d334946fff1ab9ba15b48Svetoslav Ganov mMovementGranularities = other.mMovementGranularities; 1641aa780c110922148a6a4ba06734bb2b0bb8c98f93Svetoslav Ganov final int otherChildIdCount = other.mChildNodeIds.size(); 1642aa780c110922148a6a4ba06734bb2b0bb8c98f93Svetoslav Ganov for (int i = 0; i < otherChildIdCount; i++) { 1643aa780c110922148a6a4ba06734bb2b0bb8c98f93Svetoslav Ganov mChildNodeIds.put(i, other.mChildNodeIds.valueAt(i)); 1644aa780c110922148a6a4ba06734bb2b0bb8c98f93Svetoslav Ganov } 164535bfedeaba724aeadc6f6c890269cb6bf7ef42f5Svetoslav Ganov } 164635bfedeaba724aeadc6f6c890269cb6bf7ef42f5Svetoslav Ganov 164735bfedeaba724aeadc6f6c890269cb6bf7ef42f5Svetoslav Ganov /** 16488643aa0179e598e78d938c59035389054535a229Svetoslav Ganov * Creates a new instance from a {@link Parcel}. 16498643aa0179e598e78d938c59035389054535a229Svetoslav Ganov * 16508643aa0179e598e78d938c59035389054535a229Svetoslav Ganov * @param parcel A parcel containing the state of a {@link AccessibilityNodeInfo}. 16518643aa0179e598e78d938c59035389054535a229Svetoslav Ganov */ 16528643aa0179e598e78d938c59035389054535a229Svetoslav Ganov private void initFromParcel(Parcel parcel) { 16538643aa0179e598e78d938c59035389054535a229Svetoslav Ganov mSealed = (parcel.readInt() == 1); 1654021078554b902179442a345a9d080a165c3b5139Svetoslav Ganov mSourceNodeId = parcel.readLong(); 1655021078554b902179442a345a9d080a165c3b5139Svetoslav Ganov mWindowId = parcel.readInt(); 1656021078554b902179442a345a9d080a165c3b5139Svetoslav Ganov mParentNodeId = parcel.readLong(); 165733aef98fd28dcac0a2ad37e7329afd3e666f5e0aSvetoslav Ganov mLabelForId = parcel.readLong(); 165833aef98fd28dcac0a2ad37e7329afd3e666f5e0aSvetoslav Ganov mLabeledById = parcel.readLong(); 1659d116d7c78a9c53f30a73bf273bd7618312cf3847Svetoslav Ganov mConnectionId = parcel.readInt(); 16608643aa0179e598e78d938c59035389054535a229Svetoslav Ganov 166157c7fd5a43237afc5e8ef31a076e862c0c16c328Svetoslav Ganov SparseLongArray childIds = mChildNodeIds; 16628643aa0179e598e78d938c59035389054535a229Svetoslav Ganov final int childrenSize = parcel.readInt(); 16638643aa0179e598e78d938c59035389054535a229Svetoslav Ganov for (int i = 0; i < childrenSize; i++) { 1664021078554b902179442a345a9d080a165c3b5139Svetoslav Ganov final long childId = parcel.readLong(); 16658643aa0179e598e78d938c59035389054535a229Svetoslav Ganov childIds.put(i, childId); 16668643aa0179e598e78d938c59035389054535a229Svetoslav Ganov } 16678643aa0179e598e78d938c59035389054535a229Svetoslav Ganov 1668eeee4d2c01d3c4ed99e4891dbc75c7de69a803faSvetoslav Ganov mBoundsInParent.top = parcel.readInt(); 1669eeee4d2c01d3c4ed99e4891dbc75c7de69a803faSvetoslav Ganov mBoundsInParent.bottom = parcel.readInt(); 1670eeee4d2c01d3c4ed99e4891dbc75c7de69a803faSvetoslav Ganov mBoundsInParent.left = parcel.readInt(); 1671eeee4d2c01d3c4ed99e4891dbc75c7de69a803faSvetoslav Ganov mBoundsInParent.right = parcel.readInt(); 1672eeee4d2c01d3c4ed99e4891dbc75c7de69a803faSvetoslav Ganov 1673eeee4d2c01d3c4ed99e4891dbc75c7de69a803faSvetoslav Ganov mBoundsInScreen.top = parcel.readInt(); 1674eeee4d2c01d3c4ed99e4891dbc75c7de69a803faSvetoslav Ganov mBoundsInScreen.bottom = parcel.readInt(); 1675eeee4d2c01d3c4ed99e4891dbc75c7de69a803faSvetoslav Ganov mBoundsInScreen.left = parcel.readInt(); 1676eeee4d2c01d3c4ed99e4891dbc75c7de69a803faSvetoslav Ganov mBoundsInScreen.right = parcel.readInt(); 16778643aa0179e598e78d938c59035389054535a229Svetoslav Ganov 16788643aa0179e598e78d938c59035389054535a229Svetoslav Ganov mActions = parcel.readInt(); 16798643aa0179e598e78d938c59035389054535a229Svetoslav Ganov 16802b435aada3d274a9c08d334946fff1ab9ba15b48Svetoslav Ganov mMovementGranularities = parcel.readInt(); 1681b7ff3255c6d4e12f9d2334e3bbec0a125b7b09dcSvetoslav Ganov 16828643aa0179e598e78d938c59035389054535a229Svetoslav Ganov mBooleanProperties = parcel.readInt(); 16838643aa0179e598e78d938c59035389054535a229Svetoslav Ganov 1684aa780c110922148a6a4ba06734bb2b0bb8c98f93Svetoslav Ganov mPackageName = parcel.readCharSequence(); 1685aa780c110922148a6a4ba06734bb2b0bb8c98f93Svetoslav Ganov mClassName = parcel.readCharSequence(); 1686aa780c110922148a6a4ba06734bb2b0bb8c98f93Svetoslav Ganov mText = parcel.readCharSequence(); 1687aa780c110922148a6a4ba06734bb2b0bb8c98f93Svetoslav Ganov mContentDescription = parcel.readCharSequence(); 16888643aa0179e598e78d938c59035389054535a229Svetoslav Ganov } 16898643aa0179e598e78d938c59035389054535a229Svetoslav Ganov 16908643aa0179e598e78d938c59035389054535a229Svetoslav Ganov /** 16918643aa0179e598e78d938c59035389054535a229Svetoslav Ganov * Clears the state of this instance. 16928643aa0179e598e78d938c59035389054535a229Svetoslav Ganov */ 16938643aa0179e598e78d938c59035389054535a229Svetoslav Ganov private void clear() { 16948643aa0179e598e78d938c59035389054535a229Svetoslav Ganov mSealed = false; 16950d04e245534cf777dfaf16dce3c51553837c14ffSvetoslav Ganov mSourceNodeId = ROOT_NODE_ID; 16960d04e245534cf777dfaf16dce3c51553837c14ffSvetoslav Ganov mParentNodeId = ROOT_NODE_ID; 169733aef98fd28dcac0a2ad37e7329afd3e666f5e0aSvetoslav Ganov mLabelForId = ROOT_NODE_ID; 169833aef98fd28dcac0a2ad37e7329afd3e666f5e0aSvetoslav Ganov mLabeledById = ROOT_NODE_ID; 1699f3b4f3163b5b4c0a54a2643f07c97c47b14a1eb7Svetoslav Ganov mWindowId = UNDEFINED; 1700d116d7c78a9c53f30a73bf273bd7618312cf3847Svetoslav Ganov mConnectionId = UNDEFINED; 17012b435aada3d274a9c08d334946fff1ab9ba15b48Svetoslav Ganov mMovementGranularities = 0; 170257c7fd5a43237afc5e8ef31a076e862c0c16c328Svetoslav Ganov mChildNodeIds.clear(); 1703eeee4d2c01d3c4ed99e4891dbc75c7de69a803faSvetoslav Ganov mBoundsInParent.set(0, 0, 0, 0); 1704eeee4d2c01d3c4ed99e4891dbc75c7de69a803faSvetoslav Ganov mBoundsInScreen.set(0, 0, 0, 0); 17058643aa0179e598e78d938c59035389054535a229Svetoslav Ganov mBooleanProperties = 0; 17068643aa0179e598e78d938c59035389054535a229Svetoslav Ganov mPackageName = null; 17078643aa0179e598e78d938c59035389054535a229Svetoslav Ganov mClassName = null; 17088643aa0179e598e78d938c59035389054535a229Svetoslav Ganov mText = null; 17098643aa0179e598e78d938c59035389054535a229Svetoslav Ganov mContentDescription = null; 17108643aa0179e598e78d938c59035389054535a229Svetoslav Ganov mActions = 0; 17118643aa0179e598e78d938c59035389054535a229Svetoslav Ganov } 17128643aa0179e598e78d938c59035389054535a229Svetoslav Ganov 17138643aa0179e598e78d938c59035389054535a229Svetoslav Ganov /** 17148643aa0179e598e78d938c59035389054535a229Svetoslav Ganov * Gets the human readable action symbolic name. 17158643aa0179e598e78d938c59035389054535a229Svetoslav Ganov * 17168643aa0179e598e78d938c59035389054535a229Svetoslav Ganov * @param action The action. 17178643aa0179e598e78d938c59035389054535a229Svetoslav Ganov * @return The symbolic name. 17188643aa0179e598e78d938c59035389054535a229Svetoslav Ganov */ 17198643aa0179e598e78d938c59035389054535a229Svetoslav Ganov private static String getActionSymbolicName(int action) { 172038e8b4e5bc3c93affdffbc064fd9db5aeccc3e8eSvetoslav Ganov switch (action) { 172138e8b4e5bc3c93affdffbc064fd9db5aeccc3e8eSvetoslav Ganov case ACTION_FOCUS: 172238e8b4e5bc3c93affdffbc064fd9db5aeccc3e8eSvetoslav Ganov return "ACTION_FOCUS"; 172338e8b4e5bc3c93affdffbc064fd9db5aeccc3e8eSvetoslav Ganov case ACTION_CLEAR_FOCUS: 172438e8b4e5bc3c93affdffbc064fd9db5aeccc3e8eSvetoslav Ganov return "ACTION_CLEAR_FOCUS"; 172538e8b4e5bc3c93affdffbc064fd9db5aeccc3e8eSvetoslav Ganov case ACTION_SELECT: 172638e8b4e5bc3c93affdffbc064fd9db5aeccc3e8eSvetoslav Ganov return "ACTION_SELECT"; 172738e8b4e5bc3c93affdffbc064fd9db5aeccc3e8eSvetoslav Ganov case ACTION_CLEAR_SELECTION: 172838e8b4e5bc3c93affdffbc064fd9db5aeccc3e8eSvetoslav Ganov return "ACTION_CLEAR_SELECTION"; 1729e9bda15f87c11a8827ca0ffc865611176805cc0aSvetoslav Ganov case ACTION_CLICK: 1730e9bda15f87c11a8827ca0ffc865611176805cc0aSvetoslav Ganov return "ACTION_CLICK"; 1731e9bda15f87c11a8827ca0ffc865611176805cc0aSvetoslav Ganov case ACTION_LONG_CLICK: 1732e9bda15f87c11a8827ca0ffc865611176805cc0aSvetoslav Ganov return "ACTION_LONG_CLICK"; 1733e9bda15f87c11a8827ca0ffc865611176805cc0aSvetoslav Ganov case ACTION_ACCESSIBILITY_FOCUS: 1734e9bda15f87c11a8827ca0ffc865611176805cc0aSvetoslav Ganov return "ACTION_ACCESSIBILITY_FOCUS"; 1735e9bda15f87c11a8827ca0ffc865611176805cc0aSvetoslav Ganov case ACTION_CLEAR_ACCESSIBILITY_FOCUS: 1736e9bda15f87c11a8827ca0ffc865611176805cc0aSvetoslav Ganov return "ACTION_CLEAR_ACCESSIBILITY_FOCUS"; 17372b435aada3d274a9c08d334946fff1ab9ba15b48Svetoslav Ganov case ACTION_NEXT_AT_MOVEMENT_GRANULARITY: 17382b435aada3d274a9c08d334946fff1ab9ba15b48Svetoslav Ganov return "ACTION_NEXT_AT_MOVEMENT_GRANULARITY"; 17392b435aada3d274a9c08d334946fff1ab9ba15b48Svetoslav Ganov case ACTION_PREVIOUS_AT_MOVEMENT_GRANULARITY: 17402b435aada3d274a9c08d334946fff1ab9ba15b48Svetoslav Ganov return "ACTION_PREVIOUS_AT_MOVEMENT_GRANULARITY"; 1741e9bda15f87c11a8827ca0ffc865611176805cc0aSvetoslav Ganov case ACTION_NEXT_HTML_ELEMENT: 1742e9bda15f87c11a8827ca0ffc865611176805cc0aSvetoslav Ganov return "ACTION_NEXT_HTML_ELEMENT"; 1743e9bda15f87c11a8827ca0ffc865611176805cc0aSvetoslav Ganov case ACTION_PREVIOUS_HTML_ELEMENT: 1744e9bda15f87c11a8827ca0ffc865611176805cc0aSvetoslav Ganov return "ACTION_PREVIOUS_HTML_ELEMENT"; 1745a1dc761c8322355eb1bb71d3d6c9c603c1d1fc0fSvetoslav Ganov case ACTION_SCROLL_FORWARD: 1746a1dc761c8322355eb1bb71d3d6c9c603c1d1fc0fSvetoslav Ganov return "ACTION_SCROLL_FORWARD"; 1747a1dc761c8322355eb1bb71d3d6c9c603c1d1fc0fSvetoslav Ganov case ACTION_SCROLL_BACKWARD: 1748a1dc761c8322355eb1bb71d3d6c9c603c1d1fc0fSvetoslav Ganov return "ACTION_SCROLL_BACKWARD"; 174938e8b4e5bc3c93affdffbc064fd9db5aeccc3e8eSvetoslav Ganov default: 175038e8b4e5bc3c93affdffbc064fd9db5aeccc3e8eSvetoslav Ganov throw new IllegalArgumentException("Unknown action: " + action); 17518643aa0179e598e78d938c59035389054535a229Svetoslav Ganov } 17528643aa0179e598e78d938c59035389054535a229Svetoslav Ganov } 17538643aa0179e598e78d938c59035389054535a229Svetoslav Ganov 1754b7ff3255c6d4e12f9d2334e3bbec0a125b7b09dcSvetoslav Ganov /** 17552b435aada3d274a9c08d334946fff1ab9ba15b48Svetoslav Ganov * Gets the human readable movement granularity symbolic name. 1756b7ff3255c6d4e12f9d2334e3bbec0a125b7b09dcSvetoslav Ganov * 17572b435aada3d274a9c08d334946fff1ab9ba15b48Svetoslav Ganov * @param granularity The granularity. 1758b7ff3255c6d4e12f9d2334e3bbec0a125b7b09dcSvetoslav Ganov * @return The symbolic name. 1759b7ff3255c6d4e12f9d2334e3bbec0a125b7b09dcSvetoslav Ganov */ 17602b435aada3d274a9c08d334946fff1ab9ba15b48Svetoslav Ganov private static String getMovementGranularitySymbolicName(int granularity) { 1761b7ff3255c6d4e12f9d2334e3bbec0a125b7b09dcSvetoslav Ganov switch (granularity) { 17622b435aada3d274a9c08d334946fff1ab9ba15b48Svetoslav Ganov case MOVEMENT_GRANULARITY_CHARACTER: 17632b435aada3d274a9c08d334946fff1ab9ba15b48Svetoslav Ganov return "MOVEMENT_GRANULARITY_CHARACTER"; 17642b435aada3d274a9c08d334946fff1ab9ba15b48Svetoslav Ganov case MOVEMENT_GRANULARITY_WORD: 17652b435aada3d274a9c08d334946fff1ab9ba15b48Svetoslav Ganov return "MOVEMENT_GRANULARITY_WORD"; 17662b435aada3d274a9c08d334946fff1ab9ba15b48Svetoslav Ganov case MOVEMENT_GRANULARITY_LINE: 17672b435aada3d274a9c08d334946fff1ab9ba15b48Svetoslav Ganov return "MOVEMENT_GRANULARITY_LINE"; 17682b435aada3d274a9c08d334946fff1ab9ba15b48Svetoslav Ganov case MOVEMENT_GRANULARITY_PARAGRAPH: 17692b435aada3d274a9c08d334946fff1ab9ba15b48Svetoslav Ganov return "MOVEMENT_GRANULARITY_PARAGRAPH"; 17702b435aada3d274a9c08d334946fff1ab9ba15b48Svetoslav Ganov case MOVEMENT_GRANULARITY_PAGE: 17712b435aada3d274a9c08d334946fff1ab9ba15b48Svetoslav Ganov return "MOVEMENT_GRANULARITY_PAGE"; 1772b7ff3255c6d4e12f9d2334e3bbec0a125b7b09dcSvetoslav Ganov default: 17732b435aada3d274a9c08d334946fff1ab9ba15b48Svetoslav Ganov throw new IllegalArgumentException("Unknown movement granularity: " + granularity); 1774b7ff3255c6d4e12f9d2334e3bbec0a125b7b09dcSvetoslav Ganov } 1775b7ff3255c6d4e12f9d2334e3bbec0a125b7b09dcSvetoslav Ganov } 1776b7ff3255c6d4e12f9d2334e3bbec0a125b7b09dcSvetoslav Ganov 1777021078554b902179442a345a9d080a165c3b5139Svetoslav Ganov private boolean canPerformRequestOverConnection(long accessibilityNodeId) { 1778f3b4f3163b5b4c0a54a2643f07c97c47b14a1eb7Svetoslav Ganov return (mWindowId != UNDEFINED 1779f3b4f3163b5b4c0a54a2643f07c97c47b14a1eb7Svetoslav Ganov && getAccessibilityViewId(accessibilityNodeId) != UNDEFINED 1780f3b4f3163b5b4c0a54a2643f07c97c47b14a1eb7Svetoslav Ganov && mConnectionId != UNDEFINED); 1781eeee4d2c01d3c4ed99e4891dbc75c7de69a803faSvetoslav Ganov } 1782eeee4d2c01d3c4ed99e4891dbc75c7de69a803faSvetoslav Ganov 17838643aa0179e598e78d938c59035389054535a229Svetoslav Ganov @Override 17848dffad68c7aa7da9a3d73d1ee41f3c4460f733b4Svetoslav Ganov public boolean equals(Object object) { 17858dffad68c7aa7da9a3d73d1ee41f3c4460f733b4Svetoslav Ganov if (this == object) { 17868dffad68c7aa7da9a3d73d1ee41f3c4460f733b4Svetoslav Ganov return true; 17878dffad68c7aa7da9a3d73d1ee41f3c4460f733b4Svetoslav Ganov } 17888dffad68c7aa7da9a3d73d1ee41f3c4460f733b4Svetoslav Ganov if (object == null) { 17898dffad68c7aa7da9a3d73d1ee41f3c4460f733b4Svetoslav Ganov return false; 17908dffad68c7aa7da9a3d73d1ee41f3c4460f733b4Svetoslav Ganov } 17918dffad68c7aa7da9a3d73d1ee41f3c4460f733b4Svetoslav Ganov if (getClass() != object.getClass()) { 17928dffad68c7aa7da9a3d73d1ee41f3c4460f733b4Svetoslav Ganov return false; 17938dffad68c7aa7da9a3d73d1ee41f3c4460f733b4Svetoslav Ganov } 17948dffad68c7aa7da9a3d73d1ee41f3c4460f733b4Svetoslav Ganov AccessibilityNodeInfo other = (AccessibilityNodeInfo) object; 1795021078554b902179442a345a9d080a165c3b5139Svetoslav Ganov if (mSourceNodeId != other.mSourceNodeId) { 17968dffad68c7aa7da9a3d73d1ee41f3c4460f733b4Svetoslav Ganov return false; 17978dffad68c7aa7da9a3d73d1ee41f3c4460f733b4Svetoslav Ganov } 1798021078554b902179442a345a9d080a165c3b5139Svetoslav Ganov if (mWindowId != other.mWindowId) { 17998dffad68c7aa7da9a3d73d1ee41f3c4460f733b4Svetoslav Ganov return false; 18008dffad68c7aa7da9a3d73d1ee41f3c4460f733b4Svetoslav Ganov } 18018dffad68c7aa7da9a3d73d1ee41f3c4460f733b4Svetoslav Ganov return true; 18028dffad68c7aa7da9a3d73d1ee41f3c4460f733b4Svetoslav Ganov } 18038dffad68c7aa7da9a3d73d1ee41f3c4460f733b4Svetoslav Ganov 18048dffad68c7aa7da9a3d73d1ee41f3c4460f733b4Svetoslav Ganov @Override 18058643aa0179e598e78d938c59035389054535a229Svetoslav Ganov public int hashCode() { 18068643aa0179e598e78d938c59035389054535a229Svetoslav Ganov final int prime = 31; 18078643aa0179e598e78d938c59035389054535a229Svetoslav Ganov int result = 1; 1808021078554b902179442a345a9d080a165c3b5139Svetoslav Ganov result = prime * result + getAccessibilityViewId(mSourceNodeId); 1809021078554b902179442a345a9d080a165c3b5139Svetoslav Ganov result = prime * result + getVirtualDescendantId(mSourceNodeId); 1810021078554b902179442a345a9d080a165c3b5139Svetoslav Ganov result = prime * result + mWindowId; 18118643aa0179e598e78d938c59035389054535a229Svetoslav Ganov return result; 18128643aa0179e598e78d938c59035389054535a229Svetoslav Ganov } 18138643aa0179e598e78d938c59035389054535a229Svetoslav Ganov 18148643aa0179e598e78d938c59035389054535a229Svetoslav Ganov @Override 18158643aa0179e598e78d938c59035389054535a229Svetoslav Ganov public String toString() { 18168643aa0179e598e78d938c59035389054535a229Svetoslav Ganov StringBuilder builder = new StringBuilder(); 18178643aa0179e598e78d938c59035389054535a229Svetoslav Ganov builder.append(super.toString()); 18188643aa0179e598e78d938c59035389054535a229Svetoslav Ganov 18198643aa0179e598e78d938c59035389054535a229Svetoslav Ganov if (DEBUG) { 1820021078554b902179442a345a9d080a165c3b5139Svetoslav Ganov builder.append("; accessibilityViewId: " + getAccessibilityViewId(mSourceNodeId)); 1821021078554b902179442a345a9d080a165c3b5139Svetoslav Ganov builder.append("; virtualDescendantId: " + getVirtualDescendantId(mSourceNodeId)); 1822021078554b902179442a345a9d080a165c3b5139Svetoslav Ganov builder.append("; mParentNodeId: " + mParentNodeId); 1823aa780c110922148a6a4ba06734bb2b0bb8c98f93Svetoslav Ganov 18242b435aada3d274a9c08d334946fff1ab9ba15b48Svetoslav Ganov int granularities = mMovementGranularities; 18252b435aada3d274a9c08d334946fff1ab9ba15b48Svetoslav Ganov builder.append("; MovementGranularities: ["); 1826b7ff3255c6d4e12f9d2334e3bbec0a125b7b09dcSvetoslav Ganov while (granularities != 0) { 1827b7ff3255c6d4e12f9d2334e3bbec0a125b7b09dcSvetoslav Ganov final int granularity = 1 << Integer.numberOfTrailingZeros(granularities); 1828b7ff3255c6d4e12f9d2334e3bbec0a125b7b09dcSvetoslav Ganov granularities &= ~granularity; 18292b435aada3d274a9c08d334946fff1ab9ba15b48Svetoslav Ganov builder.append(getMovementGranularitySymbolicName(granularity)); 1830b7ff3255c6d4e12f9d2334e3bbec0a125b7b09dcSvetoslav Ganov if (granularities != 0) { 1831aa780c110922148a6a4ba06734bb2b0bb8c98f93Svetoslav Ganov builder.append(", "); 1832aa780c110922148a6a4ba06734bb2b0bb8c98f93Svetoslav Ganov } 1833aa780c110922148a6a4ba06734bb2b0bb8c98f93Svetoslav Ganov } 1834aa780c110922148a6a4ba06734bb2b0bb8c98f93Svetoslav Ganov builder.append("]"); 1835aa780c110922148a6a4ba06734bb2b0bb8c98f93Svetoslav Ganov 183657c7fd5a43237afc5e8ef31a076e862c0c16c328Svetoslav Ganov SparseLongArray childIds = mChildNodeIds; 18378643aa0179e598e78d938c59035389054535a229Svetoslav Ganov builder.append("; childAccessibilityIds: ["); 18388643aa0179e598e78d938c59035389054535a229Svetoslav Ganov for (int i = 0, count = childIds.size(); i < count; i++) { 18398643aa0179e598e78d938c59035389054535a229Svetoslav Ganov builder.append(childIds.valueAt(i)); 18408643aa0179e598e78d938c59035389054535a229Svetoslav Ganov if (i < count - 1) { 18418643aa0179e598e78d938c59035389054535a229Svetoslav Ganov builder.append(", "); 18428643aa0179e598e78d938c59035389054535a229Svetoslav Ganov } 1843aa780c110922148a6a4ba06734bb2b0bb8c98f93Svetoslav Ganov } 1844aa780c110922148a6a4ba06734bb2b0bb8c98f93Svetoslav Ganov builder.append("]"); 18458643aa0179e598e78d938c59035389054535a229Svetoslav Ganov } 18468643aa0179e598e78d938c59035389054535a229Svetoslav Ganov 1847eeee4d2c01d3c4ed99e4891dbc75c7de69a803faSvetoslav Ganov builder.append("; boundsInParent: " + mBoundsInParent); 1848eeee4d2c01d3c4ed99e4891dbc75c7de69a803faSvetoslav Ganov builder.append("; boundsInScreen: " + mBoundsInScreen); 18498643aa0179e598e78d938c59035389054535a229Svetoslav Ganov 18508643aa0179e598e78d938c59035389054535a229Svetoslav Ganov builder.append("; packageName: ").append(mPackageName); 18518643aa0179e598e78d938c59035389054535a229Svetoslav Ganov builder.append("; className: ").append(mClassName); 18528643aa0179e598e78d938c59035389054535a229Svetoslav Ganov builder.append("; text: ").append(mText); 18538643aa0179e598e78d938c59035389054535a229Svetoslav Ganov builder.append("; contentDescription: ").append(mContentDescription); 18548643aa0179e598e78d938c59035389054535a229Svetoslav Ganov 18558643aa0179e598e78d938c59035389054535a229Svetoslav Ganov builder.append("; checkable: ").append(isCheckable()); 18568643aa0179e598e78d938c59035389054535a229Svetoslav Ganov builder.append("; checked: ").append(isChecked()); 18578643aa0179e598e78d938c59035389054535a229Svetoslav Ganov builder.append("; focusable: ").append(isFocusable()); 18588643aa0179e598e78d938c59035389054535a229Svetoslav Ganov builder.append("; focused: ").append(isFocused()); 18598643aa0179e598e78d938c59035389054535a229Svetoslav Ganov builder.append("; selected: ").append(isSelected()); 18608643aa0179e598e78d938c59035389054535a229Svetoslav Ganov builder.append("; clickable: ").append(isClickable()); 18618643aa0179e598e78d938c59035389054535a229Svetoslav Ganov builder.append("; longClickable: ").append(isLongClickable()); 18628643aa0179e598e78d938c59035389054535a229Svetoslav Ganov builder.append("; enabled: ").append(isEnabled()); 18638643aa0179e598e78d938c59035389054535a229Svetoslav Ganov builder.append("; password: ").append(isPassword()); 1864a0156177cdc809795dd8bc5a19943dd2b6f82b66Svetoslav Ganov builder.append("; scrollable: " + isScrollable()); 18658643aa0179e598e78d938c59035389054535a229Svetoslav Ganov 18668643aa0179e598e78d938c59035389054535a229Svetoslav Ganov builder.append("; ["); 18678643aa0179e598e78d938c59035389054535a229Svetoslav Ganov for (int actionBits = mActions; actionBits != 0;) { 18688643aa0179e598e78d938c59035389054535a229Svetoslav Ganov final int action = 1 << Integer.numberOfTrailingZeros(actionBits); 18698643aa0179e598e78d938c59035389054535a229Svetoslav Ganov actionBits &= ~action; 18708643aa0179e598e78d938c59035389054535a229Svetoslav Ganov builder.append(getActionSymbolicName(action)); 18718643aa0179e598e78d938c59035389054535a229Svetoslav Ganov if (actionBits != 0) { 18728643aa0179e598e78d938c59035389054535a229Svetoslav Ganov builder.append(", "); 18738643aa0179e598e78d938c59035389054535a229Svetoslav Ganov } 18748643aa0179e598e78d938c59035389054535a229Svetoslav Ganov } 18758643aa0179e598e78d938c59035389054535a229Svetoslav Ganov builder.append("]"); 18768643aa0179e598e78d938c59035389054535a229Svetoslav Ganov 18778643aa0179e598e78d938c59035389054535a229Svetoslav Ganov return builder.toString(); 18788643aa0179e598e78d938c59035389054535a229Svetoslav Ganov } 18798643aa0179e598e78d938c59035389054535a229Svetoslav Ganov 18808643aa0179e598e78d938c59035389054535a229Svetoslav Ganov /** 18818643aa0179e598e78d938c59035389054535a229Svetoslav Ganov * @see Parcelable.Creator 18828643aa0179e598e78d938c59035389054535a229Svetoslav Ganov */ 18838643aa0179e598e78d938c59035389054535a229Svetoslav Ganov public static final Parcelable.Creator<AccessibilityNodeInfo> CREATOR = 18848643aa0179e598e78d938c59035389054535a229Svetoslav Ganov new Parcelable.Creator<AccessibilityNodeInfo>() { 18858643aa0179e598e78d938c59035389054535a229Svetoslav Ganov public AccessibilityNodeInfo createFromParcel(Parcel parcel) { 18868643aa0179e598e78d938c59035389054535a229Svetoslav Ganov AccessibilityNodeInfo info = AccessibilityNodeInfo.obtain(); 18878643aa0179e598e78d938c59035389054535a229Svetoslav Ganov info.initFromParcel(parcel); 18888643aa0179e598e78d938c59035389054535a229Svetoslav Ganov return info; 18898643aa0179e598e78d938c59035389054535a229Svetoslav Ganov } 18908643aa0179e598e78d938c59035389054535a229Svetoslav Ganov 18918643aa0179e598e78d938c59035389054535a229Svetoslav Ganov public AccessibilityNodeInfo[] newArray(int size) { 18928643aa0179e598e78d938c59035389054535a229Svetoslav Ganov return new AccessibilityNodeInfo[size]; 18938643aa0179e598e78d938c59035389054535a229Svetoslav Ganov } 18948643aa0179e598e78d938c59035389054535a229Svetoslav Ganov }; 18958643aa0179e598e78d938c59035389054535a229Svetoslav Ganov} 1896