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
1980943d8daa6ab31ab5c486d57aea406aa0730d58Svetoslav Ganovimport android.accessibilityservice.AccessibilityServiceInfo;
2074bc19476536f2b5462eaa29e6f3029ee897c16dKristian Monsenimport android.annotation.Nullable;
218643aa0179e598e78d938c59035389054535a229Svetoslav Ganovimport android.graphics.Rect;
22aa780c110922148a6a4ba06734bb2b0bb8c98f93Svetoslav Ganovimport android.os.Bundle;
238643aa0179e598e78d938c59035389054535a229Svetoslav Ganovimport android.os.Parcel;
248643aa0179e598e78d938c59035389054535a229Svetoslav Ganovimport android.os.Parcelable;
256254f4806dd3db53b7380e77fbb183065685573eSvetoslavimport android.text.InputType;
2674bc19476536f2b5462eaa29e6f3029ee897c16dKristian Monsenimport android.text.TextUtils;
2774bc19476536f2b5462eaa29e6f3029ee897c16dKristian Monsenimport android.util.ArraySet;
28f0aed09ed8153043e40b3ac99788d47ba0831306Alan Viveretteimport android.util.LongArray;
29f4782ec9c57a40224ac0974fce6b6fe280c829ceSvetoslav Ganovimport android.util.Pools.SynchronizedPool;
308643aa0179e598e78d938c59035389054535a229Svetoslav Ganovimport android.view.View;
318643aa0179e598e78d938c59035389054535a229Svetoslav Ganov
3274bc19476536f2b5462eaa29e6f3029ee897c16dKristian Monsenimport java.util.ArrayList;
33eeee4d2c01d3c4ed99e4891dbc75c7de69a803faSvetoslav Ganovimport java.util.Collections;
34eeee4d2c01d3c4ed99e4891dbc75c7de69a803faSvetoslav Ganovimport java.util.List;
35eeee4d2c01d3c4ed99e4891dbc75c7de69a803faSvetoslav Ganov
368643aa0179e598e78d938c59035389054535a229Svetoslav Ganov/**
3738e8b4e5bc3c93affdffbc064fd9db5aeccc3e8eSvetoslav Ganov * This class represents a node of the window content as well as actions that
3838e8b4e5bc3c93affdffbc064fd9db5aeccc3e8eSvetoslav Ganov * can be requested from its source. From the point of view of an
3938e8b4e5bc3c93affdffbc064fd9db5aeccc3e8eSvetoslav Ganov * {@link android.accessibilityservice.AccessibilityService} a window content is
4038e8b4e5bc3c93affdffbc064fd9db5aeccc3e8eSvetoslav Ganov * presented as tree of accessibility node info which may or may not map one-to-one
4138e8b4e5bc3c93affdffbc064fd9db5aeccc3e8eSvetoslav Ganov * to the view hierarchy. In other words, a custom view is free to report itself as
4238e8b4e5bc3c93affdffbc064fd9db5aeccc3e8eSvetoslav Ganov * a tree of accessibility node info.
4338e8b4e5bc3c93affdffbc064fd9db5aeccc3e8eSvetoslav Ganov * </p>
4438e8b4e5bc3c93affdffbc064fd9db5aeccc3e8eSvetoslav Ganov * <p>
4538e8b4e5bc3c93affdffbc064fd9db5aeccc3e8eSvetoslav Ganov * Once an accessibility node info is delivered to an accessibility service it is
4638e8b4e5bc3c93affdffbc064fd9db5aeccc3e8eSvetoslav Ganov * made immutable and calling a state mutation method generates an error.
4738e8b4e5bc3c93affdffbc064fd9db5aeccc3e8eSvetoslav Ganov * </p>
4838e8b4e5bc3c93affdffbc064fd9db5aeccc3e8eSvetoslav Ganov * <p>
4938e8b4e5bc3c93affdffbc064fd9db5aeccc3e8eSvetoslav Ganov * Please refer to {@link android.accessibilityservice.AccessibilityService} for
5038e8b4e5bc3c93affdffbc064fd9db5aeccc3e8eSvetoslav Ganov * details about how to obtain a handle to window content as a tree of accessibility
5138e8b4e5bc3c93affdffbc064fd9db5aeccc3e8eSvetoslav Ganov * node info as well as familiarizing with the security model.
5238e8b4e5bc3c93affdffbc064fd9db5aeccc3e8eSvetoslav Ganov * </p>
53e1302edd40c5cc264f842e17e3796e0a11d6f045Joe Fernandez * <div class="special reference">
54e1302edd40c5cc264f842e17e3796e0a11d6f045Joe Fernandez * <h3>Developer Guides</h3>
55e1302edd40c5cc264f842e17e3796e0a11d6f045Joe Fernandez * <p>For more information about making applications accessible, read the
56e1302edd40c5cc264f842e17e3796e0a11d6f045Joe Fernandez * <a href="{@docRoot}guide/topics/ui/accessibility/index.html">Accessibility</a>
57e1302edd40c5cc264f842e17e3796e0a11d6f045Joe Fernandez * developer guide.</p>
58e1302edd40c5cc264f842e17e3796e0a11d6f045Joe Fernandez * </div>
598643aa0179e598e78d938c59035389054535a229Svetoslav Ganov *
6038e8b4e5bc3c93affdffbc064fd9db5aeccc3e8eSvetoslav Ganov * @see android.accessibilityservice.AccessibilityService
6138e8b4e5bc3c93affdffbc064fd9db5aeccc3e8eSvetoslav Ganov * @see AccessibilityEvent
6238e8b4e5bc3c93affdffbc064fd9db5aeccc3e8eSvetoslav Ganov * @see AccessibilityManager
638643aa0179e598e78d938c59035389054535a229Svetoslav Ganov */
648643aa0179e598e78d938c59035389054535a229Svetoslav Ganovpublic class AccessibilityNodeInfo implements Parcelable {
658643aa0179e598e78d938c59035389054535a229Svetoslav Ganov
668643aa0179e598e78d938c59035389054535a229Svetoslav Ganov    private static final boolean DEBUG = false;
678643aa0179e598e78d938c59035389054535a229Svetoslav Ganov
680d04e245534cf777dfaf16dce3c51553837c14ffSvetoslav Ganov    /** @hide */
698e3feb15c5aec2c72b0ef120a1da325e1e8f0ddaSvetoslav    public static final int UNDEFINED_CONNECTION_ID = -1;
700d04e245534cf777dfaf16dce3c51553837c14ffSvetoslav Ganov
710d04e245534cf777dfaf16dce3c51553837c14ffSvetoslav Ganov    /** @hide */
728e3feb15c5aec2c72b0ef120a1da325e1e8f0ddaSvetoslav    public static final int UNDEFINED_SELECTION_INDEX = -1;
730d04e245534cf777dfaf16dce3c51553837c14ffSvetoslav Ganov
740d04e245534cf777dfaf16dce3c51553837c14ffSvetoslav Ganov    /** @hide */
758e3feb15c5aec2c72b0ef120a1da325e1e8f0ddaSvetoslav    public static final int UNDEFINED_ITEM_ID = Integer.MAX_VALUE;
768e3feb15c5aec2c72b0ef120a1da325e1e8f0ddaSvetoslav
778e3feb15c5aec2c72b0ef120a1da325e1e8f0ddaSvetoslav    /** @hide */
788e3feb15c5aec2c72b0ef120a1da325e1e8f0ddaSvetoslav    public static final long ROOT_NODE_ID = makeNodeId(UNDEFINED_ITEM_ID, UNDEFINED_ITEM_ID);
798e3feb15c5aec2c72b0ef120a1da325e1e8f0ddaSvetoslav
808e3feb15c5aec2c72b0ef120a1da325e1e8f0ddaSvetoslav    /** @hide */
818e3feb15c5aec2c72b0ef120a1da325e1e8f0ddaSvetoslav    public static final int ACTIVE_WINDOW_ID = UNDEFINED_ITEM_ID;
82d116d7c78a9c53f30a73bf273bd7618312cf3847Svetoslav Ganov
8357c7fd5a43237afc5e8ef31a076e862c0c16c328Svetoslav Ganov    /** @hide */
841e0d4af9986c8c2a658769a63bf8b385d25e0435Svetoslav    public static final int ANY_WINDOW_ID = -2;
851e0d4af9986c8c2a658769a63bf8b385d25e0435Svetoslav
861e0d4af9986c8c2a658769a63bf8b385d25e0435Svetoslav    /** @hide */
8757c7fd5a43237afc5e8ef31a076e862c0c16c328Svetoslav Ganov    public static final int FLAG_PREFETCH_PREDECESSORS = 0x00000001;
8857c7fd5a43237afc5e8ef31a076e862c0c16c328Svetoslav Ganov
8957c7fd5a43237afc5e8ef31a076e862c0c16c328Svetoslav Ganov    /** @hide */
9057c7fd5a43237afc5e8ef31a076e862c0c16c328Svetoslav Ganov    public static final int FLAG_PREFETCH_SIBLINGS = 0x00000002;
9157c7fd5a43237afc5e8ef31a076e862c0c16c328Svetoslav Ganov
9257c7fd5a43237afc5e8ef31a076e862c0c16c328Svetoslav Ganov    /** @hide */
934213804541a8b05cd0587b138a2fd9a3b7fd9350Svetoslav Ganov    public static final int FLAG_PREFETCH_DESCENDANTS = 0x00000004;
944213804541a8b05cd0587b138a2fd9a3b7fd9350Svetoslav Ganov
954213804541a8b05cd0587b138a2fd9a3b7fd9350Svetoslav Ganov    /** @hide */
9680943d8daa6ab31ab5c486d57aea406aa0730d58Svetoslav Ganov    public static final int FLAG_INCLUDE_NOT_IMPORTANT_VIEWS = 0x00000008;
9780943d8daa6ab31ab5c486d57aea406aa0730d58Svetoslav Ganov
9880943d8daa6ab31ab5c486d57aea406aa0730d58Svetoslav Ganov    /** @hide */
9980943d8daa6ab31ab5c486d57aea406aa0730d58Svetoslav Ganov    public static final int FLAG_REPORT_VIEW_IDS = 0x00000010;
10057c7fd5a43237afc5e8ef31a076e862c0c16c328Svetoslav Ganov
1018643aa0179e598e78d938c59035389054535a229Svetoslav Ganov    // Actions.
1028643aa0179e598e78d938c59035389054535a229Svetoslav Ganov
1038643aa0179e598e78d938c59035389054535a229Svetoslav Ganov    /**
1044213804541a8b05cd0587b138a2fd9a3b7fd9350Svetoslav Ganov     * Action that gives input focus to the node.
1058643aa0179e598e78d938c59035389054535a229Svetoslav Ganov     */
106005b83b0c62d3d0538f0d566b08bd457015ec661Svetoslav Ganov    public static final int ACTION_FOCUS =  0x00000001;
1078643aa0179e598e78d938c59035389054535a229Svetoslav Ganov
1088643aa0179e598e78d938c59035389054535a229Svetoslav Ganov    /**
1094213804541a8b05cd0587b138a2fd9a3b7fd9350Svetoslav Ganov     * Action that clears input focus of the node.
1108643aa0179e598e78d938c59035389054535a229Svetoslav Ganov     */
1114213804541a8b05cd0587b138a2fd9a3b7fd9350Svetoslav Ganov    public static final int ACTION_CLEAR_FOCUS = 0x00000002;
1128643aa0179e598e78d938c59035389054535a229Svetoslav Ganov
1138643aa0179e598e78d938c59035389054535a229Svetoslav Ganov    /**
1148643aa0179e598e78d938c59035389054535a229Svetoslav Ganov     * Action that selects the node.
1158643aa0179e598e78d938c59035389054535a229Svetoslav Ganov     */
1164213804541a8b05cd0587b138a2fd9a3b7fd9350Svetoslav Ganov    public static final int ACTION_SELECT = 0x00000004;
1178643aa0179e598e78d938c59035389054535a229Svetoslav Ganov
1188643aa0179e598e78d938c59035389054535a229Svetoslav Ganov    /**
11974bc19476536f2b5462eaa29e6f3029ee897c16dKristian Monsen     * Action that deselects the node.
1208643aa0179e598e78d938c59035389054535a229Svetoslav Ganov     */
1214213804541a8b05cd0587b138a2fd9a3b7fd9350Svetoslav Ganov    public static final int ACTION_CLEAR_SELECTION = 0x00000008;
1224213804541a8b05cd0587b138a2fd9a3b7fd9350Svetoslav Ganov
1234213804541a8b05cd0587b138a2fd9a3b7fd9350Svetoslav Ganov    /**
1246d17a936f73976971135aa1e6248662533343292Svetoslav Ganov     * Action that clicks on the node info.
1254213804541a8b05cd0587b138a2fd9a3b7fd9350Svetoslav Ganov     */
126005b83b0c62d3d0538f0d566b08bd457015ec661Svetoslav Ganov    public static final int ACTION_CLICK = 0x00000010;
1274213804541a8b05cd0587b138a2fd9a3b7fd9350Svetoslav Ganov
1284213804541a8b05cd0587b138a2fd9a3b7fd9350Svetoslav Ganov    /**
1296d17a936f73976971135aa1e6248662533343292Svetoslav Ganov     * Action that long clicks on the node.
130005b83b0c62d3d0538f0d566b08bd457015ec661Svetoslav Ganov     */
131005b83b0c62d3d0538f0d566b08bd457015ec661Svetoslav Ganov    public static final int ACTION_LONG_CLICK = 0x00000020;
132005b83b0c62d3d0538f0d566b08bd457015ec661Svetoslav Ganov
133005b83b0c62d3d0538f0d566b08bd457015ec661Svetoslav Ganov    /**
134005b83b0c62d3d0538f0d566b08bd457015ec661Svetoslav Ganov     * Action that gives accessibility focus to the node.
1354213804541a8b05cd0587b138a2fd9a3b7fd9350Svetoslav Ganov     */
136005b83b0c62d3d0538f0d566b08bd457015ec661Svetoslav Ganov    public static final int ACTION_ACCESSIBILITY_FOCUS = 0x00000040;
1374213804541a8b05cd0587b138a2fd9a3b7fd9350Svetoslav Ganov
1384213804541a8b05cd0587b138a2fd9a3b7fd9350Svetoslav Ganov    /**
139005b83b0c62d3d0538f0d566b08bd457015ec661Svetoslav Ganov     * Action that clears accessibility focus of the node.
1404213804541a8b05cd0587b138a2fd9a3b7fd9350Svetoslav Ganov     */
141005b83b0c62d3d0538f0d566b08bd457015ec661Svetoslav Ganov    public static final int ACTION_CLEAR_ACCESSIBILITY_FOCUS = 0x00000080;
1424213804541a8b05cd0587b138a2fd9a3b7fd9350Svetoslav Ganov
1434213804541a8b05cd0587b138a2fd9a3b7fd9350Svetoslav Ganov    /**
144b7ff3255c6d4e12f9d2334e3bbec0a125b7b09dcSvetoslav Ganov     * Action that requests to go to the next entity in this node's text
1452b435aada3d274a9c08d334946fff1ab9ba15b48Svetoslav Ganov     * at a given movement granularity. For example, move to the next character,
1462b435aada3d274a9c08d334946fff1ab9ba15b48Svetoslav Ganov     * word, etc.
147aa780c110922148a6a4ba06734bb2b0bb8c98f93Svetoslav Ganov     * <p>
1487c51284d8019ed04ab296be84839d8a90ac042faSvetoslav     * <strong>Arguments:</strong> {@link #ACTION_ARGUMENT_MOVEMENT_GRANULARITY_INT}<,
1497c51284d8019ed04ab296be84839d8a90ac042faSvetoslav     * {@link #ACTION_ARGUMENT_EXTEND_SELECTION_BOOLEAN}<br>
1507c51284d8019ed04ab296be84839d8a90ac042faSvetoslav     * <strong>Example:</strong> Move to the previous character and do not extend selection.
151aa780c110922148a6a4ba06734bb2b0bb8c98f93Svetoslav Ganov     * <code><pre><p>
152aa780c110922148a6a4ba06734bb2b0bb8c98f93Svetoslav Ganov     *   Bundle arguments = new Bundle();
1532b435aada3d274a9c08d334946fff1ab9ba15b48Svetoslav Ganov     *   arguments.putInt(AccessibilityNodeInfo.ACTION_ARGUMENT_MOVEMENT_GRANULARITY_INT,
1542b435aada3d274a9c08d334946fff1ab9ba15b48Svetoslav Ganov     *           AccessibilityNodeInfo.MOVEMENT_GRANULARITY_CHARACTER);
1557c51284d8019ed04ab296be84839d8a90ac042faSvetoslav     *   arguments.putBoolean(AccessibilityNodeInfo.ACTION_ARGUMENT_EXTEND_SELECTION_BOOLEAN,
1567c51284d8019ed04ab296be84839d8a90ac042faSvetoslav     *           false);
1572b435aada3d274a9c08d334946fff1ab9ba15b48Svetoslav Ganov     *   info.performAction(AccessibilityNodeInfo.ACTION_NEXT_AT_MOVEMENT_GRANULARITY, arguments);
158aa780c110922148a6a4ba06734bb2b0bb8c98f93Svetoslav Ganov     * </code></pre></p>
159aa780c110922148a6a4ba06734bb2b0bb8c98f93Svetoslav Ganov     * </p>
160b7ff3255c6d4e12f9d2334e3bbec0a125b7b09dcSvetoslav Ganov     *
1617c51284d8019ed04ab296be84839d8a90ac042faSvetoslav     * @see #ACTION_ARGUMENT_MOVEMENT_GRANULARITY_INT
1627c51284d8019ed04ab296be84839d8a90ac042faSvetoslav     * @see #ACTION_ARGUMENT_EXTEND_SELECTION_BOOLEAN
1637c51284d8019ed04ab296be84839d8a90ac042faSvetoslav     *
1642b435aada3d274a9c08d334946fff1ab9ba15b48Svetoslav Ganov     * @see #setMovementGranularities(int)
1652b435aada3d274a9c08d334946fff1ab9ba15b48Svetoslav Ganov     * @see #getMovementGranularities()
166b7ff3255c6d4e12f9d2334e3bbec0a125b7b09dcSvetoslav Ganov     *
1672b435aada3d274a9c08d334946fff1ab9ba15b48Svetoslav Ganov     * @see #MOVEMENT_GRANULARITY_CHARACTER
1682b435aada3d274a9c08d334946fff1ab9ba15b48Svetoslav Ganov     * @see #MOVEMENT_GRANULARITY_WORD
1692b435aada3d274a9c08d334946fff1ab9ba15b48Svetoslav Ganov     * @see #MOVEMENT_GRANULARITY_LINE
1702b435aada3d274a9c08d334946fff1ab9ba15b48Svetoslav Ganov     * @see #MOVEMENT_GRANULARITY_PARAGRAPH
1712b435aada3d274a9c08d334946fff1ab9ba15b48Svetoslav Ganov     * @see #MOVEMENT_GRANULARITY_PAGE
172aa780c110922148a6a4ba06734bb2b0bb8c98f93Svetoslav Ganov     */
1732b435aada3d274a9c08d334946fff1ab9ba15b48Svetoslav Ganov    public static final int ACTION_NEXT_AT_MOVEMENT_GRANULARITY = 0x00000100;
174aa780c110922148a6a4ba06734bb2b0bb8c98f93Svetoslav Ganov
175aa780c110922148a6a4ba06734bb2b0bb8c98f93Svetoslav Ganov    /**
176b7ff3255c6d4e12f9d2334e3bbec0a125b7b09dcSvetoslav Ganov     * Action that requests to go to the previous entity in this node's text
1772b435aada3d274a9c08d334946fff1ab9ba15b48Svetoslav Ganov     * at a given movement granularity. For example, move to the next character,
1782b435aada3d274a9c08d334946fff1ab9ba15b48Svetoslav Ganov     * word, etc.
179aa780c110922148a6a4ba06734bb2b0bb8c98f93Svetoslav Ganov     * <p>
1807c51284d8019ed04ab296be84839d8a90ac042faSvetoslav     * <strong>Arguments:</strong> {@link #ACTION_ARGUMENT_MOVEMENT_GRANULARITY_INT}<,
1817c51284d8019ed04ab296be84839d8a90ac042faSvetoslav     * {@link #ACTION_ARGUMENT_EXTEND_SELECTION_BOOLEAN}<br>
1827c51284d8019ed04ab296be84839d8a90ac042faSvetoslav     * <strong>Example:</strong> Move to the next character and do not extend selection.
183aa780c110922148a6a4ba06734bb2b0bb8c98f93Svetoslav Ganov     * <code><pre><p>
184aa780c110922148a6a4ba06734bb2b0bb8c98f93Svetoslav Ganov     *   Bundle arguments = new Bundle();
1852b435aada3d274a9c08d334946fff1ab9ba15b48Svetoslav Ganov     *   arguments.putInt(AccessibilityNodeInfo.ACTION_ARGUMENT_MOVEMENT_GRANULARITY_INT,
1862b435aada3d274a9c08d334946fff1ab9ba15b48Svetoslav Ganov     *           AccessibilityNodeInfo.MOVEMENT_GRANULARITY_CHARACTER);
1877c51284d8019ed04ab296be84839d8a90ac042faSvetoslav     *   arguments.putBoolean(AccessibilityNodeInfo.ACTION_ARGUMENT_EXTEND_SELECTION_BOOLEAN,
1887c51284d8019ed04ab296be84839d8a90ac042faSvetoslav     *           false);
1892b435aada3d274a9c08d334946fff1ab9ba15b48Svetoslav Ganov     *   info.performAction(AccessibilityNodeInfo.ACTION_PREVIOUS_AT_MOVEMENT_GRANULARITY,
1902b435aada3d274a9c08d334946fff1ab9ba15b48Svetoslav Ganov     *           arguments);
191aa780c110922148a6a4ba06734bb2b0bb8c98f93Svetoslav Ganov     * </code></pre></p>
192aa780c110922148a6a4ba06734bb2b0bb8c98f93Svetoslav Ganov     * </p>
193b7ff3255c6d4e12f9d2334e3bbec0a125b7b09dcSvetoslav Ganov     *
1947c51284d8019ed04ab296be84839d8a90ac042faSvetoslav     * @see #ACTION_ARGUMENT_MOVEMENT_GRANULARITY_INT
1957c51284d8019ed04ab296be84839d8a90ac042faSvetoslav     * @see #ACTION_ARGUMENT_EXTEND_SELECTION_BOOLEAN
1967c51284d8019ed04ab296be84839d8a90ac042faSvetoslav     *
1972b435aada3d274a9c08d334946fff1ab9ba15b48Svetoslav Ganov     * @see #setMovementGranularities(int)
1982b435aada3d274a9c08d334946fff1ab9ba15b48Svetoslav Ganov     * @see #getMovementGranularities()
199b7ff3255c6d4e12f9d2334e3bbec0a125b7b09dcSvetoslav Ganov     *
2002b435aada3d274a9c08d334946fff1ab9ba15b48Svetoslav Ganov     * @see #MOVEMENT_GRANULARITY_CHARACTER
2012b435aada3d274a9c08d334946fff1ab9ba15b48Svetoslav Ganov     * @see #MOVEMENT_GRANULARITY_WORD
2022b435aada3d274a9c08d334946fff1ab9ba15b48Svetoslav Ganov     * @see #MOVEMENT_GRANULARITY_LINE
2032b435aada3d274a9c08d334946fff1ab9ba15b48Svetoslav Ganov     * @see #MOVEMENT_GRANULARITY_PARAGRAPH
2042b435aada3d274a9c08d334946fff1ab9ba15b48Svetoslav Ganov     * @see #MOVEMENT_GRANULARITY_PAGE
205aa780c110922148a6a4ba06734bb2b0bb8c98f93Svetoslav Ganov     */
2062b435aada3d274a9c08d334946fff1ab9ba15b48Svetoslav Ganov    public static final int ACTION_PREVIOUS_AT_MOVEMENT_GRANULARITY = 0x00000200;
207aa780c110922148a6a4ba06734bb2b0bb8c98f93Svetoslav Ganov
208aa780c110922148a6a4ba06734bb2b0bb8c98f93Svetoslav Ganov    /**
209b7ff3255c6d4e12f9d2334e3bbec0a125b7b09dcSvetoslav Ganov     * Action to move to the next HTML element of a given type. For example, move
210b7ff3255c6d4e12f9d2334e3bbec0a125b7b09dcSvetoslav Ganov     * to the BUTTON, INPUT, TABLE, etc.
211aa780c110922148a6a4ba06734bb2b0bb8c98f93Svetoslav Ganov     * <p>
212b7ff3255c6d4e12f9d2334e3bbec0a125b7b09dcSvetoslav Ganov     * <strong>Arguments:</strong> {@link #ACTION_ARGUMENT_HTML_ELEMENT_STRING}<br>
213b7ff3255c6d4e12f9d2334e3bbec0a125b7b09dcSvetoslav Ganov     * <strong>Example:</strong>
214b7ff3255c6d4e12f9d2334e3bbec0a125b7b09dcSvetoslav Ganov     * <code><pre><p>
215b7ff3255c6d4e12f9d2334e3bbec0a125b7b09dcSvetoslav Ganov     *   Bundle arguments = new Bundle();
216b7ff3255c6d4e12f9d2334e3bbec0a125b7b09dcSvetoslav Ganov     *   arguments.putString(AccessibilityNodeInfo.ACTION_ARGUMENT_HTML_ELEMENT_STRING, "BUTTON");
217b7ff3255c6d4e12f9d2334e3bbec0a125b7b09dcSvetoslav Ganov     *   info.performAction(AccessibilityNodeInfo.ACTION_NEXT_HTML_ELEMENT, arguments);
218b7ff3255c6d4e12f9d2334e3bbec0a125b7b09dcSvetoslav Ganov     * </code></pre></p>
219b7ff3255c6d4e12f9d2334e3bbec0a125b7b09dcSvetoslav Ganov     * </p>
220b7ff3255c6d4e12f9d2334e3bbec0a125b7b09dcSvetoslav Ganov     */
221b7ff3255c6d4e12f9d2334e3bbec0a125b7b09dcSvetoslav Ganov    public static final int ACTION_NEXT_HTML_ELEMENT = 0x00000400;
222b7ff3255c6d4e12f9d2334e3bbec0a125b7b09dcSvetoslav Ganov
223b7ff3255c6d4e12f9d2334e3bbec0a125b7b09dcSvetoslav Ganov    /**
224b7ff3255c6d4e12f9d2334e3bbec0a125b7b09dcSvetoslav Ganov     * Action to move to the previous HTML element of a given type. For example, move
225b7ff3255c6d4e12f9d2334e3bbec0a125b7b09dcSvetoslav Ganov     * to the BUTTON, INPUT, TABLE, etc.
226b7ff3255c6d4e12f9d2334e3bbec0a125b7b09dcSvetoslav Ganov     * <p>
227b7ff3255c6d4e12f9d2334e3bbec0a125b7b09dcSvetoslav Ganov     * <strong>Arguments:</strong> {@link #ACTION_ARGUMENT_HTML_ELEMENT_STRING}<br>
228b7ff3255c6d4e12f9d2334e3bbec0a125b7b09dcSvetoslav Ganov     * <strong>Example:</strong>
229b7ff3255c6d4e12f9d2334e3bbec0a125b7b09dcSvetoslav Ganov     * <code><pre><p>
230b7ff3255c6d4e12f9d2334e3bbec0a125b7b09dcSvetoslav Ganov     *   Bundle arguments = new Bundle();
231b7ff3255c6d4e12f9d2334e3bbec0a125b7b09dcSvetoslav Ganov     *   arguments.putString(AccessibilityNodeInfo.ACTION_ARGUMENT_HTML_ELEMENT_STRING, "BUTTON");
232b7ff3255c6d4e12f9d2334e3bbec0a125b7b09dcSvetoslav Ganov     *   info.performAction(AccessibilityNodeInfo.ACTION_PREVIOUS_HTML_ELEMENT, arguments);
233b7ff3255c6d4e12f9d2334e3bbec0a125b7b09dcSvetoslav Ganov     * </code></pre></p>
234b7ff3255c6d4e12f9d2334e3bbec0a125b7b09dcSvetoslav Ganov     * </p>
235b7ff3255c6d4e12f9d2334e3bbec0a125b7b09dcSvetoslav Ganov     */
236b7ff3255c6d4e12f9d2334e3bbec0a125b7b09dcSvetoslav Ganov    public static final int ACTION_PREVIOUS_HTML_ELEMENT = 0x00000800;
237b7ff3255c6d4e12f9d2334e3bbec0a125b7b09dcSvetoslav Ganov
238b7ff3255c6d4e12f9d2334e3bbec0a125b7b09dcSvetoslav Ganov    /**
239a1dc761c8322355eb1bb71d3d6c9c603c1d1fc0fSvetoslav Ganov     * Action to scroll the node content forward.
240a1dc761c8322355eb1bb71d3d6c9c603c1d1fc0fSvetoslav Ganov     */
241a1dc761c8322355eb1bb71d3d6c9c603c1d1fc0fSvetoslav Ganov    public static final int ACTION_SCROLL_FORWARD = 0x00001000;
242a1dc761c8322355eb1bb71d3d6c9c603c1d1fc0fSvetoslav Ganov
243a1dc761c8322355eb1bb71d3d6c9c603c1d1fc0fSvetoslav Ganov    /**
244a1dc761c8322355eb1bb71d3d6c9c603c1d1fc0fSvetoslav Ganov     * Action to scroll the node content backward.
245a1dc761c8322355eb1bb71d3d6c9c603c1d1fc0fSvetoslav Ganov     */
246a1dc761c8322355eb1bb71d3d6c9c603c1d1fc0fSvetoslav Ganov    public static final int ACTION_SCROLL_BACKWARD = 0x00002000;
247a1dc761c8322355eb1bb71d3d6c9c603c1d1fc0fSvetoslav Ganov
248a1dc761c8322355eb1bb71d3d6c9c603c1d1fc0fSvetoslav Ganov    /**
2497c51284d8019ed04ab296be84839d8a90ac042faSvetoslav     * Action to copy the current selection to the clipboard.
2507c51284d8019ed04ab296be84839d8a90ac042faSvetoslav     */
2517c51284d8019ed04ab296be84839d8a90ac042faSvetoslav    public static final int ACTION_COPY = 0x00004000;
2527c51284d8019ed04ab296be84839d8a90ac042faSvetoslav
2537c51284d8019ed04ab296be84839d8a90ac042faSvetoslav    /**
2547c51284d8019ed04ab296be84839d8a90ac042faSvetoslav     * Action to paste the current clipboard content.
2557c51284d8019ed04ab296be84839d8a90ac042faSvetoslav     */
2567c51284d8019ed04ab296be84839d8a90ac042faSvetoslav    public static final int ACTION_PASTE = 0x00008000;
2577c51284d8019ed04ab296be84839d8a90ac042faSvetoslav
2587c51284d8019ed04ab296be84839d8a90ac042faSvetoslav    /**
2597c51284d8019ed04ab296be84839d8a90ac042faSvetoslav     * Action to cut the current selection and place it to the clipboard.
2607c51284d8019ed04ab296be84839d8a90ac042faSvetoslav     */
2617c51284d8019ed04ab296be84839d8a90ac042faSvetoslav    public static final int ACTION_CUT = 0x00010000;
2627c51284d8019ed04ab296be84839d8a90ac042faSvetoslav
2637c51284d8019ed04ab296be84839d8a90ac042faSvetoslav    /**
2647c51284d8019ed04ab296be84839d8a90ac042faSvetoslav     * Action to set the selection. Performing this action with no arguments
2657c51284d8019ed04ab296be84839d8a90ac042faSvetoslav     * clears the selection.
2667c51284d8019ed04ab296be84839d8a90ac042faSvetoslav     * <p>
2677c51284d8019ed04ab296be84839d8a90ac042faSvetoslav     * <strong>Arguments:</strong> {@link #ACTION_ARGUMENT_SELECTION_START_INT},
2687c51284d8019ed04ab296be84839d8a90ac042faSvetoslav     * {@link #ACTION_ARGUMENT_SELECTION_END_INT}<br>
2697c51284d8019ed04ab296be84839d8a90ac042faSvetoslav     * <strong>Example:</strong>
2707c51284d8019ed04ab296be84839d8a90ac042faSvetoslav     * <code><pre><p>
2717c51284d8019ed04ab296be84839d8a90ac042faSvetoslav     *   Bundle arguments = new Bundle();
2727c51284d8019ed04ab296be84839d8a90ac042faSvetoslav     *   arguments.putInt(AccessibilityNodeInfo.ACTION_ARGUMENT_SELECTION_START_INT, 1);
2737c51284d8019ed04ab296be84839d8a90ac042faSvetoslav     *   arguments.putInt(AccessibilityNodeInfo.ACTION_ARGUMENT_SELECTION_END_INT, 2);
2747c51284d8019ed04ab296be84839d8a90ac042faSvetoslav     *   info.performAction(AccessibilityNodeInfo.ACTION_SET_SELECTION, arguments);
2757c51284d8019ed04ab296be84839d8a90ac042faSvetoslav     * </code></pre></p>
2767c51284d8019ed04ab296be84839d8a90ac042faSvetoslav     * </p>
2777c51284d8019ed04ab296be84839d8a90ac042faSvetoslav     *
2787c51284d8019ed04ab296be84839d8a90ac042faSvetoslav     * @see #ACTION_ARGUMENT_SELECTION_START_INT
2797c51284d8019ed04ab296be84839d8a90ac042faSvetoslav     * @see #ACTION_ARGUMENT_SELECTION_END_INT
2807c51284d8019ed04ab296be84839d8a90ac042faSvetoslav     */
2817c51284d8019ed04ab296be84839d8a90ac042faSvetoslav    public static final int ACTION_SET_SELECTION = 0x00020000;
2827c51284d8019ed04ab296be84839d8a90ac042faSvetoslav
2837c51284d8019ed04ab296be84839d8a90ac042faSvetoslav    /**
2843577a283e1af3e14fe980c4fec55781a58cd8e3cSvetoslav     * Action to expand an expandable node.
2853577a283e1af3e14fe980c4fec55781a58cd8e3cSvetoslav     */
2863577a283e1af3e14fe980c4fec55781a58cd8e3cSvetoslav    public static final int ACTION_EXPAND = 0x00040000;
2873577a283e1af3e14fe980c4fec55781a58cd8e3cSvetoslav
2883577a283e1af3e14fe980c4fec55781a58cd8e3cSvetoslav    /**
2893577a283e1af3e14fe980c4fec55781a58cd8e3cSvetoslav     * Action to collapse an expandable node.
2903577a283e1af3e14fe980c4fec55781a58cd8e3cSvetoslav     */
2913577a283e1af3e14fe980c4fec55781a58cd8e3cSvetoslav    public static final int ACTION_COLLAPSE = 0x00080000;
2923577a283e1af3e14fe980c4fec55781a58cd8e3cSvetoslav
2933577a283e1af3e14fe980c4fec55781a58cd8e3cSvetoslav    /**
2943577a283e1af3e14fe980c4fec55781a58cd8e3cSvetoslav     * Action to dismiss a dismissable node.
2953577a283e1af3e14fe980c4fec55781a58cd8e3cSvetoslav     */
2963577a283e1af3e14fe980c4fec55781a58cd8e3cSvetoslav    public static final int ACTION_DISMISS = 0x00100000;
2973577a283e1af3e14fe980c4fec55781a58cd8e3cSvetoslav
2984cd353c038ec3c21f25c12897992e5e9826fe824Guang Zhu    /**
2994cd353c038ec3c21f25c12897992e5e9826fe824Guang Zhu     * Action that sets the text of the node. Performing the action without argument, using <code>
3004cd353c038ec3c21f25c12897992e5e9826fe824Guang Zhu     * null</code> or empty {@link CharSequence} will clear the text. This action will also put the
3014cd353c038ec3c21f25c12897992e5e9826fe824Guang Zhu     * cursor at the end of text.
3024cd353c038ec3c21f25c12897992e5e9826fe824Guang Zhu     * <p>
3034cd353c038ec3c21f25c12897992e5e9826fe824Guang Zhu     * <strong>Arguments:</strong> {@link #ACTION_ARGUMENT_SET_TEXT_CHARSEQUENCE}<br>
3044cd353c038ec3c21f25c12897992e5e9826fe824Guang Zhu     * <strong>Example:</strong>
3054cd353c038ec3c21f25c12897992e5e9826fe824Guang Zhu     * <code><pre><p>
3064cd353c038ec3c21f25c12897992e5e9826fe824Guang Zhu     *   Bundle arguments = new Bundle();
3074cd353c038ec3c21f25c12897992e5e9826fe824Guang Zhu     *   arguments.putCharSequence(AccessibilityNodeInfo.ACTION_ARGUMENT_SET_TEXT_CHARSEQUENCE,
3084cd353c038ec3c21f25c12897992e5e9826fe824Guang Zhu     *       "android");
3094cd353c038ec3c21f25c12897992e5e9826fe824Guang Zhu     *   info.performAction(AccessibilityNodeInfo.ACTION_SET_TEXT, arguments);
3104cd353c038ec3c21f25c12897992e5e9826fe824Guang Zhu     * </code></pre></p>
3114cd353c038ec3c21f25c12897992e5e9826fe824Guang Zhu     */
3124cd353c038ec3c21f25c12897992e5e9826fe824Guang Zhu    public static final int ACTION_SET_TEXT = 0x00200000;
3134cd353c038ec3c21f25c12897992e5e9826fe824Guang Zhu
31474bc19476536f2b5462eaa29e6f3029ee897c16dKristian Monsen    private static final int LAST_LEGACY_STANDARD_ACTION = ACTION_SET_TEXT;
31574bc19476536f2b5462eaa29e6f3029ee897c16dKristian Monsen
31674bc19476536f2b5462eaa29e6f3029ee897c16dKristian Monsen    /**
31774bc19476536f2b5462eaa29e6f3029ee897c16dKristian Monsen     * Mask to see if the value is larger than the largest ACTION_ constant
31874bc19476536f2b5462eaa29e6f3029ee897c16dKristian Monsen     */
31974bc19476536f2b5462eaa29e6f3029ee897c16dKristian Monsen    private static final int ACTION_TYPE_MASK = 0xFF000000;
32074bc19476536f2b5462eaa29e6f3029ee897c16dKristian Monsen
3213577a283e1af3e14fe980c4fec55781a58cd8e3cSvetoslav    // Action arguments
3223577a283e1af3e14fe980c4fec55781a58cd8e3cSvetoslav
3233577a283e1af3e14fe980c4fec55781a58cd8e3cSvetoslav    /**
3242b435aada3d274a9c08d334946fff1ab9ba15b48Svetoslav Ganov     * Argument for which movement granularity to be used when traversing the node text.
325b7ff3255c6d4e12f9d2334e3bbec0a125b7b09dcSvetoslav Ganov     * <p>
326b7ff3255c6d4e12f9d2334e3bbec0a125b7b09dcSvetoslav Ganov     * <strong>Type:</strong> int<br>
3272b435aada3d274a9c08d334946fff1ab9ba15b48Svetoslav Ganov     * <strong>Actions:</strong> {@link #ACTION_NEXT_AT_MOVEMENT_GRANULARITY},
3282b435aada3d274a9c08d334946fff1ab9ba15b48Svetoslav Ganov     * {@link #ACTION_PREVIOUS_AT_MOVEMENT_GRANULARITY}
329aa780c110922148a6a4ba06734bb2b0bb8c98f93Svetoslav Ganov     * </p>
3307c51284d8019ed04ab296be84839d8a90ac042faSvetoslav     *
3317c51284d8019ed04ab296be84839d8a90ac042faSvetoslav     * @see #ACTION_NEXT_AT_MOVEMENT_GRANULARITY
3327c51284d8019ed04ab296be84839d8a90ac042faSvetoslav     * @see #ACTION_PREVIOUS_AT_MOVEMENT_GRANULARITY
333aa780c110922148a6a4ba06734bb2b0bb8c98f93Svetoslav Ganov     */
3342b435aada3d274a9c08d334946fff1ab9ba15b48Svetoslav Ganov    public static final String ACTION_ARGUMENT_MOVEMENT_GRANULARITY_INT =
3357c51284d8019ed04ab296be84839d8a90ac042faSvetoslav            "ACTION_ARGUMENT_MOVEMENT_GRANULARITY_INT";
336b7ff3255c6d4e12f9d2334e3bbec0a125b7b09dcSvetoslav Ganov
337b7ff3255c6d4e12f9d2334e3bbec0a125b7b09dcSvetoslav Ganov    /**
338b7ff3255c6d4e12f9d2334e3bbec0a125b7b09dcSvetoslav Ganov     * Argument for which HTML element to get moving to the next/previous HTML element.
339b7ff3255c6d4e12f9d2334e3bbec0a125b7b09dcSvetoslav Ganov     * <p>
340b7ff3255c6d4e12f9d2334e3bbec0a125b7b09dcSvetoslav Ganov     * <strong>Type:</strong> String<br>
341b7ff3255c6d4e12f9d2334e3bbec0a125b7b09dcSvetoslav Ganov     * <strong>Actions:</strong> {@link #ACTION_NEXT_HTML_ELEMENT},
342b7ff3255c6d4e12f9d2334e3bbec0a125b7b09dcSvetoslav Ganov     *         {@link #ACTION_PREVIOUS_HTML_ELEMENT}
343b7ff3255c6d4e12f9d2334e3bbec0a125b7b09dcSvetoslav Ganov     * </p>
3447c51284d8019ed04ab296be84839d8a90ac042faSvetoslav     *
3457c51284d8019ed04ab296be84839d8a90ac042faSvetoslav     * @see #ACTION_NEXT_HTML_ELEMENT
3467c51284d8019ed04ab296be84839d8a90ac042faSvetoslav     * @see #ACTION_PREVIOUS_HTML_ELEMENT
347b7ff3255c6d4e12f9d2334e3bbec0a125b7b09dcSvetoslav Ganov     */
348b7ff3255c6d4e12f9d2334e3bbec0a125b7b09dcSvetoslav Ganov    public static final String ACTION_ARGUMENT_HTML_ELEMENT_STRING =
3497c51284d8019ed04ab296be84839d8a90ac042faSvetoslav            "ACTION_ARGUMENT_HTML_ELEMENT_STRING";
3507c51284d8019ed04ab296be84839d8a90ac042faSvetoslav
3517c51284d8019ed04ab296be84839d8a90ac042faSvetoslav    /**
3527c51284d8019ed04ab296be84839d8a90ac042faSvetoslav     * Argument for whether when moving at granularity to extend the selection
3537c51284d8019ed04ab296be84839d8a90ac042faSvetoslav     * or to move it otherwise.
3547c51284d8019ed04ab296be84839d8a90ac042faSvetoslav     * <p>
3557c51284d8019ed04ab296be84839d8a90ac042faSvetoslav     * <strong>Type:</strong> boolean<br>
3567c51284d8019ed04ab296be84839d8a90ac042faSvetoslav     * <strong>Actions:</strong> {@link #ACTION_NEXT_AT_MOVEMENT_GRANULARITY},
3577c51284d8019ed04ab296be84839d8a90ac042faSvetoslav     * {@link #ACTION_PREVIOUS_AT_MOVEMENT_GRANULARITY}
3587c51284d8019ed04ab296be84839d8a90ac042faSvetoslav     * </p>
3597c51284d8019ed04ab296be84839d8a90ac042faSvetoslav     *
3607c51284d8019ed04ab296be84839d8a90ac042faSvetoslav     * @see #ACTION_NEXT_AT_MOVEMENT_GRANULARITY
3617c51284d8019ed04ab296be84839d8a90ac042faSvetoslav     * @see #ACTION_PREVIOUS_AT_MOVEMENT_GRANULARITY
3627c51284d8019ed04ab296be84839d8a90ac042faSvetoslav     */
3637c51284d8019ed04ab296be84839d8a90ac042faSvetoslav    public static final String ACTION_ARGUMENT_EXTEND_SELECTION_BOOLEAN =
3647c51284d8019ed04ab296be84839d8a90ac042faSvetoslav            "ACTION_ARGUMENT_EXTEND_SELECTION_BOOLEAN";
3657c51284d8019ed04ab296be84839d8a90ac042faSvetoslav
3667c51284d8019ed04ab296be84839d8a90ac042faSvetoslav    /**
3677c51284d8019ed04ab296be84839d8a90ac042faSvetoslav     * Argument for specifying the selection start.
3687c51284d8019ed04ab296be84839d8a90ac042faSvetoslav     * <p>
3697c51284d8019ed04ab296be84839d8a90ac042faSvetoslav     * <strong>Type:</strong> int<br>
3707c51284d8019ed04ab296be84839d8a90ac042faSvetoslav     * <strong>Actions:</strong> {@link #ACTION_SET_SELECTION}
3717c51284d8019ed04ab296be84839d8a90ac042faSvetoslav     * </p>
3727c51284d8019ed04ab296be84839d8a90ac042faSvetoslav     *
3737c51284d8019ed04ab296be84839d8a90ac042faSvetoslav     * @see #ACTION_SET_SELECTION
3747c51284d8019ed04ab296be84839d8a90ac042faSvetoslav     */
3757c51284d8019ed04ab296be84839d8a90ac042faSvetoslav    public static final String ACTION_ARGUMENT_SELECTION_START_INT =
3767c51284d8019ed04ab296be84839d8a90ac042faSvetoslav            "ACTION_ARGUMENT_SELECTION_START_INT";
3777c51284d8019ed04ab296be84839d8a90ac042faSvetoslav
3787c51284d8019ed04ab296be84839d8a90ac042faSvetoslav    /**
3797c51284d8019ed04ab296be84839d8a90ac042faSvetoslav     * Argument for specifying the selection end.
3807c51284d8019ed04ab296be84839d8a90ac042faSvetoslav     * <p>
3817c51284d8019ed04ab296be84839d8a90ac042faSvetoslav     * <strong>Type:</strong> int<br>
3827c51284d8019ed04ab296be84839d8a90ac042faSvetoslav     * <strong>Actions:</strong> {@link #ACTION_SET_SELECTION}
3837c51284d8019ed04ab296be84839d8a90ac042faSvetoslav     * </p>
3847c51284d8019ed04ab296be84839d8a90ac042faSvetoslav     *
3857c51284d8019ed04ab296be84839d8a90ac042faSvetoslav     * @see #ACTION_SET_SELECTION
3867c51284d8019ed04ab296be84839d8a90ac042faSvetoslav     */
3877c51284d8019ed04ab296be84839d8a90ac042faSvetoslav    public static final String ACTION_ARGUMENT_SELECTION_END_INT =
3887c51284d8019ed04ab296be84839d8a90ac042faSvetoslav            "ACTION_ARGUMENT_SELECTION_END_INT";
389aa780c110922148a6a4ba06734bb2b0bb8c98f93Svetoslav Ganov
3904cd353c038ec3c21f25c12897992e5e9826fe824Guang Zhu    /**
3914cd353c038ec3c21f25c12897992e5e9826fe824Guang Zhu     * Argument for specifying the text content to set
3924cd353c038ec3c21f25c12897992e5e9826fe824Guang Zhu     * <p>
3934cd353c038ec3c21f25c12897992e5e9826fe824Guang Zhu     * <strong>Type:</strong> CharSequence<br>
3944cd353c038ec3c21f25c12897992e5e9826fe824Guang Zhu     * <strong>Actions:</strong> {@link #ACTION_SET_TEXT}
3954cd353c038ec3c21f25c12897992e5e9826fe824Guang Zhu     * </p>
3964cd353c038ec3c21f25c12897992e5e9826fe824Guang Zhu     *
3974cd353c038ec3c21f25c12897992e5e9826fe824Guang Zhu     * @see #ACTION_SET_TEXT
3984cd353c038ec3c21f25c12897992e5e9826fe824Guang Zhu     */
3994cd353c038ec3c21f25c12897992e5e9826fe824Guang Zhu    public static final String ACTION_ARGUMENT_SET_TEXT_CHARSEQUENCE =
4004cd353c038ec3c21f25c12897992e5e9826fe824Guang Zhu            "ACTION_ARGUMENT_SET_TEXT_CHARSEQUENCE";
4014cd353c038ec3c21f25c12897992e5e9826fe824Guang Zhu
4023577a283e1af3e14fe980c4fec55781a58cd8e3cSvetoslav    // Focus types
4033577a283e1af3e14fe980c4fec55781a58cd8e3cSvetoslav
404aa780c110922148a6a4ba06734bb2b0bb8c98f93Svetoslav Ganov    /**
4054213804541a8b05cd0587b138a2fd9a3b7fd9350Svetoslav Ganov     * The input focus.
4064213804541a8b05cd0587b138a2fd9a3b7fd9350Svetoslav Ganov     */
4074213804541a8b05cd0587b138a2fd9a3b7fd9350Svetoslav Ganov    public static final int FOCUS_INPUT = 1;
4084213804541a8b05cd0587b138a2fd9a3b7fd9350Svetoslav Ganov
4094213804541a8b05cd0587b138a2fd9a3b7fd9350Svetoslav Ganov    /**
4104213804541a8b05cd0587b138a2fd9a3b7fd9350Svetoslav Ganov     * The accessibility focus.
4114213804541a8b05cd0587b138a2fd9a3b7fd9350Svetoslav Ganov     */
4124213804541a8b05cd0587b138a2fd9a3b7fd9350Svetoslav Ganov    public static final int FOCUS_ACCESSIBILITY = 2;
4138643aa0179e598e78d938c59035389054535a229Svetoslav Ganov
4142b435aada3d274a9c08d334946fff1ab9ba15b48Svetoslav Ganov    // Movement granularities
415b7ff3255c6d4e12f9d2334e3bbec0a125b7b09dcSvetoslav Ganov
416b7ff3255c6d4e12f9d2334e3bbec0a125b7b09dcSvetoslav Ganov    /**
4172b435aada3d274a9c08d334946fff1ab9ba15b48Svetoslav Ganov     * Movement granularity bit for traversing the text of a node by character.
418b7ff3255c6d4e12f9d2334e3bbec0a125b7b09dcSvetoslav Ganov     */
4192b435aada3d274a9c08d334946fff1ab9ba15b48Svetoslav Ganov    public static final int MOVEMENT_GRANULARITY_CHARACTER = 0x00000001;
420b7ff3255c6d4e12f9d2334e3bbec0a125b7b09dcSvetoslav Ganov
421b7ff3255c6d4e12f9d2334e3bbec0a125b7b09dcSvetoslav Ganov    /**
4222b435aada3d274a9c08d334946fff1ab9ba15b48Svetoslav Ganov     * Movement granularity bit for traversing the text of a node by word.
423b7ff3255c6d4e12f9d2334e3bbec0a125b7b09dcSvetoslav Ganov     */
4242b435aada3d274a9c08d334946fff1ab9ba15b48Svetoslav Ganov    public static final int MOVEMENT_GRANULARITY_WORD = 0x00000002;
425b7ff3255c6d4e12f9d2334e3bbec0a125b7b09dcSvetoslav Ganov
426b7ff3255c6d4e12f9d2334e3bbec0a125b7b09dcSvetoslav Ganov    /**
4272b435aada3d274a9c08d334946fff1ab9ba15b48Svetoslav Ganov     * Movement granularity bit for traversing the text of a node by line.
428b7ff3255c6d4e12f9d2334e3bbec0a125b7b09dcSvetoslav Ganov     */
4292b435aada3d274a9c08d334946fff1ab9ba15b48Svetoslav Ganov    public static final int MOVEMENT_GRANULARITY_LINE = 0x00000004;
430b7ff3255c6d4e12f9d2334e3bbec0a125b7b09dcSvetoslav Ganov
431b7ff3255c6d4e12f9d2334e3bbec0a125b7b09dcSvetoslav Ganov    /**
4322b435aada3d274a9c08d334946fff1ab9ba15b48Svetoslav Ganov     * Movement granularity bit for traversing the text of a node by paragraph.
433b7ff3255c6d4e12f9d2334e3bbec0a125b7b09dcSvetoslav Ganov     */
4342b435aada3d274a9c08d334946fff1ab9ba15b48Svetoslav Ganov    public static final int MOVEMENT_GRANULARITY_PARAGRAPH = 0x00000008;
435b7ff3255c6d4e12f9d2334e3bbec0a125b7b09dcSvetoslav Ganov
436b7ff3255c6d4e12f9d2334e3bbec0a125b7b09dcSvetoslav Ganov    /**
4372b435aada3d274a9c08d334946fff1ab9ba15b48Svetoslav Ganov     * Movement granularity bit for traversing the text of a node by page.
438b7ff3255c6d4e12f9d2334e3bbec0a125b7b09dcSvetoslav Ganov     */
4392b435aada3d274a9c08d334946fff1ab9ba15b48Svetoslav Ganov    public static final int MOVEMENT_GRANULARITY_PAGE = 0x00000010;
440b7ff3255c6d4e12f9d2334e3bbec0a125b7b09dcSvetoslav Ganov
4418643aa0179e598e78d938c59035389054535a229Svetoslav Ganov    // Boolean attributes.
4428643aa0179e598e78d938c59035389054535a229Svetoslav Ganov
443bcc46a0d037e62fcb5e5f0f5e1acef5a8c1314b0Svetoslav    private static final int BOOLEAN_PROPERTY_CHECKABLE = 0x00000001;
4448643aa0179e598e78d938c59035389054535a229Svetoslav Ganov
445bcc46a0d037e62fcb5e5f0f5e1acef5a8c1314b0Svetoslav    private static final int BOOLEAN_PROPERTY_CHECKED = 0x00000002;
4468643aa0179e598e78d938c59035389054535a229Svetoslav Ganov
447bcc46a0d037e62fcb5e5f0f5e1acef5a8c1314b0Svetoslav    private static final int BOOLEAN_PROPERTY_FOCUSABLE = 0x00000004;
4488643aa0179e598e78d938c59035389054535a229Svetoslav Ganov
449bcc46a0d037e62fcb5e5f0f5e1acef5a8c1314b0Svetoslav    private static final int BOOLEAN_PROPERTY_FOCUSED = 0x00000008;
4508643aa0179e598e78d938c59035389054535a229Svetoslav Ganov
451bcc46a0d037e62fcb5e5f0f5e1acef5a8c1314b0Svetoslav    private static final int BOOLEAN_PROPERTY_SELECTED = 0x00000010;
4528643aa0179e598e78d938c59035389054535a229Svetoslav Ganov
453bcc46a0d037e62fcb5e5f0f5e1acef5a8c1314b0Svetoslav    private static final int BOOLEAN_PROPERTY_CLICKABLE = 0x00000020;
4548643aa0179e598e78d938c59035389054535a229Svetoslav Ganov
455bcc46a0d037e62fcb5e5f0f5e1acef5a8c1314b0Svetoslav    private static final int BOOLEAN_PROPERTY_LONG_CLICKABLE = 0x00000040;
4568643aa0179e598e78d938c59035389054535a229Svetoslav Ganov
457bcc46a0d037e62fcb5e5f0f5e1acef5a8c1314b0Svetoslav    private static final int BOOLEAN_PROPERTY_ENABLED = 0x00000080;
4588643aa0179e598e78d938c59035389054535a229Svetoslav Ganov
459bcc46a0d037e62fcb5e5f0f5e1acef5a8c1314b0Svetoslav    private static final int BOOLEAN_PROPERTY_PASSWORD = 0x00000100;
4608643aa0179e598e78d938c59035389054535a229Svetoslav Ganov
461bcc46a0d037e62fcb5e5f0f5e1acef5a8c1314b0Svetoslav    private static final int BOOLEAN_PROPERTY_SCROLLABLE = 0x00000200;
462a0156177cdc809795dd8bc5a19943dd2b6f82b66Svetoslav Ganov
463bcc46a0d037e62fcb5e5f0f5e1acef5a8c1314b0Svetoslav    private static final int BOOLEAN_PROPERTY_ACCESSIBILITY_FOCUSED = 0x00000400;
4644213804541a8b05cd0587b138a2fd9a3b7fd9350Svetoslav Ganov
465bcc46a0d037e62fcb5e5f0f5e1acef5a8c1314b0Svetoslav    private static final int BOOLEAN_PROPERTY_VISIBLE_TO_USER = 0x00000800;
466bcc46a0d037e62fcb5e5f0f5e1acef5a8c1314b0Svetoslav
467bcc46a0d037e62fcb5e5f0f5e1acef5a8c1314b0Svetoslav    private static final int BOOLEAN_PROPERTY_EDITABLE = 0x00001000;
4680a1bb6dffc358c01e10555c5c833edb7dba69659Svetoslav Ganov
46977e9a28e2faa36f127231b842476d47f9823a83aAlan Viverette    private static final int BOOLEAN_PROPERTY_OPENS_POPUP = 0x00002000;
4703577a283e1af3e14fe980c4fec55781a58cd8e3cSvetoslav
47177e9a28e2faa36f127231b842476d47f9823a83aAlan Viverette    private static final int BOOLEAN_PROPERTY_DISMISSABLE = 0x00004000;
4723577a283e1af3e14fe980c4fec55781a58cd8e3cSvetoslav
47377e9a28e2faa36f127231b842476d47f9823a83aAlan Viverette    private static final int BOOLEAN_PROPERTY_MULTI_LINE = 0x00008000;
4743577a283e1af3e14fe980c4fec55781a58cd8e3cSvetoslav
47577e9a28e2faa36f127231b842476d47f9823a83aAlan Viverette    private static final int BOOLEAN_PROPERTY_CONTENT_INVALID = 0x00010000;
4763577a283e1af3e14fe980c4fec55781a58cd8e3cSvetoslav
477021078554b902179442a345a9d080a165c3b5139Svetoslav Ganov    /**
478021078554b902179442a345a9d080a165c3b5139Svetoslav Ganov     * Bits that provide the id of a virtual descendant of a view.
479021078554b902179442a345a9d080a165c3b5139Svetoslav Ganov     */
480021078554b902179442a345a9d080a165c3b5139Svetoslav Ganov    private static final long VIRTUAL_DESCENDANT_ID_MASK = 0xffffffff00000000L;
481021078554b902179442a345a9d080a165c3b5139Svetoslav Ganov
482021078554b902179442a345a9d080a165c3b5139Svetoslav Ganov    /**
483021078554b902179442a345a9d080a165c3b5139Svetoslav Ganov     * Bit shift of {@link #VIRTUAL_DESCENDANT_ID_MASK} to get to the id for a
484021078554b902179442a345a9d080a165c3b5139Svetoslav Ganov     * virtual descendant of a view. Such a descendant does not exist in the view
485021078554b902179442a345a9d080a165c3b5139Svetoslav Ganov     * hierarchy and is only reported via the accessibility APIs.
486021078554b902179442a345a9d080a165c3b5139Svetoslav Ganov     */
487021078554b902179442a345a9d080a165c3b5139Svetoslav Ganov    private static final int VIRTUAL_DESCENDANT_ID_SHIFT = 32;
488021078554b902179442a345a9d080a165c3b5139Svetoslav Ganov
489021078554b902179442a345a9d080a165c3b5139Svetoslav Ganov    /**
490021078554b902179442a345a9d080a165c3b5139Svetoslav Ganov     * Gets the accessibility view id which identifies a View in the view three.
491021078554b902179442a345a9d080a165c3b5139Svetoslav Ganov     *
492021078554b902179442a345a9d080a165c3b5139Svetoslav Ganov     * @param accessibilityNodeId The id of an {@link AccessibilityNodeInfo}.
493021078554b902179442a345a9d080a165c3b5139Svetoslav Ganov     * @return The accessibility view id part of the node id.
494021078554b902179442a345a9d080a165c3b5139Svetoslav Ganov     *
495021078554b902179442a345a9d080a165c3b5139Svetoslav Ganov     * @hide
496021078554b902179442a345a9d080a165c3b5139Svetoslav Ganov     */
497021078554b902179442a345a9d080a165c3b5139Svetoslav Ganov    public static int getAccessibilityViewId(long accessibilityNodeId) {
498021078554b902179442a345a9d080a165c3b5139Svetoslav Ganov        return (int) accessibilityNodeId;
499021078554b902179442a345a9d080a165c3b5139Svetoslav Ganov    }
500021078554b902179442a345a9d080a165c3b5139Svetoslav Ganov
501021078554b902179442a345a9d080a165c3b5139Svetoslav Ganov    /**
502021078554b902179442a345a9d080a165c3b5139Svetoslav Ganov     * Gets the virtual descendant id which identifies an imaginary view in a
503021078554b902179442a345a9d080a165c3b5139Svetoslav Ganov     * containing View.
504021078554b902179442a345a9d080a165c3b5139Svetoslav Ganov     *
505021078554b902179442a345a9d080a165c3b5139Svetoslav Ganov     * @param accessibilityNodeId The id of an {@link AccessibilityNodeInfo}.
506021078554b902179442a345a9d080a165c3b5139Svetoslav Ganov     * @return The virtual view id part of the node id.
507021078554b902179442a345a9d080a165c3b5139Svetoslav Ganov     *
508021078554b902179442a345a9d080a165c3b5139Svetoslav Ganov     * @hide
509021078554b902179442a345a9d080a165c3b5139Svetoslav Ganov     */
510021078554b902179442a345a9d080a165c3b5139Svetoslav Ganov    public static int getVirtualDescendantId(long accessibilityNodeId) {
511021078554b902179442a345a9d080a165c3b5139Svetoslav Ganov        return (int) ((accessibilityNodeId & VIRTUAL_DESCENDANT_ID_MASK)
512021078554b902179442a345a9d080a165c3b5139Svetoslav Ganov                >> VIRTUAL_DESCENDANT_ID_SHIFT);
513021078554b902179442a345a9d080a165c3b5139Svetoslav Ganov    }
514021078554b902179442a345a9d080a165c3b5139Svetoslav Ganov
515021078554b902179442a345a9d080a165c3b5139Svetoslav Ganov    /**
516021078554b902179442a345a9d080a165c3b5139Svetoslav Ganov     * Makes a node id by shifting the <code>virtualDescendantId</code>
517021078554b902179442a345a9d080a165c3b5139Svetoslav Ganov     * by {@link #VIRTUAL_DESCENDANT_ID_SHIFT} and taking
518021078554b902179442a345a9d080a165c3b5139Svetoslav Ganov     * the bitwise or with the <code>accessibilityViewId</code>.
519021078554b902179442a345a9d080a165c3b5139Svetoslav Ganov     *
520021078554b902179442a345a9d080a165c3b5139Svetoslav Ganov     * @param accessibilityViewId A View accessibility id.
521021078554b902179442a345a9d080a165c3b5139Svetoslav Ganov     * @param virtualDescendantId A virtual descendant id.
522021078554b902179442a345a9d080a165c3b5139Svetoslav Ganov     * @return The node id.
523021078554b902179442a345a9d080a165c3b5139Svetoslav Ganov     *
524021078554b902179442a345a9d080a165c3b5139Svetoslav Ganov     * @hide
525021078554b902179442a345a9d080a165c3b5139Svetoslav Ganov     */
526021078554b902179442a345a9d080a165c3b5139Svetoslav Ganov    public static long makeNodeId(int accessibilityViewId, int virtualDescendantId) {
5278e3feb15c5aec2c72b0ef120a1da325e1e8f0ddaSvetoslav        // We changed the value for undefined node to positive due to wrong
5288e3feb15c5aec2c72b0ef120a1da325e1e8f0ddaSvetoslav        // global id composition (two 32-bin ints into one 64-bit long) but
5298e3feb15c5aec2c72b0ef120a1da325e1e8f0ddaSvetoslav        // the value used for the host node provider view has id -1 so we
5308e3feb15c5aec2c72b0ef120a1da325e1e8f0ddaSvetoslav        // remap it here.
5318e3feb15c5aec2c72b0ef120a1da325e1e8f0ddaSvetoslav        if (virtualDescendantId == AccessibilityNodeProvider.HOST_VIEW_ID) {
5328e3feb15c5aec2c72b0ef120a1da325e1e8f0ddaSvetoslav            virtualDescendantId = UNDEFINED_ITEM_ID;
5338e3feb15c5aec2c72b0ef120a1da325e1e8f0ddaSvetoslav        }
534021078554b902179442a345a9d080a165c3b5139Svetoslav Ganov        return (((long) virtualDescendantId) << VIRTUAL_DESCENDANT_ID_SHIFT) | accessibilityViewId;
535021078554b902179442a345a9d080a165c3b5139Svetoslav Ganov    }
536021078554b902179442a345a9d080a165c3b5139Svetoslav Ganov
5378643aa0179e598e78d938c59035389054535a229Svetoslav Ganov    // Housekeeping.
5388643aa0179e598e78d938c59035389054535a229Svetoslav Ganov    private static final int MAX_POOL_SIZE = 50;
539f4782ec9c57a40224ac0974fce6b6fe280c829ceSvetoslav Ganov    private static final SynchronizedPool<AccessibilityNodeInfo> sPool =
540f4782ec9c57a40224ac0974fce6b6fe280c829ceSvetoslav Ganov            new SynchronizedPool<AccessibilityNodeInfo>(MAX_POOL_SIZE);
541f4782ec9c57a40224ac0974fce6b6fe280c829ceSvetoslav Ganov
5428643aa0179e598e78d938c59035389054535a229Svetoslav Ganov    private boolean mSealed;
5438643aa0179e598e78d938c59035389054535a229Svetoslav Ganov
5448643aa0179e598e78d938c59035389054535a229Svetoslav Ganov    // Data.
5458e3feb15c5aec2c72b0ef120a1da325e1e8f0ddaSvetoslav    private int mWindowId = UNDEFINED_ITEM_ID;
5460d04e245534cf777dfaf16dce3c51553837c14ffSvetoslav Ganov    private long mSourceNodeId = ROOT_NODE_ID;
5470d04e245534cf777dfaf16dce3c51553837c14ffSvetoslav Ganov    private long mParentNodeId = ROOT_NODE_ID;
54833aef98fd28dcac0a2ad37e7329afd3e666f5e0aSvetoslav Ganov    private long mLabelForId = ROOT_NODE_ID;
54933aef98fd28dcac0a2ad37e7329afd3e666f5e0aSvetoslav Ganov    private long mLabeledById = ROOT_NODE_ID;
5506c70290ff0b20329c8f173d5c3423eb83ddc46f1Svetoslav    private long mTraversalBefore = ROOT_NODE_ID;
5516c70290ff0b20329c8f173d5c3423eb83ddc46f1Svetoslav    private long mTraversalAfter = ROOT_NODE_ID;
552f3b4f3163b5b4c0a54a2643f07c97c47b14a1eb7Svetoslav Ganov
5538643aa0179e598e78d938c59035389054535a229Svetoslav Ganov    private int mBooleanProperties;
554eeee4d2c01d3c4ed99e4891dbc75c7de69a803faSvetoslav Ganov    private final Rect mBoundsInParent = new Rect();
555eeee4d2c01d3c4ed99e4891dbc75c7de69a803faSvetoslav Ganov    private final Rect mBoundsInScreen = new Rect();
5568643aa0179e598e78d938c59035389054535a229Svetoslav Ganov
5578643aa0179e598e78d938c59035389054535a229Svetoslav Ganov    private CharSequence mPackageName;
5588643aa0179e598e78d938c59035389054535a229Svetoslav Ganov    private CharSequence mClassName;
5598643aa0179e598e78d938c59035389054535a229Svetoslav Ganov    private CharSequence mText;
560fccbff5f021a6f95fe1c18f55866545c767ef8ebAlan Viverette    private CharSequence mError;
5618643aa0179e598e78d938c59035389054535a229Svetoslav Ganov    private CharSequence mContentDescription;
5629fa1ee563b5a9ca25554f1fa59d1222dcfdfc623Svetoslav    private String mViewIdResourceName;
5638643aa0179e598e78d938c59035389054535a229Svetoslav Ganov
564f0aed09ed8153043e40b3ac99788d47ba0831306Alan Viverette    private LongArray mChildNodeIds;
56574bc19476536f2b5462eaa29e6f3029ee897c16dKristian Monsen    private ArrayList<AccessibilityAction> mActions;
5668643aa0179e598e78d938c59035389054535a229Svetoslav Ganov
567029942f77d05ed3d20256403652b220c83dad6e1Alan Viverette    private int mMaxTextLength = -1;
5682b435aada3d274a9c08d334946fff1ab9ba15b48Svetoslav Ganov    private int mMovementGranularities;
569aa780c110922148a6a4ba06734bb2b0bb8c98f93Svetoslav Ganov
5708e3feb15c5aec2c72b0ef120a1da325e1e8f0ddaSvetoslav    private int mTextSelectionStart = UNDEFINED_SELECTION_INDEX;
5718e3feb15c5aec2c72b0ef120a1da325e1e8f0ddaSvetoslav    private int mTextSelectionEnd = UNDEFINED_SELECTION_INDEX;
5726254f4806dd3db53b7380e77fbb183065685573eSvetoslav    private int mInputType = InputType.TYPE_NULL;
57377e9a28e2faa36f127231b842476d47f9823a83aAlan Viverette    private int mLiveRegion = View.ACCESSIBILITY_LIVE_REGION_NONE;
5746254f4806dd3db53b7380e77fbb183065685573eSvetoslav
575cb8ed39b3fb591be60b9fb1799d4ea4530eab758Svetoslav Ganov    private Bundle mExtras;
576bcc46a0d037e62fcb5e5f0f5e1acef5a8c1314b0Svetoslav
5778e3feb15c5aec2c72b0ef120a1da325e1e8f0ddaSvetoslav    private int mConnectionId = UNDEFINED_CONNECTION_ID;
5788643aa0179e598e78d938c59035389054535a229Svetoslav Ganov
5793577a283e1af3e14fe980c4fec55781a58cd8e3cSvetoslav    private RangeInfo mRangeInfo;
5803577a283e1af3e14fe980c4fec55781a58cd8e3cSvetoslav    private CollectionInfo mCollectionInfo;
5813577a283e1af3e14fe980c4fec55781a58cd8e3cSvetoslav    private CollectionItemInfo mCollectionItemInfo;
5823577a283e1af3e14fe980c4fec55781a58cd8e3cSvetoslav
5838643aa0179e598e78d938c59035389054535a229Svetoslav Ganov    /**
5848643aa0179e598e78d938c59035389054535a229Svetoslav Ganov     * Hide constructor from clients.
5858643aa0179e598e78d938c59035389054535a229Svetoslav Ganov     */
5868643aa0179e598e78d938c59035389054535a229Svetoslav Ganov    private AccessibilityNodeInfo() {
5878643aa0179e598e78d938c59035389054535a229Svetoslav Ganov        /* do nothing */
5888643aa0179e598e78d938c59035389054535a229Svetoslav Ganov    }
5898643aa0179e598e78d938c59035389054535a229Svetoslav Ganov
5908643aa0179e598e78d938c59035389054535a229Svetoslav Ganov    /**
5918643aa0179e598e78d938c59035389054535a229Svetoslav Ganov     * Sets the source.
592021078554b902179442a345a9d080a165c3b5139Svetoslav Ganov     * <p>
593021078554b902179442a345a9d080a165c3b5139Svetoslav Ganov     *   <strong>Note:</strong> Cannot be called from an
594021078554b902179442a345a9d080a165c3b5139Svetoslav Ganov     *   {@link android.accessibilityservice.AccessibilityService}.
595021078554b902179442a345a9d080a165c3b5139Svetoslav Ganov     *   This class is made immutable before being delivered to an AccessibilityService.
596021078554b902179442a345a9d080a165c3b5139Svetoslav Ganov     * </p>
5978643aa0179e598e78d938c59035389054535a229Svetoslav Ganov     *
5988643aa0179e598e78d938c59035389054535a229Svetoslav Ganov     * @param source The info source.
5998643aa0179e598e78d938c59035389054535a229Svetoslav Ganov     */
6008643aa0179e598e78d938c59035389054535a229Svetoslav Ganov    public void setSource(View source) {
6018e3feb15c5aec2c72b0ef120a1da325e1e8f0ddaSvetoslav        setSource(source, UNDEFINED_ITEM_ID);
602021078554b902179442a345a9d080a165c3b5139Svetoslav Ganov    }
603021078554b902179442a345a9d080a165c3b5139Svetoslav Ganov
604021078554b902179442a345a9d080a165c3b5139Svetoslav Ganov    /**
605021078554b902179442a345a9d080a165c3b5139Svetoslav Ganov     * Sets the source to be a virtual descendant of the given <code>root</code>.
60671b4e71c67df79f53b582fabb34b96ddbe23fe0fSvetoslav Ganov     * If <code>virtualDescendantId</code> is {@link View#NO_ID} the root
607021078554b902179442a345a9d080a165c3b5139Svetoslav Ganov     * is set as the source.
608021078554b902179442a345a9d080a165c3b5139Svetoslav Ganov     * <p>
609021078554b902179442a345a9d080a165c3b5139Svetoslav Ganov     * A virtual descendant is an imaginary View that is reported as a part of the view
610021078554b902179442a345a9d080a165c3b5139Svetoslav Ganov     * hierarchy for accessibility purposes. This enables custom views that draw complex
61171b4e71c67df79f53b582fabb34b96ddbe23fe0fSvetoslav Ganov     * content to report themselves as a tree of virtual views, thus conveying their
612021078554b902179442a345a9d080a165c3b5139Svetoslav Ganov     * logical structure.
613021078554b902179442a345a9d080a165c3b5139Svetoslav Ganov     * </p>
614021078554b902179442a345a9d080a165c3b5139Svetoslav Ganov     * <p>
615021078554b902179442a345a9d080a165c3b5139Svetoslav Ganov     *   <strong>Note:</strong> Cannot be called from an
616021078554b902179442a345a9d080a165c3b5139Svetoslav Ganov     *   {@link android.accessibilityservice.AccessibilityService}.
617021078554b902179442a345a9d080a165c3b5139Svetoslav Ganov     *   This class is made immutable before being delivered to an AccessibilityService.
618021078554b902179442a345a9d080a165c3b5139Svetoslav Ganov     * </p>
619021078554b902179442a345a9d080a165c3b5139Svetoslav Ganov     *
620021078554b902179442a345a9d080a165c3b5139Svetoslav Ganov     * @param root The root of the virtual subtree.
621021078554b902179442a345a9d080a165c3b5139Svetoslav Ganov     * @param virtualDescendantId The id of the virtual descendant.
622021078554b902179442a345a9d080a165c3b5139Svetoslav Ganov     */
623021078554b902179442a345a9d080a165c3b5139Svetoslav Ganov    public void setSource(View root, int virtualDescendantId) {
6248643aa0179e598e78d938c59035389054535a229Svetoslav Ganov        enforceNotSealed();
6258e3feb15c5aec2c72b0ef120a1da325e1e8f0ddaSvetoslav        mWindowId = (root != null) ? root.getAccessibilityWindowId() : UNDEFINED_ITEM_ID;
626021078554b902179442a345a9d080a165c3b5139Svetoslav Ganov        final int rootAccessibilityViewId =
6278e3feb15c5aec2c72b0ef120a1da325e1e8f0ddaSvetoslav            (root != null) ? root.getAccessibilityViewId() : UNDEFINED_ITEM_ID;
628021078554b902179442a345a9d080a165c3b5139Svetoslav Ganov        mSourceNodeId = makeNodeId(rootAccessibilityViewId, virtualDescendantId);
6298643aa0179e598e78d938c59035389054535a229Svetoslav Ganov    }
630005b83b0c62d3d0538f0d566b08bd457015ec661Svetoslav Ganov
6314213804541a8b05cd0587b138a2fd9a3b7fd9350Svetoslav Ganov    /**
632005b83b0c62d3d0538f0d566b08bd457015ec661Svetoslav Ganov     * Find the view that has the specified focus type. The search starts from
6334213804541a8b05cd0587b138a2fd9a3b7fd9350Svetoslav Ganov     * the view represented by this node info.
6344213804541a8b05cd0587b138a2fd9a3b7fd9350Svetoslav Ganov     *
6354213804541a8b05cd0587b138a2fd9a3b7fd9350Svetoslav Ganov     * @param focus The focus to find. One of {@link #FOCUS_INPUT} or
6364213804541a8b05cd0587b138a2fd9a3b7fd9350Svetoslav Ganov     *         {@link #FOCUS_ACCESSIBILITY}.
6374213804541a8b05cd0587b138a2fd9a3b7fd9350Svetoslav Ganov     * @return The node info of the focused view or null.
6384213804541a8b05cd0587b138a2fd9a3b7fd9350Svetoslav Ganov     *
6394213804541a8b05cd0587b138a2fd9a3b7fd9350Svetoslav Ganov     * @see #FOCUS_INPUT
6404213804541a8b05cd0587b138a2fd9a3b7fd9350Svetoslav Ganov     * @see #FOCUS_ACCESSIBILITY
6414213804541a8b05cd0587b138a2fd9a3b7fd9350Svetoslav Ganov     */
6424213804541a8b05cd0587b138a2fd9a3b7fd9350Svetoslav Ganov    public AccessibilityNodeInfo findFocus(int focus) {
6434213804541a8b05cd0587b138a2fd9a3b7fd9350Svetoslav Ganov        enforceSealed();
6442ef6905003c20010032ee993dfcc5899ad9be6f8Svetoslav Ganov        enforceValidFocusType(focus);
6454213804541a8b05cd0587b138a2fd9a3b7fd9350Svetoslav Ganov        if (!canPerformRequestOverConnection(mSourceNodeId)) {
6464213804541a8b05cd0587b138a2fd9a3b7fd9350Svetoslav Ganov            return null;
6474213804541a8b05cd0587b138a2fd9a3b7fd9350Svetoslav Ganov        }
6484213804541a8b05cd0587b138a2fd9a3b7fd9350Svetoslav Ganov        return AccessibilityInteractionClient.getInstance().findFocus(mConnectionId, mWindowId,
6494213804541a8b05cd0587b138a2fd9a3b7fd9350Svetoslav Ganov                mSourceNodeId, focus);
6504213804541a8b05cd0587b138a2fd9a3b7fd9350Svetoslav Ganov    }
6514213804541a8b05cd0587b138a2fd9a3b7fd9350Svetoslav Ganov
6524213804541a8b05cd0587b138a2fd9a3b7fd9350Svetoslav Ganov    /**
6534213804541a8b05cd0587b138a2fd9a3b7fd9350Svetoslav Ganov     * Searches for the nearest view in the specified direction that can take
6544213804541a8b05cd0587b138a2fd9a3b7fd9350Svetoslav Ganov     * the input focus.
6554213804541a8b05cd0587b138a2fd9a3b7fd9350Svetoslav Ganov     *
6564213804541a8b05cd0587b138a2fd9a3b7fd9350Svetoslav Ganov     * @param direction The direction. Can be one of:
6574213804541a8b05cd0587b138a2fd9a3b7fd9350Svetoslav Ganov     *     {@link View#FOCUS_DOWN},
6584213804541a8b05cd0587b138a2fd9a3b7fd9350Svetoslav Ganov     *     {@link View#FOCUS_UP},
6594213804541a8b05cd0587b138a2fd9a3b7fd9350Svetoslav Ganov     *     {@link View#FOCUS_LEFT},
6604213804541a8b05cd0587b138a2fd9a3b7fd9350Svetoslav Ganov     *     {@link View#FOCUS_RIGHT},
6614213804541a8b05cd0587b138a2fd9a3b7fd9350Svetoslav Ganov     *     {@link View#FOCUS_FORWARD},
6628ffe8b304e4778b3c95e57ad5a77cd41c9cf9f7bSvetoslav Ganov     *     {@link View#FOCUS_BACKWARD}.
6634213804541a8b05cd0587b138a2fd9a3b7fd9350Svetoslav Ganov     *
6644213804541a8b05cd0587b138a2fd9a3b7fd9350Svetoslav Ganov     * @return The node info for the view that can take accessibility focus.
6654213804541a8b05cd0587b138a2fd9a3b7fd9350Svetoslav Ganov     */
6664213804541a8b05cd0587b138a2fd9a3b7fd9350Svetoslav Ganov    public AccessibilityNodeInfo focusSearch(int direction) {
6674213804541a8b05cd0587b138a2fd9a3b7fd9350Svetoslav Ganov        enforceSealed();
6682ef6905003c20010032ee993dfcc5899ad9be6f8Svetoslav Ganov        enforceValidFocusDirection(direction);
6694213804541a8b05cd0587b138a2fd9a3b7fd9350Svetoslav Ganov        if (!canPerformRequestOverConnection(mSourceNodeId)) {
6704213804541a8b05cd0587b138a2fd9a3b7fd9350Svetoslav Ganov            return null;
6714213804541a8b05cd0587b138a2fd9a3b7fd9350Svetoslav Ganov        }
6724213804541a8b05cd0587b138a2fd9a3b7fd9350Svetoslav Ganov        return AccessibilityInteractionClient.getInstance().focusSearch(mConnectionId, mWindowId,
6734213804541a8b05cd0587b138a2fd9a3b7fd9350Svetoslav Ganov                mSourceNodeId, direction);
6744213804541a8b05cd0587b138a2fd9a3b7fd9350Svetoslav Ganov    }
6758643aa0179e598e78d938c59035389054535a229Svetoslav Ganov
6768643aa0179e598e78d938c59035389054535a229Svetoslav Ganov    /**
6778643aa0179e598e78d938c59035389054535a229Svetoslav Ganov     * Gets the id of the window from which the info comes from.
6788643aa0179e598e78d938c59035389054535a229Svetoslav Ganov     *
6798643aa0179e598e78d938c59035389054535a229Svetoslav Ganov     * @return The window id.
6808643aa0179e598e78d938c59035389054535a229Svetoslav Ganov     */
681eeee4d2c01d3c4ed99e4891dbc75c7de69a803faSvetoslav Ganov    public int getWindowId() {
682021078554b902179442a345a9d080a165c3b5139Svetoslav Ganov        return mWindowId;
6838643aa0179e598e78d938c59035389054535a229Svetoslav Ganov    }
6848643aa0179e598e78d938c59035389054535a229Svetoslav Ganov
6858643aa0179e598e78d938c59035389054535a229Svetoslav Ganov    /**
6860b0afb49a85c54b6e876055e76dc41d4345948a4Svetoslav Ganov     * Refreshes this info with the latest state of the view it represents.
6870b0afb49a85c54b6e876055e76dc41d4345948a4Svetoslav Ganov     * <p>
6880b0afb49a85c54b6e876055e76dc41d4345948a4Svetoslav Ganov     * <strong>Note:</strong> If this method returns false this info is obsolete
6890b0afb49a85c54b6e876055e76dc41d4345948a4Svetoslav Ganov     * since it represents a view that is no longer in the view tree and should
6900b0afb49a85c54b6e876055e76dc41d4345948a4Svetoslav Ganov     * be recycled.
6910b0afb49a85c54b6e876055e76dc41d4345948a4Svetoslav Ganov     * </p>
6926254f4806dd3db53b7380e77fbb183065685573eSvetoslav     *
6936254f4806dd3db53b7380e77fbb183065685573eSvetoslav     * @param bypassCache Whether to bypass the cache.
6940b0afb49a85c54b6e876055e76dc41d4345948a4Svetoslav Ganov     * @return Whether the refresh succeeded.
6956254f4806dd3db53b7380e77fbb183065685573eSvetoslav     *
6966254f4806dd3db53b7380e77fbb183065685573eSvetoslav     * @hide
6970b0afb49a85c54b6e876055e76dc41d4345948a4Svetoslav Ganov     */
6986254f4806dd3db53b7380e77fbb183065685573eSvetoslav    public boolean refresh(boolean bypassCache) {
6990b0afb49a85c54b6e876055e76dc41d4345948a4Svetoslav Ganov        enforceSealed();
7000b0afb49a85c54b6e876055e76dc41d4345948a4Svetoslav Ganov        if (!canPerformRequestOverConnection(mSourceNodeId)) {
7010b0afb49a85c54b6e876055e76dc41d4345948a4Svetoslav Ganov            return false;
7020b0afb49a85c54b6e876055e76dc41d4345948a4Svetoslav Ganov        }
7030b0afb49a85c54b6e876055e76dc41d4345948a4Svetoslav Ganov        AccessibilityInteractionClient client = AccessibilityInteractionClient.getInstance();
7040b0afb49a85c54b6e876055e76dc41d4345948a4Svetoslav Ganov        AccessibilityNodeInfo refreshedInfo = client.findAccessibilityNodeInfoByAccessibilityId(
7056254f4806dd3db53b7380e77fbb183065685573eSvetoslav                mConnectionId, mWindowId, mSourceNodeId, bypassCache, 0);
7060b0afb49a85c54b6e876055e76dc41d4345948a4Svetoslav Ganov        if (refreshedInfo == null) {
7070b0afb49a85c54b6e876055e76dc41d4345948a4Svetoslav Ganov            return false;
7080b0afb49a85c54b6e876055e76dc41d4345948a4Svetoslav Ganov        }
7090b0afb49a85c54b6e876055e76dc41d4345948a4Svetoslav Ganov        init(refreshedInfo);
7100b0afb49a85c54b6e876055e76dc41d4345948a4Svetoslav Ganov        refreshedInfo.recycle();
7110b0afb49a85c54b6e876055e76dc41d4345948a4Svetoslav Ganov        return true;
7120b0afb49a85c54b6e876055e76dc41d4345948a4Svetoslav Ganov    }
7130b0afb49a85c54b6e876055e76dc41d4345948a4Svetoslav Ganov
7140b0afb49a85c54b6e876055e76dc41d4345948a4Svetoslav Ganov    /**
7156254f4806dd3db53b7380e77fbb183065685573eSvetoslav     * Refreshes this info with the latest state of the view it represents.
7166254f4806dd3db53b7380e77fbb183065685573eSvetoslav     * <p>
7176254f4806dd3db53b7380e77fbb183065685573eSvetoslav     * <strong>Note:</strong> If this method returns false this info is obsolete
7186254f4806dd3db53b7380e77fbb183065685573eSvetoslav     * since it represents a view that is no longer in the view tree and should
7196254f4806dd3db53b7380e77fbb183065685573eSvetoslav     * be recycled.
7206254f4806dd3db53b7380e77fbb183065685573eSvetoslav     * </p>
7216254f4806dd3db53b7380e77fbb183065685573eSvetoslav     * @return Whether the refresh succeeded.
7226254f4806dd3db53b7380e77fbb183065685573eSvetoslav     */
7236254f4806dd3db53b7380e77fbb183065685573eSvetoslav    public boolean refresh() {
72448a5ed5617067b52676c26b9230ce5b75946984bSvetoslav        return refresh(true);
7256254f4806dd3db53b7380e77fbb183065685573eSvetoslav    }
7266254f4806dd3db53b7380e77fbb183065685573eSvetoslav
7276254f4806dd3db53b7380e77fbb183065685573eSvetoslav    /**
728f0aed09ed8153043e40b3ac99788d47ba0831306Alan Viverette     * Returns the array containing the IDs of this node's children.
72957c7fd5a43237afc5e8ef31a076e862c0c16c328Svetoslav Ganov     *
73057c7fd5a43237afc5e8ef31a076e862c0c16c328Svetoslav Ganov     * @hide
73157c7fd5a43237afc5e8ef31a076e862c0c16c328Svetoslav Ganov     */
732f0aed09ed8153043e40b3ac99788d47ba0831306Alan Viverette    public LongArray getChildNodeIds() {
73357c7fd5a43237afc5e8ef31a076e862c0c16c328Svetoslav Ganov        return mChildNodeIds;
73457c7fd5a43237afc5e8ef31a076e862c0c16c328Svetoslav Ganov    }
73557c7fd5a43237afc5e8ef31a076e862c0c16c328Svetoslav Ganov
73657c7fd5a43237afc5e8ef31a076e862c0c16c328Svetoslav Ganov    /**
737f0aed09ed8153043e40b3ac99788d47ba0831306Alan Viverette     * Returns the id of the child at the specified index.
738f0aed09ed8153043e40b3ac99788d47ba0831306Alan Viverette     *
739f0aed09ed8153043e40b3ac99788d47ba0831306Alan Viverette     * @throws IndexOutOfBoundsException when index &lt; 0 || index &gt;=
740f0aed09ed8153043e40b3ac99788d47ba0831306Alan Viverette     *             getChildCount()
741f0aed09ed8153043e40b3ac99788d47ba0831306Alan Viverette     * @hide
742f0aed09ed8153043e40b3ac99788d47ba0831306Alan Viverette     */
743f0aed09ed8153043e40b3ac99788d47ba0831306Alan Viverette    public long getChildId(int index) {
744f0aed09ed8153043e40b3ac99788d47ba0831306Alan Viverette        if (mChildNodeIds == null) {
745f0aed09ed8153043e40b3ac99788d47ba0831306Alan Viverette            throw new IndexOutOfBoundsException();
746f0aed09ed8153043e40b3ac99788d47ba0831306Alan Viverette        }
747f0aed09ed8153043e40b3ac99788d47ba0831306Alan Viverette        return mChildNodeIds.get(index);
748f0aed09ed8153043e40b3ac99788d47ba0831306Alan Viverette    }
749f0aed09ed8153043e40b3ac99788d47ba0831306Alan Viverette
750f0aed09ed8153043e40b3ac99788d47ba0831306Alan Viverette    /**
7518643aa0179e598e78d938c59035389054535a229Svetoslav Ganov     * Gets the number of children.
7528643aa0179e598e78d938c59035389054535a229Svetoslav Ganov     *
7538643aa0179e598e78d938c59035389054535a229Svetoslav Ganov     * @return The child count.
7548643aa0179e598e78d938c59035389054535a229Svetoslav Ganov     */
7558643aa0179e598e78d938c59035389054535a229Svetoslav Ganov    public int getChildCount() {
756f0aed09ed8153043e40b3ac99788d47ba0831306Alan Viverette        return mChildNodeIds == null ? 0 : mChildNodeIds.size();
7578643aa0179e598e78d938c59035389054535a229Svetoslav Ganov    }
7588643aa0179e598e78d938c59035389054535a229Svetoslav Ganov
7598643aa0179e598e78d938c59035389054535a229Svetoslav Ganov    /**
7608643aa0179e598e78d938c59035389054535a229Svetoslav Ganov     * Get the child at given index.
7618643aa0179e598e78d938c59035389054535a229Svetoslav Ganov     * <p>
76238e8b4e5bc3c93affdffbc064fd9db5aeccc3e8eSvetoslav Ganov     *   <strong>Note:</strong> It is a client responsibility to recycle the
76338e8b4e5bc3c93affdffbc064fd9db5aeccc3e8eSvetoslav Ganov     *     received info by calling {@link AccessibilityNodeInfo#recycle()}
76438e8b4e5bc3c93affdffbc064fd9db5aeccc3e8eSvetoslav Ganov     *     to avoid creating of multiple instances.
7658643aa0179e598e78d938c59035389054535a229Svetoslav Ganov     * </p>
76638e8b4e5bc3c93affdffbc064fd9db5aeccc3e8eSvetoslav Ganov     *
7678643aa0179e598e78d938c59035389054535a229Svetoslav Ganov     * @param index The child index.
7688643aa0179e598e78d938c59035389054535a229Svetoslav Ganov     * @return The child node.
7698643aa0179e598e78d938c59035389054535a229Svetoslav Ganov     *
7708643aa0179e598e78d938c59035389054535a229Svetoslav Ganov     * @throws IllegalStateException If called outside of an AccessibilityService.
7718643aa0179e598e78d938c59035389054535a229Svetoslav Ganov     *
7728643aa0179e598e78d938c59035389054535a229Svetoslav Ganov     */
7738643aa0179e598e78d938c59035389054535a229Svetoslav Ganov    public AccessibilityNodeInfo getChild(int index) {
7748643aa0179e598e78d938c59035389054535a229Svetoslav Ganov        enforceSealed();
775f0aed09ed8153043e40b3ac99788d47ba0831306Alan Viverette        if (mChildNodeIds == null) {
776f0aed09ed8153043e40b3ac99788d47ba0831306Alan Viverette            return null;
777f0aed09ed8153043e40b3ac99788d47ba0831306Alan Viverette        }
778021078554b902179442a345a9d080a165c3b5139Svetoslav Ganov        if (!canPerformRequestOverConnection(mSourceNodeId)) {
779eeee4d2c01d3c4ed99e4891dbc75c7de69a803faSvetoslav Ganov            return null;
780eeee4d2c01d3c4ed99e4891dbc75c7de69a803faSvetoslav Ganov        }
78157c7fd5a43237afc5e8ef31a076e862c0c16c328Svetoslav Ganov        final long childId = mChildNodeIds.get(index);
7828bd69610aafc6995126965d1d23b771fe02a9084Svetoslav Ganov        AccessibilityInteractionClient client = AccessibilityInteractionClient.getInstance();
78357c7fd5a43237afc5e8ef31a076e862c0c16c328Svetoslav Ganov        return client.findAccessibilityNodeInfoByAccessibilityId(mConnectionId, mWindowId,
7846254f4806dd3db53b7380e77fbb183065685573eSvetoslav                childId, false, FLAG_PREFETCH_DESCENDANTS);
7858643aa0179e598e78d938c59035389054535a229Svetoslav Ganov    }
7868643aa0179e598e78d938c59035389054535a229Svetoslav Ganov
7878643aa0179e598e78d938c59035389054535a229Svetoslav Ganov    /**
7888643aa0179e598e78d938c59035389054535a229Svetoslav Ganov     * Adds a child.
7898643aa0179e598e78d938c59035389054535a229Svetoslav Ganov     * <p>
790021078554b902179442a345a9d080a165c3b5139Svetoslav Ganov     * <strong>Note:</strong> Cannot be called from an
791021078554b902179442a345a9d080a165c3b5139Svetoslav Ganov     * {@link android.accessibilityservice.AccessibilityService}.
792021078554b902179442a345a9d080a165c3b5139Svetoslav Ganov     * This class is made immutable before being delivered to an AccessibilityService.
7938643aa0179e598e78d938c59035389054535a229Svetoslav Ganov     * </p>
79438e8b4e5bc3c93affdffbc064fd9db5aeccc3e8eSvetoslav Ganov     *
7958643aa0179e598e78d938c59035389054535a229Svetoslav Ganov     * @param child The child.
7968643aa0179e598e78d938c59035389054535a229Svetoslav Ganov     *
7978643aa0179e598e78d938c59035389054535a229Svetoslav Ganov     * @throws IllegalStateException If called from an AccessibilityService.
7988643aa0179e598e78d938c59035389054535a229Svetoslav Ganov     */
7998643aa0179e598e78d938c59035389054535a229Svetoslav Ganov    public void addChild(View child) {
8008e3feb15c5aec2c72b0ef120a1da325e1e8f0ddaSvetoslav        addChildInternal(child, UNDEFINED_ITEM_ID, true);
801f0aed09ed8153043e40b3ac99788d47ba0831306Alan Viverette    }
802f0aed09ed8153043e40b3ac99788d47ba0831306Alan Viverette
803f0aed09ed8153043e40b3ac99788d47ba0831306Alan Viverette    /**
804f0aed09ed8153043e40b3ac99788d47ba0831306Alan Viverette     * Unchecked version of {@link #addChild(View)} that does not verify
805f0aed09ed8153043e40b3ac99788d47ba0831306Alan Viverette     * uniqueness. For framework use only.
806f0aed09ed8153043e40b3ac99788d47ba0831306Alan Viverette     *
807f0aed09ed8153043e40b3ac99788d47ba0831306Alan Viverette     * @hide
808f0aed09ed8153043e40b3ac99788d47ba0831306Alan Viverette     */
809f0aed09ed8153043e40b3ac99788d47ba0831306Alan Viverette    public void addChildUnchecked(View child) {
8108e3feb15c5aec2c72b0ef120a1da325e1e8f0ddaSvetoslav        addChildInternal(child, UNDEFINED_ITEM_ID, false);
811f0aed09ed8153043e40b3ac99788d47ba0831306Alan Viverette    }
812f0aed09ed8153043e40b3ac99788d47ba0831306Alan Viverette
813f0aed09ed8153043e40b3ac99788d47ba0831306Alan Viverette    /**
814f0aed09ed8153043e40b3ac99788d47ba0831306Alan Viverette     * Removes a child. If the child was not previously added to the node,
815f0aed09ed8153043e40b3ac99788d47ba0831306Alan Viverette     * calling this method has no effect.
816f0aed09ed8153043e40b3ac99788d47ba0831306Alan Viverette     * <p>
817f0aed09ed8153043e40b3ac99788d47ba0831306Alan Viverette     * <strong>Note:</strong> Cannot be called from an
818f0aed09ed8153043e40b3ac99788d47ba0831306Alan Viverette     * {@link android.accessibilityservice.AccessibilityService}.
819f0aed09ed8153043e40b3ac99788d47ba0831306Alan Viverette     * This class is made immutable before being delivered to an AccessibilityService.
820f0aed09ed8153043e40b3ac99788d47ba0831306Alan Viverette     * </p>
821f0aed09ed8153043e40b3ac99788d47ba0831306Alan Viverette     *
822f0aed09ed8153043e40b3ac99788d47ba0831306Alan Viverette     * @param child The child.
823f0aed09ed8153043e40b3ac99788d47ba0831306Alan Viverette     * @return true if the child was present
824f0aed09ed8153043e40b3ac99788d47ba0831306Alan Viverette     *
825f0aed09ed8153043e40b3ac99788d47ba0831306Alan Viverette     * @throws IllegalStateException If called from an AccessibilityService.
826f0aed09ed8153043e40b3ac99788d47ba0831306Alan Viverette     */
827f0aed09ed8153043e40b3ac99788d47ba0831306Alan Viverette    public boolean removeChild(View child) {
8288e3feb15c5aec2c72b0ef120a1da325e1e8f0ddaSvetoslav        return removeChild(child, UNDEFINED_ITEM_ID);
829021078554b902179442a345a9d080a165c3b5139Svetoslav Ganov    }
830021078554b902179442a345a9d080a165c3b5139Svetoslav Ganov
831021078554b902179442a345a9d080a165c3b5139Svetoslav Ganov    /**
832021078554b902179442a345a9d080a165c3b5139Svetoslav Ganov     * Adds a virtual child which is a descendant of the given <code>root</code>.
83371b4e71c67df79f53b582fabb34b96ddbe23fe0fSvetoslav Ganov     * If <code>virtualDescendantId</code> is {@link View#NO_ID} the root
834021078554b902179442a345a9d080a165c3b5139Svetoslav Ganov     * is added as a child.
835021078554b902179442a345a9d080a165c3b5139Svetoslav Ganov     * <p>
836021078554b902179442a345a9d080a165c3b5139Svetoslav Ganov     * A virtual descendant is an imaginary View that is reported as a part of the view
837021078554b902179442a345a9d080a165c3b5139Svetoslav Ganov     * hierarchy for accessibility purposes. This enables custom views that draw complex
838021078554b902179442a345a9d080a165c3b5139Svetoslav Ganov     * content to report them selves as a tree of virtual views, thus conveying their
839021078554b902179442a345a9d080a165c3b5139Svetoslav Ganov     * logical structure.
840021078554b902179442a345a9d080a165c3b5139Svetoslav Ganov     * </p>
841021078554b902179442a345a9d080a165c3b5139Svetoslav Ganov     *
842021078554b902179442a345a9d080a165c3b5139Svetoslav Ganov     * @param root The root of the virtual subtree.
843021078554b902179442a345a9d080a165c3b5139Svetoslav Ganov     * @param virtualDescendantId The id of the virtual child.
844021078554b902179442a345a9d080a165c3b5139Svetoslav Ganov     */
845021078554b902179442a345a9d080a165c3b5139Svetoslav Ganov    public void addChild(View root, int virtualDescendantId) {
846f0aed09ed8153043e40b3ac99788d47ba0831306Alan Viverette        addChildInternal(root, virtualDescendantId, true);
847f0aed09ed8153043e40b3ac99788d47ba0831306Alan Viverette    }
848f0aed09ed8153043e40b3ac99788d47ba0831306Alan Viverette
849f0aed09ed8153043e40b3ac99788d47ba0831306Alan Viverette    private void addChildInternal(View root, int virtualDescendantId, boolean checked) {
8508643aa0179e598e78d938c59035389054535a229Svetoslav Ganov        enforceNotSealed();
851f0aed09ed8153043e40b3ac99788d47ba0831306Alan Viverette        if (mChildNodeIds == null) {
852f0aed09ed8153043e40b3ac99788d47ba0831306Alan Viverette            mChildNodeIds = new LongArray();
853f0aed09ed8153043e40b3ac99788d47ba0831306Alan Viverette        }
854021078554b902179442a345a9d080a165c3b5139Svetoslav Ganov        final int rootAccessibilityViewId =
8558e3feb15c5aec2c72b0ef120a1da325e1e8f0ddaSvetoslav            (root != null) ? root.getAccessibilityViewId() : UNDEFINED_ITEM_ID;
856021078554b902179442a345a9d080a165c3b5139Svetoslav Ganov        final long childNodeId = makeNodeId(rootAccessibilityViewId, virtualDescendantId);
857f0aed09ed8153043e40b3ac99788d47ba0831306Alan Viverette        // If we're checking uniqueness and the ID already exists, abort.
858f0aed09ed8153043e40b3ac99788d47ba0831306Alan Viverette        if (checked && mChildNodeIds.indexOf(childNodeId) >= 0) {
859f0aed09ed8153043e40b3ac99788d47ba0831306Alan Viverette            return;
860f0aed09ed8153043e40b3ac99788d47ba0831306Alan Viverette        }
861f0aed09ed8153043e40b3ac99788d47ba0831306Alan Viverette        mChildNodeIds.add(childNodeId);
862f0aed09ed8153043e40b3ac99788d47ba0831306Alan Viverette    }
863f0aed09ed8153043e40b3ac99788d47ba0831306Alan Viverette
864f0aed09ed8153043e40b3ac99788d47ba0831306Alan Viverette    /**
865f0aed09ed8153043e40b3ac99788d47ba0831306Alan Viverette     * Removes a virtual child which is a descendant of the given
866f0aed09ed8153043e40b3ac99788d47ba0831306Alan Viverette     * <code>root</code>. If the child was not previously added to the node,
867f0aed09ed8153043e40b3ac99788d47ba0831306Alan Viverette     * calling this method has no effect.
868f0aed09ed8153043e40b3ac99788d47ba0831306Alan Viverette     *
869f0aed09ed8153043e40b3ac99788d47ba0831306Alan Viverette     * @param root The root of the virtual subtree.
870f0aed09ed8153043e40b3ac99788d47ba0831306Alan Viverette     * @param virtualDescendantId The id of the virtual child.
871f0aed09ed8153043e40b3ac99788d47ba0831306Alan Viverette     * @return true if the child was present
872f0aed09ed8153043e40b3ac99788d47ba0831306Alan Viverette     * @see #addChild(View, int)
873f0aed09ed8153043e40b3ac99788d47ba0831306Alan Viverette     */
874f0aed09ed8153043e40b3ac99788d47ba0831306Alan Viverette    public boolean removeChild(View root, int virtualDescendantId) {
875f0aed09ed8153043e40b3ac99788d47ba0831306Alan Viverette        enforceNotSealed();
876f0aed09ed8153043e40b3ac99788d47ba0831306Alan Viverette        final LongArray childIds = mChildNodeIds;
877f0aed09ed8153043e40b3ac99788d47ba0831306Alan Viverette        if (childIds == null) {
878f0aed09ed8153043e40b3ac99788d47ba0831306Alan Viverette            return false;
879f0aed09ed8153043e40b3ac99788d47ba0831306Alan Viverette        }
880f0aed09ed8153043e40b3ac99788d47ba0831306Alan Viverette        final int rootAccessibilityViewId =
8818e3feb15c5aec2c72b0ef120a1da325e1e8f0ddaSvetoslav                (root != null) ? root.getAccessibilityViewId() : UNDEFINED_ITEM_ID;
882f0aed09ed8153043e40b3ac99788d47ba0831306Alan Viverette        final long childNodeId = makeNodeId(rootAccessibilityViewId, virtualDescendantId);
883f0aed09ed8153043e40b3ac99788d47ba0831306Alan Viverette        final int index = childIds.indexOf(childNodeId);
884f0aed09ed8153043e40b3ac99788d47ba0831306Alan Viverette        if (index < 0) {
885f0aed09ed8153043e40b3ac99788d47ba0831306Alan Viverette            return false;
886f0aed09ed8153043e40b3ac99788d47ba0831306Alan Viverette        }
887f0aed09ed8153043e40b3ac99788d47ba0831306Alan Viverette        childIds.remove(index);
888f0aed09ed8153043e40b3ac99788d47ba0831306Alan Viverette        return true;
8898643aa0179e598e78d938c59035389054535a229Svetoslav Ganov    }
8908643aa0179e598e78d938c59035389054535a229Svetoslav Ganov
8918643aa0179e598e78d938c59035389054535a229Svetoslav Ganov    /**
8928643aa0179e598e78d938c59035389054535a229Svetoslav Ganov     * Gets the actions that can be performed on the node.
89374bc19476536f2b5462eaa29e6f3029ee897c16dKristian Monsen     */
89474bc19476536f2b5462eaa29e6f3029ee897c16dKristian Monsen    public List<AccessibilityAction> getActionList() {
89574bc19476536f2b5462eaa29e6f3029ee897c16dKristian Monsen        if (mActions == null) {
89674bc19476536f2b5462eaa29e6f3029ee897c16dKristian Monsen            return Collections.emptyList();
89774bc19476536f2b5462eaa29e6f3029ee897c16dKristian Monsen        }
89874bc19476536f2b5462eaa29e6f3029ee897c16dKristian Monsen
89974bc19476536f2b5462eaa29e6f3029ee897c16dKristian Monsen        return mActions;
90074bc19476536f2b5462eaa29e6f3029ee897c16dKristian Monsen    }
90174bc19476536f2b5462eaa29e6f3029ee897c16dKristian Monsen
90274bc19476536f2b5462eaa29e6f3029ee897c16dKristian Monsen    /**
90374bc19476536f2b5462eaa29e6f3029ee897c16dKristian Monsen     * Gets the actions that can be performed on the node.
9048643aa0179e598e78d938c59035389054535a229Svetoslav Ganov     *
9058643aa0179e598e78d938c59035389054535a229Svetoslav Ganov     * @return The bit mask of with actions.
9068643aa0179e598e78d938c59035389054535a229Svetoslav Ganov     *
9078643aa0179e598e78d938c59035389054535a229Svetoslav Ganov     * @see AccessibilityNodeInfo#ACTION_FOCUS
9088643aa0179e598e78d938c59035389054535a229Svetoslav Ganov     * @see AccessibilityNodeInfo#ACTION_CLEAR_FOCUS
9098643aa0179e598e78d938c59035389054535a229Svetoslav Ganov     * @see AccessibilityNodeInfo#ACTION_SELECT
9108643aa0179e598e78d938c59035389054535a229Svetoslav Ganov     * @see AccessibilityNodeInfo#ACTION_CLEAR_SELECTION
911a1dc761c8322355eb1bb71d3d6c9c603c1d1fc0fSvetoslav Ganov     * @see AccessibilityNodeInfo#ACTION_ACCESSIBILITY_FOCUS
912a1dc761c8322355eb1bb71d3d6c9c603c1d1fc0fSvetoslav Ganov     * @see AccessibilityNodeInfo#ACTION_CLEAR_ACCESSIBILITY_FOCUS
913a1dc761c8322355eb1bb71d3d6c9c603c1d1fc0fSvetoslav Ganov     * @see AccessibilityNodeInfo#ACTION_CLICK
914a1dc761c8322355eb1bb71d3d6c9c603c1d1fc0fSvetoslav Ganov     * @see AccessibilityNodeInfo#ACTION_LONG_CLICK
915a1dc761c8322355eb1bb71d3d6c9c603c1d1fc0fSvetoslav Ganov     * @see AccessibilityNodeInfo#ACTION_NEXT_AT_MOVEMENT_GRANULARITY
916a1dc761c8322355eb1bb71d3d6c9c603c1d1fc0fSvetoslav Ganov     * @see AccessibilityNodeInfo#ACTION_PREVIOUS_AT_MOVEMENT_GRANULARITY
917a1dc761c8322355eb1bb71d3d6c9c603c1d1fc0fSvetoslav Ganov     * @see AccessibilityNodeInfo#ACTION_NEXT_HTML_ELEMENT
918a1dc761c8322355eb1bb71d3d6c9c603c1d1fc0fSvetoslav Ganov     * @see AccessibilityNodeInfo#ACTION_PREVIOUS_HTML_ELEMENT
919a1dc761c8322355eb1bb71d3d6c9c603c1d1fc0fSvetoslav Ganov     * @see AccessibilityNodeInfo#ACTION_SCROLL_FORWARD
920a1dc761c8322355eb1bb71d3d6c9c603c1d1fc0fSvetoslav Ganov     * @see AccessibilityNodeInfo#ACTION_SCROLL_BACKWARD
92174bc19476536f2b5462eaa29e6f3029ee897c16dKristian Monsen     *
92274bc19476536f2b5462eaa29e6f3029ee897c16dKristian Monsen     * @deprecated Use {@link #getActionList()}.
9238643aa0179e598e78d938c59035389054535a229Svetoslav Ganov     */
92474bc19476536f2b5462eaa29e6f3029ee897c16dKristian Monsen    @Deprecated
9258643aa0179e598e78d938c59035389054535a229Svetoslav Ganov    public int getActions() {
92674bc19476536f2b5462eaa29e6f3029ee897c16dKristian Monsen        int returnValue = 0;
92774bc19476536f2b5462eaa29e6f3029ee897c16dKristian Monsen
92874bc19476536f2b5462eaa29e6f3029ee897c16dKristian Monsen        if (mActions == null) {
92974bc19476536f2b5462eaa29e6f3029ee897c16dKristian Monsen            return returnValue;
93074bc19476536f2b5462eaa29e6f3029ee897c16dKristian Monsen        }
93174bc19476536f2b5462eaa29e6f3029ee897c16dKristian Monsen
93274bc19476536f2b5462eaa29e6f3029ee897c16dKristian Monsen        final int actionSize = mActions.size();
93374bc19476536f2b5462eaa29e6f3029ee897c16dKristian Monsen        for (int i = 0; i < actionSize; i++) {
93474bc19476536f2b5462eaa29e6f3029ee897c16dKristian Monsen            int actionId = mActions.get(i).getId();
93574bc19476536f2b5462eaa29e6f3029ee897c16dKristian Monsen            if (actionId <= LAST_LEGACY_STANDARD_ACTION) {
93674bc19476536f2b5462eaa29e6f3029ee897c16dKristian Monsen                returnValue |= actionId;
93774bc19476536f2b5462eaa29e6f3029ee897c16dKristian Monsen            }
93874bc19476536f2b5462eaa29e6f3029ee897c16dKristian Monsen        }
93974bc19476536f2b5462eaa29e6f3029ee897c16dKristian Monsen
94074bc19476536f2b5462eaa29e6f3029ee897c16dKristian Monsen        return returnValue;
9418643aa0179e598e78d938c59035389054535a229Svetoslav Ganov    }
9428643aa0179e598e78d938c59035389054535a229Svetoslav Ganov
9438643aa0179e598e78d938c59035389054535a229Svetoslav Ganov    /**
9448643aa0179e598e78d938c59035389054535a229Svetoslav Ganov     * Adds an action that can be performed on the node.
9458643aa0179e598e78d938c59035389054535a229Svetoslav Ganov     * <p>
94674bc19476536f2b5462eaa29e6f3029ee897c16dKristian Monsen     * To add a standard action use the static constants on {@link AccessibilityAction}.
94774bc19476536f2b5462eaa29e6f3029ee897c16dKristian Monsen     * To add a custom action create a new {@link AccessibilityAction} by passing in a
94874bc19476536f2b5462eaa29e6f3029ee897c16dKristian Monsen     * resource id from your application as the action id and an optional label that
94974bc19476536f2b5462eaa29e6f3029ee897c16dKristian Monsen     * describes the action. To override one of the standard actions use as the action
95074bc19476536f2b5462eaa29e6f3029ee897c16dKristian Monsen     * id of a standard action id such as {@link #ACTION_CLICK} and an optional label that
95174bc19476536f2b5462eaa29e6f3029ee897c16dKristian Monsen     * describes the action.
95274bc19476536f2b5462eaa29e6f3029ee897c16dKristian Monsen     * </p>
95374bc19476536f2b5462eaa29e6f3029ee897c16dKristian Monsen     * <p>
95438e8b4e5bc3c93affdffbc064fd9db5aeccc3e8eSvetoslav Ganov     *   <strong>Note:</strong> Cannot be called from an
95538e8b4e5bc3c93affdffbc064fd9db5aeccc3e8eSvetoslav Ganov     *   {@link android.accessibilityservice.AccessibilityService}.
9568643aa0179e598e78d938c59035389054535a229Svetoslav Ganov     *   This class is made immutable before being delivered to an AccessibilityService.
9578643aa0179e598e78d938c59035389054535a229Svetoslav Ganov     * </p>
95838e8b4e5bc3c93affdffbc064fd9db5aeccc3e8eSvetoslav Ganov     *
9598643aa0179e598e78d938c59035389054535a229Svetoslav Ganov     * @param action The action.
9608643aa0179e598e78d938c59035389054535a229Svetoslav Ganov     *
9618643aa0179e598e78d938c59035389054535a229Svetoslav Ganov     * @throws IllegalStateException If called from an AccessibilityService.
9628643aa0179e598e78d938c59035389054535a229Svetoslav Ganov     */
96374bc19476536f2b5462eaa29e6f3029ee897c16dKristian Monsen    public void addAction(AccessibilityAction action) {
96474bc19476536f2b5462eaa29e6f3029ee897c16dKristian Monsen        enforceNotSealed();
96574bc19476536f2b5462eaa29e6f3029ee897c16dKristian Monsen
96674bc19476536f2b5462eaa29e6f3029ee897c16dKristian Monsen        if (action == null) {
96774bc19476536f2b5462eaa29e6f3029ee897c16dKristian Monsen            return;
96874bc19476536f2b5462eaa29e6f3029ee897c16dKristian Monsen        }
96974bc19476536f2b5462eaa29e6f3029ee897c16dKristian Monsen
97074bc19476536f2b5462eaa29e6f3029ee897c16dKristian Monsen        if (mActions == null) {
97174bc19476536f2b5462eaa29e6f3029ee897c16dKristian Monsen            mActions = new ArrayList<AccessibilityAction>();
97274bc19476536f2b5462eaa29e6f3029ee897c16dKristian Monsen        }
97374bc19476536f2b5462eaa29e6f3029ee897c16dKristian Monsen
97474bc19476536f2b5462eaa29e6f3029ee897c16dKristian Monsen        mActions.remove(action);
97574bc19476536f2b5462eaa29e6f3029ee897c16dKristian Monsen        mActions.add(action);
97674bc19476536f2b5462eaa29e6f3029ee897c16dKristian Monsen    }
97774bc19476536f2b5462eaa29e6f3029ee897c16dKristian Monsen
97874bc19476536f2b5462eaa29e6f3029ee897c16dKristian Monsen    /**
97974bc19476536f2b5462eaa29e6f3029ee897c16dKristian Monsen     * Adds an action that can be performed on the node.
98074bc19476536f2b5462eaa29e6f3029ee897c16dKristian Monsen     * <p>
98174bc19476536f2b5462eaa29e6f3029ee897c16dKristian Monsen     *   <strong>Note:</strong> Cannot be called from an
98274bc19476536f2b5462eaa29e6f3029ee897c16dKristian Monsen     *   {@link android.accessibilityservice.AccessibilityService}.
98374bc19476536f2b5462eaa29e6f3029ee897c16dKristian Monsen     *   This class is made immutable before being delivered to an AccessibilityService.
98474bc19476536f2b5462eaa29e6f3029ee897c16dKristian Monsen     * </p>
98574bc19476536f2b5462eaa29e6f3029ee897c16dKristian Monsen     *
98674bc19476536f2b5462eaa29e6f3029ee897c16dKristian Monsen     * @param action The action.
98774bc19476536f2b5462eaa29e6f3029ee897c16dKristian Monsen     *
98874bc19476536f2b5462eaa29e6f3029ee897c16dKristian Monsen     * @throws IllegalStateException If called from an AccessibilityService.
98974bc19476536f2b5462eaa29e6f3029ee897c16dKristian Monsen     * @throws IllegalArgumentException If the argument is not one of the standard actions.
99074bc19476536f2b5462eaa29e6f3029ee897c16dKristian Monsen     *
99174bc19476536f2b5462eaa29e6f3029ee897c16dKristian Monsen     * @deprecated This has been deprecated for {@link #addAction(AccessibilityAction)}
99274bc19476536f2b5462eaa29e6f3029ee897c16dKristian Monsen     */
99374bc19476536f2b5462eaa29e6f3029ee897c16dKristian Monsen    @Deprecated
9948643aa0179e598e78d938c59035389054535a229Svetoslav Ganov    public void addAction(int action) {
9958643aa0179e598e78d938c59035389054535a229Svetoslav Ganov        enforceNotSealed();
99674bc19476536f2b5462eaa29e6f3029ee897c16dKristian Monsen
9978d5f3fa6455c1eedb4f31bbaf075f2c1f9a2887aKristian Monsen        if ((action & ACTION_TYPE_MASK) != 0) {
9988d5f3fa6455c1eedb4f31bbaf075f2c1f9a2887aKristian Monsen            throw new IllegalArgumentException("Action is not a combination of the standard " +
9998d5f3fa6455c1eedb4f31bbaf075f2c1f9a2887aKristian Monsen                    "actions: " + action);
100074bc19476536f2b5462eaa29e6f3029ee897c16dKristian Monsen        }
100174bc19476536f2b5462eaa29e6f3029ee897c16dKristian Monsen
10028d5f3fa6455c1eedb4f31bbaf075f2c1f9a2887aKristian Monsen        addLegacyStandardActions(action);
10038643aa0179e598e78d938c59035389054535a229Svetoslav Ganov    }
10048643aa0179e598e78d938c59035389054535a229Svetoslav Ganov
10058643aa0179e598e78d938c59035389054535a229Svetoslav Ganov    /**
1006f0aed09ed8153043e40b3ac99788d47ba0831306Alan Viverette     * Removes an action that can be performed on the node. If the action was
1007f0aed09ed8153043e40b3ac99788d47ba0831306Alan Viverette     * not already added to the node, calling this method has no effect.
1008f0aed09ed8153043e40b3ac99788d47ba0831306Alan Viverette     * <p>
1009f0aed09ed8153043e40b3ac99788d47ba0831306Alan Viverette     *   <strong>Note:</strong> Cannot be called from an
1010f0aed09ed8153043e40b3ac99788d47ba0831306Alan Viverette     *   {@link android.accessibilityservice.AccessibilityService}.
1011f0aed09ed8153043e40b3ac99788d47ba0831306Alan Viverette     *   This class is made immutable before being delivered to an AccessibilityService.
1012f0aed09ed8153043e40b3ac99788d47ba0831306Alan Viverette     * </p>
1013f0aed09ed8153043e40b3ac99788d47ba0831306Alan Viverette     *
101474bc19476536f2b5462eaa29e6f3029ee897c16dKristian Monsen     * @param action The action to be removed.
1015f0aed09ed8153043e40b3ac99788d47ba0831306Alan Viverette     *
1016f0aed09ed8153043e40b3ac99788d47ba0831306Alan Viverette     * @throws IllegalStateException If called from an AccessibilityService.
101774bc19476536f2b5462eaa29e6f3029ee897c16dKristian Monsen     * @deprecated Use {@link #removeAction(AccessibilityAction)}
1018f0aed09ed8153043e40b3ac99788d47ba0831306Alan Viverette     */
101974bc19476536f2b5462eaa29e6f3029ee897c16dKristian Monsen    @Deprecated
1020f0aed09ed8153043e40b3ac99788d47ba0831306Alan Viverette    public void removeAction(int action) {
1021f0aed09ed8153043e40b3ac99788d47ba0831306Alan Viverette        enforceNotSealed();
102274bc19476536f2b5462eaa29e6f3029ee897c16dKristian Monsen
102374bc19476536f2b5462eaa29e6f3029ee897c16dKristian Monsen        removeAction(getActionSingleton(action));
102474bc19476536f2b5462eaa29e6f3029ee897c16dKristian Monsen    }
102574bc19476536f2b5462eaa29e6f3029ee897c16dKristian Monsen
102674bc19476536f2b5462eaa29e6f3029ee897c16dKristian Monsen    /**
102774bc19476536f2b5462eaa29e6f3029ee897c16dKristian Monsen     * Removes an action that can be performed on the node. If the action was
102874bc19476536f2b5462eaa29e6f3029ee897c16dKristian Monsen     * not already added to the node, calling this method has no effect.
102974bc19476536f2b5462eaa29e6f3029ee897c16dKristian Monsen     * <p>
103074bc19476536f2b5462eaa29e6f3029ee897c16dKristian Monsen     *   <strong>Note:</strong> Cannot be called from an
103174bc19476536f2b5462eaa29e6f3029ee897c16dKristian Monsen     *   {@link android.accessibilityservice.AccessibilityService}.
103274bc19476536f2b5462eaa29e6f3029ee897c16dKristian Monsen     *   This class is made immutable before being delivered to an AccessibilityService.
103374bc19476536f2b5462eaa29e6f3029ee897c16dKristian Monsen     * </p>
103474bc19476536f2b5462eaa29e6f3029ee897c16dKristian Monsen     *
103574bc19476536f2b5462eaa29e6f3029ee897c16dKristian Monsen     * @param action The action to be removed.
103674bc19476536f2b5462eaa29e6f3029ee897c16dKristian Monsen     * @return The action removed from the list of actions.
103774bc19476536f2b5462eaa29e6f3029ee897c16dKristian Monsen     *
103874bc19476536f2b5462eaa29e6f3029ee897c16dKristian Monsen     * @throws IllegalStateException If called from an AccessibilityService.
103974bc19476536f2b5462eaa29e6f3029ee897c16dKristian Monsen     */
104074bc19476536f2b5462eaa29e6f3029ee897c16dKristian Monsen    public boolean removeAction(AccessibilityAction action) {
104174bc19476536f2b5462eaa29e6f3029ee897c16dKristian Monsen        enforceNotSealed();
104274bc19476536f2b5462eaa29e6f3029ee897c16dKristian Monsen
104374bc19476536f2b5462eaa29e6f3029ee897c16dKristian Monsen        if (mActions == null || action == null) {
104474bc19476536f2b5462eaa29e6f3029ee897c16dKristian Monsen            return false;
104574bc19476536f2b5462eaa29e6f3029ee897c16dKristian Monsen        }
104674bc19476536f2b5462eaa29e6f3029ee897c16dKristian Monsen
104774bc19476536f2b5462eaa29e6f3029ee897c16dKristian Monsen        return mActions.remove(action);
1048f0aed09ed8153043e40b3ac99788d47ba0831306Alan Viverette    }
1049f0aed09ed8153043e40b3ac99788d47ba0831306Alan Viverette
1050f0aed09ed8153043e40b3ac99788d47ba0831306Alan Viverette    /**
10516c70290ff0b20329c8f173d5c3423eb83ddc46f1Svetoslav     * Gets the node before which this one is visited during traversal. A screen-reader
10526c70290ff0b20329c8f173d5c3423eb83ddc46f1Svetoslav     * must visit the content of this node before the content of the one it precedes.
10536c70290ff0b20329c8f173d5c3423eb83ddc46f1Svetoslav     *
10546c70290ff0b20329c8f173d5c3423eb83ddc46f1Svetoslav     * @return The succeeding node if such or <code>null</code>.
10556c70290ff0b20329c8f173d5c3423eb83ddc46f1Svetoslav     *
10566c70290ff0b20329c8f173d5c3423eb83ddc46f1Svetoslav     * @see #setTraversalBefore(android.view.View)
10576c70290ff0b20329c8f173d5c3423eb83ddc46f1Svetoslav     * @see #setTraversalBefore(android.view.View, int)
10586c70290ff0b20329c8f173d5c3423eb83ddc46f1Svetoslav     */
10596c70290ff0b20329c8f173d5c3423eb83ddc46f1Svetoslav    public AccessibilityNodeInfo getTraversalBefore() {
10606c70290ff0b20329c8f173d5c3423eb83ddc46f1Svetoslav        enforceSealed();
10616c70290ff0b20329c8f173d5c3423eb83ddc46f1Svetoslav        return getNodeForAccessibilityId(mTraversalBefore);
10626c70290ff0b20329c8f173d5c3423eb83ddc46f1Svetoslav    }
10636c70290ff0b20329c8f173d5c3423eb83ddc46f1Svetoslav
10646c70290ff0b20329c8f173d5c3423eb83ddc46f1Svetoslav    /**
10656c70290ff0b20329c8f173d5c3423eb83ddc46f1Svetoslav     * Sets the view before whose node this one should be visited during traversal. A
10666c70290ff0b20329c8f173d5c3423eb83ddc46f1Svetoslav     * screen-reader must visit the content of this node before the content of the one
10676c70290ff0b20329c8f173d5c3423eb83ddc46f1Svetoslav     * it precedes.
10686c70290ff0b20329c8f173d5c3423eb83ddc46f1Svetoslav     * <p>
10696c70290ff0b20329c8f173d5c3423eb83ddc46f1Svetoslav     *   <strong>Note:</strong> Cannot be called from an
10706c70290ff0b20329c8f173d5c3423eb83ddc46f1Svetoslav     *   {@link android.accessibilityservice.AccessibilityService}.
10716c70290ff0b20329c8f173d5c3423eb83ddc46f1Svetoslav     *   This class is made immutable before being delivered to an AccessibilityService.
10726c70290ff0b20329c8f173d5c3423eb83ddc46f1Svetoslav     * </p>
10736c70290ff0b20329c8f173d5c3423eb83ddc46f1Svetoslav     *
10746c70290ff0b20329c8f173d5c3423eb83ddc46f1Svetoslav     * @param view The view providing the preceding node.
10756c70290ff0b20329c8f173d5c3423eb83ddc46f1Svetoslav     *
10766c70290ff0b20329c8f173d5c3423eb83ddc46f1Svetoslav     * @see #getTraversalBefore()
10776c70290ff0b20329c8f173d5c3423eb83ddc46f1Svetoslav     */
10786c70290ff0b20329c8f173d5c3423eb83ddc46f1Svetoslav    public void setTraversalBefore(View view) {
10796c70290ff0b20329c8f173d5c3423eb83ddc46f1Svetoslav        setTraversalBefore(view, UNDEFINED_ITEM_ID);
10806c70290ff0b20329c8f173d5c3423eb83ddc46f1Svetoslav    }
10816c70290ff0b20329c8f173d5c3423eb83ddc46f1Svetoslav
10826c70290ff0b20329c8f173d5c3423eb83ddc46f1Svetoslav    /**
10836c70290ff0b20329c8f173d5c3423eb83ddc46f1Svetoslav     * Sets the node before which this one is visited during traversal. A screen-reader
10846c70290ff0b20329c8f173d5c3423eb83ddc46f1Svetoslav     * must visit the content of this node before the content of the one it precedes.
10856c70290ff0b20329c8f173d5c3423eb83ddc46f1Svetoslav     * The successor is a virtual descendant of the given <code>root</code>. If
10866c70290ff0b20329c8f173d5c3423eb83ddc46f1Svetoslav     * <code>virtualDescendantId</code> equals to {@link View#NO_ID} the root is set
10876c70290ff0b20329c8f173d5c3423eb83ddc46f1Svetoslav     * as the successor.
10886c70290ff0b20329c8f173d5c3423eb83ddc46f1Svetoslav     * <p>
10896c70290ff0b20329c8f173d5c3423eb83ddc46f1Svetoslav     * A virtual descendant is an imaginary View that is reported as a part of the view
10906c70290ff0b20329c8f173d5c3423eb83ddc46f1Svetoslav     * hierarchy for accessibility purposes. This enables custom views that draw complex
10916c70290ff0b20329c8f173d5c3423eb83ddc46f1Svetoslav     * content to report them selves as a tree of virtual views, thus conveying their
10926c70290ff0b20329c8f173d5c3423eb83ddc46f1Svetoslav     * logical structure.
10936c70290ff0b20329c8f173d5c3423eb83ddc46f1Svetoslav     * </p>
10946c70290ff0b20329c8f173d5c3423eb83ddc46f1Svetoslav     * <p>
10956c70290ff0b20329c8f173d5c3423eb83ddc46f1Svetoslav     *   <strong>Note:</strong> Cannot be called from an
10966c70290ff0b20329c8f173d5c3423eb83ddc46f1Svetoslav     *   {@link android.accessibilityservice.AccessibilityService}.
10976c70290ff0b20329c8f173d5c3423eb83ddc46f1Svetoslav     *   This class is made immutable before being delivered to an AccessibilityService.
10986c70290ff0b20329c8f173d5c3423eb83ddc46f1Svetoslav     * </p>
10996c70290ff0b20329c8f173d5c3423eb83ddc46f1Svetoslav     *
11006c70290ff0b20329c8f173d5c3423eb83ddc46f1Svetoslav     * @param root The root of the virtual subtree.
11016c70290ff0b20329c8f173d5c3423eb83ddc46f1Svetoslav     * @param virtualDescendantId The id of the virtual descendant.
11026c70290ff0b20329c8f173d5c3423eb83ddc46f1Svetoslav     */
11036c70290ff0b20329c8f173d5c3423eb83ddc46f1Svetoslav    public void setTraversalBefore(View root, int virtualDescendantId) {
11046c70290ff0b20329c8f173d5c3423eb83ddc46f1Svetoslav        enforceNotSealed();
11056c70290ff0b20329c8f173d5c3423eb83ddc46f1Svetoslav        final int rootAccessibilityViewId = (root != null)
11066c70290ff0b20329c8f173d5c3423eb83ddc46f1Svetoslav                ? root.getAccessibilityViewId() : UNDEFINED_ITEM_ID;
11076c70290ff0b20329c8f173d5c3423eb83ddc46f1Svetoslav        mTraversalBefore = makeNodeId(rootAccessibilityViewId, virtualDescendantId);
11086c70290ff0b20329c8f173d5c3423eb83ddc46f1Svetoslav    }
11096c70290ff0b20329c8f173d5c3423eb83ddc46f1Svetoslav
11106c70290ff0b20329c8f173d5c3423eb83ddc46f1Svetoslav    /**
11116c70290ff0b20329c8f173d5c3423eb83ddc46f1Svetoslav     * Gets the node after which this one is visited in accessibility traversal.
11126c70290ff0b20329c8f173d5c3423eb83ddc46f1Svetoslav     * A screen-reader must visit the content of the other node before the content
11136c70290ff0b20329c8f173d5c3423eb83ddc46f1Svetoslav     * of this one.
11146c70290ff0b20329c8f173d5c3423eb83ddc46f1Svetoslav     *
11156c70290ff0b20329c8f173d5c3423eb83ddc46f1Svetoslav     * @return The succeeding node if such or <code>null</code>.
11166c70290ff0b20329c8f173d5c3423eb83ddc46f1Svetoslav     *
11176c70290ff0b20329c8f173d5c3423eb83ddc46f1Svetoslav     * @see #setTraversalAfter(android.view.View)
11186c70290ff0b20329c8f173d5c3423eb83ddc46f1Svetoslav     * @see #setTraversalAfter(android.view.View, int)
11196c70290ff0b20329c8f173d5c3423eb83ddc46f1Svetoslav     */
11206c70290ff0b20329c8f173d5c3423eb83ddc46f1Svetoslav    public AccessibilityNodeInfo getTraversalAfter() {
11216c70290ff0b20329c8f173d5c3423eb83ddc46f1Svetoslav        enforceSealed();
11226c70290ff0b20329c8f173d5c3423eb83ddc46f1Svetoslav        return getNodeForAccessibilityId(mTraversalAfter);
11236c70290ff0b20329c8f173d5c3423eb83ddc46f1Svetoslav    }
11246c70290ff0b20329c8f173d5c3423eb83ddc46f1Svetoslav
11256c70290ff0b20329c8f173d5c3423eb83ddc46f1Svetoslav    /**
11266c70290ff0b20329c8f173d5c3423eb83ddc46f1Svetoslav     * Sets the view whose node is visited after this one in accessibility traversal.
11276c70290ff0b20329c8f173d5c3423eb83ddc46f1Svetoslav     * A screen-reader must visit the content of the other node before the content
11286c70290ff0b20329c8f173d5c3423eb83ddc46f1Svetoslav     * of this one.
11296c70290ff0b20329c8f173d5c3423eb83ddc46f1Svetoslav     * <p>
11306c70290ff0b20329c8f173d5c3423eb83ddc46f1Svetoslav     *   <strong>Note:</strong> Cannot be called from an
11316c70290ff0b20329c8f173d5c3423eb83ddc46f1Svetoslav     *   {@link android.accessibilityservice.AccessibilityService}.
11326c70290ff0b20329c8f173d5c3423eb83ddc46f1Svetoslav     *   This class is made immutable before being delivered to an AccessibilityService.
11336c70290ff0b20329c8f173d5c3423eb83ddc46f1Svetoslav     * </p>
11346c70290ff0b20329c8f173d5c3423eb83ddc46f1Svetoslav     *
11356c70290ff0b20329c8f173d5c3423eb83ddc46f1Svetoslav     * @param view The previous view.
11366c70290ff0b20329c8f173d5c3423eb83ddc46f1Svetoslav     *
11376c70290ff0b20329c8f173d5c3423eb83ddc46f1Svetoslav     * @see #getTraversalAfter()
11386c70290ff0b20329c8f173d5c3423eb83ddc46f1Svetoslav     */
11396c70290ff0b20329c8f173d5c3423eb83ddc46f1Svetoslav    public void setTraversalAfter(View view) {
11406c70290ff0b20329c8f173d5c3423eb83ddc46f1Svetoslav        setTraversalAfter(view, UNDEFINED_ITEM_ID);
11416c70290ff0b20329c8f173d5c3423eb83ddc46f1Svetoslav    }
11426c70290ff0b20329c8f173d5c3423eb83ddc46f1Svetoslav
11436c70290ff0b20329c8f173d5c3423eb83ddc46f1Svetoslav    /**
11446c70290ff0b20329c8f173d5c3423eb83ddc46f1Svetoslav     * Sets the node after which this one is visited in accessibility traversal.
11456c70290ff0b20329c8f173d5c3423eb83ddc46f1Svetoslav     * A screen-reader must visit the content of the other node before the content
11466c70290ff0b20329c8f173d5c3423eb83ddc46f1Svetoslav     * of this one. If <code>virtualDescendantId</code> equals to {@link View#NO_ID}
11476c70290ff0b20329c8f173d5c3423eb83ddc46f1Svetoslav     * the root is set as the predecessor.
11486c70290ff0b20329c8f173d5c3423eb83ddc46f1Svetoslav     * <p>
11496c70290ff0b20329c8f173d5c3423eb83ddc46f1Svetoslav     * A virtual descendant is an imaginary View that is reported as a part of the view
11506c70290ff0b20329c8f173d5c3423eb83ddc46f1Svetoslav     * hierarchy for accessibility purposes. This enables custom views that draw complex
11516c70290ff0b20329c8f173d5c3423eb83ddc46f1Svetoslav     * content to report them selves as a tree of virtual views, thus conveying their
11526c70290ff0b20329c8f173d5c3423eb83ddc46f1Svetoslav     * logical structure.
11536c70290ff0b20329c8f173d5c3423eb83ddc46f1Svetoslav     * </p>
11546c70290ff0b20329c8f173d5c3423eb83ddc46f1Svetoslav     * <p>
11556c70290ff0b20329c8f173d5c3423eb83ddc46f1Svetoslav     *   <strong>Note:</strong> Cannot be called from an
11566c70290ff0b20329c8f173d5c3423eb83ddc46f1Svetoslav     *   {@link android.accessibilityservice.AccessibilityService}.
11576c70290ff0b20329c8f173d5c3423eb83ddc46f1Svetoslav     *   This class is made immutable before being delivered to an AccessibilityService.
11586c70290ff0b20329c8f173d5c3423eb83ddc46f1Svetoslav     * </p>
11596c70290ff0b20329c8f173d5c3423eb83ddc46f1Svetoslav     *
11606c70290ff0b20329c8f173d5c3423eb83ddc46f1Svetoslav     * @param root The root of the virtual subtree.
11616c70290ff0b20329c8f173d5c3423eb83ddc46f1Svetoslav     * @param virtualDescendantId The id of the virtual descendant.
11626c70290ff0b20329c8f173d5c3423eb83ddc46f1Svetoslav     */
11636c70290ff0b20329c8f173d5c3423eb83ddc46f1Svetoslav    public void setTraversalAfter(View root, int virtualDescendantId) {
11646c70290ff0b20329c8f173d5c3423eb83ddc46f1Svetoslav        enforceNotSealed();
11656c70290ff0b20329c8f173d5c3423eb83ddc46f1Svetoslav        final int rootAccessibilityViewId = (root != null)
11666c70290ff0b20329c8f173d5c3423eb83ddc46f1Svetoslav                ? root.getAccessibilityViewId() : UNDEFINED_ITEM_ID;
11676c70290ff0b20329c8f173d5c3423eb83ddc46f1Svetoslav        mTraversalAfter = makeNodeId(rootAccessibilityViewId, virtualDescendantId);
11686c70290ff0b20329c8f173d5c3423eb83ddc46f1Svetoslav    }
11696c70290ff0b20329c8f173d5c3423eb83ddc46f1Svetoslav
11706c70290ff0b20329c8f173d5c3423eb83ddc46f1Svetoslav    /**
1171029942f77d05ed3d20256403652b220c83dad6e1Alan Viverette     * Sets the maximum text length, or -1 for no limit.
1172029942f77d05ed3d20256403652b220c83dad6e1Alan Viverette     * <p>
1173029942f77d05ed3d20256403652b220c83dad6e1Alan Viverette     * Typically used to indicate that an editable text field has a limit on
1174029942f77d05ed3d20256403652b220c83dad6e1Alan Viverette     * the number of characters entered.
1175029942f77d05ed3d20256403652b220c83dad6e1Alan Viverette     * <p>
1176029942f77d05ed3d20256403652b220c83dad6e1Alan Viverette     * <strong>Note:</strong> Cannot be called from an
1177029942f77d05ed3d20256403652b220c83dad6e1Alan Viverette     * {@link android.accessibilityservice.AccessibilityService}.
1178029942f77d05ed3d20256403652b220c83dad6e1Alan Viverette     * This class is made immutable before being delivered to an AccessibilityService.
1179029942f77d05ed3d20256403652b220c83dad6e1Alan Viverette     *
1180029942f77d05ed3d20256403652b220c83dad6e1Alan Viverette     * @param max The maximum text length.
1181029942f77d05ed3d20256403652b220c83dad6e1Alan Viverette     * @see #getMaxTextLength()
1182029942f77d05ed3d20256403652b220c83dad6e1Alan Viverette     *
1183029942f77d05ed3d20256403652b220c83dad6e1Alan Viverette     * @throws IllegalStateException If called from an AccessibilityService.
1184029942f77d05ed3d20256403652b220c83dad6e1Alan Viverette     */
1185029942f77d05ed3d20256403652b220c83dad6e1Alan Viverette    public void setMaxTextLength(int max) {
1186029942f77d05ed3d20256403652b220c83dad6e1Alan Viverette        enforceNotSealed();
1187029942f77d05ed3d20256403652b220c83dad6e1Alan Viverette        mMaxTextLength = max;
1188029942f77d05ed3d20256403652b220c83dad6e1Alan Viverette    }
1189029942f77d05ed3d20256403652b220c83dad6e1Alan Viverette
1190029942f77d05ed3d20256403652b220c83dad6e1Alan Viverette    /**
1191029942f77d05ed3d20256403652b220c83dad6e1Alan Viverette     * Returns the maximum text length for this node.
1192029942f77d05ed3d20256403652b220c83dad6e1Alan Viverette     *
1193029942f77d05ed3d20256403652b220c83dad6e1Alan Viverette     * @return The maximum text length, or -1 for no limit.
1194029942f77d05ed3d20256403652b220c83dad6e1Alan Viverette     * @see #setMaxTextLength(int)
1195029942f77d05ed3d20256403652b220c83dad6e1Alan Viverette     */
1196029942f77d05ed3d20256403652b220c83dad6e1Alan Viverette    public int getMaxTextLength() {
1197029942f77d05ed3d20256403652b220c83dad6e1Alan Viverette        return mMaxTextLength;
1198029942f77d05ed3d20256403652b220c83dad6e1Alan Viverette    }
1199029942f77d05ed3d20256403652b220c83dad6e1Alan Viverette
1200029942f77d05ed3d20256403652b220c83dad6e1Alan Viverette    /**
12012b435aada3d274a9c08d334946fff1ab9ba15b48Svetoslav Ganov     * Sets the movement granularities for traversing the text of this node.
1202aa780c110922148a6a4ba06734bb2b0bb8c98f93Svetoslav Ganov     * <p>
1203aa780c110922148a6a4ba06734bb2b0bb8c98f93Svetoslav Ganov     *   <strong>Note:</strong> Cannot be called from an
1204aa780c110922148a6a4ba06734bb2b0bb8c98f93Svetoslav Ganov     *   {@link android.accessibilityservice.AccessibilityService}.
1205aa780c110922148a6a4ba06734bb2b0bb8c98f93Svetoslav Ganov     *   This class is made immutable before being delivered to an AccessibilityService.
1206aa780c110922148a6a4ba06734bb2b0bb8c98f93Svetoslav Ganov     * </p>
1207aa780c110922148a6a4ba06734bb2b0bb8c98f93Svetoslav Ganov     *
1208b7ff3255c6d4e12f9d2334e3bbec0a125b7b09dcSvetoslav Ganov     * @param granularities The bit mask with granularities.
1209aa780c110922148a6a4ba06734bb2b0bb8c98f93Svetoslav Ganov     *
1210aa780c110922148a6a4ba06734bb2b0bb8c98f93Svetoslav Ganov     * @throws IllegalStateException If called from an AccessibilityService.
1211aa780c110922148a6a4ba06734bb2b0bb8c98f93Svetoslav Ganov     */
12122b435aada3d274a9c08d334946fff1ab9ba15b48Svetoslav Ganov    public void setMovementGranularities(int granularities) {
1213aa780c110922148a6a4ba06734bb2b0bb8c98f93Svetoslav Ganov        enforceNotSealed();
12142b435aada3d274a9c08d334946fff1ab9ba15b48Svetoslav Ganov        mMovementGranularities = granularities;
1215aa780c110922148a6a4ba06734bb2b0bb8c98f93Svetoslav Ganov    }
1216aa780c110922148a6a4ba06734bb2b0bb8c98f93Svetoslav Ganov
1217aa780c110922148a6a4ba06734bb2b0bb8c98f93Svetoslav Ganov    /**
12182b435aada3d274a9c08d334946fff1ab9ba15b48Svetoslav Ganov     * Gets the movement granularities for traversing the text of this node.
1219aa780c110922148a6a4ba06734bb2b0bb8c98f93Svetoslav Ganov     *
1220b7ff3255c6d4e12f9d2334e3bbec0a125b7b09dcSvetoslav Ganov     * @return The bit mask with granularities.
1221aa780c110922148a6a4ba06734bb2b0bb8c98f93Svetoslav Ganov     */
12222b435aada3d274a9c08d334946fff1ab9ba15b48Svetoslav Ganov    public int getMovementGranularities() {
12232b435aada3d274a9c08d334946fff1ab9ba15b48Svetoslav Ganov        return mMovementGranularities;
1224aa780c110922148a6a4ba06734bb2b0bb8c98f93Svetoslav Ganov    }
1225aa780c110922148a6a4ba06734bb2b0bb8c98f93Svetoslav Ganov
1226aa780c110922148a6a4ba06734bb2b0bb8c98f93Svetoslav Ganov    /**
12278643aa0179e598e78d938c59035389054535a229Svetoslav Ganov     * Performs an action on the node.
12288643aa0179e598e78d938c59035389054535a229Svetoslav Ganov     * <p>
122938e8b4e5bc3c93affdffbc064fd9db5aeccc3e8eSvetoslav Ganov     *   <strong>Note:</strong> An action can be performed only if the request is made
12308643aa0179e598e78d938c59035389054535a229Svetoslav Ganov     *   from an {@link android.accessibilityservice.AccessibilityService}.
12318643aa0179e598e78d938c59035389054535a229Svetoslav Ganov     * </p>
123238e8b4e5bc3c93affdffbc064fd9db5aeccc3e8eSvetoslav Ganov     *
12338643aa0179e598e78d938c59035389054535a229Svetoslav Ganov     * @param action The action to perform.
12348643aa0179e598e78d938c59035389054535a229Svetoslav Ganov     * @return True if the action was performed.
12358643aa0179e598e78d938c59035389054535a229Svetoslav Ganov     *
12368643aa0179e598e78d938c59035389054535a229Svetoslav Ganov     * @throws IllegalStateException If called outside of an AccessibilityService.
12378643aa0179e598e78d938c59035389054535a229Svetoslav Ganov     */
12388643aa0179e598e78d938c59035389054535a229Svetoslav Ganov    public boolean performAction(int action) {
12398643aa0179e598e78d938c59035389054535a229Svetoslav Ganov        enforceSealed();
1240021078554b902179442a345a9d080a165c3b5139Svetoslav Ganov        if (!canPerformRequestOverConnection(mSourceNodeId)) {
1241eeee4d2c01d3c4ed99e4891dbc75c7de69a803faSvetoslav Ganov            return false;
1242eeee4d2c01d3c4ed99e4891dbc75c7de69a803faSvetoslav Ganov        }
12438bd69610aafc6995126965d1d23b771fe02a9084Svetoslav Ganov        AccessibilityInteractionClient client = AccessibilityInteractionClient.getInstance();
1244aa780c110922148a6a4ba06734bb2b0bb8c98f93Svetoslav Ganov        return client.performAccessibilityAction(mConnectionId, mWindowId, mSourceNodeId,
1245aa780c110922148a6a4ba06734bb2b0bb8c98f93Svetoslav Ganov                action, null);
1246aa780c110922148a6a4ba06734bb2b0bb8c98f93Svetoslav Ganov    }
1247aa780c110922148a6a4ba06734bb2b0bb8c98f93Svetoslav Ganov
1248aa780c110922148a6a4ba06734bb2b0bb8c98f93Svetoslav Ganov    /**
1249aa780c110922148a6a4ba06734bb2b0bb8c98f93Svetoslav Ganov     * Performs an action on the node.
1250aa780c110922148a6a4ba06734bb2b0bb8c98f93Svetoslav Ganov     * <p>
1251aa780c110922148a6a4ba06734bb2b0bb8c98f93Svetoslav Ganov     *   <strong>Note:</strong> An action can be performed only if the request is made
1252aa780c110922148a6a4ba06734bb2b0bb8c98f93Svetoslav Ganov     *   from an {@link android.accessibilityservice.AccessibilityService}.
1253aa780c110922148a6a4ba06734bb2b0bb8c98f93Svetoslav Ganov     * </p>
1254aa780c110922148a6a4ba06734bb2b0bb8c98f93Svetoslav Ganov     *
1255aa780c110922148a6a4ba06734bb2b0bb8c98f93Svetoslav Ganov     * @param action The action to perform.
1256aa780c110922148a6a4ba06734bb2b0bb8c98f93Svetoslav Ganov     * @param arguments A bundle with additional arguments.
1257aa780c110922148a6a4ba06734bb2b0bb8c98f93Svetoslav Ganov     * @return True if the action was performed.
1258aa780c110922148a6a4ba06734bb2b0bb8c98f93Svetoslav Ganov     *
1259aa780c110922148a6a4ba06734bb2b0bb8c98f93Svetoslav Ganov     * @throws IllegalStateException If called outside of an AccessibilityService.
1260aa780c110922148a6a4ba06734bb2b0bb8c98f93Svetoslav Ganov     */
1261aa780c110922148a6a4ba06734bb2b0bb8c98f93Svetoslav Ganov    public boolean performAction(int action, Bundle arguments) {
1262aa780c110922148a6a4ba06734bb2b0bb8c98f93Svetoslav Ganov        enforceSealed();
1263aa780c110922148a6a4ba06734bb2b0bb8c98f93Svetoslav Ganov        if (!canPerformRequestOverConnection(mSourceNodeId)) {
1264aa780c110922148a6a4ba06734bb2b0bb8c98f93Svetoslav Ganov            return false;
1265aa780c110922148a6a4ba06734bb2b0bb8c98f93Svetoslav Ganov        }
1266aa780c110922148a6a4ba06734bb2b0bb8c98f93Svetoslav Ganov        AccessibilityInteractionClient client = AccessibilityInteractionClient.getInstance();
1267aa780c110922148a6a4ba06734bb2b0bb8c98f93Svetoslav Ganov        return client.performAccessibilityAction(mConnectionId, mWindowId, mSourceNodeId,
1268aa780c110922148a6a4ba06734bb2b0bb8c98f93Svetoslav Ganov                action, arguments);
1269eeee4d2c01d3c4ed99e4891dbc75c7de69a803faSvetoslav Ganov    }
1270eeee4d2c01d3c4ed99e4891dbc75c7de69a803faSvetoslav Ganov
1271eeee4d2c01d3c4ed99e4891dbc75c7de69a803faSvetoslav Ganov    /**
1272eeee4d2c01d3c4ed99e4891dbc75c7de69a803faSvetoslav Ganov     * Finds {@link AccessibilityNodeInfo}s by text. The match is case
127386398bda3dd869c67faa841a5d961316b5f4aa8aSvetoslav Ganov     * insensitive containment. The search is relative to this info i.e.
127486398bda3dd869c67faa841a5d961316b5f4aa8aSvetoslav Ganov     * this info is the root of the traversed tree.
1275ea515aeafa01de6f50c854ee381b972ef2478284Svetoslav Ganov     *
127638e8b4e5bc3c93affdffbc064fd9db5aeccc3e8eSvetoslav Ganov     * <p>
127738e8b4e5bc3c93affdffbc064fd9db5aeccc3e8eSvetoslav Ganov     *   <strong>Note:</strong> It is a client responsibility to recycle the
127838e8b4e5bc3c93affdffbc064fd9db5aeccc3e8eSvetoslav Ganov     *     received info by calling {@link AccessibilityNodeInfo#recycle()}
127938e8b4e5bc3c93affdffbc064fd9db5aeccc3e8eSvetoslav Ganov     *     to avoid creating of multiple instances.
128038e8b4e5bc3c93affdffbc064fd9db5aeccc3e8eSvetoslav Ganov     * </p>
1281eeee4d2c01d3c4ed99e4891dbc75c7de69a803faSvetoslav Ganov     *
1282eeee4d2c01d3c4ed99e4891dbc75c7de69a803faSvetoslav Ganov     * @param text The searched text.
1283eeee4d2c01d3c4ed99e4891dbc75c7de69a803faSvetoslav Ganov     * @return A list of node info.
1284eeee4d2c01d3c4ed99e4891dbc75c7de69a803faSvetoslav Ganov     */
1285eeee4d2c01d3c4ed99e4891dbc75c7de69a803faSvetoslav Ganov    public List<AccessibilityNodeInfo> findAccessibilityNodeInfosByText(String text) {
1286eeee4d2c01d3c4ed99e4891dbc75c7de69a803faSvetoslav Ganov        enforceSealed();
1287021078554b902179442a345a9d080a165c3b5139Svetoslav Ganov        if (!canPerformRequestOverConnection(mSourceNodeId)) {
128886398bda3dd869c67faa841a5d961316b5f4aa8aSvetoslav Ganov            return Collections.emptyList();
1289eeee4d2c01d3c4ed99e4891dbc75c7de69a803faSvetoslav Ganov        }
12908bd69610aafc6995126965d1d23b771fe02a9084Svetoslav Ganov        AccessibilityInteractionClient client = AccessibilityInteractionClient.getInstance();
129179311c4af8b54d3cd47ab37a120c648bfc990511Svetoslav Ganov        return client.findAccessibilityNodeInfosByText(mConnectionId, mWindowId, mSourceNodeId,
129279311c4af8b54d3cd47ab37a120c648bfc990511Svetoslav Ganov                text);
12938643aa0179e598e78d938c59035389054535a229Svetoslav Ganov    }
12948643aa0179e598e78d938c59035389054535a229Svetoslav Ganov
12958643aa0179e598e78d938c59035389054535a229Svetoslav Ganov    /**
129680943d8daa6ab31ab5c486d57aea406aa0730d58Svetoslav Ganov     * Finds {@link AccessibilityNodeInfo}s by the fully qualified view id's resource
129780943d8daa6ab31ab5c486d57aea406aa0730d58Svetoslav Ganov     * name where a fully qualified id is of the from "package:id/id_resource_name".
129880943d8daa6ab31ab5c486d57aea406aa0730d58Svetoslav Ganov     * For example, if the target application's package is "foo.bar" and the id
129980943d8daa6ab31ab5c486d57aea406aa0730d58Svetoslav Ganov     * resource name is "baz", the fully qualified resource id is "foo.bar:id/baz".
130080943d8daa6ab31ab5c486d57aea406aa0730d58Svetoslav Ganov     *
130180943d8daa6ab31ab5c486d57aea406aa0730d58Svetoslav Ganov     * <p>
130280943d8daa6ab31ab5c486d57aea406aa0730d58Svetoslav Ganov     *   <strong>Note:</strong> It is a client responsibility to recycle the
130380943d8daa6ab31ab5c486d57aea406aa0730d58Svetoslav Ganov     *     received info by calling {@link AccessibilityNodeInfo#recycle()}
130480943d8daa6ab31ab5c486d57aea406aa0730d58Svetoslav Ganov     *     to avoid creating of multiple instances.
130580943d8daa6ab31ab5c486d57aea406aa0730d58Svetoslav Ganov     * </p>
130680943d8daa6ab31ab5c486d57aea406aa0730d58Svetoslav Ganov     * <p>
130780943d8daa6ab31ab5c486d57aea406aa0730d58Svetoslav Ganov     *   <strong>Note:</strong> The primary usage of this API is for UI test automation
130880943d8daa6ab31ab5c486d57aea406aa0730d58Svetoslav Ganov     *   and in order to report the fully qualified view id if an {@link AccessibilityNodeInfo}
130980943d8daa6ab31ab5c486d57aea406aa0730d58Svetoslav Ganov     *   the client has to set the {@link AccessibilityServiceInfo#FLAG_REPORT_VIEW_IDS}
131014ff996ce82734100ba3faedbc80c4783eebea9dSvetoslav     *   flag when configuring his {@link android.accessibilityservice.AccessibilityService}.
131180943d8daa6ab31ab5c486d57aea406aa0730d58Svetoslav Ganov     * </p>
131280943d8daa6ab31ab5c486d57aea406aa0730d58Svetoslav Ganov     *
131380943d8daa6ab31ab5c486d57aea406aa0730d58Svetoslav Ganov     * @param viewId The fully qualified resource name of the view id to find.
131480943d8daa6ab31ab5c486d57aea406aa0730d58Svetoslav Ganov     * @return A list of node info.
131580943d8daa6ab31ab5c486d57aea406aa0730d58Svetoslav Ganov     */
131680943d8daa6ab31ab5c486d57aea406aa0730d58Svetoslav Ganov    public List<AccessibilityNodeInfo> findAccessibilityNodeInfosByViewId(String viewId) {
131780943d8daa6ab31ab5c486d57aea406aa0730d58Svetoslav Ganov        enforceSealed();
131880943d8daa6ab31ab5c486d57aea406aa0730d58Svetoslav Ganov        if (!canPerformRequestOverConnection(mSourceNodeId)) {
131980943d8daa6ab31ab5c486d57aea406aa0730d58Svetoslav Ganov            return Collections.emptyList();
132080943d8daa6ab31ab5c486d57aea406aa0730d58Svetoslav Ganov        }
132180943d8daa6ab31ab5c486d57aea406aa0730d58Svetoslav Ganov        AccessibilityInteractionClient client = AccessibilityInteractionClient.getInstance();
132280943d8daa6ab31ab5c486d57aea406aa0730d58Svetoslav Ganov        return client.findAccessibilityNodeInfosByViewId(mConnectionId, mWindowId, mSourceNodeId,
132380943d8daa6ab31ab5c486d57aea406aa0730d58Svetoslav Ganov                viewId);
132480943d8daa6ab31ab5c486d57aea406aa0730d58Svetoslav Ganov    }
132580943d8daa6ab31ab5c486d57aea406aa0730d58Svetoslav Ganov
132680943d8daa6ab31ab5c486d57aea406aa0730d58Svetoslav Ganov    /**
13278e3feb15c5aec2c72b0ef120a1da325e1e8f0ddaSvetoslav     * Gets the window to which this node belongs.
13288e3feb15c5aec2c72b0ef120a1da325e1e8f0ddaSvetoslav     *
13298e3feb15c5aec2c72b0ef120a1da325e1e8f0ddaSvetoslav     * @return The window.
13308e3feb15c5aec2c72b0ef120a1da325e1e8f0ddaSvetoslav     *
13318e3feb15c5aec2c72b0ef120a1da325e1e8f0ddaSvetoslav     * @see android.accessibilityservice.AccessibilityService#getWindows()
13328e3feb15c5aec2c72b0ef120a1da325e1e8f0ddaSvetoslav     */
13338e3feb15c5aec2c72b0ef120a1da325e1e8f0ddaSvetoslav    public AccessibilityWindowInfo getWindow() {
13348e3feb15c5aec2c72b0ef120a1da325e1e8f0ddaSvetoslav        enforceSealed();
13358e3feb15c5aec2c72b0ef120a1da325e1e8f0ddaSvetoslav        if (!canPerformRequestOverConnection(mSourceNodeId)) {
13368e3feb15c5aec2c72b0ef120a1da325e1e8f0ddaSvetoslav            return null;
13378e3feb15c5aec2c72b0ef120a1da325e1e8f0ddaSvetoslav        }
13388e3feb15c5aec2c72b0ef120a1da325e1e8f0ddaSvetoslav        AccessibilityInteractionClient client = AccessibilityInteractionClient.getInstance();
13398e3feb15c5aec2c72b0ef120a1da325e1e8f0ddaSvetoslav        return client.getWindow(mConnectionId, mWindowId);
13408e3feb15c5aec2c72b0ef120a1da325e1e8f0ddaSvetoslav    }
13418e3feb15c5aec2c72b0ef120a1da325e1e8f0ddaSvetoslav
13428e3feb15c5aec2c72b0ef120a1da325e1e8f0ddaSvetoslav    /**
134300aabf7d187bc05408199bd687a538b2e68bdc17Svetoslav Ganov     * Gets the parent.
13448643aa0179e598e78d938c59035389054535a229Svetoslav Ganov     * <p>
134538e8b4e5bc3c93affdffbc064fd9db5aeccc3e8eSvetoslav Ganov     *   <strong>Note:</strong> It is a client responsibility to recycle the
134638e8b4e5bc3c93affdffbc064fd9db5aeccc3e8eSvetoslav Ganov     *     received info by calling {@link AccessibilityNodeInfo#recycle()}
134738e8b4e5bc3c93affdffbc064fd9db5aeccc3e8eSvetoslav Ganov     *     to avoid creating of multiple instances.
13488643aa0179e598e78d938c59035389054535a229Svetoslav Ganov     * </p>
134938e8b4e5bc3c93affdffbc064fd9db5aeccc3e8eSvetoslav Ganov     *
135000aabf7d187bc05408199bd687a538b2e68bdc17Svetoslav Ganov     * @return The parent.
13518643aa0179e598e78d938c59035389054535a229Svetoslav Ganov     */
13528643aa0179e598e78d938c59035389054535a229Svetoslav Ganov    public AccessibilityNodeInfo getParent() {
13538643aa0179e598e78d938c59035389054535a229Svetoslav Ganov        enforceSealed();
13546c70290ff0b20329c8f173d5c3423eb83ddc46f1Svetoslav        return getNodeForAccessibilityId(mParentNodeId);
135557c7fd5a43237afc5e8ef31a076e862c0c16c328Svetoslav Ganov    }
135657c7fd5a43237afc5e8ef31a076e862c0c16c328Svetoslav Ganov
135757c7fd5a43237afc5e8ef31a076e862c0c16c328Svetoslav Ganov    /**
135857c7fd5a43237afc5e8ef31a076e862c0c16c328Svetoslav Ganov     * @return The parent node id.
135957c7fd5a43237afc5e8ef31a076e862c0c16c328Svetoslav Ganov     *
136057c7fd5a43237afc5e8ef31a076e862c0c16c328Svetoslav Ganov     * @hide
136157c7fd5a43237afc5e8ef31a076e862c0c16c328Svetoslav Ganov     */
136257c7fd5a43237afc5e8ef31a076e862c0c16c328Svetoslav Ganov    public long getParentNodeId() {
136357c7fd5a43237afc5e8ef31a076e862c0c16c328Svetoslav Ganov        return mParentNodeId;
13648643aa0179e598e78d938c59035389054535a229Svetoslav Ganov    }
13658643aa0179e598e78d938c59035389054535a229Svetoslav Ganov
13668643aa0179e598e78d938c59035389054535a229Svetoslav Ganov    /**
13678643aa0179e598e78d938c59035389054535a229Svetoslav Ganov     * Sets the parent.
13688643aa0179e598e78d938c59035389054535a229Svetoslav Ganov     * <p>
136938e8b4e5bc3c93affdffbc064fd9db5aeccc3e8eSvetoslav Ganov     *   <strong>Note:</strong> Cannot be called from an
137038e8b4e5bc3c93affdffbc064fd9db5aeccc3e8eSvetoslav Ganov     *   {@link android.accessibilityservice.AccessibilityService}.
13718643aa0179e598e78d938c59035389054535a229Svetoslav Ganov     *   This class is made immutable before being delivered to an AccessibilityService.
13728643aa0179e598e78d938c59035389054535a229Svetoslav Ganov     * </p>
137338e8b4e5bc3c93affdffbc064fd9db5aeccc3e8eSvetoslav Ganov     *
13748643aa0179e598e78d938c59035389054535a229Svetoslav Ganov     * @param parent The parent.
13758643aa0179e598e78d938c59035389054535a229Svetoslav Ganov     *
13768643aa0179e598e78d938c59035389054535a229Svetoslav Ganov     * @throws IllegalStateException If called from an AccessibilityService.
13778643aa0179e598e78d938c59035389054535a229Svetoslav Ganov     */
13788643aa0179e598e78d938c59035389054535a229Svetoslav Ganov    public void setParent(View parent) {
13798e3feb15c5aec2c72b0ef120a1da325e1e8f0ddaSvetoslav        setParent(parent, UNDEFINED_ITEM_ID);
1380021078554b902179442a345a9d080a165c3b5139Svetoslav Ganov    }
1381021078554b902179442a345a9d080a165c3b5139Svetoslav Ganov
1382021078554b902179442a345a9d080a165c3b5139Svetoslav Ganov    /**
1383021078554b902179442a345a9d080a165c3b5139Svetoslav Ganov     * Sets the parent to be a virtual descendant of the given <code>root</code>.
1384021078554b902179442a345a9d080a165c3b5139Svetoslav Ganov     * If <code>virtualDescendantId</code> equals to {@link View#NO_ID} the root
1385021078554b902179442a345a9d080a165c3b5139Svetoslav Ganov     * is set as the parent.
1386021078554b902179442a345a9d080a165c3b5139Svetoslav Ganov     * <p>
1387021078554b902179442a345a9d080a165c3b5139Svetoslav Ganov     * A virtual descendant is an imaginary View that is reported as a part of the view
1388021078554b902179442a345a9d080a165c3b5139Svetoslav Ganov     * hierarchy for accessibility purposes. This enables custom views that draw complex
1389021078554b902179442a345a9d080a165c3b5139Svetoslav Ganov     * content to report them selves as a tree of virtual views, thus conveying their
1390021078554b902179442a345a9d080a165c3b5139Svetoslav Ganov     * logical structure.
1391021078554b902179442a345a9d080a165c3b5139Svetoslav Ganov     * </p>
1392021078554b902179442a345a9d080a165c3b5139Svetoslav Ganov     * <p>
1393021078554b902179442a345a9d080a165c3b5139Svetoslav Ganov     *   <strong>Note:</strong> Cannot be called from an
1394021078554b902179442a345a9d080a165c3b5139Svetoslav Ganov     *   {@link android.accessibilityservice.AccessibilityService}.
1395021078554b902179442a345a9d080a165c3b5139Svetoslav Ganov     *   This class is made immutable before being delivered to an AccessibilityService.
1396021078554b902179442a345a9d080a165c3b5139Svetoslav Ganov     * </p>
1397021078554b902179442a345a9d080a165c3b5139Svetoslav Ganov     *
1398021078554b902179442a345a9d080a165c3b5139Svetoslav Ganov     * @param root The root of the virtual subtree.
1399021078554b902179442a345a9d080a165c3b5139Svetoslav Ganov     * @param virtualDescendantId The id of the virtual descendant.
1400021078554b902179442a345a9d080a165c3b5139Svetoslav Ganov     */
1401021078554b902179442a345a9d080a165c3b5139Svetoslav Ganov    public void setParent(View root, int virtualDescendantId) {
14028643aa0179e598e78d938c59035389054535a229Svetoslav Ganov        enforceNotSealed();
1403021078554b902179442a345a9d080a165c3b5139Svetoslav Ganov        final int rootAccessibilityViewId =
14048e3feb15c5aec2c72b0ef120a1da325e1e8f0ddaSvetoslav            (root != null) ? root.getAccessibilityViewId() : UNDEFINED_ITEM_ID;
1405021078554b902179442a345a9d080a165c3b5139Svetoslav Ganov        mParentNodeId = makeNodeId(rootAccessibilityViewId, virtualDescendantId);
14068643aa0179e598e78d938c59035389054535a229Svetoslav Ganov    }
14078643aa0179e598e78d938c59035389054535a229Svetoslav Ganov
14088643aa0179e598e78d938c59035389054535a229Svetoslav Ganov    /**
14098643aa0179e598e78d938c59035389054535a229Svetoslav Ganov     * Gets the node bounds in parent coordinates.
14108643aa0179e598e78d938c59035389054535a229Svetoslav Ganov     *
14118643aa0179e598e78d938c59035389054535a229Svetoslav Ganov     * @param outBounds The output node bounds.
14128643aa0179e598e78d938c59035389054535a229Svetoslav Ganov     */
1413eeee4d2c01d3c4ed99e4891dbc75c7de69a803faSvetoslav Ganov    public void getBoundsInParent(Rect outBounds) {
1414eeee4d2c01d3c4ed99e4891dbc75c7de69a803faSvetoslav Ganov        outBounds.set(mBoundsInParent.left, mBoundsInParent.top,
1415eeee4d2c01d3c4ed99e4891dbc75c7de69a803faSvetoslav Ganov                mBoundsInParent.right, mBoundsInParent.bottom);
14168643aa0179e598e78d938c59035389054535a229Svetoslav Ganov    }
14178643aa0179e598e78d938c59035389054535a229Svetoslav Ganov
14188643aa0179e598e78d938c59035389054535a229Svetoslav Ganov    /**
14198643aa0179e598e78d938c59035389054535a229Svetoslav Ganov     * Sets the node bounds in parent coordinates.
14208643aa0179e598e78d938c59035389054535a229Svetoslav Ganov     * <p>
142138e8b4e5bc3c93affdffbc064fd9db5aeccc3e8eSvetoslav Ganov     *   <strong>Note:</strong> Cannot be called from an
142238e8b4e5bc3c93affdffbc064fd9db5aeccc3e8eSvetoslav Ganov     *   {@link android.accessibilityservice.AccessibilityService}.
14238643aa0179e598e78d938c59035389054535a229Svetoslav Ganov     *   This class is made immutable before being delivered to an AccessibilityService.
14248643aa0179e598e78d938c59035389054535a229Svetoslav Ganov     * </p>
142538e8b4e5bc3c93affdffbc064fd9db5aeccc3e8eSvetoslav Ganov     *
14268643aa0179e598e78d938c59035389054535a229Svetoslav Ganov     * @param bounds The node bounds.
14278643aa0179e598e78d938c59035389054535a229Svetoslav Ganov     *
14288643aa0179e598e78d938c59035389054535a229Svetoslav Ganov     * @throws IllegalStateException If called from an AccessibilityService.
14298643aa0179e598e78d938c59035389054535a229Svetoslav Ganov     */
1430eeee4d2c01d3c4ed99e4891dbc75c7de69a803faSvetoslav Ganov    public void setBoundsInParent(Rect bounds) {
14318643aa0179e598e78d938c59035389054535a229Svetoslav Ganov        enforceNotSealed();
1432eeee4d2c01d3c4ed99e4891dbc75c7de69a803faSvetoslav Ganov        mBoundsInParent.set(bounds.left, bounds.top, bounds.right, bounds.bottom);
1433eeee4d2c01d3c4ed99e4891dbc75c7de69a803faSvetoslav Ganov    }
1434eeee4d2c01d3c4ed99e4891dbc75c7de69a803faSvetoslav Ganov
1435eeee4d2c01d3c4ed99e4891dbc75c7de69a803faSvetoslav Ganov    /**
1436eeee4d2c01d3c4ed99e4891dbc75c7de69a803faSvetoslav Ganov     * Gets the node bounds in screen coordinates.
1437eeee4d2c01d3c4ed99e4891dbc75c7de69a803faSvetoslav Ganov     *
1438eeee4d2c01d3c4ed99e4891dbc75c7de69a803faSvetoslav Ganov     * @param outBounds The output node bounds.
1439eeee4d2c01d3c4ed99e4891dbc75c7de69a803faSvetoslav Ganov     */
1440eeee4d2c01d3c4ed99e4891dbc75c7de69a803faSvetoslav Ganov    public void getBoundsInScreen(Rect outBounds) {
1441eeee4d2c01d3c4ed99e4891dbc75c7de69a803faSvetoslav Ganov        outBounds.set(mBoundsInScreen.left, mBoundsInScreen.top,
1442eeee4d2c01d3c4ed99e4891dbc75c7de69a803faSvetoslav Ganov                mBoundsInScreen.right, mBoundsInScreen.bottom);
1443eeee4d2c01d3c4ed99e4891dbc75c7de69a803faSvetoslav Ganov    }
1444eeee4d2c01d3c4ed99e4891dbc75c7de69a803faSvetoslav Ganov
1445eeee4d2c01d3c4ed99e4891dbc75c7de69a803faSvetoslav Ganov    /**
1446eeee4d2c01d3c4ed99e4891dbc75c7de69a803faSvetoslav Ganov     * Sets the node bounds in screen coordinates.
1447eeee4d2c01d3c4ed99e4891dbc75c7de69a803faSvetoslav Ganov     * <p>
144838e8b4e5bc3c93affdffbc064fd9db5aeccc3e8eSvetoslav Ganov     *   <strong>Note:</strong> Cannot be called from an
144938e8b4e5bc3c93affdffbc064fd9db5aeccc3e8eSvetoslav Ganov     *   {@link android.accessibilityservice.AccessibilityService}.
1450eeee4d2c01d3c4ed99e4891dbc75c7de69a803faSvetoslav Ganov     *   This class is made immutable before being delivered to an AccessibilityService.
1451eeee4d2c01d3c4ed99e4891dbc75c7de69a803faSvetoslav Ganov     * </p>
145238e8b4e5bc3c93affdffbc064fd9db5aeccc3e8eSvetoslav Ganov     *
1453eeee4d2c01d3c4ed99e4891dbc75c7de69a803faSvetoslav Ganov     * @param bounds The node bounds.
1454eeee4d2c01d3c4ed99e4891dbc75c7de69a803faSvetoslav Ganov     *
1455eeee4d2c01d3c4ed99e4891dbc75c7de69a803faSvetoslav Ganov     * @throws IllegalStateException If called from an AccessibilityService.
1456eeee4d2c01d3c4ed99e4891dbc75c7de69a803faSvetoslav Ganov     */
1457eeee4d2c01d3c4ed99e4891dbc75c7de69a803faSvetoslav Ganov    public void setBoundsInScreen(Rect bounds) {
1458eeee4d2c01d3c4ed99e4891dbc75c7de69a803faSvetoslav Ganov        enforceNotSealed();
1459eeee4d2c01d3c4ed99e4891dbc75c7de69a803faSvetoslav Ganov        mBoundsInScreen.set(bounds.left, bounds.top, bounds.right, bounds.bottom);
14608643aa0179e598e78d938c59035389054535a229Svetoslav Ganov    }
14618643aa0179e598e78d938c59035389054535a229Svetoslav Ganov
14628643aa0179e598e78d938c59035389054535a229Svetoslav Ganov    /**
14638643aa0179e598e78d938c59035389054535a229Svetoslav Ganov     * Gets whether this node is checkable.
14648643aa0179e598e78d938c59035389054535a229Svetoslav Ganov     *
14658643aa0179e598e78d938c59035389054535a229Svetoslav Ganov     * @return True if the node is checkable.
14668643aa0179e598e78d938c59035389054535a229Svetoslav Ganov     */
14678643aa0179e598e78d938c59035389054535a229Svetoslav Ganov    public boolean isCheckable() {
1468bcc46a0d037e62fcb5e5f0f5e1acef5a8c1314b0Svetoslav        return getBooleanProperty(BOOLEAN_PROPERTY_CHECKABLE);
14698643aa0179e598e78d938c59035389054535a229Svetoslav Ganov    }
14708643aa0179e598e78d938c59035389054535a229Svetoslav Ganov
14718643aa0179e598e78d938c59035389054535a229Svetoslav Ganov    /**
14728643aa0179e598e78d938c59035389054535a229Svetoslav Ganov     * Sets whether this node is checkable.
14738643aa0179e598e78d938c59035389054535a229Svetoslav Ganov     * <p>
147438e8b4e5bc3c93affdffbc064fd9db5aeccc3e8eSvetoslav Ganov     *   <strong>Note:</strong> Cannot be called from an
147538e8b4e5bc3c93affdffbc064fd9db5aeccc3e8eSvetoslav Ganov     *   {@link android.accessibilityservice.AccessibilityService}.
14768643aa0179e598e78d938c59035389054535a229Svetoslav Ganov     *   This class is made immutable before being delivered to an AccessibilityService.
14778643aa0179e598e78d938c59035389054535a229Svetoslav Ganov     * </p>
147838e8b4e5bc3c93affdffbc064fd9db5aeccc3e8eSvetoslav Ganov     *
14798643aa0179e598e78d938c59035389054535a229Svetoslav Ganov     * @param checkable True if the node is checkable.
14808643aa0179e598e78d938c59035389054535a229Svetoslav Ganov     *
14818643aa0179e598e78d938c59035389054535a229Svetoslav Ganov     * @throws IllegalStateException If called from an AccessibilityService.
14828643aa0179e598e78d938c59035389054535a229Svetoslav Ganov     */
14838643aa0179e598e78d938c59035389054535a229Svetoslav Ganov    public void setCheckable(boolean checkable) {
1484bcc46a0d037e62fcb5e5f0f5e1acef5a8c1314b0Svetoslav        setBooleanProperty(BOOLEAN_PROPERTY_CHECKABLE, checkable);
14858643aa0179e598e78d938c59035389054535a229Svetoslav Ganov    }
14868643aa0179e598e78d938c59035389054535a229Svetoslav Ganov
14878643aa0179e598e78d938c59035389054535a229Svetoslav Ganov    /**
14888643aa0179e598e78d938c59035389054535a229Svetoslav Ganov     * Gets whether this node is checked.
14898643aa0179e598e78d938c59035389054535a229Svetoslav Ganov     *
14908643aa0179e598e78d938c59035389054535a229Svetoslav Ganov     * @return True if the node is checked.
14918643aa0179e598e78d938c59035389054535a229Svetoslav Ganov     */
14928643aa0179e598e78d938c59035389054535a229Svetoslav Ganov    public boolean isChecked() {
1493bcc46a0d037e62fcb5e5f0f5e1acef5a8c1314b0Svetoslav        return getBooleanProperty(BOOLEAN_PROPERTY_CHECKED);
14948643aa0179e598e78d938c59035389054535a229Svetoslav Ganov    }
14958643aa0179e598e78d938c59035389054535a229Svetoslav Ganov
14968643aa0179e598e78d938c59035389054535a229Svetoslav Ganov    /**
14978643aa0179e598e78d938c59035389054535a229Svetoslav Ganov     * Sets whether this node is checked.
14988643aa0179e598e78d938c59035389054535a229Svetoslav Ganov     * <p>
149938e8b4e5bc3c93affdffbc064fd9db5aeccc3e8eSvetoslav Ganov     *   <strong>Note:</strong> Cannot be called from an
150038e8b4e5bc3c93affdffbc064fd9db5aeccc3e8eSvetoslav Ganov     *   {@link android.accessibilityservice.AccessibilityService}.
15018643aa0179e598e78d938c59035389054535a229Svetoslav Ganov     *   This class is made immutable before being delivered to an AccessibilityService.
15028643aa0179e598e78d938c59035389054535a229Svetoslav Ganov     * </p>
150338e8b4e5bc3c93affdffbc064fd9db5aeccc3e8eSvetoslav Ganov     *
15048643aa0179e598e78d938c59035389054535a229Svetoslav Ganov     * @param checked True if the node is checked.
15058643aa0179e598e78d938c59035389054535a229Svetoslav Ganov     *
15068643aa0179e598e78d938c59035389054535a229Svetoslav Ganov     * @throws IllegalStateException If called from an AccessibilityService.
15078643aa0179e598e78d938c59035389054535a229Svetoslav Ganov     */
15088643aa0179e598e78d938c59035389054535a229Svetoslav Ganov    public void setChecked(boolean checked) {
1509bcc46a0d037e62fcb5e5f0f5e1acef5a8c1314b0Svetoslav        setBooleanProperty(BOOLEAN_PROPERTY_CHECKED, checked);
15108643aa0179e598e78d938c59035389054535a229Svetoslav Ganov    }
15118643aa0179e598e78d938c59035389054535a229Svetoslav Ganov
15128643aa0179e598e78d938c59035389054535a229Svetoslav Ganov    /**
15138643aa0179e598e78d938c59035389054535a229Svetoslav Ganov     * Gets whether this node is focusable.
15148643aa0179e598e78d938c59035389054535a229Svetoslav Ganov     *
15158643aa0179e598e78d938c59035389054535a229Svetoslav Ganov     * @return True if the node is focusable.
15168643aa0179e598e78d938c59035389054535a229Svetoslav Ganov     */
15178643aa0179e598e78d938c59035389054535a229Svetoslav Ganov    public boolean isFocusable() {
1518bcc46a0d037e62fcb5e5f0f5e1acef5a8c1314b0Svetoslav        return getBooleanProperty(BOOLEAN_PROPERTY_FOCUSABLE);
15198643aa0179e598e78d938c59035389054535a229Svetoslav Ganov    }
15208643aa0179e598e78d938c59035389054535a229Svetoslav Ganov
15218643aa0179e598e78d938c59035389054535a229Svetoslav Ganov    /**
15228643aa0179e598e78d938c59035389054535a229Svetoslav Ganov     * Sets whether this node is focusable.
15238643aa0179e598e78d938c59035389054535a229Svetoslav Ganov     * <p>
152438e8b4e5bc3c93affdffbc064fd9db5aeccc3e8eSvetoslav Ganov     *   <strong>Note:</strong> Cannot be called from an
152538e8b4e5bc3c93affdffbc064fd9db5aeccc3e8eSvetoslav Ganov     *   {@link android.accessibilityservice.AccessibilityService}.
15268643aa0179e598e78d938c59035389054535a229Svetoslav Ganov     *   This class is made immutable before being delivered to an AccessibilityService.
15278643aa0179e598e78d938c59035389054535a229Svetoslav Ganov     * </p>
152838e8b4e5bc3c93affdffbc064fd9db5aeccc3e8eSvetoslav Ganov     *
15298643aa0179e598e78d938c59035389054535a229Svetoslav Ganov     * @param focusable True if the node is focusable.
15308643aa0179e598e78d938c59035389054535a229Svetoslav Ganov     *
15318643aa0179e598e78d938c59035389054535a229Svetoslav Ganov     * @throws IllegalStateException If called from an AccessibilityService.
15328643aa0179e598e78d938c59035389054535a229Svetoslav Ganov     */
15338643aa0179e598e78d938c59035389054535a229Svetoslav Ganov    public void setFocusable(boolean focusable) {
1534bcc46a0d037e62fcb5e5f0f5e1acef5a8c1314b0Svetoslav        setBooleanProperty(BOOLEAN_PROPERTY_FOCUSABLE, focusable);
15358643aa0179e598e78d938c59035389054535a229Svetoslav Ganov    }
15368643aa0179e598e78d938c59035389054535a229Svetoslav Ganov
15378643aa0179e598e78d938c59035389054535a229Svetoslav Ganov    /**
15388643aa0179e598e78d938c59035389054535a229Svetoslav Ganov     * Gets whether this node is focused.
15398643aa0179e598e78d938c59035389054535a229Svetoslav Ganov     *
15408643aa0179e598e78d938c59035389054535a229Svetoslav Ganov     * @return True if the node is focused.
15418643aa0179e598e78d938c59035389054535a229Svetoslav Ganov     */
15428643aa0179e598e78d938c59035389054535a229Svetoslav Ganov    public boolean isFocused() {
1543bcc46a0d037e62fcb5e5f0f5e1acef5a8c1314b0Svetoslav        return getBooleanProperty(BOOLEAN_PROPERTY_FOCUSED);
15448643aa0179e598e78d938c59035389054535a229Svetoslav Ganov    }
15458643aa0179e598e78d938c59035389054535a229Svetoslav Ganov
15468643aa0179e598e78d938c59035389054535a229Svetoslav Ganov    /**
15478643aa0179e598e78d938c59035389054535a229Svetoslav Ganov     * Sets whether this node is focused.
15488643aa0179e598e78d938c59035389054535a229Svetoslav Ganov     * <p>
154938e8b4e5bc3c93affdffbc064fd9db5aeccc3e8eSvetoslav Ganov     *   <strong>Note:</strong> Cannot be called from an
155038e8b4e5bc3c93affdffbc064fd9db5aeccc3e8eSvetoslav Ganov     *   {@link android.accessibilityservice.AccessibilityService}.
15518643aa0179e598e78d938c59035389054535a229Svetoslav Ganov     *   This class is made immutable before being delivered to an AccessibilityService.
15528643aa0179e598e78d938c59035389054535a229Svetoslav Ganov     * </p>
155338e8b4e5bc3c93affdffbc064fd9db5aeccc3e8eSvetoslav Ganov     *
15548643aa0179e598e78d938c59035389054535a229Svetoslav Ganov     * @param focused True if the node is focused.
15558643aa0179e598e78d938c59035389054535a229Svetoslav Ganov     *
15568643aa0179e598e78d938c59035389054535a229Svetoslav Ganov     * @throws IllegalStateException If called from an AccessibilityService.
15578643aa0179e598e78d938c59035389054535a229Svetoslav Ganov     */
15588643aa0179e598e78d938c59035389054535a229Svetoslav Ganov    public void setFocused(boolean focused) {
1559bcc46a0d037e62fcb5e5f0f5e1acef5a8c1314b0Svetoslav        setBooleanProperty(BOOLEAN_PROPERTY_FOCUSED, focused);
15608643aa0179e598e78d938c59035389054535a229Svetoslav Ganov    }
15618643aa0179e598e78d938c59035389054535a229Svetoslav Ganov
15628643aa0179e598e78d938c59035389054535a229Svetoslav Ganov    /**
15630a1bb6dffc358c01e10555c5c833edb7dba69659Svetoslav Ganov     * Sets whether this node is visible to the user.
15640a1bb6dffc358c01e10555c5c833edb7dba69659Svetoslav Ganov     *
15650a1bb6dffc358c01e10555c5c833edb7dba69659Svetoslav Ganov     * @return Whether the node is visible to the user.
15660a1bb6dffc358c01e10555c5c833edb7dba69659Svetoslav Ganov     */
15670a1bb6dffc358c01e10555c5c833edb7dba69659Svetoslav Ganov    public boolean isVisibleToUser() {
1568bcc46a0d037e62fcb5e5f0f5e1acef5a8c1314b0Svetoslav        return getBooleanProperty(BOOLEAN_PROPERTY_VISIBLE_TO_USER);
15690a1bb6dffc358c01e10555c5c833edb7dba69659Svetoslav Ganov    }
15700a1bb6dffc358c01e10555c5c833edb7dba69659Svetoslav Ganov
15710a1bb6dffc358c01e10555c5c833edb7dba69659Svetoslav Ganov    /**
15720a1bb6dffc358c01e10555c5c833edb7dba69659Svetoslav Ganov     * Sets whether this node is visible to the user.
15730a1bb6dffc358c01e10555c5c833edb7dba69659Svetoslav Ganov     * <p>
15740a1bb6dffc358c01e10555c5c833edb7dba69659Svetoslav Ganov     *   <strong>Note:</strong> Cannot be called from an
15750a1bb6dffc358c01e10555c5c833edb7dba69659Svetoslav Ganov     *   {@link android.accessibilityservice.AccessibilityService}.
15760a1bb6dffc358c01e10555c5c833edb7dba69659Svetoslav Ganov     *   This class is made immutable before being delivered to an AccessibilityService.
15770a1bb6dffc358c01e10555c5c833edb7dba69659Svetoslav Ganov     * </p>
15780a1bb6dffc358c01e10555c5c833edb7dba69659Svetoslav Ganov     *
15790a1bb6dffc358c01e10555c5c833edb7dba69659Svetoslav Ganov     * @param visibleToUser Whether the node is visible to the user.
15800a1bb6dffc358c01e10555c5c833edb7dba69659Svetoslav Ganov     *
15810a1bb6dffc358c01e10555c5c833edb7dba69659Svetoslav Ganov     * @throws IllegalStateException If called from an AccessibilityService.
15820a1bb6dffc358c01e10555c5c833edb7dba69659Svetoslav Ganov     */
15830a1bb6dffc358c01e10555c5c833edb7dba69659Svetoslav Ganov    public void setVisibleToUser(boolean visibleToUser) {
1584bcc46a0d037e62fcb5e5f0f5e1acef5a8c1314b0Svetoslav        setBooleanProperty(BOOLEAN_PROPERTY_VISIBLE_TO_USER, visibleToUser);
15850a1bb6dffc358c01e10555c5c833edb7dba69659Svetoslav Ganov    }
15860a1bb6dffc358c01e10555c5c833edb7dba69659Svetoslav Ganov
15870a1bb6dffc358c01e10555c5c833edb7dba69659Svetoslav Ganov    /**
15884213804541a8b05cd0587b138a2fd9a3b7fd9350Svetoslav Ganov     * Gets whether this node is accessibility focused.
15894213804541a8b05cd0587b138a2fd9a3b7fd9350Svetoslav Ganov     *
15904213804541a8b05cd0587b138a2fd9a3b7fd9350Svetoslav Ganov     * @return True if the node is accessibility focused.
15914213804541a8b05cd0587b138a2fd9a3b7fd9350Svetoslav Ganov     */
15924213804541a8b05cd0587b138a2fd9a3b7fd9350Svetoslav Ganov    public boolean isAccessibilityFocused() {
1593bcc46a0d037e62fcb5e5f0f5e1acef5a8c1314b0Svetoslav        return getBooleanProperty(BOOLEAN_PROPERTY_ACCESSIBILITY_FOCUSED);
15944213804541a8b05cd0587b138a2fd9a3b7fd9350Svetoslav Ganov    }
15954213804541a8b05cd0587b138a2fd9a3b7fd9350Svetoslav Ganov
15964213804541a8b05cd0587b138a2fd9a3b7fd9350Svetoslav Ganov    /**
15974213804541a8b05cd0587b138a2fd9a3b7fd9350Svetoslav Ganov     * Sets whether this node is accessibility focused.
15984213804541a8b05cd0587b138a2fd9a3b7fd9350Svetoslav Ganov     * <p>
15994213804541a8b05cd0587b138a2fd9a3b7fd9350Svetoslav Ganov     *   <strong>Note:</strong> Cannot be called from an
16004213804541a8b05cd0587b138a2fd9a3b7fd9350Svetoslav Ganov     *   {@link android.accessibilityservice.AccessibilityService}.
16014213804541a8b05cd0587b138a2fd9a3b7fd9350Svetoslav Ganov     *   This class is made immutable before being delivered to an AccessibilityService.
16024213804541a8b05cd0587b138a2fd9a3b7fd9350Svetoslav Ganov     * </p>
16034213804541a8b05cd0587b138a2fd9a3b7fd9350Svetoslav Ganov     *
16044213804541a8b05cd0587b138a2fd9a3b7fd9350Svetoslav Ganov     * @param focused True if the node is accessibility focused.
16054213804541a8b05cd0587b138a2fd9a3b7fd9350Svetoslav Ganov     *
16064213804541a8b05cd0587b138a2fd9a3b7fd9350Svetoslav Ganov     * @throws IllegalStateException If called from an AccessibilityService.
16074213804541a8b05cd0587b138a2fd9a3b7fd9350Svetoslav Ganov     */
16084213804541a8b05cd0587b138a2fd9a3b7fd9350Svetoslav Ganov    public void setAccessibilityFocused(boolean focused) {
1609bcc46a0d037e62fcb5e5f0f5e1acef5a8c1314b0Svetoslav        setBooleanProperty(BOOLEAN_PROPERTY_ACCESSIBILITY_FOCUSED, focused);
16104213804541a8b05cd0587b138a2fd9a3b7fd9350Svetoslav Ganov    }
16114213804541a8b05cd0587b138a2fd9a3b7fd9350Svetoslav Ganov
16124213804541a8b05cd0587b138a2fd9a3b7fd9350Svetoslav Ganov    /**
16138643aa0179e598e78d938c59035389054535a229Svetoslav Ganov     * Gets whether this node is selected.
16148643aa0179e598e78d938c59035389054535a229Svetoslav Ganov     *
16158643aa0179e598e78d938c59035389054535a229Svetoslav Ganov     * @return True if the node is selected.
16168643aa0179e598e78d938c59035389054535a229Svetoslav Ganov     */
16178643aa0179e598e78d938c59035389054535a229Svetoslav Ganov    public boolean isSelected() {
1618bcc46a0d037e62fcb5e5f0f5e1acef5a8c1314b0Svetoslav        return getBooleanProperty(BOOLEAN_PROPERTY_SELECTED);
16198643aa0179e598e78d938c59035389054535a229Svetoslav Ganov    }
16208643aa0179e598e78d938c59035389054535a229Svetoslav Ganov
16218643aa0179e598e78d938c59035389054535a229Svetoslav Ganov    /**
16228643aa0179e598e78d938c59035389054535a229Svetoslav Ganov     * Sets whether this node is selected.
16238643aa0179e598e78d938c59035389054535a229Svetoslav Ganov     * <p>
162438e8b4e5bc3c93affdffbc064fd9db5aeccc3e8eSvetoslav Ganov     *   <strong>Note:</strong> Cannot be called from an
162538e8b4e5bc3c93affdffbc064fd9db5aeccc3e8eSvetoslav Ganov     *   {@link android.accessibilityservice.AccessibilityService}.
16268643aa0179e598e78d938c59035389054535a229Svetoslav Ganov     *   This class is made immutable before being delivered to an AccessibilityService.
16278643aa0179e598e78d938c59035389054535a229Svetoslav Ganov     * </p>
162838e8b4e5bc3c93affdffbc064fd9db5aeccc3e8eSvetoslav Ganov     *
16298643aa0179e598e78d938c59035389054535a229Svetoslav Ganov     * @param selected True if the node is selected.
16308643aa0179e598e78d938c59035389054535a229Svetoslav Ganov     *
16318643aa0179e598e78d938c59035389054535a229Svetoslav Ganov     * @throws IllegalStateException If called from an AccessibilityService.
16328643aa0179e598e78d938c59035389054535a229Svetoslav Ganov     */
16338643aa0179e598e78d938c59035389054535a229Svetoslav Ganov    public void setSelected(boolean selected) {
1634bcc46a0d037e62fcb5e5f0f5e1acef5a8c1314b0Svetoslav        setBooleanProperty(BOOLEAN_PROPERTY_SELECTED, selected);
16358643aa0179e598e78d938c59035389054535a229Svetoslav Ganov    }
16368643aa0179e598e78d938c59035389054535a229Svetoslav Ganov
16378643aa0179e598e78d938c59035389054535a229Svetoslav Ganov    /**
16388643aa0179e598e78d938c59035389054535a229Svetoslav Ganov     * Gets whether this node is clickable.
16398643aa0179e598e78d938c59035389054535a229Svetoslav Ganov     *
16408643aa0179e598e78d938c59035389054535a229Svetoslav Ganov     * @return True if the node is clickable.
16418643aa0179e598e78d938c59035389054535a229Svetoslav Ganov     */
16428643aa0179e598e78d938c59035389054535a229Svetoslav Ganov    public boolean isClickable() {
1643bcc46a0d037e62fcb5e5f0f5e1acef5a8c1314b0Svetoslav        return getBooleanProperty(BOOLEAN_PROPERTY_CLICKABLE);
16448643aa0179e598e78d938c59035389054535a229Svetoslav Ganov    }
16458643aa0179e598e78d938c59035389054535a229Svetoslav Ganov
16468643aa0179e598e78d938c59035389054535a229Svetoslav Ganov    /**
16478643aa0179e598e78d938c59035389054535a229Svetoslav Ganov     * Sets whether this node is clickable.
16488643aa0179e598e78d938c59035389054535a229Svetoslav Ganov     * <p>
164938e8b4e5bc3c93affdffbc064fd9db5aeccc3e8eSvetoslav Ganov     *   <strong>Note:</strong> Cannot be called from an
165038e8b4e5bc3c93affdffbc064fd9db5aeccc3e8eSvetoslav Ganov     *   {@link android.accessibilityservice.AccessibilityService}.
16518643aa0179e598e78d938c59035389054535a229Svetoslav Ganov     *   This class is made immutable before being delivered to an AccessibilityService.
16528643aa0179e598e78d938c59035389054535a229Svetoslav Ganov     * </p>
165338e8b4e5bc3c93affdffbc064fd9db5aeccc3e8eSvetoslav Ganov     *
16548643aa0179e598e78d938c59035389054535a229Svetoslav Ganov     * @param clickable True if the node is clickable.
16558643aa0179e598e78d938c59035389054535a229Svetoslav Ganov     *
16568643aa0179e598e78d938c59035389054535a229Svetoslav Ganov     * @throws IllegalStateException If called from an AccessibilityService.
16578643aa0179e598e78d938c59035389054535a229Svetoslav Ganov     */
16588643aa0179e598e78d938c59035389054535a229Svetoslav Ganov    public void setClickable(boolean clickable) {
1659bcc46a0d037e62fcb5e5f0f5e1acef5a8c1314b0Svetoslav        setBooleanProperty(BOOLEAN_PROPERTY_CLICKABLE, clickable);
16608643aa0179e598e78d938c59035389054535a229Svetoslav Ganov    }
16618643aa0179e598e78d938c59035389054535a229Svetoslav Ganov
16628643aa0179e598e78d938c59035389054535a229Svetoslav Ganov    /**
16638643aa0179e598e78d938c59035389054535a229Svetoslav Ganov     * Gets whether this node is long clickable.
16648643aa0179e598e78d938c59035389054535a229Svetoslav Ganov     *
16658643aa0179e598e78d938c59035389054535a229Svetoslav Ganov     * @return True if the node is long clickable.
16668643aa0179e598e78d938c59035389054535a229Svetoslav Ganov     */
16678643aa0179e598e78d938c59035389054535a229Svetoslav Ganov    public boolean isLongClickable() {
1668bcc46a0d037e62fcb5e5f0f5e1acef5a8c1314b0Svetoslav        return getBooleanProperty(BOOLEAN_PROPERTY_LONG_CLICKABLE);
16698643aa0179e598e78d938c59035389054535a229Svetoslav Ganov    }
16708643aa0179e598e78d938c59035389054535a229Svetoslav Ganov
16718643aa0179e598e78d938c59035389054535a229Svetoslav Ganov    /**
16728643aa0179e598e78d938c59035389054535a229Svetoslav Ganov     * Sets whether this node is long clickable.
16738643aa0179e598e78d938c59035389054535a229Svetoslav Ganov     * <p>
167438e8b4e5bc3c93affdffbc064fd9db5aeccc3e8eSvetoslav Ganov     *   <strong>Note:</strong> Cannot be called from an
167538e8b4e5bc3c93affdffbc064fd9db5aeccc3e8eSvetoslav Ganov     *   {@link android.accessibilityservice.AccessibilityService}.
16768643aa0179e598e78d938c59035389054535a229Svetoslav Ganov     *   This class is made immutable before being delivered to an AccessibilityService.
16778643aa0179e598e78d938c59035389054535a229Svetoslav Ganov     * </p>
167838e8b4e5bc3c93affdffbc064fd9db5aeccc3e8eSvetoslav Ganov     *
16798643aa0179e598e78d938c59035389054535a229Svetoslav Ganov     * @param longClickable True if the node is long clickable.
16808643aa0179e598e78d938c59035389054535a229Svetoslav Ganov     *
16818643aa0179e598e78d938c59035389054535a229Svetoslav Ganov     * @throws IllegalStateException If called from an AccessibilityService.
16828643aa0179e598e78d938c59035389054535a229Svetoslav Ganov     */
16838643aa0179e598e78d938c59035389054535a229Svetoslav Ganov    public void setLongClickable(boolean longClickable) {
1684bcc46a0d037e62fcb5e5f0f5e1acef5a8c1314b0Svetoslav        setBooleanProperty(BOOLEAN_PROPERTY_LONG_CLICKABLE, longClickable);
16858643aa0179e598e78d938c59035389054535a229Svetoslav Ganov    }
16868643aa0179e598e78d938c59035389054535a229Svetoslav Ganov
16878643aa0179e598e78d938c59035389054535a229Svetoslav Ganov    /**
16888643aa0179e598e78d938c59035389054535a229Svetoslav Ganov     * Gets whether this node is enabled.
16898643aa0179e598e78d938c59035389054535a229Svetoslav Ganov     *
16908643aa0179e598e78d938c59035389054535a229Svetoslav Ganov     * @return True if the node is enabled.
16918643aa0179e598e78d938c59035389054535a229Svetoslav Ganov     */
16928643aa0179e598e78d938c59035389054535a229Svetoslav Ganov    public boolean isEnabled() {
1693bcc46a0d037e62fcb5e5f0f5e1acef5a8c1314b0Svetoslav        return getBooleanProperty(BOOLEAN_PROPERTY_ENABLED);
16948643aa0179e598e78d938c59035389054535a229Svetoslav Ganov    }
16958643aa0179e598e78d938c59035389054535a229Svetoslav Ganov
16968643aa0179e598e78d938c59035389054535a229Svetoslav Ganov    /**
16978643aa0179e598e78d938c59035389054535a229Svetoslav Ganov     * Sets whether this node is enabled.
16988643aa0179e598e78d938c59035389054535a229Svetoslav Ganov     * <p>
169938e8b4e5bc3c93affdffbc064fd9db5aeccc3e8eSvetoslav Ganov     *   <strong>Note:</strong> Cannot be called from an
170038e8b4e5bc3c93affdffbc064fd9db5aeccc3e8eSvetoslav Ganov     *   {@link android.accessibilityservice.AccessibilityService}.
17018643aa0179e598e78d938c59035389054535a229Svetoslav Ganov     *   This class is made immutable before being delivered to an AccessibilityService.
17028643aa0179e598e78d938c59035389054535a229Svetoslav Ganov     * </p>
170338e8b4e5bc3c93affdffbc064fd9db5aeccc3e8eSvetoslav Ganov     *
17048643aa0179e598e78d938c59035389054535a229Svetoslav Ganov     * @param enabled True if the node is enabled.
17058643aa0179e598e78d938c59035389054535a229Svetoslav Ganov     *
17068643aa0179e598e78d938c59035389054535a229Svetoslav Ganov     * @throws IllegalStateException If called from an AccessibilityService.
17078643aa0179e598e78d938c59035389054535a229Svetoslav Ganov     */
17088643aa0179e598e78d938c59035389054535a229Svetoslav Ganov    public void setEnabled(boolean enabled) {
1709bcc46a0d037e62fcb5e5f0f5e1acef5a8c1314b0Svetoslav        setBooleanProperty(BOOLEAN_PROPERTY_ENABLED, enabled);
17108643aa0179e598e78d938c59035389054535a229Svetoslav Ganov    }
17118643aa0179e598e78d938c59035389054535a229Svetoslav Ganov
17128643aa0179e598e78d938c59035389054535a229Svetoslav Ganov    /**
17138643aa0179e598e78d938c59035389054535a229Svetoslav Ganov     * Gets whether this node is a password.
17148643aa0179e598e78d938c59035389054535a229Svetoslav Ganov     *
17158643aa0179e598e78d938c59035389054535a229Svetoslav Ganov     * @return True if the node is a password.
17168643aa0179e598e78d938c59035389054535a229Svetoslav Ganov     */
17178643aa0179e598e78d938c59035389054535a229Svetoslav Ganov    public boolean isPassword() {
1718bcc46a0d037e62fcb5e5f0f5e1acef5a8c1314b0Svetoslav        return getBooleanProperty(BOOLEAN_PROPERTY_PASSWORD);
17198643aa0179e598e78d938c59035389054535a229Svetoslav Ganov    }
17208643aa0179e598e78d938c59035389054535a229Svetoslav Ganov
17218643aa0179e598e78d938c59035389054535a229Svetoslav Ganov    /**
17228643aa0179e598e78d938c59035389054535a229Svetoslav Ganov     * Sets whether this node is a password.
17238643aa0179e598e78d938c59035389054535a229Svetoslav Ganov     * <p>
172438e8b4e5bc3c93affdffbc064fd9db5aeccc3e8eSvetoslav Ganov     *   <strong>Note:</strong> Cannot be called from an
172538e8b4e5bc3c93affdffbc064fd9db5aeccc3e8eSvetoslav Ganov     *   {@link android.accessibilityservice.AccessibilityService}.
17268643aa0179e598e78d938c59035389054535a229Svetoslav Ganov     *   This class is made immutable before being delivered to an AccessibilityService.
17278643aa0179e598e78d938c59035389054535a229Svetoslav Ganov     * </p>
172838e8b4e5bc3c93affdffbc064fd9db5aeccc3e8eSvetoslav Ganov     *
17298643aa0179e598e78d938c59035389054535a229Svetoslav Ganov     * @param password True if the node is a password.
17308643aa0179e598e78d938c59035389054535a229Svetoslav Ganov     *
17318643aa0179e598e78d938c59035389054535a229Svetoslav Ganov     * @throws IllegalStateException If called from an AccessibilityService.
17328643aa0179e598e78d938c59035389054535a229Svetoslav Ganov     */
17338643aa0179e598e78d938c59035389054535a229Svetoslav Ganov    public void setPassword(boolean password) {
1734bcc46a0d037e62fcb5e5f0f5e1acef5a8c1314b0Svetoslav        setBooleanProperty(BOOLEAN_PROPERTY_PASSWORD, password);
17358643aa0179e598e78d938c59035389054535a229Svetoslav Ganov    }
17368643aa0179e598e78d938c59035389054535a229Svetoslav Ganov
17378643aa0179e598e78d938c59035389054535a229Svetoslav Ganov    /**
1738a0156177cdc809795dd8bc5a19943dd2b6f82b66Svetoslav Ganov     * Gets if the node is scrollable.
1739a0156177cdc809795dd8bc5a19943dd2b6f82b66Svetoslav Ganov     *
1740a0156177cdc809795dd8bc5a19943dd2b6f82b66Svetoslav Ganov     * @return True if the node is scrollable, false otherwise.
1741a0156177cdc809795dd8bc5a19943dd2b6f82b66Svetoslav Ganov     */
1742a0156177cdc809795dd8bc5a19943dd2b6f82b66Svetoslav Ganov    public boolean isScrollable() {
1743bcc46a0d037e62fcb5e5f0f5e1acef5a8c1314b0Svetoslav        return getBooleanProperty(BOOLEAN_PROPERTY_SCROLLABLE);
1744a0156177cdc809795dd8bc5a19943dd2b6f82b66Svetoslav Ganov    }
1745a0156177cdc809795dd8bc5a19943dd2b6f82b66Svetoslav Ganov
1746a0156177cdc809795dd8bc5a19943dd2b6f82b66Svetoslav Ganov    /**
1747a0156177cdc809795dd8bc5a19943dd2b6f82b66Svetoslav Ganov     * Sets if the node is scrollable.
174838e8b4e5bc3c93affdffbc064fd9db5aeccc3e8eSvetoslav Ganov     * <p>
174938e8b4e5bc3c93affdffbc064fd9db5aeccc3e8eSvetoslav Ganov     *   <strong>Note:</strong> Cannot be called from an
175038e8b4e5bc3c93affdffbc064fd9db5aeccc3e8eSvetoslav Ganov     *   {@link android.accessibilityservice.AccessibilityService}.
175138e8b4e5bc3c93affdffbc064fd9db5aeccc3e8eSvetoslav Ganov     *   This class is made immutable before being delivered to an AccessibilityService.
175238e8b4e5bc3c93affdffbc064fd9db5aeccc3e8eSvetoslav Ganov     * </p>
1753a0156177cdc809795dd8bc5a19943dd2b6f82b66Svetoslav Ganov     *
1754a0156177cdc809795dd8bc5a19943dd2b6f82b66Svetoslav Ganov     * @param scrollable True if the node is scrollable, false otherwise.
1755a0156177cdc809795dd8bc5a19943dd2b6f82b66Svetoslav Ganov     *
1756a0156177cdc809795dd8bc5a19943dd2b6f82b66Svetoslav Ganov     * @throws IllegalStateException If called from an AccessibilityService.
1757a0156177cdc809795dd8bc5a19943dd2b6f82b66Svetoslav Ganov     */
1758a0156177cdc809795dd8bc5a19943dd2b6f82b66Svetoslav Ganov    public void setScrollable(boolean scrollable) {
1759bcc46a0d037e62fcb5e5f0f5e1acef5a8c1314b0Svetoslav        setBooleanProperty(BOOLEAN_PROPERTY_SCROLLABLE, scrollable);
1760bcc46a0d037e62fcb5e5f0f5e1acef5a8c1314b0Svetoslav    }
1761bcc46a0d037e62fcb5e5f0f5e1acef5a8c1314b0Svetoslav
1762bcc46a0d037e62fcb5e5f0f5e1acef5a8c1314b0Svetoslav    /**
1763bcc46a0d037e62fcb5e5f0f5e1acef5a8c1314b0Svetoslav     * Gets if the node is editable.
1764bcc46a0d037e62fcb5e5f0f5e1acef5a8c1314b0Svetoslav     *
1765bcc46a0d037e62fcb5e5f0f5e1acef5a8c1314b0Svetoslav     * @return True if the node is editable, false otherwise.
1766bcc46a0d037e62fcb5e5f0f5e1acef5a8c1314b0Svetoslav     */
1767bcc46a0d037e62fcb5e5f0f5e1acef5a8c1314b0Svetoslav    public boolean isEditable() {
1768bcc46a0d037e62fcb5e5f0f5e1acef5a8c1314b0Svetoslav        return getBooleanProperty(BOOLEAN_PROPERTY_EDITABLE);
1769bcc46a0d037e62fcb5e5f0f5e1acef5a8c1314b0Svetoslav    }
1770bcc46a0d037e62fcb5e5f0f5e1acef5a8c1314b0Svetoslav
1771bcc46a0d037e62fcb5e5f0f5e1acef5a8c1314b0Svetoslav    /**
1772bcc46a0d037e62fcb5e5f0f5e1acef5a8c1314b0Svetoslav     * Sets whether this node is editable.
1773bcc46a0d037e62fcb5e5f0f5e1acef5a8c1314b0Svetoslav     * <p>
1774bcc46a0d037e62fcb5e5f0f5e1acef5a8c1314b0Svetoslav     *   <strong>Note:</strong> Cannot be called from an
1775bcc46a0d037e62fcb5e5f0f5e1acef5a8c1314b0Svetoslav     *   {@link android.accessibilityservice.AccessibilityService}.
1776bcc46a0d037e62fcb5e5f0f5e1acef5a8c1314b0Svetoslav     *   This class is made immutable before being delivered to an AccessibilityService.
1777bcc46a0d037e62fcb5e5f0f5e1acef5a8c1314b0Svetoslav     * </p>
1778bcc46a0d037e62fcb5e5f0f5e1acef5a8c1314b0Svetoslav     *
1779bcc46a0d037e62fcb5e5f0f5e1acef5a8c1314b0Svetoslav     * @param editable True if the node is editable.
1780bcc46a0d037e62fcb5e5f0f5e1acef5a8c1314b0Svetoslav     *
1781bcc46a0d037e62fcb5e5f0f5e1acef5a8c1314b0Svetoslav     * @throws IllegalStateException If called from an AccessibilityService.
1782bcc46a0d037e62fcb5e5f0f5e1acef5a8c1314b0Svetoslav     */
1783bcc46a0d037e62fcb5e5f0f5e1acef5a8c1314b0Svetoslav    public void setEditable(boolean editable) {
1784bcc46a0d037e62fcb5e5f0f5e1acef5a8c1314b0Svetoslav        setBooleanProperty(BOOLEAN_PROPERTY_EDITABLE, editable);
1785a0156177cdc809795dd8bc5a19943dd2b6f82b66Svetoslav Ganov    }
1786a0156177cdc809795dd8bc5a19943dd2b6f82b66Svetoslav Ganov
1787a0156177cdc809795dd8bc5a19943dd2b6f82b66Svetoslav Ganov    /**
17883577a283e1af3e14fe980c4fec55781a58cd8e3cSvetoslav     * Gets the collection info if the node is a collection. A collection
17893577a283e1af3e14fe980c4fec55781a58cd8e3cSvetoslav     * child is always a collection item.
17903577a283e1af3e14fe980c4fec55781a58cd8e3cSvetoslav     *
17913577a283e1af3e14fe980c4fec55781a58cd8e3cSvetoslav     * @return The collection info.
17923577a283e1af3e14fe980c4fec55781a58cd8e3cSvetoslav     */
17933577a283e1af3e14fe980c4fec55781a58cd8e3cSvetoslav    public CollectionInfo getCollectionInfo() {
17943577a283e1af3e14fe980c4fec55781a58cd8e3cSvetoslav        return mCollectionInfo;
17953577a283e1af3e14fe980c4fec55781a58cd8e3cSvetoslav    }
17963577a283e1af3e14fe980c4fec55781a58cd8e3cSvetoslav
17973577a283e1af3e14fe980c4fec55781a58cd8e3cSvetoslav    /**
17983577a283e1af3e14fe980c4fec55781a58cd8e3cSvetoslav     * Sets the collection info if the node is a collection. A collection
17993577a283e1af3e14fe980c4fec55781a58cd8e3cSvetoslav     * child is always a collection item.
18003577a283e1af3e14fe980c4fec55781a58cd8e3cSvetoslav     * <p>
18013577a283e1af3e14fe980c4fec55781a58cd8e3cSvetoslav     *   <strong>Note:</strong> Cannot be called from an
18023577a283e1af3e14fe980c4fec55781a58cd8e3cSvetoslav     *   {@link android.accessibilityservice.AccessibilityService}.
18033577a283e1af3e14fe980c4fec55781a58cd8e3cSvetoslav     *   This class is made immutable before being delivered to an AccessibilityService.
18043577a283e1af3e14fe980c4fec55781a58cd8e3cSvetoslav     * </p>
18053577a283e1af3e14fe980c4fec55781a58cd8e3cSvetoslav     *
18063577a283e1af3e14fe980c4fec55781a58cd8e3cSvetoslav     * @param collectionInfo The collection info.
18073577a283e1af3e14fe980c4fec55781a58cd8e3cSvetoslav     */
18083577a283e1af3e14fe980c4fec55781a58cd8e3cSvetoslav    public void setCollectionInfo(CollectionInfo collectionInfo) {
18093577a283e1af3e14fe980c4fec55781a58cd8e3cSvetoslav        enforceNotSealed();
18103577a283e1af3e14fe980c4fec55781a58cd8e3cSvetoslav        mCollectionInfo = collectionInfo;
18113577a283e1af3e14fe980c4fec55781a58cd8e3cSvetoslav    }
18123577a283e1af3e14fe980c4fec55781a58cd8e3cSvetoslav
18133577a283e1af3e14fe980c4fec55781a58cd8e3cSvetoslav    /**
18143577a283e1af3e14fe980c4fec55781a58cd8e3cSvetoslav     * Gets the collection item info if the node is a collection item. A collection
18153577a283e1af3e14fe980c4fec55781a58cd8e3cSvetoslav     * item is always a child of a collection.
18163577a283e1af3e14fe980c4fec55781a58cd8e3cSvetoslav     *
18173577a283e1af3e14fe980c4fec55781a58cd8e3cSvetoslav     * @return The collection item info.
18183577a283e1af3e14fe980c4fec55781a58cd8e3cSvetoslav     */
18193577a283e1af3e14fe980c4fec55781a58cd8e3cSvetoslav    public CollectionItemInfo getCollectionItemInfo() {
18203577a283e1af3e14fe980c4fec55781a58cd8e3cSvetoslav        return mCollectionItemInfo;
18213577a283e1af3e14fe980c4fec55781a58cd8e3cSvetoslav    }
18223577a283e1af3e14fe980c4fec55781a58cd8e3cSvetoslav
18233577a283e1af3e14fe980c4fec55781a58cd8e3cSvetoslav    /**
18243577a283e1af3e14fe980c4fec55781a58cd8e3cSvetoslav     * Sets the collection item info if the node is a collection item. A collection
18253577a283e1af3e14fe980c4fec55781a58cd8e3cSvetoslav     * item is always a child of a collection.
18263577a283e1af3e14fe980c4fec55781a58cd8e3cSvetoslav     * <p>
18273577a283e1af3e14fe980c4fec55781a58cd8e3cSvetoslav     *   <strong>Note:</strong> Cannot be called from an
18283577a283e1af3e14fe980c4fec55781a58cd8e3cSvetoslav     *   {@link android.accessibilityservice.AccessibilityService}.
18293577a283e1af3e14fe980c4fec55781a58cd8e3cSvetoslav     *   This class is made immutable before being delivered to an AccessibilityService.
18303577a283e1af3e14fe980c4fec55781a58cd8e3cSvetoslav     * </p>
18313577a283e1af3e14fe980c4fec55781a58cd8e3cSvetoslav     */
18323577a283e1af3e14fe980c4fec55781a58cd8e3cSvetoslav    public void setCollectionItemInfo(CollectionItemInfo collectionItemInfo) {
18333577a283e1af3e14fe980c4fec55781a58cd8e3cSvetoslav        enforceNotSealed();
18343577a283e1af3e14fe980c4fec55781a58cd8e3cSvetoslav        mCollectionItemInfo = collectionItemInfo;
18353577a283e1af3e14fe980c4fec55781a58cd8e3cSvetoslav    }
18363577a283e1af3e14fe980c4fec55781a58cd8e3cSvetoslav
18373577a283e1af3e14fe980c4fec55781a58cd8e3cSvetoslav    /**
18383577a283e1af3e14fe980c4fec55781a58cd8e3cSvetoslav     * Gets the range info if this node is a range.
18393577a283e1af3e14fe980c4fec55781a58cd8e3cSvetoslav     *
18403577a283e1af3e14fe980c4fec55781a58cd8e3cSvetoslav     * @return The range.
18413577a283e1af3e14fe980c4fec55781a58cd8e3cSvetoslav     */
18423577a283e1af3e14fe980c4fec55781a58cd8e3cSvetoslav    public RangeInfo getRangeInfo() {
18433577a283e1af3e14fe980c4fec55781a58cd8e3cSvetoslav        return mRangeInfo;
18443577a283e1af3e14fe980c4fec55781a58cd8e3cSvetoslav    }
18453577a283e1af3e14fe980c4fec55781a58cd8e3cSvetoslav
18463577a283e1af3e14fe980c4fec55781a58cd8e3cSvetoslav    /**
18473577a283e1af3e14fe980c4fec55781a58cd8e3cSvetoslav     * Sets the range info if this node is a range.
18483577a283e1af3e14fe980c4fec55781a58cd8e3cSvetoslav     * <p>
18493577a283e1af3e14fe980c4fec55781a58cd8e3cSvetoslav     *   <strong>Note:</strong> Cannot be called from an
18503577a283e1af3e14fe980c4fec55781a58cd8e3cSvetoslav     *   {@link android.accessibilityservice.AccessibilityService}.
18513577a283e1af3e14fe980c4fec55781a58cd8e3cSvetoslav     *   This class is made immutable before being delivered to an AccessibilityService.
18523577a283e1af3e14fe980c4fec55781a58cd8e3cSvetoslav     * </p>
18533577a283e1af3e14fe980c4fec55781a58cd8e3cSvetoslav     *
18543577a283e1af3e14fe980c4fec55781a58cd8e3cSvetoslav     * @param rangeInfo The range info.
18553577a283e1af3e14fe980c4fec55781a58cd8e3cSvetoslav     */
18563577a283e1af3e14fe980c4fec55781a58cd8e3cSvetoslav    public void setRangeInfo(RangeInfo rangeInfo) {
18573577a283e1af3e14fe980c4fec55781a58cd8e3cSvetoslav        enforceNotSealed();
18583577a283e1af3e14fe980c4fec55781a58cd8e3cSvetoslav        mRangeInfo = rangeInfo;
18593577a283e1af3e14fe980c4fec55781a58cd8e3cSvetoslav    }
18603577a283e1af3e14fe980c4fec55781a58cd8e3cSvetoslav
18613577a283e1af3e14fe980c4fec55781a58cd8e3cSvetoslav    /**
18623577a283e1af3e14fe980c4fec55781a58cd8e3cSvetoslav     * Gets if the content of this node is invalid. For example,
18633577a283e1af3e14fe980c4fec55781a58cd8e3cSvetoslav     * a date is not well-formed.
18643577a283e1af3e14fe980c4fec55781a58cd8e3cSvetoslav     *
18653577a283e1af3e14fe980c4fec55781a58cd8e3cSvetoslav     * @return If the node content is invalid.
18663577a283e1af3e14fe980c4fec55781a58cd8e3cSvetoslav     */
18673577a283e1af3e14fe980c4fec55781a58cd8e3cSvetoslav    public boolean isContentInvalid() {
18683577a283e1af3e14fe980c4fec55781a58cd8e3cSvetoslav        return getBooleanProperty(BOOLEAN_PROPERTY_CONTENT_INVALID);
18693577a283e1af3e14fe980c4fec55781a58cd8e3cSvetoslav    }
18703577a283e1af3e14fe980c4fec55781a58cd8e3cSvetoslav
18713577a283e1af3e14fe980c4fec55781a58cd8e3cSvetoslav    /**
18723577a283e1af3e14fe980c4fec55781a58cd8e3cSvetoslav     * Sets if the content of this node is invalid. For example,
18733577a283e1af3e14fe980c4fec55781a58cd8e3cSvetoslav     * a date is not well-formed.
18743577a283e1af3e14fe980c4fec55781a58cd8e3cSvetoslav     * <p>
18753577a283e1af3e14fe980c4fec55781a58cd8e3cSvetoslav     *   <strong>Note:</strong> Cannot be called from an
18763577a283e1af3e14fe980c4fec55781a58cd8e3cSvetoslav     *   {@link android.accessibilityservice.AccessibilityService}.
18773577a283e1af3e14fe980c4fec55781a58cd8e3cSvetoslav     *   This class is made immutable before being delivered to an AccessibilityService.
18783577a283e1af3e14fe980c4fec55781a58cd8e3cSvetoslav     * </p>
18793577a283e1af3e14fe980c4fec55781a58cd8e3cSvetoslav     *
18803577a283e1af3e14fe980c4fec55781a58cd8e3cSvetoslav     * @param contentInvalid If the node content is invalid.
18813577a283e1af3e14fe980c4fec55781a58cd8e3cSvetoslav     */
18823577a283e1af3e14fe980c4fec55781a58cd8e3cSvetoslav    public void setContentInvalid(boolean contentInvalid) {
18833577a283e1af3e14fe980c4fec55781a58cd8e3cSvetoslav        setBooleanProperty(BOOLEAN_PROPERTY_CONTENT_INVALID, contentInvalid);
18843577a283e1af3e14fe980c4fec55781a58cd8e3cSvetoslav    }
18853577a283e1af3e14fe980c4fec55781a58cd8e3cSvetoslav
18863577a283e1af3e14fe980c4fec55781a58cd8e3cSvetoslav    /**
188777e9a28e2faa36f127231b842476d47f9823a83aAlan Viverette     * Gets the node's live region mode.
1888cb8ed39b3fb591be60b9fb1799d4ea4530eab758Svetoslav Ganov     * <p>
188977e9a28e2faa36f127231b842476d47f9823a83aAlan Viverette     * A live region is a node that contains information that is important for
189077e9a28e2faa36f127231b842476d47f9823a83aAlan Viverette     * the user and when it changes the user should be notified. For example,
189177e9a28e2faa36f127231b842476d47f9823a83aAlan Viverette     * in a login screen with a TextView that displays an "incorrect password"
189277e9a28e2faa36f127231b842476d47f9823a83aAlan Viverette     * notification, that view should be marked as a live region with mode
189377e9a28e2faa36f127231b842476d47f9823a83aAlan Viverette     * {@link View#ACCESSIBILITY_LIVE_REGION_POLITE}.
1894cb8ed39b3fb591be60b9fb1799d4ea4530eab758Svetoslav Ganov     * <p>
189577e9a28e2faa36f127231b842476d47f9823a83aAlan Viverette     * It is the responsibility of the accessibility service to monitor
189677e9a28e2faa36f127231b842476d47f9823a83aAlan Viverette     * {@link AccessibilityEvent#TYPE_WINDOW_CONTENT_CHANGED} events indicating
189777e9a28e2faa36f127231b842476d47f9823a83aAlan Viverette     * changes to live region nodes and their children.
18983577a283e1af3e14fe980c4fec55781a58cd8e3cSvetoslav     *
189977e9a28e2faa36f127231b842476d47f9823a83aAlan Viverette     * @return The live region mode, or
190077e9a28e2faa36f127231b842476d47f9823a83aAlan Viverette     *         {@link View#ACCESSIBILITY_LIVE_REGION_NONE} if the view is not a
190177e9a28e2faa36f127231b842476d47f9823a83aAlan Viverette     *         live region.
190277e9a28e2faa36f127231b842476d47f9823a83aAlan Viverette     * @see android.view.View#getAccessibilityLiveRegion()
19033577a283e1af3e14fe980c4fec55781a58cd8e3cSvetoslav     */
190477e9a28e2faa36f127231b842476d47f9823a83aAlan Viverette    public int getLiveRegion() {
190577e9a28e2faa36f127231b842476d47f9823a83aAlan Viverette        return mLiveRegion;
19063577a283e1af3e14fe980c4fec55781a58cd8e3cSvetoslav    }
19073577a283e1af3e14fe980c4fec55781a58cd8e3cSvetoslav
19083577a283e1af3e14fe980c4fec55781a58cd8e3cSvetoslav    /**
190977e9a28e2faa36f127231b842476d47f9823a83aAlan Viverette     * Sets the node's live region mode.
19103577a283e1af3e14fe980c4fec55781a58cd8e3cSvetoslav     * <p>
191177e9a28e2faa36f127231b842476d47f9823a83aAlan Viverette     * <strong>Note:</strong> Cannot be called from an
191277e9a28e2faa36f127231b842476d47f9823a83aAlan Viverette     * {@link android.accessibilityservice.AccessibilityService}. This class is
191377e9a28e2faa36f127231b842476d47f9823a83aAlan Viverette     * made immutable before being delivered to an AccessibilityService.
19143577a283e1af3e14fe980c4fec55781a58cd8e3cSvetoslav     *
191577e9a28e2faa36f127231b842476d47f9823a83aAlan Viverette     * @param mode The live region mode, or
191677e9a28e2faa36f127231b842476d47f9823a83aAlan Viverette     *        {@link View#ACCESSIBILITY_LIVE_REGION_NONE} if the view is not a
191777e9a28e2faa36f127231b842476d47f9823a83aAlan Viverette     *        live region.
191877e9a28e2faa36f127231b842476d47f9823a83aAlan Viverette     * @see android.view.View#setAccessibilityLiveRegion(int)
19193577a283e1af3e14fe980c4fec55781a58cd8e3cSvetoslav     */
192077e9a28e2faa36f127231b842476d47f9823a83aAlan Viverette    public void setLiveRegion(int mode) {
192177e9a28e2faa36f127231b842476d47f9823a83aAlan Viverette        enforceNotSealed();
192277e9a28e2faa36f127231b842476d47f9823a83aAlan Viverette        mLiveRegion = mode;
19233577a283e1af3e14fe980c4fec55781a58cd8e3cSvetoslav    }
19243577a283e1af3e14fe980c4fec55781a58cd8e3cSvetoslav
19253577a283e1af3e14fe980c4fec55781a58cd8e3cSvetoslav    /**
19263577a283e1af3e14fe980c4fec55781a58cd8e3cSvetoslav     * Gets if the node is a multi line editable text.
19273577a283e1af3e14fe980c4fec55781a58cd8e3cSvetoslav     *
19283577a283e1af3e14fe980c4fec55781a58cd8e3cSvetoslav     * @return True if the node is multi line.
19293577a283e1af3e14fe980c4fec55781a58cd8e3cSvetoslav     */
19303577a283e1af3e14fe980c4fec55781a58cd8e3cSvetoslav    public boolean isMultiLine() {
19313577a283e1af3e14fe980c4fec55781a58cd8e3cSvetoslav        return getBooleanProperty(BOOLEAN_PROPERTY_MULTI_LINE);
19323577a283e1af3e14fe980c4fec55781a58cd8e3cSvetoslav    }
19333577a283e1af3e14fe980c4fec55781a58cd8e3cSvetoslav
19343577a283e1af3e14fe980c4fec55781a58cd8e3cSvetoslav    /**
19353577a283e1af3e14fe980c4fec55781a58cd8e3cSvetoslav     * Sets if the node is a multi line editable text.
19363577a283e1af3e14fe980c4fec55781a58cd8e3cSvetoslav     * <p>
19373577a283e1af3e14fe980c4fec55781a58cd8e3cSvetoslav     *   <strong>Note:</strong> Cannot be called from an
19383577a283e1af3e14fe980c4fec55781a58cd8e3cSvetoslav     *   {@link android.accessibilityservice.AccessibilityService}.
19393577a283e1af3e14fe980c4fec55781a58cd8e3cSvetoslav     *   This class is made immutable before being delivered to an AccessibilityService.
19403577a283e1af3e14fe980c4fec55781a58cd8e3cSvetoslav     * </p>
19413577a283e1af3e14fe980c4fec55781a58cd8e3cSvetoslav     *
19423577a283e1af3e14fe980c4fec55781a58cd8e3cSvetoslav     * @param multiLine True if the node is multi line.
19433577a283e1af3e14fe980c4fec55781a58cd8e3cSvetoslav     */
19443577a283e1af3e14fe980c4fec55781a58cd8e3cSvetoslav    public void setMultiLine(boolean multiLine) {
19453577a283e1af3e14fe980c4fec55781a58cd8e3cSvetoslav        setBooleanProperty(BOOLEAN_PROPERTY_MULTI_LINE, multiLine);
19463577a283e1af3e14fe980c4fec55781a58cd8e3cSvetoslav    }
19473577a283e1af3e14fe980c4fec55781a58cd8e3cSvetoslav
19483577a283e1af3e14fe980c4fec55781a58cd8e3cSvetoslav    /**
19493577a283e1af3e14fe980c4fec55781a58cd8e3cSvetoslav     * Gets if this node opens a popup or a dialog.
19503577a283e1af3e14fe980c4fec55781a58cd8e3cSvetoslav     *
19513577a283e1af3e14fe980c4fec55781a58cd8e3cSvetoslav     * @return If the the node opens a popup.
19523577a283e1af3e14fe980c4fec55781a58cd8e3cSvetoslav     */
1953cb8ed39b3fb591be60b9fb1799d4ea4530eab758Svetoslav Ganov    public boolean canOpenPopup() {
19543577a283e1af3e14fe980c4fec55781a58cd8e3cSvetoslav        return getBooleanProperty(BOOLEAN_PROPERTY_OPENS_POPUP);
19553577a283e1af3e14fe980c4fec55781a58cd8e3cSvetoslav    }
19563577a283e1af3e14fe980c4fec55781a58cd8e3cSvetoslav
19573577a283e1af3e14fe980c4fec55781a58cd8e3cSvetoslav    /**
19583577a283e1af3e14fe980c4fec55781a58cd8e3cSvetoslav     * Sets if this node opens a popup or a dialog.
19593577a283e1af3e14fe980c4fec55781a58cd8e3cSvetoslav     * <p>
19603577a283e1af3e14fe980c4fec55781a58cd8e3cSvetoslav     *   <strong>Note:</strong> Cannot be called from an
19613577a283e1af3e14fe980c4fec55781a58cd8e3cSvetoslav     *   {@link android.accessibilityservice.AccessibilityService}.
19623577a283e1af3e14fe980c4fec55781a58cd8e3cSvetoslav     *   This class is made immutable before being delivered to an AccessibilityService.
19633577a283e1af3e14fe980c4fec55781a58cd8e3cSvetoslav     * </p>
19643577a283e1af3e14fe980c4fec55781a58cd8e3cSvetoslav     *
19653577a283e1af3e14fe980c4fec55781a58cd8e3cSvetoslav     * @param opensPopup If the the node opens a popup.
19663577a283e1af3e14fe980c4fec55781a58cd8e3cSvetoslav     */
1967cb8ed39b3fb591be60b9fb1799d4ea4530eab758Svetoslav Ganov    public void setCanOpenPopup(boolean opensPopup) {
1968cb8ed39b3fb591be60b9fb1799d4ea4530eab758Svetoslav Ganov        enforceNotSealed();
19693577a283e1af3e14fe980c4fec55781a58cd8e3cSvetoslav        setBooleanProperty(BOOLEAN_PROPERTY_OPENS_POPUP, opensPopup);
19703577a283e1af3e14fe980c4fec55781a58cd8e3cSvetoslav    }
19713577a283e1af3e14fe980c4fec55781a58cd8e3cSvetoslav
19723577a283e1af3e14fe980c4fec55781a58cd8e3cSvetoslav    /**
19733577a283e1af3e14fe980c4fec55781a58cd8e3cSvetoslav     * Gets if the node can be dismissed.
19743577a283e1af3e14fe980c4fec55781a58cd8e3cSvetoslav     *
19753577a283e1af3e14fe980c4fec55781a58cd8e3cSvetoslav     * @return If the node can be dismissed.
19763577a283e1af3e14fe980c4fec55781a58cd8e3cSvetoslav     */
19773577a283e1af3e14fe980c4fec55781a58cd8e3cSvetoslav    public boolean isDismissable() {
19783577a283e1af3e14fe980c4fec55781a58cd8e3cSvetoslav        return getBooleanProperty(BOOLEAN_PROPERTY_DISMISSABLE);
19793577a283e1af3e14fe980c4fec55781a58cd8e3cSvetoslav    }
19803577a283e1af3e14fe980c4fec55781a58cd8e3cSvetoslav
19813577a283e1af3e14fe980c4fec55781a58cd8e3cSvetoslav    /**
19823577a283e1af3e14fe980c4fec55781a58cd8e3cSvetoslav     * Sets if the node can be dismissed.
19833577a283e1af3e14fe980c4fec55781a58cd8e3cSvetoslav     * <p>
19843577a283e1af3e14fe980c4fec55781a58cd8e3cSvetoslav     *   <strong>Note:</strong> Cannot be called from an
19853577a283e1af3e14fe980c4fec55781a58cd8e3cSvetoslav     *   {@link android.accessibilityservice.AccessibilityService}.
19863577a283e1af3e14fe980c4fec55781a58cd8e3cSvetoslav     *   This class is made immutable before being delivered to an AccessibilityService.
19873577a283e1af3e14fe980c4fec55781a58cd8e3cSvetoslav     * </p>
19883577a283e1af3e14fe980c4fec55781a58cd8e3cSvetoslav     *
19893577a283e1af3e14fe980c4fec55781a58cd8e3cSvetoslav     * @param dismissable If the node can be dismissed.
19903577a283e1af3e14fe980c4fec55781a58cd8e3cSvetoslav     */
19913577a283e1af3e14fe980c4fec55781a58cd8e3cSvetoslav    public void setDismissable(boolean dismissable) {
19923577a283e1af3e14fe980c4fec55781a58cd8e3cSvetoslav        setBooleanProperty(BOOLEAN_PROPERTY_DISMISSABLE, dismissable);
19933577a283e1af3e14fe980c4fec55781a58cd8e3cSvetoslav    }
19943577a283e1af3e14fe980c4fec55781a58cd8e3cSvetoslav
19953577a283e1af3e14fe980c4fec55781a58cd8e3cSvetoslav    /**
19968643aa0179e598e78d938c59035389054535a229Svetoslav Ganov     * Gets the package this node comes from.
19978643aa0179e598e78d938c59035389054535a229Svetoslav Ganov     *
19988643aa0179e598e78d938c59035389054535a229Svetoslav Ganov     * @return The package name.
19998643aa0179e598e78d938c59035389054535a229Svetoslav Ganov     */
20008643aa0179e598e78d938c59035389054535a229Svetoslav Ganov    public CharSequence getPackageName() {
20018643aa0179e598e78d938c59035389054535a229Svetoslav Ganov        return mPackageName;
20028643aa0179e598e78d938c59035389054535a229Svetoslav Ganov    }
20038643aa0179e598e78d938c59035389054535a229Svetoslav Ganov
20048643aa0179e598e78d938c59035389054535a229Svetoslav Ganov    /**
20058643aa0179e598e78d938c59035389054535a229Svetoslav Ganov     * Sets the package this node comes from.
20068643aa0179e598e78d938c59035389054535a229Svetoslav Ganov     * <p>
200738e8b4e5bc3c93affdffbc064fd9db5aeccc3e8eSvetoslav Ganov     *   <strong>Note:</strong> Cannot be called from an
200838e8b4e5bc3c93affdffbc064fd9db5aeccc3e8eSvetoslav Ganov     *   {@link android.accessibilityservice.AccessibilityService}.
20098643aa0179e598e78d938c59035389054535a229Svetoslav Ganov     *   This class is made immutable before being delivered to an AccessibilityService.
20108643aa0179e598e78d938c59035389054535a229Svetoslav Ganov     * </p>
201138e8b4e5bc3c93affdffbc064fd9db5aeccc3e8eSvetoslav Ganov     *
20128643aa0179e598e78d938c59035389054535a229Svetoslav Ganov     * @param packageName The package name.
20138643aa0179e598e78d938c59035389054535a229Svetoslav Ganov     *
20148643aa0179e598e78d938c59035389054535a229Svetoslav Ganov     * @throws IllegalStateException If called from an AccessibilityService.
20158643aa0179e598e78d938c59035389054535a229Svetoslav Ganov     */
20168643aa0179e598e78d938c59035389054535a229Svetoslav Ganov    public void setPackageName(CharSequence packageName) {
20178643aa0179e598e78d938c59035389054535a229Svetoslav Ganov        enforceNotSealed();
20188643aa0179e598e78d938c59035389054535a229Svetoslav Ganov        mPackageName = packageName;
20198643aa0179e598e78d938c59035389054535a229Svetoslav Ganov    }
20208643aa0179e598e78d938c59035389054535a229Svetoslav Ganov
20218643aa0179e598e78d938c59035389054535a229Svetoslav Ganov    /**
20228643aa0179e598e78d938c59035389054535a229Svetoslav Ganov     * Gets the class this node comes from.
20238643aa0179e598e78d938c59035389054535a229Svetoslav Ganov     *
20248643aa0179e598e78d938c59035389054535a229Svetoslav Ganov     * @return The class name.
20258643aa0179e598e78d938c59035389054535a229Svetoslav Ganov     */
20268643aa0179e598e78d938c59035389054535a229Svetoslav Ganov    public CharSequence getClassName() {
20278643aa0179e598e78d938c59035389054535a229Svetoslav Ganov        return mClassName;
20288643aa0179e598e78d938c59035389054535a229Svetoslav Ganov    }
20298643aa0179e598e78d938c59035389054535a229Svetoslav Ganov
20308643aa0179e598e78d938c59035389054535a229Svetoslav Ganov    /**
20318643aa0179e598e78d938c59035389054535a229Svetoslav Ganov     * Sets the class this node comes from.
20328643aa0179e598e78d938c59035389054535a229Svetoslav Ganov     * <p>
203338e8b4e5bc3c93affdffbc064fd9db5aeccc3e8eSvetoslav Ganov     *   <strong>Note:</strong> Cannot be called from an
203438e8b4e5bc3c93affdffbc064fd9db5aeccc3e8eSvetoslav Ganov     *   {@link android.accessibilityservice.AccessibilityService}.
20358643aa0179e598e78d938c59035389054535a229Svetoslav Ganov     *   This class is made immutable before being delivered to an AccessibilityService.
20368643aa0179e598e78d938c59035389054535a229Svetoslav Ganov     * </p>
203738e8b4e5bc3c93affdffbc064fd9db5aeccc3e8eSvetoslav Ganov     *
20388643aa0179e598e78d938c59035389054535a229Svetoslav Ganov     * @param className The class name.
20398643aa0179e598e78d938c59035389054535a229Svetoslav Ganov     *
20408643aa0179e598e78d938c59035389054535a229Svetoslav Ganov     * @throws IllegalStateException If called from an AccessibilityService.
20418643aa0179e598e78d938c59035389054535a229Svetoslav Ganov     */
20428643aa0179e598e78d938c59035389054535a229Svetoslav Ganov    public void setClassName(CharSequence className) {
20438643aa0179e598e78d938c59035389054535a229Svetoslav Ganov        enforceNotSealed();
20448643aa0179e598e78d938c59035389054535a229Svetoslav Ganov        mClassName = className;
20458643aa0179e598e78d938c59035389054535a229Svetoslav Ganov    }
20468643aa0179e598e78d938c59035389054535a229Svetoslav Ganov
20478643aa0179e598e78d938c59035389054535a229Svetoslav Ganov    /**
20488643aa0179e598e78d938c59035389054535a229Svetoslav Ganov     * Gets the text of this node.
20498643aa0179e598e78d938c59035389054535a229Svetoslav Ganov     *
20508643aa0179e598e78d938c59035389054535a229Svetoslav Ganov     * @return The text.
20518643aa0179e598e78d938c59035389054535a229Svetoslav Ganov     */
20528643aa0179e598e78d938c59035389054535a229Svetoslav Ganov    public CharSequence getText() {
20538643aa0179e598e78d938c59035389054535a229Svetoslav Ganov        return mText;
20548643aa0179e598e78d938c59035389054535a229Svetoslav Ganov    }
20558643aa0179e598e78d938c59035389054535a229Svetoslav Ganov
20568643aa0179e598e78d938c59035389054535a229Svetoslav Ganov    /**
20578643aa0179e598e78d938c59035389054535a229Svetoslav Ganov     * Sets the text of this node.
20588643aa0179e598e78d938c59035389054535a229Svetoslav Ganov     * <p>
205938e8b4e5bc3c93affdffbc064fd9db5aeccc3e8eSvetoslav Ganov     *   <strong>Note:</strong> Cannot be called from an
206038e8b4e5bc3c93affdffbc064fd9db5aeccc3e8eSvetoslav Ganov     *   {@link android.accessibilityservice.AccessibilityService}.
20618643aa0179e598e78d938c59035389054535a229Svetoslav Ganov     *   This class is made immutable before being delivered to an AccessibilityService.
20628643aa0179e598e78d938c59035389054535a229Svetoslav Ganov     * </p>
206338e8b4e5bc3c93affdffbc064fd9db5aeccc3e8eSvetoslav Ganov     *
20648643aa0179e598e78d938c59035389054535a229Svetoslav Ganov     * @param text The text.
20658643aa0179e598e78d938c59035389054535a229Svetoslav Ganov     *
20668643aa0179e598e78d938c59035389054535a229Svetoslav Ganov     * @throws IllegalStateException If called from an AccessibilityService.
20678643aa0179e598e78d938c59035389054535a229Svetoslav Ganov     */
20688643aa0179e598e78d938c59035389054535a229Svetoslav Ganov    public void setText(CharSequence text) {
20698643aa0179e598e78d938c59035389054535a229Svetoslav Ganov        enforceNotSealed();
20708643aa0179e598e78d938c59035389054535a229Svetoslav Ganov        mText = text;
20718643aa0179e598e78d938c59035389054535a229Svetoslav Ganov    }
20728643aa0179e598e78d938c59035389054535a229Svetoslav Ganov
20738643aa0179e598e78d938c59035389054535a229Svetoslav Ganov    /**
2074fccbff5f021a6f95fe1c18f55866545c767ef8ebAlan Viverette     * Sets the error text of this node.
2075fccbff5f021a6f95fe1c18f55866545c767ef8ebAlan Viverette     * <p>
2076fccbff5f021a6f95fe1c18f55866545c767ef8ebAlan Viverette     *   <strong>Note:</strong> Cannot be called from an
2077fccbff5f021a6f95fe1c18f55866545c767ef8ebAlan Viverette     *   {@link android.accessibilityservice.AccessibilityService}.
2078fccbff5f021a6f95fe1c18f55866545c767ef8ebAlan Viverette     *   This class is made immutable before being delivered to an AccessibilityService.
2079fccbff5f021a6f95fe1c18f55866545c767ef8ebAlan Viverette     * </p>
2080fccbff5f021a6f95fe1c18f55866545c767ef8ebAlan Viverette     *
2081fccbff5f021a6f95fe1c18f55866545c767ef8ebAlan Viverette     * @param error The error text.
2082fccbff5f021a6f95fe1c18f55866545c767ef8ebAlan Viverette     *
2083fccbff5f021a6f95fe1c18f55866545c767ef8ebAlan Viverette     * @throws IllegalStateException If called from an AccessibilityService.
2084fccbff5f021a6f95fe1c18f55866545c767ef8ebAlan Viverette     */
2085fccbff5f021a6f95fe1c18f55866545c767ef8ebAlan Viverette    public void setError(CharSequence error) {
2086fccbff5f021a6f95fe1c18f55866545c767ef8ebAlan Viverette        enforceNotSealed();
2087fccbff5f021a6f95fe1c18f55866545c767ef8ebAlan Viverette        mError = error;
2088fccbff5f021a6f95fe1c18f55866545c767ef8ebAlan Viverette    }
2089fccbff5f021a6f95fe1c18f55866545c767ef8ebAlan Viverette
2090fccbff5f021a6f95fe1c18f55866545c767ef8ebAlan Viverette    /**
2091fccbff5f021a6f95fe1c18f55866545c767ef8ebAlan Viverette     * Gets the error text of this node.
2092fccbff5f021a6f95fe1c18f55866545c767ef8ebAlan Viverette     *
2093fccbff5f021a6f95fe1c18f55866545c767ef8ebAlan Viverette     * @return The error text.
2094fccbff5f021a6f95fe1c18f55866545c767ef8ebAlan Viverette     */
2095fccbff5f021a6f95fe1c18f55866545c767ef8ebAlan Viverette    public CharSequence getError() {
2096fccbff5f021a6f95fe1c18f55866545c767ef8ebAlan Viverette        return mError;
2097fccbff5f021a6f95fe1c18f55866545c767ef8ebAlan Viverette    }
2098fccbff5f021a6f95fe1c18f55866545c767ef8ebAlan Viverette
2099fccbff5f021a6f95fe1c18f55866545c767ef8ebAlan Viverette    /**
21008643aa0179e598e78d938c59035389054535a229Svetoslav Ganov     * Gets the content description of this node.
21018643aa0179e598e78d938c59035389054535a229Svetoslav Ganov     *
21028643aa0179e598e78d938c59035389054535a229Svetoslav Ganov     * @return The content description.
21038643aa0179e598e78d938c59035389054535a229Svetoslav Ganov     */
21048643aa0179e598e78d938c59035389054535a229Svetoslav Ganov    public CharSequence getContentDescription() {
21058643aa0179e598e78d938c59035389054535a229Svetoslav Ganov        return mContentDescription;
21068643aa0179e598e78d938c59035389054535a229Svetoslav Ganov    }
21078643aa0179e598e78d938c59035389054535a229Svetoslav Ganov
21088643aa0179e598e78d938c59035389054535a229Svetoslav Ganov    /**
21098643aa0179e598e78d938c59035389054535a229Svetoslav Ganov     * Sets the content description of this node.
21108643aa0179e598e78d938c59035389054535a229Svetoslav Ganov     * <p>
211138e8b4e5bc3c93affdffbc064fd9db5aeccc3e8eSvetoslav Ganov     *   <strong>Note:</strong> Cannot be called from an
211238e8b4e5bc3c93affdffbc064fd9db5aeccc3e8eSvetoslav Ganov     *   {@link android.accessibilityservice.AccessibilityService}.
21138643aa0179e598e78d938c59035389054535a229Svetoslav Ganov     *   This class is made immutable before being delivered to an AccessibilityService.
21148643aa0179e598e78d938c59035389054535a229Svetoslav Ganov     * </p>
211538e8b4e5bc3c93affdffbc064fd9db5aeccc3e8eSvetoslav Ganov     *
21168643aa0179e598e78d938c59035389054535a229Svetoslav Ganov     * @param contentDescription The content description.
21178643aa0179e598e78d938c59035389054535a229Svetoslav Ganov     *
21188643aa0179e598e78d938c59035389054535a229Svetoslav Ganov     * @throws IllegalStateException If called from an AccessibilityService.
21198643aa0179e598e78d938c59035389054535a229Svetoslav Ganov     */
21208643aa0179e598e78d938c59035389054535a229Svetoslav Ganov    public void setContentDescription(CharSequence contentDescription) {
21218643aa0179e598e78d938c59035389054535a229Svetoslav Ganov        enforceNotSealed();
21228643aa0179e598e78d938c59035389054535a229Svetoslav Ganov        mContentDescription = contentDescription;
21238643aa0179e598e78d938c59035389054535a229Svetoslav Ganov    }
21248643aa0179e598e78d938c59035389054535a229Svetoslav Ganov
21258643aa0179e598e78d938c59035389054535a229Svetoslav Ganov    /**
212633aef98fd28dcac0a2ad37e7329afd3e666f5e0aSvetoslav Ganov     * Sets the view for which the view represented by this info serves as a
212733aef98fd28dcac0a2ad37e7329afd3e666f5e0aSvetoslav Ganov     * label for accessibility purposes.
212833aef98fd28dcac0a2ad37e7329afd3e666f5e0aSvetoslav Ganov     *
212933aef98fd28dcac0a2ad37e7329afd3e666f5e0aSvetoslav Ganov     * @param labeled The view for which this info serves as a label.
213033aef98fd28dcac0a2ad37e7329afd3e666f5e0aSvetoslav Ganov     */
213133aef98fd28dcac0a2ad37e7329afd3e666f5e0aSvetoslav Ganov    public void setLabelFor(View labeled) {
21328e3feb15c5aec2c72b0ef120a1da325e1e8f0ddaSvetoslav        setLabelFor(labeled, UNDEFINED_ITEM_ID);
213333aef98fd28dcac0a2ad37e7329afd3e666f5e0aSvetoslav Ganov    }
213433aef98fd28dcac0a2ad37e7329afd3e666f5e0aSvetoslav Ganov
213533aef98fd28dcac0a2ad37e7329afd3e666f5e0aSvetoslav Ganov    /**
213633aef98fd28dcac0a2ad37e7329afd3e666f5e0aSvetoslav Ganov     * Sets the view for which the view represented by this info serves as a
213733aef98fd28dcac0a2ad37e7329afd3e666f5e0aSvetoslav Ganov     * label for accessibility purposes. If <code>virtualDescendantId</code>
213833aef98fd28dcac0a2ad37e7329afd3e666f5e0aSvetoslav Ganov     * is {@link View#NO_ID} the root is set as the labeled.
213933aef98fd28dcac0a2ad37e7329afd3e666f5e0aSvetoslav Ganov     * <p>
214033aef98fd28dcac0a2ad37e7329afd3e666f5e0aSvetoslav Ganov     * A virtual descendant is an imaginary View that is reported as a part of the view
214133aef98fd28dcac0a2ad37e7329afd3e666f5e0aSvetoslav Ganov     * hierarchy for accessibility purposes. This enables custom views that draw complex
214233aef98fd28dcac0a2ad37e7329afd3e666f5e0aSvetoslav Ganov     * content to report themselves as a tree of virtual views, thus conveying their
214333aef98fd28dcac0a2ad37e7329afd3e666f5e0aSvetoslav Ganov     * logical structure.
214433aef98fd28dcac0a2ad37e7329afd3e666f5e0aSvetoslav Ganov     * </p>
214533aef98fd28dcac0a2ad37e7329afd3e666f5e0aSvetoslav Ganov     * <p>
214633aef98fd28dcac0a2ad37e7329afd3e666f5e0aSvetoslav Ganov     *   <strong>Note:</strong> Cannot be called from an
214733aef98fd28dcac0a2ad37e7329afd3e666f5e0aSvetoslav Ganov     *   {@link android.accessibilityservice.AccessibilityService}.
214833aef98fd28dcac0a2ad37e7329afd3e666f5e0aSvetoslav Ganov     *   This class is made immutable before being delivered to an AccessibilityService.
214933aef98fd28dcac0a2ad37e7329afd3e666f5e0aSvetoslav Ganov     * </p>
215033aef98fd28dcac0a2ad37e7329afd3e666f5e0aSvetoslav Ganov     *
215133aef98fd28dcac0a2ad37e7329afd3e666f5e0aSvetoslav Ganov     * @param root The root whose virtual descendant serves as a label.
215233aef98fd28dcac0a2ad37e7329afd3e666f5e0aSvetoslav Ganov     * @param virtualDescendantId The id of the virtual descendant.
215333aef98fd28dcac0a2ad37e7329afd3e666f5e0aSvetoslav Ganov     */
215433aef98fd28dcac0a2ad37e7329afd3e666f5e0aSvetoslav Ganov    public void setLabelFor(View root, int virtualDescendantId) {
215533aef98fd28dcac0a2ad37e7329afd3e666f5e0aSvetoslav Ganov        enforceNotSealed();
215633aef98fd28dcac0a2ad37e7329afd3e666f5e0aSvetoslav Ganov        final int rootAccessibilityViewId = (root != null)
21578e3feb15c5aec2c72b0ef120a1da325e1e8f0ddaSvetoslav                ? root.getAccessibilityViewId() : UNDEFINED_ITEM_ID;
215833aef98fd28dcac0a2ad37e7329afd3e666f5e0aSvetoslav Ganov        mLabelForId = makeNodeId(rootAccessibilityViewId, virtualDescendantId);
215933aef98fd28dcac0a2ad37e7329afd3e666f5e0aSvetoslav Ganov    }
216033aef98fd28dcac0a2ad37e7329afd3e666f5e0aSvetoslav Ganov
216133aef98fd28dcac0a2ad37e7329afd3e666f5e0aSvetoslav Ganov    /**
216233aef98fd28dcac0a2ad37e7329afd3e666f5e0aSvetoslav Ganov     * Gets the node info for which the view represented by this info serves as
216333aef98fd28dcac0a2ad37e7329afd3e666f5e0aSvetoslav Ganov     * a label for accessibility purposes.
216433aef98fd28dcac0a2ad37e7329afd3e666f5e0aSvetoslav Ganov     * <p>
216533aef98fd28dcac0a2ad37e7329afd3e666f5e0aSvetoslav Ganov     *   <strong>Note:</strong> It is a client responsibility to recycle the
216633aef98fd28dcac0a2ad37e7329afd3e666f5e0aSvetoslav Ganov     *     received info by calling {@link AccessibilityNodeInfo#recycle()}
216733aef98fd28dcac0a2ad37e7329afd3e666f5e0aSvetoslav Ganov     *     to avoid creating of multiple instances.
216833aef98fd28dcac0a2ad37e7329afd3e666f5e0aSvetoslav Ganov     * </p>
216933aef98fd28dcac0a2ad37e7329afd3e666f5e0aSvetoslav Ganov     *
217033aef98fd28dcac0a2ad37e7329afd3e666f5e0aSvetoslav Ganov     * @return The labeled info.
217133aef98fd28dcac0a2ad37e7329afd3e666f5e0aSvetoslav Ganov     */
217233aef98fd28dcac0a2ad37e7329afd3e666f5e0aSvetoslav Ganov    public AccessibilityNodeInfo getLabelFor() {
217333aef98fd28dcac0a2ad37e7329afd3e666f5e0aSvetoslav Ganov        enforceSealed();
21746c70290ff0b20329c8f173d5c3423eb83ddc46f1Svetoslav        return getNodeForAccessibilityId(mLabelForId);
217533aef98fd28dcac0a2ad37e7329afd3e666f5e0aSvetoslav Ganov    }
217633aef98fd28dcac0a2ad37e7329afd3e666f5e0aSvetoslav Ganov
217733aef98fd28dcac0a2ad37e7329afd3e666f5e0aSvetoslav Ganov    /**
217833aef98fd28dcac0a2ad37e7329afd3e666f5e0aSvetoslav Ganov     * Sets the view which serves as the label of the view represented by
217933aef98fd28dcac0a2ad37e7329afd3e666f5e0aSvetoslav Ganov     * this info for accessibility purposes.
218033aef98fd28dcac0a2ad37e7329afd3e666f5e0aSvetoslav Ganov     *
218133aef98fd28dcac0a2ad37e7329afd3e666f5e0aSvetoslav Ganov     * @param label The view that labels this node's source.
218233aef98fd28dcac0a2ad37e7329afd3e666f5e0aSvetoslav Ganov     */
218333aef98fd28dcac0a2ad37e7329afd3e666f5e0aSvetoslav Ganov    public void setLabeledBy(View label) {
21848e3feb15c5aec2c72b0ef120a1da325e1e8f0ddaSvetoslav        setLabeledBy(label, UNDEFINED_ITEM_ID);
218533aef98fd28dcac0a2ad37e7329afd3e666f5e0aSvetoslav Ganov    }
218633aef98fd28dcac0a2ad37e7329afd3e666f5e0aSvetoslav Ganov
218733aef98fd28dcac0a2ad37e7329afd3e666f5e0aSvetoslav Ganov    /**
218833aef98fd28dcac0a2ad37e7329afd3e666f5e0aSvetoslav Ganov     * Sets the view which serves as the label of the view represented by
218933aef98fd28dcac0a2ad37e7329afd3e666f5e0aSvetoslav Ganov     * this info for accessibility purposes. If <code>virtualDescendantId</code>
219033aef98fd28dcac0a2ad37e7329afd3e666f5e0aSvetoslav Ganov     * is {@link View#NO_ID} the root is set as the label.
219133aef98fd28dcac0a2ad37e7329afd3e666f5e0aSvetoslav Ganov     * <p>
219233aef98fd28dcac0a2ad37e7329afd3e666f5e0aSvetoslav Ganov     * A virtual descendant is an imaginary View that is reported as a part of the view
219333aef98fd28dcac0a2ad37e7329afd3e666f5e0aSvetoslav Ganov     * hierarchy for accessibility purposes. This enables custom views that draw complex
219433aef98fd28dcac0a2ad37e7329afd3e666f5e0aSvetoslav Ganov     * content to report themselves as a tree of virtual views, thus conveying their
219533aef98fd28dcac0a2ad37e7329afd3e666f5e0aSvetoslav Ganov     * logical structure.
219633aef98fd28dcac0a2ad37e7329afd3e666f5e0aSvetoslav Ganov     * </p>
219733aef98fd28dcac0a2ad37e7329afd3e666f5e0aSvetoslav Ganov     * <p>
219833aef98fd28dcac0a2ad37e7329afd3e666f5e0aSvetoslav Ganov     *   <strong>Note:</strong> Cannot be called from an
219933aef98fd28dcac0a2ad37e7329afd3e666f5e0aSvetoslav Ganov     *   {@link android.accessibilityservice.AccessibilityService}.
220033aef98fd28dcac0a2ad37e7329afd3e666f5e0aSvetoslav Ganov     *   This class is made immutable before being delivered to an AccessibilityService.
220133aef98fd28dcac0a2ad37e7329afd3e666f5e0aSvetoslav Ganov     * </p>
220233aef98fd28dcac0a2ad37e7329afd3e666f5e0aSvetoslav Ganov     *
220333aef98fd28dcac0a2ad37e7329afd3e666f5e0aSvetoslav Ganov     * @param root The root whose virtual descendant labels this node's source.
220433aef98fd28dcac0a2ad37e7329afd3e666f5e0aSvetoslav Ganov     * @param virtualDescendantId The id of the virtual descendant.
220533aef98fd28dcac0a2ad37e7329afd3e666f5e0aSvetoslav Ganov     */
220633aef98fd28dcac0a2ad37e7329afd3e666f5e0aSvetoslav Ganov    public void setLabeledBy(View root, int virtualDescendantId) {
220733aef98fd28dcac0a2ad37e7329afd3e666f5e0aSvetoslav Ganov        enforceNotSealed();
220833aef98fd28dcac0a2ad37e7329afd3e666f5e0aSvetoslav Ganov        final int rootAccessibilityViewId = (root != null)
22098e3feb15c5aec2c72b0ef120a1da325e1e8f0ddaSvetoslav                ? root.getAccessibilityViewId() : UNDEFINED_ITEM_ID;
221033aef98fd28dcac0a2ad37e7329afd3e666f5e0aSvetoslav Ganov        mLabeledById = makeNodeId(rootAccessibilityViewId, virtualDescendantId);
221133aef98fd28dcac0a2ad37e7329afd3e666f5e0aSvetoslav Ganov    }
221233aef98fd28dcac0a2ad37e7329afd3e666f5e0aSvetoslav Ganov
221333aef98fd28dcac0a2ad37e7329afd3e666f5e0aSvetoslav Ganov    /**
221433aef98fd28dcac0a2ad37e7329afd3e666f5e0aSvetoslav Ganov     * Gets the node info which serves as the label of the view represented by
221533aef98fd28dcac0a2ad37e7329afd3e666f5e0aSvetoslav Ganov     * this info for accessibility purposes.
221633aef98fd28dcac0a2ad37e7329afd3e666f5e0aSvetoslav Ganov     * <p>
221733aef98fd28dcac0a2ad37e7329afd3e666f5e0aSvetoslav Ganov     *   <strong>Note:</strong> It is a client responsibility to recycle the
221833aef98fd28dcac0a2ad37e7329afd3e666f5e0aSvetoslav Ganov     *     received info by calling {@link AccessibilityNodeInfo#recycle()}
221933aef98fd28dcac0a2ad37e7329afd3e666f5e0aSvetoslav Ganov     *     to avoid creating of multiple instances.
222033aef98fd28dcac0a2ad37e7329afd3e666f5e0aSvetoslav Ganov     * </p>
222133aef98fd28dcac0a2ad37e7329afd3e666f5e0aSvetoslav Ganov     *
222233aef98fd28dcac0a2ad37e7329afd3e666f5e0aSvetoslav Ganov     * @return The label.
222333aef98fd28dcac0a2ad37e7329afd3e666f5e0aSvetoslav Ganov     */
222433aef98fd28dcac0a2ad37e7329afd3e666f5e0aSvetoslav Ganov    public AccessibilityNodeInfo getLabeledBy() {
222533aef98fd28dcac0a2ad37e7329afd3e666f5e0aSvetoslav Ganov        enforceSealed();
22266c70290ff0b20329c8f173d5c3423eb83ddc46f1Svetoslav        return getNodeForAccessibilityId(mLabeledById);
222733aef98fd28dcac0a2ad37e7329afd3e666f5e0aSvetoslav Ganov    }
222833aef98fd28dcac0a2ad37e7329afd3e666f5e0aSvetoslav Ganov
222933aef98fd28dcac0a2ad37e7329afd3e666f5e0aSvetoslav Ganov    /**
223080943d8daa6ab31ab5c486d57aea406aa0730d58Svetoslav Ganov     * Sets the fully qualified resource name of the source view's id.
223180943d8daa6ab31ab5c486d57aea406aa0730d58Svetoslav Ganov     *
223280943d8daa6ab31ab5c486d57aea406aa0730d58Svetoslav Ganov     * <p>
223380943d8daa6ab31ab5c486d57aea406aa0730d58Svetoslav Ganov     *   <strong>Note:</strong> Cannot be called from an
223480943d8daa6ab31ab5c486d57aea406aa0730d58Svetoslav Ganov     *   {@link android.accessibilityservice.AccessibilityService}.
223580943d8daa6ab31ab5c486d57aea406aa0730d58Svetoslav Ganov     *   This class is made immutable before being delivered to an AccessibilityService.
223680943d8daa6ab31ab5c486d57aea406aa0730d58Svetoslav Ganov     * </p>
223780943d8daa6ab31ab5c486d57aea406aa0730d58Svetoslav Ganov     *
223892826459d101d2d76b2d75347232b1fee08962cfSvetoslav     * @param viewIdResName The id resource name.
223980943d8daa6ab31ab5c486d57aea406aa0730d58Svetoslav Ganov     */
22409fa1ee563b5a9ca25554f1fa59d1222dcfdfc623Svetoslav    public void setViewIdResourceName(String viewIdResName) {
224180943d8daa6ab31ab5c486d57aea406aa0730d58Svetoslav Ganov        enforceNotSealed();
224222431a3b6fb5ae3498c6ae780648ca0228635ebaSvetoslav        mViewIdResourceName = viewIdResName;
224380943d8daa6ab31ab5c486d57aea406aa0730d58Svetoslav Ganov    }
224480943d8daa6ab31ab5c486d57aea406aa0730d58Svetoslav Ganov
224580943d8daa6ab31ab5c486d57aea406aa0730d58Svetoslav Ganov    /**
224680943d8daa6ab31ab5c486d57aea406aa0730d58Svetoslav Ganov     * Gets the fully qualified resource name of the source view's id.
224780943d8daa6ab31ab5c486d57aea406aa0730d58Svetoslav Ganov     *
224880943d8daa6ab31ab5c486d57aea406aa0730d58Svetoslav Ganov     * <p>
224980943d8daa6ab31ab5c486d57aea406aa0730d58Svetoslav Ganov     *   <strong>Note:</strong> The primary usage of this API is for UI test automation
225080943d8daa6ab31ab5c486d57aea406aa0730d58Svetoslav Ganov     *   and in order to report the source view id of an {@link AccessibilityNodeInfo} the
225180943d8daa6ab31ab5c486d57aea406aa0730d58Svetoslav Ganov     *   client has to set the {@link AccessibilityServiceInfo#FLAG_REPORT_VIEW_IDS}
225214ff996ce82734100ba3faedbc80c4783eebea9dSvetoslav     *   flag when configuring his {@link android.accessibilityservice.AccessibilityService}.
225380943d8daa6ab31ab5c486d57aea406aa0730d58Svetoslav Ganov     * </p>
225480943d8daa6ab31ab5c486d57aea406aa0730d58Svetoslav Ganov
225580943d8daa6ab31ab5c486d57aea406aa0730d58Svetoslav Ganov     * @return The id resource name.
225680943d8daa6ab31ab5c486d57aea406aa0730d58Svetoslav Ganov     */
22579fa1ee563b5a9ca25554f1fa59d1222dcfdfc623Svetoslav    public String getViewIdResourceName() {
225822431a3b6fb5ae3498c6ae780648ca0228635ebaSvetoslav        return mViewIdResourceName;
225980943d8daa6ab31ab5c486d57aea406aa0730d58Svetoslav Ganov    }
226080943d8daa6ab31ab5c486d57aea406aa0730d58Svetoslav Ganov
226180943d8daa6ab31ab5c486d57aea406aa0730d58Svetoslav Ganov    /**
2262bcc46a0d037e62fcb5e5f0f5e1acef5a8c1314b0Svetoslav     * Gets the text selection start.
2263bcc46a0d037e62fcb5e5f0f5e1acef5a8c1314b0Svetoslav     *
2264bcc46a0d037e62fcb5e5f0f5e1acef5a8c1314b0Svetoslav     * @return The text selection start if there is selection or -1.
2265bcc46a0d037e62fcb5e5f0f5e1acef5a8c1314b0Svetoslav     */
2266bcc46a0d037e62fcb5e5f0f5e1acef5a8c1314b0Svetoslav    public int getTextSelectionStart() {
2267bcc46a0d037e62fcb5e5f0f5e1acef5a8c1314b0Svetoslav        return mTextSelectionStart;
2268bcc46a0d037e62fcb5e5f0f5e1acef5a8c1314b0Svetoslav    }
2269bcc46a0d037e62fcb5e5f0f5e1acef5a8c1314b0Svetoslav
2270bcc46a0d037e62fcb5e5f0f5e1acef5a8c1314b0Svetoslav    /**
2271bcc46a0d037e62fcb5e5f0f5e1acef5a8c1314b0Svetoslav     * Gets the text selection end.
2272bcc46a0d037e62fcb5e5f0f5e1acef5a8c1314b0Svetoslav     *
2273bcc46a0d037e62fcb5e5f0f5e1acef5a8c1314b0Svetoslav     * @return The text selection end if there is selection or -1.
2274bcc46a0d037e62fcb5e5f0f5e1acef5a8c1314b0Svetoslav     */
2275bcc46a0d037e62fcb5e5f0f5e1acef5a8c1314b0Svetoslav    public int getTextSelectionEnd() {
2276bcc46a0d037e62fcb5e5f0f5e1acef5a8c1314b0Svetoslav        return mTextSelectionEnd;
2277bcc46a0d037e62fcb5e5f0f5e1acef5a8c1314b0Svetoslav    }
2278bcc46a0d037e62fcb5e5f0f5e1acef5a8c1314b0Svetoslav
2279bcc46a0d037e62fcb5e5f0f5e1acef5a8c1314b0Svetoslav    /**
2280bcc46a0d037e62fcb5e5f0f5e1acef5a8c1314b0Svetoslav     * Sets the text selection start and end.
2281bcc46a0d037e62fcb5e5f0f5e1acef5a8c1314b0Svetoslav     * <p>
2282bcc46a0d037e62fcb5e5f0f5e1acef5a8c1314b0Svetoslav     *   <strong>Note:</strong> Cannot be called from an
2283bcc46a0d037e62fcb5e5f0f5e1acef5a8c1314b0Svetoslav     *   {@link android.accessibilityservice.AccessibilityService}.
2284bcc46a0d037e62fcb5e5f0f5e1acef5a8c1314b0Svetoslav     *   This class is made immutable before being delivered to an AccessibilityService.
2285bcc46a0d037e62fcb5e5f0f5e1acef5a8c1314b0Svetoslav     * </p>
2286bcc46a0d037e62fcb5e5f0f5e1acef5a8c1314b0Svetoslav     *
2287bcc46a0d037e62fcb5e5f0f5e1acef5a8c1314b0Svetoslav     * @param start The text selection start.
2288bcc46a0d037e62fcb5e5f0f5e1acef5a8c1314b0Svetoslav     * @param end The text selection end.
2289bcc46a0d037e62fcb5e5f0f5e1acef5a8c1314b0Svetoslav     *
2290bcc46a0d037e62fcb5e5f0f5e1acef5a8c1314b0Svetoslav     * @throws IllegalStateException If called from an AccessibilityService.
2291bcc46a0d037e62fcb5e5f0f5e1acef5a8c1314b0Svetoslav     */
2292bcc46a0d037e62fcb5e5f0f5e1acef5a8c1314b0Svetoslav    public void setTextSelection(int start, int end) {
2293bcc46a0d037e62fcb5e5f0f5e1acef5a8c1314b0Svetoslav        enforceNotSealed();
2294bcc46a0d037e62fcb5e5f0f5e1acef5a8c1314b0Svetoslav        mTextSelectionStart = start;
2295bcc46a0d037e62fcb5e5f0f5e1acef5a8c1314b0Svetoslav        mTextSelectionEnd = end;
2296bcc46a0d037e62fcb5e5f0f5e1acef5a8c1314b0Svetoslav    }
2297bcc46a0d037e62fcb5e5f0f5e1acef5a8c1314b0Svetoslav
2298bcc46a0d037e62fcb5e5f0f5e1acef5a8c1314b0Svetoslav    /**
22996254f4806dd3db53b7380e77fbb183065685573eSvetoslav     * Gets the input type of the source as defined by {@link InputType}.
23006254f4806dd3db53b7380e77fbb183065685573eSvetoslav     *
23016254f4806dd3db53b7380e77fbb183065685573eSvetoslav     * @return The input type.
23026254f4806dd3db53b7380e77fbb183065685573eSvetoslav     */
23036254f4806dd3db53b7380e77fbb183065685573eSvetoslav    public int getInputType() {
23046254f4806dd3db53b7380e77fbb183065685573eSvetoslav        return mInputType;
23056254f4806dd3db53b7380e77fbb183065685573eSvetoslav    }
23066254f4806dd3db53b7380e77fbb183065685573eSvetoslav
23076254f4806dd3db53b7380e77fbb183065685573eSvetoslav    /**
23086254f4806dd3db53b7380e77fbb183065685573eSvetoslav     * Sets the input type of the source as defined by {@link InputType}.
23096254f4806dd3db53b7380e77fbb183065685573eSvetoslav     * <p>
23106254f4806dd3db53b7380e77fbb183065685573eSvetoslav     *   <strong>Note:</strong> Cannot be called from an
23116254f4806dd3db53b7380e77fbb183065685573eSvetoslav     *   {@link android.accessibilityservice.AccessibilityService}.
23126254f4806dd3db53b7380e77fbb183065685573eSvetoslav     *   This class is made immutable before being delivered to an
23136254f4806dd3db53b7380e77fbb183065685573eSvetoslav     *   AccessibilityService.
23146254f4806dd3db53b7380e77fbb183065685573eSvetoslav     * </p>
23156254f4806dd3db53b7380e77fbb183065685573eSvetoslav     *
23166254f4806dd3db53b7380e77fbb183065685573eSvetoslav     * @param inputType The input type.
23176254f4806dd3db53b7380e77fbb183065685573eSvetoslav     *
23186254f4806dd3db53b7380e77fbb183065685573eSvetoslav     * @throws IllegalStateException If called from an AccessibilityService.
23196254f4806dd3db53b7380e77fbb183065685573eSvetoslav     */
23206254f4806dd3db53b7380e77fbb183065685573eSvetoslav    public void setInputType(int inputType) {
2321df39cb9b05a223f24b43c783574abbe67d643fdbAlan Viverette        enforceNotSealed();
23226254f4806dd3db53b7380e77fbb183065685573eSvetoslav        mInputType = inputType;
23236254f4806dd3db53b7380e77fbb183065685573eSvetoslav    }
23246254f4806dd3db53b7380e77fbb183065685573eSvetoslav
23256254f4806dd3db53b7380e77fbb183065685573eSvetoslav    /**
2326cb8ed39b3fb591be60b9fb1799d4ea4530eab758Svetoslav Ganov     * Gets an optional bundle with extra data. The bundle
23276254f4806dd3db53b7380e77fbb183065685573eSvetoslav     * is lazily created and never <code>null</code>.
23286254f4806dd3db53b7380e77fbb183065685573eSvetoslav     * <p>
23296254f4806dd3db53b7380e77fbb183065685573eSvetoslav     * <strong>Note:</strong> It is recommended to use the package
23306254f4806dd3db53b7380e77fbb183065685573eSvetoslav     * name of your application as a prefix for the keys to avoid
23316254f4806dd3db53b7380e77fbb183065685573eSvetoslav     * collisions which may confuse an accessibility service if the
23326254f4806dd3db53b7380e77fbb183065685573eSvetoslav     * same key has different meaning when emitted from different
23336254f4806dd3db53b7380e77fbb183065685573eSvetoslav     * applications.
23346254f4806dd3db53b7380e77fbb183065685573eSvetoslav     * </p>
23356254f4806dd3db53b7380e77fbb183065685573eSvetoslav     *
23366254f4806dd3db53b7380e77fbb183065685573eSvetoslav     * @return The bundle.
23376254f4806dd3db53b7380e77fbb183065685573eSvetoslav     */
2338cb8ed39b3fb591be60b9fb1799d4ea4530eab758Svetoslav Ganov    public Bundle getExtras() {
2339cb8ed39b3fb591be60b9fb1799d4ea4530eab758Svetoslav Ganov        if (mExtras == null) {
2340cb8ed39b3fb591be60b9fb1799d4ea4530eab758Svetoslav Ganov            mExtras = new Bundle();
23416254f4806dd3db53b7380e77fbb183065685573eSvetoslav        }
2342cb8ed39b3fb591be60b9fb1799d4ea4530eab758Svetoslav Ganov        return mExtras;
23436254f4806dd3db53b7380e77fbb183065685573eSvetoslav    }
23446254f4806dd3db53b7380e77fbb183065685573eSvetoslav
23456254f4806dd3db53b7380e77fbb183065685573eSvetoslav    /**
23468643aa0179e598e78d938c59035389054535a229Svetoslav Ganov     * Gets the value of a boolean property.
23478643aa0179e598e78d938c59035389054535a229Svetoslav Ganov     *
23488643aa0179e598e78d938c59035389054535a229Svetoslav Ganov     * @param property The property.
23498643aa0179e598e78d938c59035389054535a229Svetoslav Ganov     * @return The value.
23508643aa0179e598e78d938c59035389054535a229Svetoslav Ganov     */
23518643aa0179e598e78d938c59035389054535a229Svetoslav Ganov    private boolean getBooleanProperty(int property) {
23528643aa0179e598e78d938c59035389054535a229Svetoslav Ganov        return (mBooleanProperties & property) != 0;
23538643aa0179e598e78d938c59035389054535a229Svetoslav Ganov    }
23548643aa0179e598e78d938c59035389054535a229Svetoslav Ganov
23558643aa0179e598e78d938c59035389054535a229Svetoslav Ganov    /**
23568643aa0179e598e78d938c59035389054535a229Svetoslav Ganov     * Sets a boolean property.
23578643aa0179e598e78d938c59035389054535a229Svetoslav Ganov     *
23588643aa0179e598e78d938c59035389054535a229Svetoslav Ganov     * @param property The property.
23598643aa0179e598e78d938c59035389054535a229Svetoslav Ganov     * @param value The value.
23608643aa0179e598e78d938c59035389054535a229Svetoslav Ganov     *
23618643aa0179e598e78d938c59035389054535a229Svetoslav Ganov     * @throws IllegalStateException If called from an AccessibilityService.
23628643aa0179e598e78d938c59035389054535a229Svetoslav Ganov     */
23638643aa0179e598e78d938c59035389054535a229Svetoslav Ganov    private void setBooleanProperty(int property, boolean value) {
23648643aa0179e598e78d938c59035389054535a229Svetoslav Ganov        enforceNotSealed();
23658643aa0179e598e78d938c59035389054535a229Svetoslav Ganov        if (value) {
23668643aa0179e598e78d938c59035389054535a229Svetoslav Ganov            mBooleanProperties |= property;
23678643aa0179e598e78d938c59035389054535a229Svetoslav Ganov        } else {
23688643aa0179e598e78d938c59035389054535a229Svetoslav Ganov            mBooleanProperties &= ~property;
23698643aa0179e598e78d938c59035389054535a229Svetoslav Ganov        }
23708643aa0179e598e78d938c59035389054535a229Svetoslav Ganov    }
23718643aa0179e598e78d938c59035389054535a229Svetoslav Ganov
23728643aa0179e598e78d938c59035389054535a229Svetoslav Ganov    /**
2373d116d7c78a9c53f30a73bf273bd7618312cf3847Svetoslav Ganov     * Sets the unique id of the IAccessibilityServiceConnection over which
2374d116d7c78a9c53f30a73bf273bd7618312cf3847Svetoslav Ganov     * this instance can send requests to the system.
23758643aa0179e598e78d938c59035389054535a229Svetoslav Ganov     *
2376d116d7c78a9c53f30a73bf273bd7618312cf3847Svetoslav Ganov     * @param connectionId The connection id.
23778643aa0179e598e78d938c59035389054535a229Svetoslav Ganov     *
23788643aa0179e598e78d938c59035389054535a229Svetoslav Ganov     * @hide
23798643aa0179e598e78d938c59035389054535a229Svetoslav Ganov     */
2380d116d7c78a9c53f30a73bf273bd7618312cf3847Svetoslav Ganov    public void setConnectionId(int connectionId) {
2381eeee4d2c01d3c4ed99e4891dbc75c7de69a803faSvetoslav Ganov        enforceNotSealed();
2382d116d7c78a9c53f30a73bf273bd7618312cf3847Svetoslav Ganov        mConnectionId = connectionId;
23838643aa0179e598e78d938c59035389054535a229Svetoslav Ganov    }
23848643aa0179e598e78d938c59035389054535a229Svetoslav Ganov
23858643aa0179e598e78d938c59035389054535a229Svetoslav Ganov    /**
23868643aa0179e598e78d938c59035389054535a229Svetoslav Ganov     * {@inheritDoc}
23878643aa0179e598e78d938c59035389054535a229Svetoslav Ganov     */
2388f0aed09ed8153043e40b3ac99788d47ba0831306Alan Viverette    @Override
23898643aa0179e598e78d938c59035389054535a229Svetoslav Ganov    public int describeContents() {
23908643aa0179e598e78d938c59035389054535a229Svetoslav Ganov        return 0;
23918643aa0179e598e78d938c59035389054535a229Svetoslav Ganov    }
23928643aa0179e598e78d938c59035389054535a229Svetoslav Ganov
23938643aa0179e598e78d938c59035389054535a229Svetoslav Ganov    /**
239479311c4af8b54d3cd47ab37a120c648bfc990511Svetoslav Ganov     * Gets the id of the source node.
239579311c4af8b54d3cd47ab37a120c648bfc990511Svetoslav Ganov     *
239679311c4af8b54d3cd47ab37a120c648bfc990511Svetoslav Ganov     * @return The id.
239779311c4af8b54d3cd47ab37a120c648bfc990511Svetoslav Ganov     *
239879311c4af8b54d3cd47ab37a120c648bfc990511Svetoslav Ganov     * @hide
239979311c4af8b54d3cd47ab37a120c648bfc990511Svetoslav Ganov     */
240079311c4af8b54d3cd47ab37a120c648bfc990511Svetoslav Ganov    public long getSourceNodeId() {
240179311c4af8b54d3cd47ab37a120c648bfc990511Svetoslav Ganov        return mSourceNodeId;
240279311c4af8b54d3cd47ab37a120c648bfc990511Svetoslav Ganov    }
240379311c4af8b54d3cd47ab37a120c648bfc990511Svetoslav Ganov
240479311c4af8b54d3cd47ab37a120c648bfc990511Svetoslav Ganov    /**
24058643aa0179e598e78d938c59035389054535a229Svetoslav Ganov     * Sets if this instance is sealed.
24068643aa0179e598e78d938c59035389054535a229Svetoslav Ganov     *
24078643aa0179e598e78d938c59035389054535a229Svetoslav Ganov     * @param sealed Whether is sealed.
24088643aa0179e598e78d938c59035389054535a229Svetoslav Ganov     *
24098643aa0179e598e78d938c59035389054535a229Svetoslav Ganov     * @hide
24108643aa0179e598e78d938c59035389054535a229Svetoslav Ganov     */
24118643aa0179e598e78d938c59035389054535a229Svetoslav Ganov    public void setSealed(boolean sealed) {
24128643aa0179e598e78d938c59035389054535a229Svetoslav Ganov        mSealed = sealed;
24138643aa0179e598e78d938c59035389054535a229Svetoslav Ganov    }
24148643aa0179e598e78d938c59035389054535a229Svetoslav Ganov
24158643aa0179e598e78d938c59035389054535a229Svetoslav Ganov    /**
24168643aa0179e598e78d938c59035389054535a229Svetoslav Ganov     * Gets if this instance is sealed.
24178643aa0179e598e78d938c59035389054535a229Svetoslav Ganov     *
24188643aa0179e598e78d938c59035389054535a229Svetoslav Ganov     * @return Whether is sealed.
24198643aa0179e598e78d938c59035389054535a229Svetoslav Ganov     *
24208643aa0179e598e78d938c59035389054535a229Svetoslav Ganov     * @hide
24218643aa0179e598e78d938c59035389054535a229Svetoslav Ganov     */
24228643aa0179e598e78d938c59035389054535a229Svetoslav Ganov    public boolean isSealed() {
24238643aa0179e598e78d938c59035389054535a229Svetoslav Ganov        return mSealed;
24248643aa0179e598e78d938c59035389054535a229Svetoslav Ganov    }
24258643aa0179e598e78d938c59035389054535a229Svetoslav Ganov
24268643aa0179e598e78d938c59035389054535a229Svetoslav Ganov    /**
24278643aa0179e598e78d938c59035389054535a229Svetoslav Ganov     * Enforces that this instance is sealed.
24288643aa0179e598e78d938c59035389054535a229Svetoslav Ganov     *
24298643aa0179e598e78d938c59035389054535a229Svetoslav Ganov     * @throws IllegalStateException If this instance is not sealed.
24308643aa0179e598e78d938c59035389054535a229Svetoslav Ganov     *
24318643aa0179e598e78d938c59035389054535a229Svetoslav Ganov     * @hide
24328643aa0179e598e78d938c59035389054535a229Svetoslav Ganov     */
24338643aa0179e598e78d938c59035389054535a229Svetoslav Ganov    protected void enforceSealed() {
24348643aa0179e598e78d938c59035389054535a229Svetoslav Ganov        if (!isSealed()) {
24358643aa0179e598e78d938c59035389054535a229Svetoslav Ganov            throw new IllegalStateException("Cannot perform this "
24368643aa0179e598e78d938c59035389054535a229Svetoslav Ganov                    + "action on a not sealed instance.");
24378643aa0179e598e78d938c59035389054535a229Svetoslav Ganov        }
24388643aa0179e598e78d938c59035389054535a229Svetoslav Ganov    }
24398643aa0179e598e78d938c59035389054535a229Svetoslav Ganov
24402ef6905003c20010032ee993dfcc5899ad9be6f8Svetoslav Ganov    private void enforceValidFocusDirection(int direction) {
24412ef6905003c20010032ee993dfcc5899ad9be6f8Svetoslav Ganov        switch (direction) {
24422ef6905003c20010032ee993dfcc5899ad9be6f8Svetoslav Ganov            case View.FOCUS_DOWN:
24432ef6905003c20010032ee993dfcc5899ad9be6f8Svetoslav Ganov            case View.FOCUS_UP:
24442ef6905003c20010032ee993dfcc5899ad9be6f8Svetoslav Ganov            case View.FOCUS_LEFT:
24452ef6905003c20010032ee993dfcc5899ad9be6f8Svetoslav Ganov            case View.FOCUS_RIGHT:
24462ef6905003c20010032ee993dfcc5899ad9be6f8Svetoslav Ganov            case View.FOCUS_FORWARD:
24472ef6905003c20010032ee993dfcc5899ad9be6f8Svetoslav Ganov            case View.FOCUS_BACKWARD:
24482ef6905003c20010032ee993dfcc5899ad9be6f8Svetoslav Ganov                return;
24492ef6905003c20010032ee993dfcc5899ad9be6f8Svetoslav Ganov            default:
24502ef6905003c20010032ee993dfcc5899ad9be6f8Svetoslav Ganov                throw new IllegalArgumentException("Unknown direction: " + direction);
24512ef6905003c20010032ee993dfcc5899ad9be6f8Svetoslav Ganov        }
24522ef6905003c20010032ee993dfcc5899ad9be6f8Svetoslav Ganov    }
24532ef6905003c20010032ee993dfcc5899ad9be6f8Svetoslav Ganov
24542ef6905003c20010032ee993dfcc5899ad9be6f8Svetoslav Ganov    private void enforceValidFocusType(int focusType) {
24552ef6905003c20010032ee993dfcc5899ad9be6f8Svetoslav Ganov        switch (focusType) {
24562ef6905003c20010032ee993dfcc5899ad9be6f8Svetoslav Ganov            case FOCUS_INPUT:
24572ef6905003c20010032ee993dfcc5899ad9be6f8Svetoslav Ganov            case FOCUS_ACCESSIBILITY:
24582ef6905003c20010032ee993dfcc5899ad9be6f8Svetoslav Ganov                return;
24592ef6905003c20010032ee993dfcc5899ad9be6f8Svetoslav Ganov            default:
24602ef6905003c20010032ee993dfcc5899ad9be6f8Svetoslav Ganov                throw new IllegalArgumentException("Unknown focus type: " + focusType);
24612ef6905003c20010032ee993dfcc5899ad9be6f8Svetoslav Ganov        }
24622ef6905003c20010032ee993dfcc5899ad9be6f8Svetoslav Ganov    }
24632ef6905003c20010032ee993dfcc5899ad9be6f8Svetoslav Ganov
24648643aa0179e598e78d938c59035389054535a229Svetoslav Ganov    /**
24658643aa0179e598e78d938c59035389054535a229Svetoslav Ganov     * Enforces that this instance is not sealed.
24668643aa0179e598e78d938c59035389054535a229Svetoslav Ganov     *
24678643aa0179e598e78d938c59035389054535a229Svetoslav Ganov     * @throws IllegalStateException If this instance is sealed.
24688643aa0179e598e78d938c59035389054535a229Svetoslav Ganov     *
24698643aa0179e598e78d938c59035389054535a229Svetoslav Ganov     * @hide
24708643aa0179e598e78d938c59035389054535a229Svetoslav Ganov     */
24718643aa0179e598e78d938c59035389054535a229Svetoslav Ganov    protected void enforceNotSealed() {
24728643aa0179e598e78d938c59035389054535a229Svetoslav Ganov        if (isSealed()) {
24738643aa0179e598e78d938c59035389054535a229Svetoslav Ganov            throw new IllegalStateException("Cannot perform this "
2474f76a50ce8fdc6aea22cabc77b2977a1a15a79630Ken Wakasa                    + "action on a sealed instance.");
24758643aa0179e598e78d938c59035389054535a229Svetoslav Ganov        }
24768643aa0179e598e78d938c59035389054535a229Svetoslav Ganov    }
24778643aa0179e598e78d938c59035389054535a229Svetoslav Ganov
24788643aa0179e598e78d938c59035389054535a229Svetoslav Ganov    /**
24798643aa0179e598e78d938c59035389054535a229Svetoslav Ganov     * Returns a cached instance if such is available otherwise a new one
24808643aa0179e598e78d938c59035389054535a229Svetoslav Ganov     * and sets the source.
24818643aa0179e598e78d938c59035389054535a229Svetoslav Ganov     *
2482021078554b902179442a345a9d080a165c3b5139Svetoslav Ganov     * @param source The source view.
24838643aa0179e598e78d938c59035389054535a229Svetoslav Ganov     * @return An instance.
24848643aa0179e598e78d938c59035389054535a229Svetoslav Ganov     *
24858643aa0179e598e78d938c59035389054535a229Svetoslav Ganov     * @see #setSource(View)
24868643aa0179e598e78d938c59035389054535a229Svetoslav Ganov     */
24878643aa0179e598e78d938c59035389054535a229Svetoslav Ganov    public static AccessibilityNodeInfo obtain(View source) {
24888643aa0179e598e78d938c59035389054535a229Svetoslav Ganov        AccessibilityNodeInfo info = AccessibilityNodeInfo.obtain();
24898643aa0179e598e78d938c59035389054535a229Svetoslav Ganov        info.setSource(source);
24908643aa0179e598e78d938c59035389054535a229Svetoslav Ganov        return info;
24918643aa0179e598e78d938c59035389054535a229Svetoslav Ganov    }
24928643aa0179e598e78d938c59035389054535a229Svetoslav Ganov
24938643aa0179e598e78d938c59035389054535a229Svetoslav Ganov    /**
2494021078554b902179442a345a9d080a165c3b5139Svetoslav Ganov     * Returns a cached instance if such is available otherwise a new one
2495021078554b902179442a345a9d080a165c3b5139Svetoslav Ganov     * and sets the source.
2496021078554b902179442a345a9d080a165c3b5139Svetoslav Ganov     *
2497021078554b902179442a345a9d080a165c3b5139Svetoslav Ganov     * @param root The root of the virtual subtree.
2498021078554b902179442a345a9d080a165c3b5139Svetoslav Ganov     * @param virtualDescendantId The id of the virtual descendant.
2499021078554b902179442a345a9d080a165c3b5139Svetoslav Ganov     * @return An instance.
2500021078554b902179442a345a9d080a165c3b5139Svetoslav Ganov     *
2501021078554b902179442a345a9d080a165c3b5139Svetoslav Ganov     * @see #setSource(View, int)
2502021078554b902179442a345a9d080a165c3b5139Svetoslav Ganov     */
2503021078554b902179442a345a9d080a165c3b5139Svetoslav Ganov    public static AccessibilityNodeInfo obtain(View root, int virtualDescendantId) {
2504021078554b902179442a345a9d080a165c3b5139Svetoslav Ganov        AccessibilityNodeInfo info = AccessibilityNodeInfo.obtain();
2505021078554b902179442a345a9d080a165c3b5139Svetoslav Ganov        info.setSource(root, virtualDescendantId);
2506021078554b902179442a345a9d080a165c3b5139Svetoslav Ganov        return info;
2507021078554b902179442a345a9d080a165c3b5139Svetoslav Ganov    }
2508021078554b902179442a345a9d080a165c3b5139Svetoslav Ganov
2509021078554b902179442a345a9d080a165c3b5139Svetoslav Ganov    /**
25108643aa0179e598e78d938c59035389054535a229Svetoslav Ganov     * Returns a cached instance if such is available otherwise a new one.
25118643aa0179e598e78d938c59035389054535a229Svetoslav Ganov     *
25128643aa0179e598e78d938c59035389054535a229Svetoslav Ganov     * @return An instance.
25138643aa0179e598e78d938c59035389054535a229Svetoslav Ganov     */
25148643aa0179e598e78d938c59035389054535a229Svetoslav Ganov    public static AccessibilityNodeInfo obtain() {
2515f4782ec9c57a40224ac0974fce6b6fe280c829ceSvetoslav Ganov        AccessibilityNodeInfo info = sPool.acquire();
2516f4782ec9c57a40224ac0974fce6b6fe280c829ceSvetoslav Ganov        return (info != null) ? info : new AccessibilityNodeInfo();
25178643aa0179e598e78d938c59035389054535a229Svetoslav Ganov    }
25188643aa0179e598e78d938c59035389054535a229Svetoslav Ganov
25198643aa0179e598e78d938c59035389054535a229Svetoslav Ganov    /**
252035bfedeaba724aeadc6f6c890269cb6bf7ef42f5Svetoslav Ganov     * Returns a cached instance if such is available or a new one is
252135bfedeaba724aeadc6f6c890269cb6bf7ef42f5Svetoslav Ganov     * create. The returned instance is initialized from the given
252235bfedeaba724aeadc6f6c890269cb6bf7ef42f5Svetoslav Ganov     * <code>info</code>.
252335bfedeaba724aeadc6f6c890269cb6bf7ef42f5Svetoslav Ganov     *
252435bfedeaba724aeadc6f6c890269cb6bf7ef42f5Svetoslav Ganov     * @param info The other info.
252535bfedeaba724aeadc6f6c890269cb6bf7ef42f5Svetoslav Ganov     * @return An instance.
252635bfedeaba724aeadc6f6c890269cb6bf7ef42f5Svetoslav Ganov     */
252735bfedeaba724aeadc6f6c890269cb6bf7ef42f5Svetoslav Ganov    public static AccessibilityNodeInfo obtain(AccessibilityNodeInfo info) {
252835bfedeaba724aeadc6f6c890269cb6bf7ef42f5Svetoslav Ganov        AccessibilityNodeInfo infoClone = AccessibilityNodeInfo.obtain();
252935bfedeaba724aeadc6f6c890269cb6bf7ef42f5Svetoslav Ganov        infoClone.init(info);
253035bfedeaba724aeadc6f6c890269cb6bf7ef42f5Svetoslav Ganov        return infoClone;
253135bfedeaba724aeadc6f6c890269cb6bf7ef42f5Svetoslav Ganov    }
253235bfedeaba724aeadc6f6c890269cb6bf7ef42f5Svetoslav Ganov
253335bfedeaba724aeadc6f6c890269cb6bf7ef42f5Svetoslav Ganov    /**
25348643aa0179e598e78d938c59035389054535a229Svetoslav Ganov     * Return an instance back to be reused.
25358643aa0179e598e78d938c59035389054535a229Svetoslav Ganov     * <p>
253638e8b4e5bc3c93affdffbc064fd9db5aeccc3e8eSvetoslav Ganov     * <strong>Note:</strong> You must not touch the object after calling this function.
25378643aa0179e598e78d938c59035389054535a229Svetoslav Ganov     *
25388643aa0179e598e78d938c59035389054535a229Svetoslav Ganov     * @throws IllegalStateException If the info is already recycled.
25398643aa0179e598e78d938c59035389054535a229Svetoslav Ganov     */
25408643aa0179e598e78d938c59035389054535a229Svetoslav Ganov    public void recycle() {
25418643aa0179e598e78d938c59035389054535a229Svetoslav Ganov        clear();
2542f4782ec9c57a40224ac0974fce6b6fe280c829ceSvetoslav Ganov        sPool.release(this);
25438643aa0179e598e78d938c59035389054535a229Svetoslav Ganov    }
25448643aa0179e598e78d938c59035389054535a229Svetoslav Ganov
25458643aa0179e598e78d938c59035389054535a229Svetoslav Ganov    /**
25468643aa0179e598e78d938c59035389054535a229Svetoslav Ganov     * {@inheritDoc}
25478643aa0179e598e78d938c59035389054535a229Svetoslav Ganov     * <p>
254838e8b4e5bc3c93affdffbc064fd9db5aeccc3e8eSvetoslav Ganov     *   <strong>Note:</strong> After the instance is written to a parcel it
254938e8b4e5bc3c93affdffbc064fd9db5aeccc3e8eSvetoslav Ganov     *      is recycled. You must not touch the object after calling this function.
25508643aa0179e598e78d938c59035389054535a229Svetoslav Ganov     * </p>
25518643aa0179e598e78d938c59035389054535a229Svetoslav Ganov     */
2552f0aed09ed8153043e40b3ac99788d47ba0831306Alan Viverette    @Override
25538643aa0179e598e78d938c59035389054535a229Svetoslav Ganov    public void writeToParcel(Parcel parcel, int flags) {
25548643aa0179e598e78d938c59035389054535a229Svetoslav Ganov        parcel.writeInt(isSealed() ? 1 : 0);
2555021078554b902179442a345a9d080a165c3b5139Svetoslav Ganov        parcel.writeLong(mSourceNodeId);
2556021078554b902179442a345a9d080a165c3b5139Svetoslav Ganov        parcel.writeInt(mWindowId);
2557021078554b902179442a345a9d080a165c3b5139Svetoslav Ganov        parcel.writeLong(mParentNodeId);
255833aef98fd28dcac0a2ad37e7329afd3e666f5e0aSvetoslav Ganov        parcel.writeLong(mLabelForId);
255933aef98fd28dcac0a2ad37e7329afd3e666f5e0aSvetoslav Ganov        parcel.writeLong(mLabeledById);
25606c70290ff0b20329c8f173d5c3423eb83ddc46f1Svetoslav        parcel.writeLong(mTraversalBefore);
25616c70290ff0b20329c8f173d5c3423eb83ddc46f1Svetoslav        parcel.writeLong(mTraversalAfter);
25626c70290ff0b20329c8f173d5c3423eb83ddc46f1Svetoslav
2563d116d7c78a9c53f30a73bf273bd7618312cf3847Svetoslav Ganov        parcel.writeInt(mConnectionId);
25648643aa0179e598e78d938c59035389054535a229Svetoslav Ganov
2565f0aed09ed8153043e40b3ac99788d47ba0831306Alan Viverette        final LongArray childIds = mChildNodeIds;
2566f0aed09ed8153043e40b3ac99788d47ba0831306Alan Viverette        if (childIds == null) {
2567f0aed09ed8153043e40b3ac99788d47ba0831306Alan Viverette            parcel.writeInt(0);
2568f0aed09ed8153043e40b3ac99788d47ba0831306Alan Viverette        } else {
2569f0aed09ed8153043e40b3ac99788d47ba0831306Alan Viverette            final int childIdsSize = childIds.size();
2570f0aed09ed8153043e40b3ac99788d47ba0831306Alan Viverette            parcel.writeInt(childIdsSize);
2571f0aed09ed8153043e40b3ac99788d47ba0831306Alan Viverette            for (int i = 0; i < childIdsSize; i++) {
2572f0aed09ed8153043e40b3ac99788d47ba0831306Alan Viverette                parcel.writeLong(childIds.get(i));
2573f0aed09ed8153043e40b3ac99788d47ba0831306Alan Viverette            }
25748643aa0179e598e78d938c59035389054535a229Svetoslav Ganov        }
25758643aa0179e598e78d938c59035389054535a229Svetoslav Ganov
2576eeee4d2c01d3c4ed99e4891dbc75c7de69a803faSvetoslav Ganov        parcel.writeInt(mBoundsInParent.top);
2577eeee4d2c01d3c4ed99e4891dbc75c7de69a803faSvetoslav Ganov        parcel.writeInt(mBoundsInParent.bottom);
2578eeee4d2c01d3c4ed99e4891dbc75c7de69a803faSvetoslav Ganov        parcel.writeInt(mBoundsInParent.left);
2579eeee4d2c01d3c4ed99e4891dbc75c7de69a803faSvetoslav Ganov        parcel.writeInt(mBoundsInParent.right);
2580eeee4d2c01d3c4ed99e4891dbc75c7de69a803faSvetoslav Ganov
2581eeee4d2c01d3c4ed99e4891dbc75c7de69a803faSvetoslav Ganov        parcel.writeInt(mBoundsInScreen.top);
2582eeee4d2c01d3c4ed99e4891dbc75c7de69a803faSvetoslav Ganov        parcel.writeInt(mBoundsInScreen.bottom);
2583eeee4d2c01d3c4ed99e4891dbc75c7de69a803faSvetoslav Ganov        parcel.writeInt(mBoundsInScreen.left);
2584eeee4d2c01d3c4ed99e4891dbc75c7de69a803faSvetoslav Ganov        parcel.writeInt(mBoundsInScreen.right);
25858643aa0179e598e78d938c59035389054535a229Svetoslav Ganov
258674bc19476536f2b5462eaa29e6f3029ee897c16dKristian Monsen        if (mActions != null && !mActions.isEmpty()) {
258774bc19476536f2b5462eaa29e6f3029ee897c16dKristian Monsen            final int actionCount = mActions.size();
258874bc19476536f2b5462eaa29e6f3029ee897c16dKristian Monsen            parcel.writeInt(actionCount);
258974bc19476536f2b5462eaa29e6f3029ee897c16dKristian Monsen
259074bc19476536f2b5462eaa29e6f3029ee897c16dKristian Monsen            int defaultLegacyStandardActions = 0;
259174bc19476536f2b5462eaa29e6f3029ee897c16dKristian Monsen            for (int i = 0; i < actionCount; i++) {
259274bc19476536f2b5462eaa29e6f3029ee897c16dKristian Monsen                AccessibilityAction action = mActions.get(i);
259374bc19476536f2b5462eaa29e6f3029ee897c16dKristian Monsen                if (isDefaultLegacyStandardAction(action)) {
259474bc19476536f2b5462eaa29e6f3029ee897c16dKristian Monsen                    defaultLegacyStandardActions |= action.getId();
259574bc19476536f2b5462eaa29e6f3029ee897c16dKristian Monsen                }
259674bc19476536f2b5462eaa29e6f3029ee897c16dKristian Monsen            }
259774bc19476536f2b5462eaa29e6f3029ee897c16dKristian Monsen            parcel.writeInt(defaultLegacyStandardActions);
259874bc19476536f2b5462eaa29e6f3029ee897c16dKristian Monsen
259974bc19476536f2b5462eaa29e6f3029ee897c16dKristian Monsen            for (int i = 0; i < actionCount; i++) {
260074bc19476536f2b5462eaa29e6f3029ee897c16dKristian Monsen                AccessibilityAction action = mActions.get(i);
260174bc19476536f2b5462eaa29e6f3029ee897c16dKristian Monsen                if (!isDefaultLegacyStandardAction(action)) {
260274bc19476536f2b5462eaa29e6f3029ee897c16dKristian Monsen                    parcel.writeInt(action.getId());
260374bc19476536f2b5462eaa29e6f3029ee897c16dKristian Monsen                    parcel.writeCharSequence(action.getLabel());
260474bc19476536f2b5462eaa29e6f3029ee897c16dKristian Monsen                }
260574bc19476536f2b5462eaa29e6f3029ee897c16dKristian Monsen            }
260674bc19476536f2b5462eaa29e6f3029ee897c16dKristian Monsen        } else {
260774bc19476536f2b5462eaa29e6f3029ee897c16dKristian Monsen            parcel.writeInt(0);
260874bc19476536f2b5462eaa29e6f3029ee897c16dKristian Monsen        }
26098643aa0179e598e78d938c59035389054535a229Svetoslav Ganov
2610029942f77d05ed3d20256403652b220c83dad6e1Alan Viverette        parcel.writeInt(mMaxTextLength);
26112b435aada3d274a9c08d334946fff1ab9ba15b48Svetoslav Ganov        parcel.writeInt(mMovementGranularities);
26128643aa0179e598e78d938c59035389054535a229Svetoslav Ganov        parcel.writeInt(mBooleanProperties);
26138643aa0179e598e78d938c59035389054535a229Svetoslav Ganov
2614aa780c110922148a6a4ba06734bb2b0bb8c98f93Svetoslav Ganov        parcel.writeCharSequence(mPackageName);
2615aa780c110922148a6a4ba06734bb2b0bb8c98f93Svetoslav Ganov        parcel.writeCharSequence(mClassName);
2616aa780c110922148a6a4ba06734bb2b0bb8c98f93Svetoslav Ganov        parcel.writeCharSequence(mText);
2617fccbff5f021a6f95fe1c18f55866545c767ef8ebAlan Viverette        parcel.writeCharSequence(mError);
2618aa780c110922148a6a4ba06734bb2b0bb8c98f93Svetoslav Ganov        parcel.writeCharSequence(mContentDescription);
26199fa1ee563b5a9ca25554f1fa59d1222dcfdfc623Svetoslav        parcel.writeString(mViewIdResourceName);
26208643aa0179e598e78d938c59035389054535a229Svetoslav Ganov
2621bcc46a0d037e62fcb5e5f0f5e1acef5a8c1314b0Svetoslav        parcel.writeInt(mTextSelectionStart);
2622bcc46a0d037e62fcb5e5f0f5e1acef5a8c1314b0Svetoslav        parcel.writeInt(mTextSelectionEnd);
26236254f4806dd3db53b7380e77fbb183065685573eSvetoslav        parcel.writeInt(mInputType);
262477e9a28e2faa36f127231b842476d47f9823a83aAlan Viverette        parcel.writeInt(mLiveRegion);
26256254f4806dd3db53b7380e77fbb183065685573eSvetoslav
2626cb8ed39b3fb591be60b9fb1799d4ea4530eab758Svetoslav Ganov        if (mExtras != null) {
26276254f4806dd3db53b7380e77fbb183065685573eSvetoslav            parcel.writeInt(1);
2628cb8ed39b3fb591be60b9fb1799d4ea4530eab758Svetoslav Ganov            parcel.writeBundle(mExtras);
26296254f4806dd3db53b7380e77fbb183065685573eSvetoslav        } else {
26306254f4806dd3db53b7380e77fbb183065685573eSvetoslav            parcel.writeInt(0);
26316254f4806dd3db53b7380e77fbb183065685573eSvetoslav        }
2632bcc46a0d037e62fcb5e5f0f5e1acef5a8c1314b0Svetoslav
26333577a283e1af3e14fe980c4fec55781a58cd8e3cSvetoslav        if (mRangeInfo != null) {
26343577a283e1af3e14fe980c4fec55781a58cd8e3cSvetoslav            parcel.writeInt(1);
26353577a283e1af3e14fe980c4fec55781a58cd8e3cSvetoslav            parcel.writeInt(mRangeInfo.getType());
26363577a283e1af3e14fe980c4fec55781a58cd8e3cSvetoslav            parcel.writeFloat(mRangeInfo.getMin());
26373577a283e1af3e14fe980c4fec55781a58cd8e3cSvetoslav            parcel.writeFloat(mRangeInfo.getMax());
26383577a283e1af3e14fe980c4fec55781a58cd8e3cSvetoslav            parcel.writeFloat(mRangeInfo.getCurrent());
26393577a283e1af3e14fe980c4fec55781a58cd8e3cSvetoslav        } else {
26403577a283e1af3e14fe980c4fec55781a58cd8e3cSvetoslav            parcel.writeInt(0);
26413577a283e1af3e14fe980c4fec55781a58cd8e3cSvetoslav        }
26423577a283e1af3e14fe980c4fec55781a58cd8e3cSvetoslav
26433577a283e1af3e14fe980c4fec55781a58cd8e3cSvetoslav        if (mCollectionInfo != null) {
26443577a283e1af3e14fe980c4fec55781a58cd8e3cSvetoslav            parcel.writeInt(1);
2645cb8ed39b3fb591be60b9fb1799d4ea4530eab758Svetoslav Ganov            parcel.writeInt(mCollectionInfo.getRowCount());
2646cb8ed39b3fb591be60b9fb1799d4ea4530eab758Svetoslav Ganov            parcel.writeInt(mCollectionInfo.getColumnCount());
26473577a283e1af3e14fe980c4fec55781a58cd8e3cSvetoslav            parcel.writeInt(mCollectionInfo.isHierarchical() ? 1 : 0);
264876769ae02e713f50816ee67ff618b748d95050a8Alan Viverette            parcel.writeInt(mCollectionInfo.getSelectionMode());
26493577a283e1af3e14fe980c4fec55781a58cd8e3cSvetoslav        } else {
26503577a283e1af3e14fe980c4fec55781a58cd8e3cSvetoslav            parcel.writeInt(0);
26513577a283e1af3e14fe980c4fec55781a58cd8e3cSvetoslav        }
26523577a283e1af3e14fe980c4fec55781a58cd8e3cSvetoslav
26533577a283e1af3e14fe980c4fec55781a58cd8e3cSvetoslav        if (mCollectionItemInfo != null) {
26543577a283e1af3e14fe980c4fec55781a58cd8e3cSvetoslav            parcel.writeInt(1);
2655cb8ed39b3fb591be60b9fb1799d4ea4530eab758Svetoslav Ganov            parcel.writeInt(mCollectionItemInfo.getColumnIndex());
2656cb8ed39b3fb591be60b9fb1799d4ea4530eab758Svetoslav Ganov            parcel.writeInt(mCollectionItemInfo.getColumnSpan());
2657cb8ed39b3fb591be60b9fb1799d4ea4530eab758Svetoslav Ganov            parcel.writeInt(mCollectionItemInfo.getRowIndex());
2658cb8ed39b3fb591be60b9fb1799d4ea4530eab758Svetoslav Ganov            parcel.writeInt(mCollectionItemInfo.getRowSpan());
26593577a283e1af3e14fe980c4fec55781a58cd8e3cSvetoslav            parcel.writeInt(mCollectionItemInfo.isHeading() ? 1 : 0);
266076769ae02e713f50816ee67ff618b748d95050a8Alan Viverette            parcel.writeInt(mCollectionItemInfo.isSelected() ? 1 : 0);
26613577a283e1af3e14fe980c4fec55781a58cd8e3cSvetoslav        } else {
26623577a283e1af3e14fe980c4fec55781a58cd8e3cSvetoslav            parcel.writeInt(0);
26633577a283e1af3e14fe980c4fec55781a58cd8e3cSvetoslav        }
26643577a283e1af3e14fe980c4fec55781a58cd8e3cSvetoslav
26658643aa0179e598e78d938c59035389054535a229Svetoslav Ganov        // Since instances of this class are fetched via synchronous i.e. blocking
266638e8b4e5bc3c93affdffbc064fd9db5aeccc3e8eSvetoslav Ganov        // calls in IPCs we always recycle as soon as the instance is marshaled.
26678643aa0179e598e78d938c59035389054535a229Svetoslav Ganov        recycle();
26688643aa0179e598e78d938c59035389054535a229Svetoslav Ganov    }
26698643aa0179e598e78d938c59035389054535a229Svetoslav Ganov
26708643aa0179e598e78d938c59035389054535a229Svetoslav Ganov    /**
267135bfedeaba724aeadc6f6c890269cb6bf7ef42f5Svetoslav Ganov     * Initializes this instance from another one.
267235bfedeaba724aeadc6f6c890269cb6bf7ef42f5Svetoslav Ganov     *
267335bfedeaba724aeadc6f6c890269cb6bf7ef42f5Svetoslav Ganov     * @param other The other instance.
267435bfedeaba724aeadc6f6c890269cb6bf7ef42f5Svetoslav Ganov     */
267535bfedeaba724aeadc6f6c890269cb6bf7ef42f5Svetoslav Ganov    private void init(AccessibilityNodeInfo other) {
267635bfedeaba724aeadc6f6c890269cb6bf7ef42f5Svetoslav Ganov        mSealed = other.mSealed;
2677021078554b902179442a345a9d080a165c3b5139Svetoslav Ganov        mSourceNodeId = other.mSourceNodeId;
2678021078554b902179442a345a9d080a165c3b5139Svetoslav Ganov        mParentNodeId = other.mParentNodeId;
267933aef98fd28dcac0a2ad37e7329afd3e666f5e0aSvetoslav Ganov        mLabelForId = other.mLabelForId;
268033aef98fd28dcac0a2ad37e7329afd3e666f5e0aSvetoslav Ganov        mLabeledById = other.mLabeledById;
26816c70290ff0b20329c8f173d5c3423eb83ddc46f1Svetoslav        mTraversalBefore = other.mTraversalBefore;
26826c70290ff0b20329c8f173d5c3423eb83ddc46f1Svetoslav        mTraversalAfter = other.mTraversalAfter;
2683021078554b902179442a345a9d080a165c3b5139Svetoslav Ganov        mWindowId = other.mWindowId;
2684d116d7c78a9c53f30a73bf273bd7618312cf3847Svetoslav Ganov        mConnectionId = other.mConnectionId;
268535bfedeaba724aeadc6f6c890269cb6bf7ef42f5Svetoslav Ganov        mBoundsInParent.set(other.mBoundsInParent);
268635bfedeaba724aeadc6f6c890269cb6bf7ef42f5Svetoslav Ganov        mBoundsInScreen.set(other.mBoundsInScreen);
268735bfedeaba724aeadc6f6c890269cb6bf7ef42f5Svetoslav Ganov        mPackageName = other.mPackageName;
268835bfedeaba724aeadc6f6c890269cb6bf7ef42f5Svetoslav Ganov        mClassName = other.mClassName;
268935bfedeaba724aeadc6f6c890269cb6bf7ef42f5Svetoslav Ganov        mText = other.mText;
2690fccbff5f021a6f95fe1c18f55866545c767ef8ebAlan Viverette        mError = other.mError;
269135bfedeaba724aeadc6f6c890269cb6bf7ef42f5Svetoslav Ganov        mContentDescription = other.mContentDescription;
269222431a3b6fb5ae3498c6ae780648ca0228635ebaSvetoslav        mViewIdResourceName = other.mViewIdResourceName;
269374bc19476536f2b5462eaa29e6f3029ee897c16dKristian Monsen
269474bc19476536f2b5462eaa29e6f3029ee897c16dKristian Monsen        final ArrayList<AccessibilityAction> otherActions = other.mActions;
269574bc19476536f2b5462eaa29e6f3029ee897c16dKristian Monsen        if (otherActions != null && otherActions.size() > 0) {
269674bc19476536f2b5462eaa29e6f3029ee897c16dKristian Monsen            if (mActions == null) {
269774bc19476536f2b5462eaa29e6f3029ee897c16dKristian Monsen                mActions = new ArrayList(otherActions);
269874bc19476536f2b5462eaa29e6f3029ee897c16dKristian Monsen            } else {
269974bc19476536f2b5462eaa29e6f3029ee897c16dKristian Monsen                mActions.clear();
270074bc19476536f2b5462eaa29e6f3029ee897c16dKristian Monsen                mActions.addAll(other.mActions);
270174bc19476536f2b5462eaa29e6f3029ee897c16dKristian Monsen            }
270274bc19476536f2b5462eaa29e6f3029ee897c16dKristian Monsen        }
270374bc19476536f2b5462eaa29e6f3029ee897c16dKristian Monsen
270435bfedeaba724aeadc6f6c890269cb6bf7ef42f5Svetoslav Ganov        mBooleanProperties = other.mBooleanProperties;
2705029942f77d05ed3d20256403652b220c83dad6e1Alan Viverette        mMaxTextLength = other.mMaxTextLength;
27062b435aada3d274a9c08d334946fff1ab9ba15b48Svetoslav Ganov        mMovementGranularities = other.mMovementGranularities;
2707f0aed09ed8153043e40b3ac99788d47ba0831306Alan Viverette
2708f0aed09ed8153043e40b3ac99788d47ba0831306Alan Viverette        final LongArray otherChildNodeIds = other.mChildNodeIds;
2709f0aed09ed8153043e40b3ac99788d47ba0831306Alan Viverette        if (otherChildNodeIds != null && otherChildNodeIds.size() > 0) {
2710f0aed09ed8153043e40b3ac99788d47ba0831306Alan Viverette            if (mChildNodeIds == null) {
2711f0aed09ed8153043e40b3ac99788d47ba0831306Alan Viverette                mChildNodeIds = otherChildNodeIds.clone();
2712f0aed09ed8153043e40b3ac99788d47ba0831306Alan Viverette            } else {
27138e3feb15c5aec2c72b0ef120a1da325e1e8f0ddaSvetoslav                mChildNodeIds.clear();
2714f0aed09ed8153043e40b3ac99788d47ba0831306Alan Viverette                mChildNodeIds.addAll(otherChildNodeIds);
2715f0aed09ed8153043e40b3ac99788d47ba0831306Alan Viverette            }
2716aa780c110922148a6a4ba06734bb2b0bb8c98f93Svetoslav Ganov        }
2717f0aed09ed8153043e40b3ac99788d47ba0831306Alan Viverette
2718bcc46a0d037e62fcb5e5f0f5e1acef5a8c1314b0Svetoslav        mTextSelectionStart = other.mTextSelectionStart;
2719bcc46a0d037e62fcb5e5f0f5e1acef5a8c1314b0Svetoslav        mTextSelectionEnd = other.mTextSelectionEnd;
27206254f4806dd3db53b7380e77fbb183065685573eSvetoslav        mInputType = other.mInputType;
272177e9a28e2faa36f127231b842476d47f9823a83aAlan Viverette        mLiveRegion = other.mLiveRegion;
2722cb8ed39b3fb591be60b9fb1799d4ea4530eab758Svetoslav Ganov        if (other.mExtras != null && !other.mExtras.isEmpty()) {
2723cb8ed39b3fb591be60b9fb1799d4ea4530eab758Svetoslav Ganov            getExtras().putAll(other.mExtras);
27246254f4806dd3db53b7380e77fbb183065685573eSvetoslav        }
27256685f1bacead5f765c71a49f5cf0dc88750344d5Svetoslav Ganov        mRangeInfo = (other.mRangeInfo != null)
27266685f1bacead5f765c71a49f5cf0dc88750344d5Svetoslav Ganov                ? RangeInfo.obtain(other.mRangeInfo) : null;
27276685f1bacead5f765c71a49f5cf0dc88750344d5Svetoslav Ganov        mCollectionInfo = (other.mCollectionInfo != null)
27286685f1bacead5f765c71a49f5cf0dc88750344d5Svetoslav Ganov                ? CollectionInfo.obtain(other.mCollectionInfo) : null;
27296685f1bacead5f765c71a49f5cf0dc88750344d5Svetoslav Ganov        mCollectionItemInfo =  (other.mCollectionItemInfo != null)
27306685f1bacead5f765c71a49f5cf0dc88750344d5Svetoslav Ganov                ? CollectionItemInfo.obtain(other.mCollectionItemInfo) : null;
273135bfedeaba724aeadc6f6c890269cb6bf7ef42f5Svetoslav Ganov    }
273235bfedeaba724aeadc6f6c890269cb6bf7ef42f5Svetoslav Ganov
273335bfedeaba724aeadc6f6c890269cb6bf7ef42f5Svetoslav Ganov    /**
27348643aa0179e598e78d938c59035389054535a229Svetoslav Ganov     * Creates a new instance from a {@link Parcel}.
27358643aa0179e598e78d938c59035389054535a229Svetoslav Ganov     *
27368643aa0179e598e78d938c59035389054535a229Svetoslav Ganov     * @param parcel A parcel containing the state of a {@link AccessibilityNodeInfo}.
27378643aa0179e598e78d938c59035389054535a229Svetoslav Ganov     */
27388643aa0179e598e78d938c59035389054535a229Svetoslav Ganov    private void initFromParcel(Parcel parcel) {
27398643aa0179e598e78d938c59035389054535a229Svetoslav Ganov        mSealed = (parcel.readInt()  == 1);
2740021078554b902179442a345a9d080a165c3b5139Svetoslav Ganov        mSourceNodeId = parcel.readLong();
2741021078554b902179442a345a9d080a165c3b5139Svetoslav Ganov        mWindowId = parcel.readInt();
2742021078554b902179442a345a9d080a165c3b5139Svetoslav Ganov        mParentNodeId = parcel.readLong();
274333aef98fd28dcac0a2ad37e7329afd3e666f5e0aSvetoslav Ganov        mLabelForId = parcel.readLong();
274433aef98fd28dcac0a2ad37e7329afd3e666f5e0aSvetoslav Ganov        mLabeledById = parcel.readLong();
27456c70290ff0b20329c8f173d5c3423eb83ddc46f1Svetoslav        mTraversalBefore = parcel.readLong();
27466c70290ff0b20329c8f173d5c3423eb83ddc46f1Svetoslav        mTraversalAfter = parcel.readLong();
27476c70290ff0b20329c8f173d5c3423eb83ddc46f1Svetoslav
2748d116d7c78a9c53f30a73bf273bd7618312cf3847Svetoslav Ganov        mConnectionId = parcel.readInt();
27498643aa0179e598e78d938c59035389054535a229Svetoslav Ganov
27508643aa0179e598e78d938c59035389054535a229Svetoslav Ganov        final int childrenSize = parcel.readInt();
2751f0aed09ed8153043e40b3ac99788d47ba0831306Alan Viverette        if (childrenSize <= 0) {
2752f0aed09ed8153043e40b3ac99788d47ba0831306Alan Viverette            mChildNodeIds = null;
2753f0aed09ed8153043e40b3ac99788d47ba0831306Alan Viverette        } else {
2754f0aed09ed8153043e40b3ac99788d47ba0831306Alan Viverette            mChildNodeIds = new LongArray(childrenSize);
2755f0aed09ed8153043e40b3ac99788d47ba0831306Alan Viverette            for (int i = 0; i < childrenSize; i++) {
2756f0aed09ed8153043e40b3ac99788d47ba0831306Alan Viverette                final long childId = parcel.readLong();
2757f0aed09ed8153043e40b3ac99788d47ba0831306Alan Viverette                mChildNodeIds.add(childId);
2758f0aed09ed8153043e40b3ac99788d47ba0831306Alan Viverette            }
27598643aa0179e598e78d938c59035389054535a229Svetoslav Ganov        }
27608643aa0179e598e78d938c59035389054535a229Svetoslav Ganov
2761eeee4d2c01d3c4ed99e4891dbc75c7de69a803faSvetoslav Ganov        mBoundsInParent.top = parcel.readInt();
2762eeee4d2c01d3c4ed99e4891dbc75c7de69a803faSvetoslav Ganov        mBoundsInParent.bottom = parcel.readInt();
2763eeee4d2c01d3c4ed99e4891dbc75c7de69a803faSvetoslav Ganov        mBoundsInParent.left = parcel.readInt();
2764eeee4d2c01d3c4ed99e4891dbc75c7de69a803faSvetoslav Ganov        mBoundsInParent.right = parcel.readInt();
2765eeee4d2c01d3c4ed99e4891dbc75c7de69a803faSvetoslav Ganov
2766eeee4d2c01d3c4ed99e4891dbc75c7de69a803faSvetoslav Ganov        mBoundsInScreen.top = parcel.readInt();
2767eeee4d2c01d3c4ed99e4891dbc75c7de69a803faSvetoslav Ganov        mBoundsInScreen.bottom = parcel.readInt();
2768eeee4d2c01d3c4ed99e4891dbc75c7de69a803faSvetoslav Ganov        mBoundsInScreen.left = parcel.readInt();
2769eeee4d2c01d3c4ed99e4891dbc75c7de69a803faSvetoslav Ganov        mBoundsInScreen.right = parcel.readInt();
27708643aa0179e598e78d938c59035389054535a229Svetoslav Ganov
277174bc19476536f2b5462eaa29e6f3029ee897c16dKristian Monsen        final int actionCount = parcel.readInt();
277274bc19476536f2b5462eaa29e6f3029ee897c16dKristian Monsen        if (actionCount > 0) {
277374bc19476536f2b5462eaa29e6f3029ee897c16dKristian Monsen            final int legacyStandardActions = parcel.readInt();
277474bc19476536f2b5462eaa29e6f3029ee897c16dKristian Monsen            addLegacyStandardActions(legacyStandardActions);
277574bc19476536f2b5462eaa29e6f3029ee897c16dKristian Monsen            final int nonLegacyActionCount = actionCount - Integer.bitCount(legacyStandardActions);
277674bc19476536f2b5462eaa29e6f3029ee897c16dKristian Monsen            for (int i = 0; i < nonLegacyActionCount; i++) {
277774bc19476536f2b5462eaa29e6f3029ee897c16dKristian Monsen                AccessibilityAction action = new AccessibilityAction(
277874bc19476536f2b5462eaa29e6f3029ee897c16dKristian Monsen                        parcel.readInt(), parcel.readCharSequence());
277974bc19476536f2b5462eaa29e6f3029ee897c16dKristian Monsen                addAction(action);
278074bc19476536f2b5462eaa29e6f3029ee897c16dKristian Monsen            }
278174bc19476536f2b5462eaa29e6f3029ee897c16dKristian Monsen        }
27828643aa0179e598e78d938c59035389054535a229Svetoslav Ganov
2783029942f77d05ed3d20256403652b220c83dad6e1Alan Viverette        mMaxTextLength = parcel.readInt();
27842b435aada3d274a9c08d334946fff1ab9ba15b48Svetoslav Ganov        mMovementGranularities = parcel.readInt();
27858643aa0179e598e78d938c59035389054535a229Svetoslav Ganov        mBooleanProperties = parcel.readInt();
27868643aa0179e598e78d938c59035389054535a229Svetoslav Ganov
2787aa780c110922148a6a4ba06734bb2b0bb8c98f93Svetoslav Ganov        mPackageName = parcel.readCharSequence();
2788aa780c110922148a6a4ba06734bb2b0bb8c98f93Svetoslav Ganov        mClassName = parcel.readCharSequence();
2789aa780c110922148a6a4ba06734bb2b0bb8c98f93Svetoslav Ganov        mText = parcel.readCharSequence();
2790fccbff5f021a6f95fe1c18f55866545c767ef8ebAlan Viverette        mError = parcel.readCharSequence();
2791aa780c110922148a6a4ba06734bb2b0bb8c98f93Svetoslav Ganov        mContentDescription = parcel.readCharSequence();
27929fa1ee563b5a9ca25554f1fa59d1222dcfdfc623Svetoslav        mViewIdResourceName = parcel.readString();
2793bcc46a0d037e62fcb5e5f0f5e1acef5a8c1314b0Svetoslav
2794bcc46a0d037e62fcb5e5f0f5e1acef5a8c1314b0Svetoslav        mTextSelectionStart = parcel.readInt();
2795bcc46a0d037e62fcb5e5f0f5e1acef5a8c1314b0Svetoslav        mTextSelectionEnd = parcel.readInt();
27963577a283e1af3e14fe980c4fec55781a58cd8e3cSvetoslav
27976254f4806dd3db53b7380e77fbb183065685573eSvetoslav        mInputType = parcel.readInt();
279877e9a28e2faa36f127231b842476d47f9823a83aAlan Viverette        mLiveRegion = parcel.readInt();
27996254f4806dd3db53b7380e77fbb183065685573eSvetoslav
28006254f4806dd3db53b7380e77fbb183065685573eSvetoslav        if (parcel.readInt() == 1) {
2801cb8ed39b3fb591be60b9fb1799d4ea4530eab758Svetoslav Ganov            getExtras().putAll(parcel.readBundle());
28026254f4806dd3db53b7380e77fbb183065685573eSvetoslav        }
28033577a283e1af3e14fe980c4fec55781a58cd8e3cSvetoslav
28043577a283e1af3e14fe980c4fec55781a58cd8e3cSvetoslav        if (parcel.readInt() == 1) {
28053577a283e1af3e14fe980c4fec55781a58cd8e3cSvetoslav            mRangeInfo = RangeInfo.obtain(
28063577a283e1af3e14fe980c4fec55781a58cd8e3cSvetoslav                    parcel.readInt(),
28073577a283e1af3e14fe980c4fec55781a58cd8e3cSvetoslav                    parcel.readFloat(),
28083577a283e1af3e14fe980c4fec55781a58cd8e3cSvetoslav                    parcel.readFloat(),
28093577a283e1af3e14fe980c4fec55781a58cd8e3cSvetoslav                    parcel.readFloat());
28103577a283e1af3e14fe980c4fec55781a58cd8e3cSvetoslav        }
28113577a283e1af3e14fe980c4fec55781a58cd8e3cSvetoslav
28123577a283e1af3e14fe980c4fec55781a58cd8e3cSvetoslav        if (parcel.readInt() == 1) {
28133577a283e1af3e14fe980c4fec55781a58cd8e3cSvetoslav            mCollectionInfo = CollectionInfo.obtain(
28143577a283e1af3e14fe980c4fec55781a58cd8e3cSvetoslav                    parcel.readInt(),
28153577a283e1af3e14fe980c4fec55781a58cd8e3cSvetoslav                    parcel.readInt(),
281676769ae02e713f50816ee67ff618b748d95050a8Alan Viverette                    parcel.readInt() == 1,
281776769ae02e713f50816ee67ff618b748d95050a8Alan Viverette                    parcel.readInt());
28183577a283e1af3e14fe980c4fec55781a58cd8e3cSvetoslav        }
28193577a283e1af3e14fe980c4fec55781a58cd8e3cSvetoslav
28203577a283e1af3e14fe980c4fec55781a58cd8e3cSvetoslav        if (parcel.readInt() == 1) {
28213577a283e1af3e14fe980c4fec55781a58cd8e3cSvetoslav            mCollectionItemInfo = CollectionItemInfo.obtain(
28223577a283e1af3e14fe980c4fec55781a58cd8e3cSvetoslav                    parcel.readInt(),
28233577a283e1af3e14fe980c4fec55781a58cd8e3cSvetoslav                    parcel.readInt(),
28243577a283e1af3e14fe980c4fec55781a58cd8e3cSvetoslav                    parcel.readInt(),
28253577a283e1af3e14fe980c4fec55781a58cd8e3cSvetoslav                    parcel.readInt(),
282676769ae02e713f50816ee67ff618b748d95050a8Alan Viverette                    parcel.readInt() == 1,
28273577a283e1af3e14fe980c4fec55781a58cd8e3cSvetoslav                    parcel.readInt() == 1);
28283577a283e1af3e14fe980c4fec55781a58cd8e3cSvetoslav        }
28298643aa0179e598e78d938c59035389054535a229Svetoslav Ganov    }
28308643aa0179e598e78d938c59035389054535a229Svetoslav Ganov
28318643aa0179e598e78d938c59035389054535a229Svetoslav Ganov    /**
28328643aa0179e598e78d938c59035389054535a229Svetoslav Ganov     * Clears the state of this instance.
28338643aa0179e598e78d938c59035389054535a229Svetoslav Ganov     */
28348643aa0179e598e78d938c59035389054535a229Svetoslav Ganov    private void clear() {
28358643aa0179e598e78d938c59035389054535a229Svetoslav Ganov        mSealed = false;
28360d04e245534cf777dfaf16dce3c51553837c14ffSvetoslav Ganov        mSourceNodeId = ROOT_NODE_ID;
28370d04e245534cf777dfaf16dce3c51553837c14ffSvetoslav Ganov        mParentNodeId = ROOT_NODE_ID;
283833aef98fd28dcac0a2ad37e7329afd3e666f5e0aSvetoslav Ganov        mLabelForId = ROOT_NODE_ID;
283933aef98fd28dcac0a2ad37e7329afd3e666f5e0aSvetoslav Ganov        mLabeledById = ROOT_NODE_ID;
28406c70290ff0b20329c8f173d5c3423eb83ddc46f1Svetoslav        mTraversalBefore = ROOT_NODE_ID;
28416c70290ff0b20329c8f173d5c3423eb83ddc46f1Svetoslav        mTraversalAfter = ROOT_NODE_ID;
28428e3feb15c5aec2c72b0ef120a1da325e1e8f0ddaSvetoslav        mWindowId = UNDEFINED_ITEM_ID;
28438e3feb15c5aec2c72b0ef120a1da325e1e8f0ddaSvetoslav        mConnectionId = UNDEFINED_CONNECTION_ID;
2844029942f77d05ed3d20256403652b220c83dad6e1Alan Viverette        mMaxTextLength = -1;
28452b435aada3d274a9c08d334946fff1ab9ba15b48Svetoslav Ganov        mMovementGranularities = 0;
2846f0aed09ed8153043e40b3ac99788d47ba0831306Alan Viverette        if (mChildNodeIds != null) {
2847f0aed09ed8153043e40b3ac99788d47ba0831306Alan Viverette            mChildNodeIds.clear();
2848f0aed09ed8153043e40b3ac99788d47ba0831306Alan Viverette        }
2849eeee4d2c01d3c4ed99e4891dbc75c7de69a803faSvetoslav Ganov        mBoundsInParent.set(0, 0, 0, 0);
2850eeee4d2c01d3c4ed99e4891dbc75c7de69a803faSvetoslav Ganov        mBoundsInScreen.set(0, 0, 0, 0);
28518643aa0179e598e78d938c59035389054535a229Svetoslav Ganov        mBooleanProperties = 0;
28528643aa0179e598e78d938c59035389054535a229Svetoslav Ganov        mPackageName = null;
28538643aa0179e598e78d938c59035389054535a229Svetoslav Ganov        mClassName = null;
28548643aa0179e598e78d938c59035389054535a229Svetoslav Ganov        mText = null;
2855fccbff5f021a6f95fe1c18f55866545c767ef8ebAlan Viverette        mError = null;
28568643aa0179e598e78d938c59035389054535a229Svetoslav Ganov        mContentDescription = null;
285722431a3b6fb5ae3498c6ae780648ca0228635ebaSvetoslav        mViewIdResourceName = null;
285874bc19476536f2b5462eaa29e6f3029ee897c16dKristian Monsen        if (mActions != null) {
285974bc19476536f2b5462eaa29e6f3029ee897c16dKristian Monsen            mActions.clear();
286074bc19476536f2b5462eaa29e6f3029ee897c16dKristian Monsen        }
28618e3feb15c5aec2c72b0ef120a1da325e1e8f0ddaSvetoslav        mTextSelectionStart = UNDEFINED_SELECTION_INDEX;
28628e3feb15c5aec2c72b0ef120a1da325e1e8f0ddaSvetoslav        mTextSelectionEnd = UNDEFINED_SELECTION_INDEX;
28636254f4806dd3db53b7380e77fbb183065685573eSvetoslav        mInputType = InputType.TYPE_NULL;
286477e9a28e2faa36f127231b842476d47f9823a83aAlan Viverette        mLiveRegion = View.ACCESSIBILITY_LIVE_REGION_NONE;
2865cb8ed39b3fb591be60b9fb1799d4ea4530eab758Svetoslav Ganov        if (mExtras != null) {
2866cb8ed39b3fb591be60b9fb1799d4ea4530eab758Svetoslav Ganov            mExtras.clear();
28676254f4806dd3db53b7380e77fbb183065685573eSvetoslav        }
28683577a283e1af3e14fe980c4fec55781a58cd8e3cSvetoslav        if (mRangeInfo != null) {
28693577a283e1af3e14fe980c4fec55781a58cd8e3cSvetoslav            mRangeInfo.recycle();
28703577a283e1af3e14fe980c4fec55781a58cd8e3cSvetoslav            mRangeInfo = null;
28713577a283e1af3e14fe980c4fec55781a58cd8e3cSvetoslav        }
28723577a283e1af3e14fe980c4fec55781a58cd8e3cSvetoslav        if (mCollectionInfo != null) {
28733577a283e1af3e14fe980c4fec55781a58cd8e3cSvetoslav            mCollectionInfo.recycle();
28743577a283e1af3e14fe980c4fec55781a58cd8e3cSvetoslav            mCollectionInfo = null;
28753577a283e1af3e14fe980c4fec55781a58cd8e3cSvetoslav        }
28763577a283e1af3e14fe980c4fec55781a58cd8e3cSvetoslav        if (mCollectionItemInfo != null) {
28773577a283e1af3e14fe980c4fec55781a58cd8e3cSvetoslav            mCollectionItemInfo.recycle();
28783577a283e1af3e14fe980c4fec55781a58cd8e3cSvetoslav            mCollectionItemInfo = null;
28793577a283e1af3e14fe980c4fec55781a58cd8e3cSvetoslav        }
28808643aa0179e598e78d938c59035389054535a229Svetoslav Ganov    }
28818643aa0179e598e78d938c59035389054535a229Svetoslav Ganov
288274bc19476536f2b5462eaa29e6f3029ee897c16dKristian Monsen    private static boolean isDefaultLegacyStandardAction(AccessibilityAction action) {
288374bc19476536f2b5462eaa29e6f3029ee897c16dKristian Monsen        return (action.getId() <= LAST_LEGACY_STANDARD_ACTION
288474bc19476536f2b5462eaa29e6f3029ee897c16dKristian Monsen                && TextUtils.isEmpty(action.getLabel()));
288574bc19476536f2b5462eaa29e6f3029ee897c16dKristian Monsen    }
288674bc19476536f2b5462eaa29e6f3029ee897c16dKristian Monsen
288774bc19476536f2b5462eaa29e6f3029ee897c16dKristian Monsen    private static AccessibilityAction getActionSingleton(int actionId) {
288874bc19476536f2b5462eaa29e6f3029ee897c16dKristian Monsen        final int actions = AccessibilityAction.sStandardActions.size();
288974bc19476536f2b5462eaa29e6f3029ee897c16dKristian Monsen        for (int i = 0; i < actions; i++) {
289074bc19476536f2b5462eaa29e6f3029ee897c16dKristian Monsen            AccessibilityAction currentAction = AccessibilityAction.sStandardActions.valueAt(i);
289174bc19476536f2b5462eaa29e6f3029ee897c16dKristian Monsen            if (actionId == currentAction.getId()) {
289274bc19476536f2b5462eaa29e6f3029ee897c16dKristian Monsen                return currentAction;
289374bc19476536f2b5462eaa29e6f3029ee897c16dKristian Monsen            }
289474bc19476536f2b5462eaa29e6f3029ee897c16dKristian Monsen        }
289574bc19476536f2b5462eaa29e6f3029ee897c16dKristian Monsen
289674bc19476536f2b5462eaa29e6f3029ee897c16dKristian Monsen        return null;
289774bc19476536f2b5462eaa29e6f3029ee897c16dKristian Monsen    }
289874bc19476536f2b5462eaa29e6f3029ee897c16dKristian Monsen
289974bc19476536f2b5462eaa29e6f3029ee897c16dKristian Monsen    private void addLegacyStandardActions(int actionMask) {
290074bc19476536f2b5462eaa29e6f3029ee897c16dKristian Monsen        int remainingIds = actionMask;
290174bc19476536f2b5462eaa29e6f3029ee897c16dKristian Monsen        while (remainingIds > 0) {
290274bc19476536f2b5462eaa29e6f3029ee897c16dKristian Monsen            final int id = 1 << Integer.numberOfTrailingZeros(remainingIds);
290374bc19476536f2b5462eaa29e6f3029ee897c16dKristian Monsen            remainingIds &= ~id;
290474bc19476536f2b5462eaa29e6f3029ee897c16dKristian Monsen            AccessibilityAction action = getActionSingleton(id);
290574bc19476536f2b5462eaa29e6f3029ee897c16dKristian Monsen            addAction(action);
290674bc19476536f2b5462eaa29e6f3029ee897c16dKristian Monsen        }
290774bc19476536f2b5462eaa29e6f3029ee897c16dKristian Monsen    }
290874bc19476536f2b5462eaa29e6f3029ee897c16dKristian Monsen
29098643aa0179e598e78d938c59035389054535a229Svetoslav Ganov    /**
29108643aa0179e598e78d938c59035389054535a229Svetoslav Ganov     * Gets the human readable action symbolic name.
29118643aa0179e598e78d938c59035389054535a229Svetoslav Ganov     *
29128643aa0179e598e78d938c59035389054535a229Svetoslav Ganov     * @param action The action.
29138643aa0179e598e78d938c59035389054535a229Svetoslav Ganov     * @return The symbolic name.
29148643aa0179e598e78d938c59035389054535a229Svetoslav Ganov     */
29158643aa0179e598e78d938c59035389054535a229Svetoslav Ganov    private static String getActionSymbolicName(int action) {
291638e8b4e5bc3c93affdffbc064fd9db5aeccc3e8eSvetoslav Ganov        switch (action) {
291738e8b4e5bc3c93affdffbc064fd9db5aeccc3e8eSvetoslav Ganov            case ACTION_FOCUS:
291838e8b4e5bc3c93affdffbc064fd9db5aeccc3e8eSvetoslav Ganov                return "ACTION_FOCUS";
291938e8b4e5bc3c93affdffbc064fd9db5aeccc3e8eSvetoslav Ganov            case ACTION_CLEAR_FOCUS:
292038e8b4e5bc3c93affdffbc064fd9db5aeccc3e8eSvetoslav Ganov                return "ACTION_CLEAR_FOCUS";
292138e8b4e5bc3c93affdffbc064fd9db5aeccc3e8eSvetoslav Ganov            case ACTION_SELECT:
292238e8b4e5bc3c93affdffbc064fd9db5aeccc3e8eSvetoslav Ganov                return "ACTION_SELECT";
292338e8b4e5bc3c93affdffbc064fd9db5aeccc3e8eSvetoslav Ganov            case ACTION_CLEAR_SELECTION:
292438e8b4e5bc3c93affdffbc064fd9db5aeccc3e8eSvetoslav Ganov                return "ACTION_CLEAR_SELECTION";
2925e9bda15f87c11a8827ca0ffc865611176805cc0aSvetoslav Ganov            case ACTION_CLICK:
2926e9bda15f87c11a8827ca0ffc865611176805cc0aSvetoslav Ganov                return "ACTION_CLICK";
2927e9bda15f87c11a8827ca0ffc865611176805cc0aSvetoslav Ganov            case ACTION_LONG_CLICK:
2928e9bda15f87c11a8827ca0ffc865611176805cc0aSvetoslav Ganov                return "ACTION_LONG_CLICK";
2929e9bda15f87c11a8827ca0ffc865611176805cc0aSvetoslav Ganov            case ACTION_ACCESSIBILITY_FOCUS:
2930e9bda15f87c11a8827ca0ffc865611176805cc0aSvetoslav Ganov                return "ACTION_ACCESSIBILITY_FOCUS";
2931e9bda15f87c11a8827ca0ffc865611176805cc0aSvetoslav Ganov            case ACTION_CLEAR_ACCESSIBILITY_FOCUS:
2932e9bda15f87c11a8827ca0ffc865611176805cc0aSvetoslav Ganov                return "ACTION_CLEAR_ACCESSIBILITY_FOCUS";
29332b435aada3d274a9c08d334946fff1ab9ba15b48Svetoslav Ganov            case ACTION_NEXT_AT_MOVEMENT_GRANULARITY:
29342b435aada3d274a9c08d334946fff1ab9ba15b48Svetoslav Ganov                return "ACTION_NEXT_AT_MOVEMENT_GRANULARITY";
29352b435aada3d274a9c08d334946fff1ab9ba15b48Svetoslav Ganov            case ACTION_PREVIOUS_AT_MOVEMENT_GRANULARITY:
29362b435aada3d274a9c08d334946fff1ab9ba15b48Svetoslav Ganov                return "ACTION_PREVIOUS_AT_MOVEMENT_GRANULARITY";
2937e9bda15f87c11a8827ca0ffc865611176805cc0aSvetoslav Ganov            case ACTION_NEXT_HTML_ELEMENT:
2938e9bda15f87c11a8827ca0ffc865611176805cc0aSvetoslav Ganov                return "ACTION_NEXT_HTML_ELEMENT";
2939e9bda15f87c11a8827ca0ffc865611176805cc0aSvetoslav Ganov            case ACTION_PREVIOUS_HTML_ELEMENT:
2940e9bda15f87c11a8827ca0ffc865611176805cc0aSvetoslav Ganov                return "ACTION_PREVIOUS_HTML_ELEMENT";
2941a1dc761c8322355eb1bb71d3d6c9c603c1d1fc0fSvetoslav Ganov            case ACTION_SCROLL_FORWARD:
2942a1dc761c8322355eb1bb71d3d6c9c603c1d1fc0fSvetoslav Ganov                return "ACTION_SCROLL_FORWARD";
2943a1dc761c8322355eb1bb71d3d6c9c603c1d1fc0fSvetoslav Ganov            case ACTION_SCROLL_BACKWARD:
2944a1dc761c8322355eb1bb71d3d6c9c603c1d1fc0fSvetoslav Ganov                return "ACTION_SCROLL_BACKWARD";
2945242724ee524573b42cad3812c633295607f9c6e1Svetoslav Ganov            case ACTION_CUT:
2946242724ee524573b42cad3812c633295607f9c6e1Svetoslav Ganov                return "ACTION_CUT";
2947242724ee524573b42cad3812c633295607f9c6e1Svetoslav Ganov            case ACTION_COPY:
2948242724ee524573b42cad3812c633295607f9c6e1Svetoslav Ganov                return "ACTION_COPY";
2949242724ee524573b42cad3812c633295607f9c6e1Svetoslav Ganov            case ACTION_PASTE:
2950242724ee524573b42cad3812c633295607f9c6e1Svetoslav Ganov                return "ACTION_PASTE";
2951242724ee524573b42cad3812c633295607f9c6e1Svetoslav Ganov            case ACTION_SET_SELECTION:
2952242724ee524573b42cad3812c633295607f9c6e1Svetoslav Ganov                return "ACTION_SET_SELECTION";
295338e8b4e5bc3c93affdffbc064fd9db5aeccc3e8eSvetoslav Ganov            default:
2954242724ee524573b42cad3812c633295607f9c6e1Svetoslav Ganov                return"ACTION_UNKNOWN";
29558643aa0179e598e78d938c59035389054535a229Svetoslav Ganov        }
29568643aa0179e598e78d938c59035389054535a229Svetoslav Ganov    }
29578643aa0179e598e78d938c59035389054535a229Svetoslav Ganov
2958b7ff3255c6d4e12f9d2334e3bbec0a125b7b09dcSvetoslav Ganov    /**
29592b435aada3d274a9c08d334946fff1ab9ba15b48Svetoslav Ganov     * Gets the human readable movement granularity symbolic name.
2960b7ff3255c6d4e12f9d2334e3bbec0a125b7b09dcSvetoslav Ganov     *
29612b435aada3d274a9c08d334946fff1ab9ba15b48Svetoslav Ganov     * @param granularity The granularity.
2962b7ff3255c6d4e12f9d2334e3bbec0a125b7b09dcSvetoslav Ganov     * @return The symbolic name.
2963b7ff3255c6d4e12f9d2334e3bbec0a125b7b09dcSvetoslav Ganov     */
29642b435aada3d274a9c08d334946fff1ab9ba15b48Svetoslav Ganov    private static String getMovementGranularitySymbolicName(int granularity) {
2965b7ff3255c6d4e12f9d2334e3bbec0a125b7b09dcSvetoslav Ganov        switch (granularity) {
29662b435aada3d274a9c08d334946fff1ab9ba15b48Svetoslav Ganov            case MOVEMENT_GRANULARITY_CHARACTER:
29672b435aada3d274a9c08d334946fff1ab9ba15b48Svetoslav Ganov                return "MOVEMENT_GRANULARITY_CHARACTER";
29682b435aada3d274a9c08d334946fff1ab9ba15b48Svetoslav Ganov            case MOVEMENT_GRANULARITY_WORD:
29692b435aada3d274a9c08d334946fff1ab9ba15b48Svetoslav Ganov                return "MOVEMENT_GRANULARITY_WORD";
29702b435aada3d274a9c08d334946fff1ab9ba15b48Svetoslav Ganov            case MOVEMENT_GRANULARITY_LINE:
29712b435aada3d274a9c08d334946fff1ab9ba15b48Svetoslav Ganov                return "MOVEMENT_GRANULARITY_LINE";
29722b435aada3d274a9c08d334946fff1ab9ba15b48Svetoslav Ganov            case MOVEMENT_GRANULARITY_PARAGRAPH:
29732b435aada3d274a9c08d334946fff1ab9ba15b48Svetoslav Ganov                return "MOVEMENT_GRANULARITY_PARAGRAPH";
29742b435aada3d274a9c08d334946fff1ab9ba15b48Svetoslav Ganov            case MOVEMENT_GRANULARITY_PAGE:
29752b435aada3d274a9c08d334946fff1ab9ba15b48Svetoslav Ganov                return "MOVEMENT_GRANULARITY_PAGE";
2976b7ff3255c6d4e12f9d2334e3bbec0a125b7b09dcSvetoslav Ganov            default:
29772b435aada3d274a9c08d334946fff1ab9ba15b48Svetoslav Ganov                throw new IllegalArgumentException("Unknown movement granularity: " + granularity);
2978b7ff3255c6d4e12f9d2334e3bbec0a125b7b09dcSvetoslav Ganov        }
2979b7ff3255c6d4e12f9d2334e3bbec0a125b7b09dcSvetoslav Ganov    }
2980b7ff3255c6d4e12f9d2334e3bbec0a125b7b09dcSvetoslav Ganov
2981021078554b902179442a345a9d080a165c3b5139Svetoslav Ganov    private boolean canPerformRequestOverConnection(long accessibilityNodeId) {
29828e3feb15c5aec2c72b0ef120a1da325e1e8f0ddaSvetoslav        return (mWindowId != UNDEFINED_ITEM_ID
29838e3feb15c5aec2c72b0ef120a1da325e1e8f0ddaSvetoslav                && getAccessibilityViewId(accessibilityNodeId) != UNDEFINED_ITEM_ID
29848e3feb15c5aec2c72b0ef120a1da325e1e8f0ddaSvetoslav                && mConnectionId != UNDEFINED_CONNECTION_ID);
2985eeee4d2c01d3c4ed99e4891dbc75c7de69a803faSvetoslav Ganov    }
2986eeee4d2c01d3c4ed99e4891dbc75c7de69a803faSvetoslav Ganov
29878643aa0179e598e78d938c59035389054535a229Svetoslav Ganov    @Override
29888dffad68c7aa7da9a3d73d1ee41f3c4460f733b4Svetoslav Ganov    public boolean equals(Object object) {
29898dffad68c7aa7da9a3d73d1ee41f3c4460f733b4Svetoslav Ganov        if (this == object) {
29908dffad68c7aa7da9a3d73d1ee41f3c4460f733b4Svetoslav Ganov            return true;
29918dffad68c7aa7da9a3d73d1ee41f3c4460f733b4Svetoslav Ganov        }
29928dffad68c7aa7da9a3d73d1ee41f3c4460f733b4Svetoslav Ganov        if (object == null) {
29938dffad68c7aa7da9a3d73d1ee41f3c4460f733b4Svetoslav Ganov            return false;
29948dffad68c7aa7da9a3d73d1ee41f3c4460f733b4Svetoslav Ganov        }
29958dffad68c7aa7da9a3d73d1ee41f3c4460f733b4Svetoslav Ganov        if (getClass() != object.getClass()) {
29968dffad68c7aa7da9a3d73d1ee41f3c4460f733b4Svetoslav Ganov            return false;
29978dffad68c7aa7da9a3d73d1ee41f3c4460f733b4Svetoslav Ganov        }
29988dffad68c7aa7da9a3d73d1ee41f3c4460f733b4Svetoslav Ganov        AccessibilityNodeInfo other = (AccessibilityNodeInfo) object;
2999021078554b902179442a345a9d080a165c3b5139Svetoslav Ganov        if (mSourceNodeId != other.mSourceNodeId) {
30008dffad68c7aa7da9a3d73d1ee41f3c4460f733b4Svetoslav Ganov            return false;
30018dffad68c7aa7da9a3d73d1ee41f3c4460f733b4Svetoslav Ganov        }
3002021078554b902179442a345a9d080a165c3b5139Svetoslav Ganov        if (mWindowId != other.mWindowId) {
30038dffad68c7aa7da9a3d73d1ee41f3c4460f733b4Svetoslav Ganov            return false;
30048dffad68c7aa7da9a3d73d1ee41f3c4460f733b4Svetoslav Ganov        }
30058dffad68c7aa7da9a3d73d1ee41f3c4460f733b4Svetoslav Ganov        return true;
30068dffad68c7aa7da9a3d73d1ee41f3c4460f733b4Svetoslav Ganov    }
30078dffad68c7aa7da9a3d73d1ee41f3c4460f733b4Svetoslav Ganov
30088dffad68c7aa7da9a3d73d1ee41f3c4460f733b4Svetoslav Ganov    @Override
30098643aa0179e598e78d938c59035389054535a229Svetoslav Ganov    public int hashCode() {
30108643aa0179e598e78d938c59035389054535a229Svetoslav Ganov        final int prime = 31;
30118643aa0179e598e78d938c59035389054535a229Svetoslav Ganov        int result = 1;
3012021078554b902179442a345a9d080a165c3b5139Svetoslav Ganov        result = prime * result + getAccessibilityViewId(mSourceNodeId);
3013021078554b902179442a345a9d080a165c3b5139Svetoslav Ganov        result = prime * result + getVirtualDescendantId(mSourceNodeId);
3014021078554b902179442a345a9d080a165c3b5139Svetoslav Ganov        result = prime * result + mWindowId;
30158643aa0179e598e78d938c59035389054535a229Svetoslav Ganov        return result;
30168643aa0179e598e78d938c59035389054535a229Svetoslav Ganov    }
30178643aa0179e598e78d938c59035389054535a229Svetoslav Ganov
30188643aa0179e598e78d938c59035389054535a229Svetoslav Ganov    @Override
30198643aa0179e598e78d938c59035389054535a229Svetoslav Ganov    public String toString() {
30208643aa0179e598e78d938c59035389054535a229Svetoslav Ganov        StringBuilder builder = new StringBuilder();
30218643aa0179e598e78d938c59035389054535a229Svetoslav Ganov        builder.append(super.toString());
30228643aa0179e598e78d938c59035389054535a229Svetoslav Ganov
30238643aa0179e598e78d938c59035389054535a229Svetoslav Ganov        if (DEBUG) {
30248e3feb15c5aec2c72b0ef120a1da325e1e8f0ddaSvetoslav            builder.append("; sourceNodeId: " + mSourceNodeId);
3025021078554b902179442a345a9d080a165c3b5139Svetoslav Ganov            builder.append("; accessibilityViewId: " + getAccessibilityViewId(mSourceNodeId));
3026021078554b902179442a345a9d080a165c3b5139Svetoslav Ganov            builder.append("; virtualDescendantId: " + getVirtualDescendantId(mSourceNodeId));
3027021078554b902179442a345a9d080a165c3b5139Svetoslav Ganov            builder.append("; mParentNodeId: " + mParentNodeId);
30286c70290ff0b20329c8f173d5c3423eb83ddc46f1Svetoslav            builder.append("; traversalBefore: ").append(mTraversalBefore);
30296c70290ff0b20329c8f173d5c3423eb83ddc46f1Svetoslav            builder.append("; traversalAfter: ").append(mTraversalAfter);
3030aa780c110922148a6a4ba06734bb2b0bb8c98f93Svetoslav Ganov
30312b435aada3d274a9c08d334946fff1ab9ba15b48Svetoslav Ganov            int granularities = mMovementGranularities;
30322b435aada3d274a9c08d334946fff1ab9ba15b48Svetoslav Ganov            builder.append("; MovementGranularities: [");
3033b7ff3255c6d4e12f9d2334e3bbec0a125b7b09dcSvetoslav Ganov            while (granularities != 0) {
3034b7ff3255c6d4e12f9d2334e3bbec0a125b7b09dcSvetoslav Ganov                final int granularity = 1 << Integer.numberOfTrailingZeros(granularities);
3035b7ff3255c6d4e12f9d2334e3bbec0a125b7b09dcSvetoslav Ganov                granularities &= ~granularity;
30362b435aada3d274a9c08d334946fff1ab9ba15b48Svetoslav Ganov                builder.append(getMovementGranularitySymbolicName(granularity));
3037b7ff3255c6d4e12f9d2334e3bbec0a125b7b09dcSvetoslav Ganov                if (granularities != 0) {
3038aa780c110922148a6a4ba06734bb2b0bb8c98f93Svetoslav Ganov                    builder.append(", ");
3039aa780c110922148a6a4ba06734bb2b0bb8c98f93Svetoslav Ganov                }
3040aa780c110922148a6a4ba06734bb2b0bb8c98f93Svetoslav Ganov            }
3041aa780c110922148a6a4ba06734bb2b0bb8c98f93Svetoslav Ganov            builder.append("]");
3042aa780c110922148a6a4ba06734bb2b0bb8c98f93Svetoslav Ganov
30438643aa0179e598e78d938c59035389054535a229Svetoslav Ganov            builder.append("; childAccessibilityIds: [");
3044f0aed09ed8153043e40b3ac99788d47ba0831306Alan Viverette            final LongArray childIds = mChildNodeIds;
3045f0aed09ed8153043e40b3ac99788d47ba0831306Alan Viverette            if (childIds != null) {
3046f0aed09ed8153043e40b3ac99788d47ba0831306Alan Viverette                for (int i = 0, count = childIds.size(); i < count; i++) {
3047f0aed09ed8153043e40b3ac99788d47ba0831306Alan Viverette                    builder.append(childIds.get(i));
3048f0aed09ed8153043e40b3ac99788d47ba0831306Alan Viverette                    if (i < count - 1) {
3049f0aed09ed8153043e40b3ac99788d47ba0831306Alan Viverette                        builder.append(", ");
3050f0aed09ed8153043e40b3ac99788d47ba0831306Alan Viverette                    }
30518643aa0179e598e78d938c59035389054535a229Svetoslav Ganov                }
3052aa780c110922148a6a4ba06734bb2b0bb8c98f93Svetoslav Ganov            }
3053aa780c110922148a6a4ba06734bb2b0bb8c98f93Svetoslav Ganov            builder.append("]");
30548643aa0179e598e78d938c59035389054535a229Svetoslav Ganov        }
30558643aa0179e598e78d938c59035389054535a229Svetoslav Ganov
3056eeee4d2c01d3c4ed99e4891dbc75c7de69a803faSvetoslav Ganov        builder.append("; boundsInParent: " + mBoundsInParent);
3057eeee4d2c01d3c4ed99e4891dbc75c7de69a803faSvetoslav Ganov        builder.append("; boundsInScreen: " + mBoundsInScreen);
30588643aa0179e598e78d938c59035389054535a229Svetoslav Ganov
30598643aa0179e598e78d938c59035389054535a229Svetoslav Ganov        builder.append("; packageName: ").append(mPackageName);
30608643aa0179e598e78d938c59035389054535a229Svetoslav Ganov        builder.append("; className: ").append(mClassName);
30618643aa0179e598e78d938c59035389054535a229Svetoslav Ganov        builder.append("; text: ").append(mText);
3062fccbff5f021a6f95fe1c18f55866545c767ef8ebAlan Viverette        builder.append("; error: ").append(mError);
3063029942f77d05ed3d20256403652b220c83dad6e1Alan Viverette        builder.append("; maxTextLength: ").append(mMaxTextLength);
30648643aa0179e598e78d938c59035389054535a229Svetoslav Ganov        builder.append("; contentDescription: ").append(mContentDescription);
306522431a3b6fb5ae3498c6ae780648ca0228635ebaSvetoslav        builder.append("; viewIdResName: ").append(mViewIdResourceName);
30668643aa0179e598e78d938c59035389054535a229Svetoslav Ganov
30678643aa0179e598e78d938c59035389054535a229Svetoslav Ganov        builder.append("; checkable: ").append(isCheckable());
30688643aa0179e598e78d938c59035389054535a229Svetoslav Ganov        builder.append("; checked: ").append(isChecked());
30698643aa0179e598e78d938c59035389054535a229Svetoslav Ganov        builder.append("; focusable: ").append(isFocusable());
30708643aa0179e598e78d938c59035389054535a229Svetoslav Ganov        builder.append("; focused: ").append(isFocused());
30718643aa0179e598e78d938c59035389054535a229Svetoslav Ganov        builder.append("; selected: ").append(isSelected());
30728643aa0179e598e78d938c59035389054535a229Svetoslav Ganov        builder.append("; clickable: ").append(isClickable());
30738643aa0179e598e78d938c59035389054535a229Svetoslav Ganov        builder.append("; longClickable: ").append(isLongClickable());
30748643aa0179e598e78d938c59035389054535a229Svetoslav Ganov        builder.append("; enabled: ").append(isEnabled());
30758643aa0179e598e78d938c59035389054535a229Svetoslav Ganov        builder.append("; password: ").append(isPassword());
307674bc19476536f2b5462eaa29e6f3029ee897c16dKristian Monsen        builder.append("; scrollable: ").append(isScrollable());
307774bc19476536f2b5462eaa29e6f3029ee897c16dKristian Monsen        builder.append("; actions: ").append(mActions);
307874bc19476536f2b5462eaa29e6f3029ee897c16dKristian Monsen
307974bc19476536f2b5462eaa29e6f3029ee897c16dKristian Monsen        return builder.toString();
308074bc19476536f2b5462eaa29e6f3029ee897c16dKristian Monsen    }
308174bc19476536f2b5462eaa29e6f3029ee897c16dKristian Monsen
30826c70290ff0b20329c8f173d5c3423eb83ddc46f1Svetoslav    private AccessibilityNodeInfo getNodeForAccessibilityId(long accessibilityId) {
30836c70290ff0b20329c8f173d5c3423eb83ddc46f1Svetoslav        if (!canPerformRequestOverConnection(accessibilityId)) {
30846c70290ff0b20329c8f173d5c3423eb83ddc46f1Svetoslav            return null;
30856c70290ff0b20329c8f173d5c3423eb83ddc46f1Svetoslav        }
30866c70290ff0b20329c8f173d5c3423eb83ddc46f1Svetoslav        AccessibilityInteractionClient client = AccessibilityInteractionClient.getInstance();
30876c70290ff0b20329c8f173d5c3423eb83ddc46f1Svetoslav        return client.findAccessibilityNodeInfoByAccessibilityId(mConnectionId,
30886c70290ff0b20329c8f173d5c3423eb83ddc46f1Svetoslav                mWindowId, accessibilityId, false, FLAG_PREFETCH_PREDECESSORS
30896c70290ff0b20329c8f173d5c3423eb83ddc46f1Svetoslav                        | FLAG_PREFETCH_DESCENDANTS | FLAG_PREFETCH_SIBLINGS);
30906c70290ff0b20329c8f173d5c3423eb83ddc46f1Svetoslav    }
30916c70290ff0b20329c8f173d5c3423eb83ddc46f1Svetoslav
309274bc19476536f2b5462eaa29e6f3029ee897c16dKristian Monsen    /**
309374bc19476536f2b5462eaa29e6f3029ee897c16dKristian Monsen     * A class defining an action that can be performed on an {@link AccessibilityNodeInfo}.
309474bc19476536f2b5462eaa29e6f3029ee897c16dKristian Monsen     * Each action has a unique id that is mandatory and optional data.
309574bc19476536f2b5462eaa29e6f3029ee897c16dKristian Monsen     * <p>
309674bc19476536f2b5462eaa29e6f3029ee897c16dKristian Monsen     * There are three categories of actions:
309774bc19476536f2b5462eaa29e6f3029ee897c16dKristian Monsen     * <ul>
309874bc19476536f2b5462eaa29e6f3029ee897c16dKristian Monsen     * <li><strong>Standard actions</strong> - These are actions that are reported and
309974bc19476536f2b5462eaa29e6f3029ee897c16dKristian Monsen     * handled by the standard UI widgets in the platform. For each standard action
310074bc19476536f2b5462eaa29e6f3029ee897c16dKristian Monsen     * there is a static constant defined in this class, e.g. {@link #ACTION_FOCUS}.
310174bc19476536f2b5462eaa29e6f3029ee897c16dKristian Monsen     * </li>
310274bc19476536f2b5462eaa29e6f3029ee897c16dKristian Monsen     * <li><strong>Custom actions action</strong> - These are actions that are reported
310374bc19476536f2b5462eaa29e6f3029ee897c16dKristian Monsen     * and handled by custom widgets. i.e. ones that are not part of the UI toolkit. For
310474bc19476536f2b5462eaa29e6f3029ee897c16dKristian Monsen     * example, an application may define a custom action for clearing the user history.
310574bc19476536f2b5462eaa29e6f3029ee897c16dKristian Monsen     * </li>
310674bc19476536f2b5462eaa29e6f3029ee897c16dKristian Monsen     * <li><strong>Overriden standard actions</strong> - These are actions that override
310774bc19476536f2b5462eaa29e6f3029ee897c16dKristian Monsen     * standard actions to customize them. For example, an app may add a label to the
310874bc19476536f2b5462eaa29e6f3029ee897c16dKristian Monsen     * standard click action to announce that this action clears browsing history.
310974bc19476536f2b5462eaa29e6f3029ee897c16dKristian Monsen     * </ul>
311074bc19476536f2b5462eaa29e6f3029ee897c16dKristian Monsen     * </p>
311174bc19476536f2b5462eaa29e6f3029ee897c16dKristian Monsen     */
311274bc19476536f2b5462eaa29e6f3029ee897c16dKristian Monsen    public static final class AccessibilityAction {
311374bc19476536f2b5462eaa29e6f3029ee897c16dKristian Monsen
311474bc19476536f2b5462eaa29e6f3029ee897c16dKristian Monsen        /**
311574bc19476536f2b5462eaa29e6f3029ee897c16dKristian Monsen         * Action that gives input focus to the node.
311674bc19476536f2b5462eaa29e6f3029ee897c16dKristian Monsen         */
311774bc19476536f2b5462eaa29e6f3029ee897c16dKristian Monsen        public static final AccessibilityAction ACTION_FOCUS =
311874bc19476536f2b5462eaa29e6f3029ee897c16dKristian Monsen                new AccessibilityAction(
311974bc19476536f2b5462eaa29e6f3029ee897c16dKristian Monsen                        AccessibilityNodeInfo.ACTION_FOCUS, null);
312074bc19476536f2b5462eaa29e6f3029ee897c16dKristian Monsen
312174bc19476536f2b5462eaa29e6f3029ee897c16dKristian Monsen        /**
312274bc19476536f2b5462eaa29e6f3029ee897c16dKristian Monsen         * Action that clears input focus of the node.
312374bc19476536f2b5462eaa29e6f3029ee897c16dKristian Monsen         */
312474bc19476536f2b5462eaa29e6f3029ee897c16dKristian Monsen        public static final AccessibilityAction ACTION_CLEAR_FOCUS =
312574bc19476536f2b5462eaa29e6f3029ee897c16dKristian Monsen                new AccessibilityAction(
312674bc19476536f2b5462eaa29e6f3029ee897c16dKristian Monsen                        AccessibilityNodeInfo.ACTION_CLEAR_FOCUS, null);
312774bc19476536f2b5462eaa29e6f3029ee897c16dKristian Monsen
312874bc19476536f2b5462eaa29e6f3029ee897c16dKristian Monsen        /**
312974bc19476536f2b5462eaa29e6f3029ee897c16dKristian Monsen         *  Action that selects the node.
313074bc19476536f2b5462eaa29e6f3029ee897c16dKristian Monsen         */
313174bc19476536f2b5462eaa29e6f3029ee897c16dKristian Monsen        public static final AccessibilityAction ACTION_SELECT =
313274bc19476536f2b5462eaa29e6f3029ee897c16dKristian Monsen                new AccessibilityAction(
313374bc19476536f2b5462eaa29e6f3029ee897c16dKristian Monsen                        AccessibilityNodeInfo.ACTION_SELECT, null);
313474bc19476536f2b5462eaa29e6f3029ee897c16dKristian Monsen
313574bc19476536f2b5462eaa29e6f3029ee897c16dKristian Monsen        /**
313674bc19476536f2b5462eaa29e6f3029ee897c16dKristian Monsen         * Action that deselects the node.
313774bc19476536f2b5462eaa29e6f3029ee897c16dKristian Monsen         */
313874bc19476536f2b5462eaa29e6f3029ee897c16dKristian Monsen        public static final AccessibilityAction ACTION_CLEAR_SELECTION =
313974bc19476536f2b5462eaa29e6f3029ee897c16dKristian Monsen                new AccessibilityAction(
314074bc19476536f2b5462eaa29e6f3029ee897c16dKristian Monsen                        AccessibilityNodeInfo.ACTION_CLEAR_SELECTION, null);
314174bc19476536f2b5462eaa29e6f3029ee897c16dKristian Monsen
314274bc19476536f2b5462eaa29e6f3029ee897c16dKristian Monsen        /**
314374bc19476536f2b5462eaa29e6f3029ee897c16dKristian Monsen         * Action that clicks on the node info.
314474bc19476536f2b5462eaa29e6f3029ee897c16dKristian Monsen         */
314574bc19476536f2b5462eaa29e6f3029ee897c16dKristian Monsen        public static final AccessibilityAction ACTION_CLICK =
314674bc19476536f2b5462eaa29e6f3029ee897c16dKristian Monsen                new AccessibilityAction(
314774bc19476536f2b5462eaa29e6f3029ee897c16dKristian Monsen                        AccessibilityNodeInfo.ACTION_CLICK, null);
314874bc19476536f2b5462eaa29e6f3029ee897c16dKristian Monsen
314974bc19476536f2b5462eaa29e6f3029ee897c16dKristian Monsen        /**
315074bc19476536f2b5462eaa29e6f3029ee897c16dKristian Monsen         * Action that long clicks on the node.
315174bc19476536f2b5462eaa29e6f3029ee897c16dKristian Monsen         */
315274bc19476536f2b5462eaa29e6f3029ee897c16dKristian Monsen        public static final AccessibilityAction ACTION_LONG_CLICK =
315374bc19476536f2b5462eaa29e6f3029ee897c16dKristian Monsen                new AccessibilityAction(
315474bc19476536f2b5462eaa29e6f3029ee897c16dKristian Monsen                        AccessibilityNodeInfo.ACTION_LONG_CLICK, null);
315574bc19476536f2b5462eaa29e6f3029ee897c16dKristian Monsen
315674bc19476536f2b5462eaa29e6f3029ee897c16dKristian Monsen        /**
315774bc19476536f2b5462eaa29e6f3029ee897c16dKristian Monsen         * Action that gives accessibility focus to the node.
315874bc19476536f2b5462eaa29e6f3029ee897c16dKristian Monsen         */
315974bc19476536f2b5462eaa29e6f3029ee897c16dKristian Monsen        public static final AccessibilityAction ACTION_ACCESSIBILITY_FOCUS =
316074bc19476536f2b5462eaa29e6f3029ee897c16dKristian Monsen                new AccessibilityAction(
316174bc19476536f2b5462eaa29e6f3029ee897c16dKristian Monsen                        AccessibilityNodeInfo.ACTION_ACCESSIBILITY_FOCUS, null);
316274bc19476536f2b5462eaa29e6f3029ee897c16dKristian Monsen
316374bc19476536f2b5462eaa29e6f3029ee897c16dKristian Monsen        /**
316474bc19476536f2b5462eaa29e6f3029ee897c16dKristian Monsen         * Action that clears accessibility focus of the node.
316574bc19476536f2b5462eaa29e6f3029ee897c16dKristian Monsen         */
316674bc19476536f2b5462eaa29e6f3029ee897c16dKristian Monsen        public static final AccessibilityAction ACTION_CLEAR_ACCESSIBILITY_FOCUS =
316774bc19476536f2b5462eaa29e6f3029ee897c16dKristian Monsen                new AccessibilityAction(
316874bc19476536f2b5462eaa29e6f3029ee897c16dKristian Monsen                        AccessibilityNodeInfo.ACTION_CLEAR_ACCESSIBILITY_FOCUS, null);
316974bc19476536f2b5462eaa29e6f3029ee897c16dKristian Monsen
317074bc19476536f2b5462eaa29e6f3029ee897c16dKristian Monsen        /**
317174bc19476536f2b5462eaa29e6f3029ee897c16dKristian Monsen         * Action that requests to go to the next entity in this node's text
317274bc19476536f2b5462eaa29e6f3029ee897c16dKristian Monsen         * at a given movement granularity. For example, move to the next character,
317374bc19476536f2b5462eaa29e6f3029ee897c16dKristian Monsen         * word, etc.
317474bc19476536f2b5462eaa29e6f3029ee897c16dKristian Monsen         * <p>
317574bc19476536f2b5462eaa29e6f3029ee897c16dKristian Monsen         * <strong>Arguments:</strong>
317674bc19476536f2b5462eaa29e6f3029ee897c16dKristian Monsen         * {@link AccessibilityNodeInfo#ACTION_ARGUMENT_MOVEMENT_GRANULARITY_INT
317774bc19476536f2b5462eaa29e6f3029ee897c16dKristian Monsen         *  AccessibilityNodeInfo.ACTION_ARGUMENT_MOVEMENT_GRANULARITY_INT},
317874bc19476536f2b5462eaa29e6f3029ee897c16dKristian Monsen         * {@link AccessibilityNodeInfo#ACTION_ARGUMENT_EXTEND_SELECTION_BOOLEAN
317974bc19476536f2b5462eaa29e6f3029ee897c16dKristian Monsen         *  AccessibilityNodeInfo.ACTION_ARGUMENT_EXTEND_SELECTION_BOOLEAN}<br>
318074bc19476536f2b5462eaa29e6f3029ee897c16dKristian Monsen         * <strong>Example:</strong> Move to the previous character and do not extend selection.
318174bc19476536f2b5462eaa29e6f3029ee897c16dKristian Monsen         * <code><pre><p>
318274bc19476536f2b5462eaa29e6f3029ee897c16dKristian Monsen         *   Bundle arguments = new Bundle();
318374bc19476536f2b5462eaa29e6f3029ee897c16dKristian Monsen         *   arguments.putInt(AccessibilityNodeInfo.ACTION_ARGUMENT_MOVEMENT_GRANULARITY_INT,
318474bc19476536f2b5462eaa29e6f3029ee897c16dKristian Monsen         *           AccessibilityNodeInfo.MOVEMENT_GRANULARITY_CHARACTER);
318574bc19476536f2b5462eaa29e6f3029ee897c16dKristian Monsen         *   arguments.putBoolean(AccessibilityNodeInfo.ACTION_ARGUMENT_EXTEND_SELECTION_BOOLEAN,
318674bc19476536f2b5462eaa29e6f3029ee897c16dKristian Monsen         *           false);
318774bc19476536f2b5462eaa29e6f3029ee897c16dKristian Monsen         *   info.performAction(AccessibilityAction.ACTION_NEXT_AT_MOVEMENT_GRANULARITY.getId(),
318874bc19476536f2b5462eaa29e6f3029ee897c16dKristian Monsen         *           arguments);
318974bc19476536f2b5462eaa29e6f3029ee897c16dKristian Monsen         * </code></pre></p>
319074bc19476536f2b5462eaa29e6f3029ee897c16dKristian Monsen         * </p>
319174bc19476536f2b5462eaa29e6f3029ee897c16dKristian Monsen         *
319274bc19476536f2b5462eaa29e6f3029ee897c16dKristian Monsen         * @see AccessibilityNodeInfo#ACTION_ARGUMENT_MOVEMENT_GRANULARITY_INT
319374bc19476536f2b5462eaa29e6f3029ee897c16dKristian Monsen         *  AccessibilityNodeInfo.ACTION_ARGUMENT_MOVEMENT_GRANULARITY_INT
319474bc19476536f2b5462eaa29e6f3029ee897c16dKristian Monsen         * @see AccessibilityNodeInfo#ACTION_ARGUMENT_EXTEND_SELECTION_BOOLEAN
319574bc19476536f2b5462eaa29e6f3029ee897c16dKristian Monsen         *  AccessibilityNodeInfo.ACTION_ARGUMENT_EXTEND_SELECTION_BOOLEAN
319674bc19476536f2b5462eaa29e6f3029ee897c16dKristian Monsen         *
319774bc19476536f2b5462eaa29e6f3029ee897c16dKristian Monsen         * @see AccessibilityNodeInfo#setMovementGranularities(int)
319874bc19476536f2b5462eaa29e6f3029ee897c16dKristian Monsen         *  AccessibilityNodeInfo.ACTION_ARGUMENT_EXTEND_SELECTION_BOOLEAN
319974bc19476536f2b5462eaa29e6f3029ee897c16dKristian Monsen         * @see AccessibilityNodeInfo#getMovementGranularities()
320074bc19476536f2b5462eaa29e6f3029ee897c16dKristian Monsen         *  AccessibilityNodeInfo.getMovementGranularities()
320174bc19476536f2b5462eaa29e6f3029ee897c16dKristian Monsen         *
320274bc19476536f2b5462eaa29e6f3029ee897c16dKristian Monsen         * @see AccessibilityNodeInfo#MOVEMENT_GRANULARITY_CHARACTER
320374bc19476536f2b5462eaa29e6f3029ee897c16dKristian Monsen         *  AccessibilityNodeInfo.MOVEMENT_GRANULARITY_CHARACTER
320474bc19476536f2b5462eaa29e6f3029ee897c16dKristian Monsen         * @see AccessibilityNodeInfo#MOVEMENT_GRANULARITY_WORD
320574bc19476536f2b5462eaa29e6f3029ee897c16dKristian Monsen         *  AccessibilityNodeInfo.MOVEMENT_GRANULARITY_WORD
320674bc19476536f2b5462eaa29e6f3029ee897c16dKristian Monsen         * @see AccessibilityNodeInfo#MOVEMENT_GRANULARITY_LINE
320774bc19476536f2b5462eaa29e6f3029ee897c16dKristian Monsen         *  AccessibilityNodeInfo.MOVEMENT_GRANULARITY_LINE
320874bc19476536f2b5462eaa29e6f3029ee897c16dKristian Monsen         * @see AccessibilityNodeInfo#MOVEMENT_GRANULARITY_PARAGRAPH
320974bc19476536f2b5462eaa29e6f3029ee897c16dKristian Monsen         *  AccessibilityNodeInfo.MOVEMENT_GRANULARITY_PARAGRAPH
321074bc19476536f2b5462eaa29e6f3029ee897c16dKristian Monsen         * @see AccessibilityNodeInfo#MOVEMENT_GRANULARITY_PAGE
321174bc19476536f2b5462eaa29e6f3029ee897c16dKristian Monsen         *  AccessibilityNodeInfo.MOVEMENT_GRANULARITY_PAGE
321274bc19476536f2b5462eaa29e6f3029ee897c16dKristian Monsen         */
321374bc19476536f2b5462eaa29e6f3029ee897c16dKristian Monsen        public static final AccessibilityAction ACTION_NEXT_AT_MOVEMENT_GRANULARITY =
321474bc19476536f2b5462eaa29e6f3029ee897c16dKristian Monsen                new AccessibilityAction(
321574bc19476536f2b5462eaa29e6f3029ee897c16dKristian Monsen                        AccessibilityNodeInfo.ACTION_NEXT_AT_MOVEMENT_GRANULARITY, null);
321674bc19476536f2b5462eaa29e6f3029ee897c16dKristian Monsen
321774bc19476536f2b5462eaa29e6f3029ee897c16dKristian Monsen        /**
321874bc19476536f2b5462eaa29e6f3029ee897c16dKristian Monsen         * Action that requests to go to the previous entity in this node's text
321974bc19476536f2b5462eaa29e6f3029ee897c16dKristian Monsen         * at a given movement granularity. For example, move to the next character,
322074bc19476536f2b5462eaa29e6f3029ee897c16dKristian Monsen         * word, etc.
322174bc19476536f2b5462eaa29e6f3029ee897c16dKristian Monsen         * <p>
322274bc19476536f2b5462eaa29e6f3029ee897c16dKristian Monsen         * <strong>Arguments:</strong>
322374bc19476536f2b5462eaa29e6f3029ee897c16dKristian Monsen         * {@link AccessibilityNodeInfo#ACTION_ARGUMENT_MOVEMENT_GRANULARITY_INT
322474bc19476536f2b5462eaa29e6f3029ee897c16dKristian Monsen         *  AccessibilityNodeInfo.ACTION_ARGUMENT_MOVEMENT_GRANULARITY_INT},
322574bc19476536f2b5462eaa29e6f3029ee897c16dKristian Monsen         * {@link AccessibilityNodeInfo#ACTION_ARGUMENT_EXTEND_SELECTION_BOOLEAN
322674bc19476536f2b5462eaa29e6f3029ee897c16dKristian Monsen         *  AccessibilityNodeInfo.ACTION_ARGUMENT_EXTEND_SELECTION_BOOLEAN}<br>
322774bc19476536f2b5462eaa29e6f3029ee897c16dKristian Monsen         * <strong>Example:</strong> Move to the next character and do not extend selection.
322874bc19476536f2b5462eaa29e6f3029ee897c16dKristian Monsen         * <code><pre><p>
322974bc19476536f2b5462eaa29e6f3029ee897c16dKristian Monsen         *   Bundle arguments = new Bundle();
323074bc19476536f2b5462eaa29e6f3029ee897c16dKristian Monsen         *   arguments.putInt(AccessibilityNodeInfo.ACTION_ARGUMENT_MOVEMENT_GRANULARITY_INT,
323174bc19476536f2b5462eaa29e6f3029ee897c16dKristian Monsen         *           AccessibilityNodeInfo.MOVEMENT_GRANULARITY_CHARACTER);
323274bc19476536f2b5462eaa29e6f3029ee897c16dKristian Monsen         *   arguments.putBoolean(AccessibilityNodeInfo.ACTION_ARGUMENT_EXTEND_SELECTION_BOOLEAN,
323374bc19476536f2b5462eaa29e6f3029ee897c16dKristian Monsen         *           false);
323474bc19476536f2b5462eaa29e6f3029ee897c16dKristian Monsen         *   info.performAction(AccessibilityAction.ACTION_PREVIOUS_AT_MOVEMENT_GRANULARITY.getId(),
323574bc19476536f2b5462eaa29e6f3029ee897c16dKristian Monsen         *           arguments);
323674bc19476536f2b5462eaa29e6f3029ee897c16dKristian Monsen         * </code></pre></p>
323774bc19476536f2b5462eaa29e6f3029ee897c16dKristian Monsen         * </p>
323874bc19476536f2b5462eaa29e6f3029ee897c16dKristian Monsen         *
323974bc19476536f2b5462eaa29e6f3029ee897c16dKristian Monsen         * @see AccessibilityNodeInfo#ACTION_ARGUMENT_MOVEMENT_GRANULARITY_INT
324074bc19476536f2b5462eaa29e6f3029ee897c16dKristian Monsen         *  AccessibilityNodeInfo.ACTION_ARGUMENT_MOVEMENT_GRANULARITY_INT
324174bc19476536f2b5462eaa29e6f3029ee897c16dKristian Monsen         * @see AccessibilityNodeInfo#ACTION_ARGUMENT_EXTEND_SELECTION_BOOLEAN
324274bc19476536f2b5462eaa29e6f3029ee897c16dKristian Monsen         *  AccessibilityNodeInfo.ACTION_ARGUMENT_EXTEND_SELECTION_BOOLEAN
324374bc19476536f2b5462eaa29e6f3029ee897c16dKristian Monsen         *
324474bc19476536f2b5462eaa29e6f3029ee897c16dKristian Monsen         * @see AccessibilityNodeInfo#setMovementGranularities(int)
324574bc19476536f2b5462eaa29e6f3029ee897c16dKristian Monsen         *   AccessibilityNodeInfo.setMovementGranularities(int)
324674bc19476536f2b5462eaa29e6f3029ee897c16dKristian Monsen         * @see AccessibilityNodeInfo#getMovementGranularities()
324774bc19476536f2b5462eaa29e6f3029ee897c16dKristian Monsen         *  AccessibilityNodeInfo.getMovementGranularities()
324874bc19476536f2b5462eaa29e6f3029ee897c16dKristian Monsen         *
324974bc19476536f2b5462eaa29e6f3029ee897c16dKristian Monsen         * @see AccessibilityNodeInfo#MOVEMENT_GRANULARITY_CHARACTER
325074bc19476536f2b5462eaa29e6f3029ee897c16dKristian Monsen         *  AccessibilityNodeInfo.MOVEMENT_GRANULARITY_CHARACTER
325174bc19476536f2b5462eaa29e6f3029ee897c16dKristian Monsen         * @see AccessibilityNodeInfo#MOVEMENT_GRANULARITY_WORD
325274bc19476536f2b5462eaa29e6f3029ee897c16dKristian Monsen         *  AccessibilityNodeInfo.MOVEMENT_GRANULARITY_WORD
325374bc19476536f2b5462eaa29e6f3029ee897c16dKristian Monsen         * @see AccessibilityNodeInfo#MOVEMENT_GRANULARITY_LINE
325474bc19476536f2b5462eaa29e6f3029ee897c16dKristian Monsen         *  AccessibilityNodeInfo.MOVEMENT_GRANULARITY_LINE
325574bc19476536f2b5462eaa29e6f3029ee897c16dKristian Monsen         * @see AccessibilityNodeInfo#MOVEMENT_GRANULARITY_PARAGRAPH
325674bc19476536f2b5462eaa29e6f3029ee897c16dKristian Monsen         *  AccessibilityNodeInfo.MOVEMENT_GRANULARITY_PARAGRAPH
325774bc19476536f2b5462eaa29e6f3029ee897c16dKristian Monsen         * @see AccessibilityNodeInfo#MOVEMENT_GRANULARITY_PAGE
325874bc19476536f2b5462eaa29e6f3029ee897c16dKristian Monsen         *  AccessibilityNodeInfo.MOVEMENT_GRANULARITY_PAGE
325974bc19476536f2b5462eaa29e6f3029ee897c16dKristian Monsen         */
326074bc19476536f2b5462eaa29e6f3029ee897c16dKristian Monsen        public static final AccessibilityAction ACTION_PREVIOUS_AT_MOVEMENT_GRANULARITY =
326174bc19476536f2b5462eaa29e6f3029ee897c16dKristian Monsen                new AccessibilityAction(
326274bc19476536f2b5462eaa29e6f3029ee897c16dKristian Monsen                        AccessibilityNodeInfo.ACTION_PREVIOUS_AT_MOVEMENT_GRANULARITY, null);
326374bc19476536f2b5462eaa29e6f3029ee897c16dKristian Monsen
326474bc19476536f2b5462eaa29e6f3029ee897c16dKristian Monsen        /**
326574bc19476536f2b5462eaa29e6f3029ee897c16dKristian Monsen         * Action to move to the next HTML element of a given type. For example, move
326674bc19476536f2b5462eaa29e6f3029ee897c16dKristian Monsen         * to the BUTTON, INPUT, TABLE, etc.
326774bc19476536f2b5462eaa29e6f3029ee897c16dKristian Monsen         * <p>
326874bc19476536f2b5462eaa29e6f3029ee897c16dKristian Monsen         * <strong>Arguments:</strong>
326974bc19476536f2b5462eaa29e6f3029ee897c16dKristian Monsen         * {@link AccessibilityNodeInfo#ACTION_ARGUMENT_HTML_ELEMENT_STRING
327074bc19476536f2b5462eaa29e6f3029ee897c16dKristian Monsen         *  AccessibilityNodeInfo.ACTION_ARGUMENT_HTML_ELEMENT_STRING}<br>
327174bc19476536f2b5462eaa29e6f3029ee897c16dKristian Monsen         * <strong>Example:</strong>
327274bc19476536f2b5462eaa29e6f3029ee897c16dKristian Monsen         * <code><pre><p>
327374bc19476536f2b5462eaa29e6f3029ee897c16dKristian Monsen         *   Bundle arguments = new Bundle();
327474bc19476536f2b5462eaa29e6f3029ee897c16dKristian Monsen         *   arguments.putString(AccessibilityNodeInfo.ACTION_ARGUMENT_HTML_ELEMENT_STRING, "BUTTON");
327574bc19476536f2b5462eaa29e6f3029ee897c16dKristian Monsen         *   info.performAction(AccessibilityAction.ACTION_NEXT_HTML_ELEMENT.getId(), arguments);
327674bc19476536f2b5462eaa29e6f3029ee897c16dKristian Monsen         * </code></pre></p>
327774bc19476536f2b5462eaa29e6f3029ee897c16dKristian Monsen         * </p>
327874bc19476536f2b5462eaa29e6f3029ee897c16dKristian Monsen         */
327974bc19476536f2b5462eaa29e6f3029ee897c16dKristian Monsen        public static final AccessibilityAction ACTION_NEXT_HTML_ELEMENT =
328074bc19476536f2b5462eaa29e6f3029ee897c16dKristian Monsen                new AccessibilityAction(
328174bc19476536f2b5462eaa29e6f3029ee897c16dKristian Monsen                        AccessibilityNodeInfo.ACTION_NEXT_HTML_ELEMENT, null);
328274bc19476536f2b5462eaa29e6f3029ee897c16dKristian Monsen
328374bc19476536f2b5462eaa29e6f3029ee897c16dKristian Monsen        /**
328474bc19476536f2b5462eaa29e6f3029ee897c16dKristian Monsen         * Action to move to the previous HTML element of a given type. For example, move
328574bc19476536f2b5462eaa29e6f3029ee897c16dKristian Monsen         * to the BUTTON, INPUT, TABLE, etc.
328674bc19476536f2b5462eaa29e6f3029ee897c16dKristian Monsen         * <p>
328774bc19476536f2b5462eaa29e6f3029ee897c16dKristian Monsen         * <strong>Arguments:</strong>
328874bc19476536f2b5462eaa29e6f3029ee897c16dKristian Monsen         * {@link AccessibilityNodeInfo#ACTION_ARGUMENT_HTML_ELEMENT_STRING
328974bc19476536f2b5462eaa29e6f3029ee897c16dKristian Monsen         *  AccessibilityNodeInfo.ACTION_ARGUMENT_HTML_ELEMENT_STRING}<br>
329074bc19476536f2b5462eaa29e6f3029ee897c16dKristian Monsen         * <strong>Example:</strong>
329174bc19476536f2b5462eaa29e6f3029ee897c16dKristian Monsen         * <code><pre><p>
329274bc19476536f2b5462eaa29e6f3029ee897c16dKristian Monsen         *   Bundle arguments = new Bundle();
329374bc19476536f2b5462eaa29e6f3029ee897c16dKristian Monsen         *   arguments.putString(AccessibilityNodeInfo.ACTION_ARGUMENT_HTML_ELEMENT_STRING, "BUTTON");
329474bc19476536f2b5462eaa29e6f3029ee897c16dKristian Monsen         *   info.performAction(AccessibilityAction.ACTION_PREVIOUS_HTML_ELEMENT.getId(), arguments);
329574bc19476536f2b5462eaa29e6f3029ee897c16dKristian Monsen         * </code></pre></p>
329674bc19476536f2b5462eaa29e6f3029ee897c16dKristian Monsen         * </p>
329774bc19476536f2b5462eaa29e6f3029ee897c16dKristian Monsen         */
329874bc19476536f2b5462eaa29e6f3029ee897c16dKristian Monsen        public static final AccessibilityAction ACTION_PREVIOUS_HTML_ELEMENT =
329974bc19476536f2b5462eaa29e6f3029ee897c16dKristian Monsen                new AccessibilityAction(
330074bc19476536f2b5462eaa29e6f3029ee897c16dKristian Monsen                        AccessibilityNodeInfo.ACTION_PREVIOUS_HTML_ELEMENT, null);
330174bc19476536f2b5462eaa29e6f3029ee897c16dKristian Monsen
330274bc19476536f2b5462eaa29e6f3029ee897c16dKristian Monsen        /**
330374bc19476536f2b5462eaa29e6f3029ee897c16dKristian Monsen         * Action to scroll the node content forward.
330474bc19476536f2b5462eaa29e6f3029ee897c16dKristian Monsen         */
330574bc19476536f2b5462eaa29e6f3029ee897c16dKristian Monsen        public static final AccessibilityAction ACTION_SCROLL_FORWARD =
330674bc19476536f2b5462eaa29e6f3029ee897c16dKristian Monsen                new AccessibilityAction(
330774bc19476536f2b5462eaa29e6f3029ee897c16dKristian Monsen                        AccessibilityNodeInfo.ACTION_SCROLL_FORWARD, null);
330874bc19476536f2b5462eaa29e6f3029ee897c16dKristian Monsen
330974bc19476536f2b5462eaa29e6f3029ee897c16dKristian Monsen        /**
331074bc19476536f2b5462eaa29e6f3029ee897c16dKristian Monsen         * Action to scroll the node content backward.
331174bc19476536f2b5462eaa29e6f3029ee897c16dKristian Monsen         */
331274bc19476536f2b5462eaa29e6f3029ee897c16dKristian Monsen        public static final AccessibilityAction ACTION_SCROLL_BACKWARD =
331374bc19476536f2b5462eaa29e6f3029ee897c16dKristian Monsen                new AccessibilityAction(
331474bc19476536f2b5462eaa29e6f3029ee897c16dKristian Monsen                        AccessibilityNodeInfo.ACTION_SCROLL_BACKWARD, null);
331574bc19476536f2b5462eaa29e6f3029ee897c16dKristian Monsen
331674bc19476536f2b5462eaa29e6f3029ee897c16dKristian Monsen        /**
331774bc19476536f2b5462eaa29e6f3029ee897c16dKristian Monsen         * Action to copy the current selection to the clipboard.
331874bc19476536f2b5462eaa29e6f3029ee897c16dKristian Monsen         */
331974bc19476536f2b5462eaa29e6f3029ee897c16dKristian Monsen        public static final AccessibilityAction ACTION_COPY =
332074bc19476536f2b5462eaa29e6f3029ee897c16dKristian Monsen                new AccessibilityAction(
332174bc19476536f2b5462eaa29e6f3029ee897c16dKristian Monsen                        AccessibilityNodeInfo.ACTION_COPY, null);
332274bc19476536f2b5462eaa29e6f3029ee897c16dKristian Monsen
332374bc19476536f2b5462eaa29e6f3029ee897c16dKristian Monsen        /**
332474bc19476536f2b5462eaa29e6f3029ee897c16dKristian Monsen         * Action to paste the current clipboard content.
332574bc19476536f2b5462eaa29e6f3029ee897c16dKristian Monsen         */
332674bc19476536f2b5462eaa29e6f3029ee897c16dKristian Monsen        public static final AccessibilityAction ACTION_PASTE =
332774bc19476536f2b5462eaa29e6f3029ee897c16dKristian Monsen                new AccessibilityAction(
332874bc19476536f2b5462eaa29e6f3029ee897c16dKristian Monsen                        AccessibilityNodeInfo.ACTION_PASTE, null);
332974bc19476536f2b5462eaa29e6f3029ee897c16dKristian Monsen
333074bc19476536f2b5462eaa29e6f3029ee897c16dKristian Monsen        /**
333174bc19476536f2b5462eaa29e6f3029ee897c16dKristian Monsen         * Action to cut the current selection and place it to the clipboard.
333274bc19476536f2b5462eaa29e6f3029ee897c16dKristian Monsen         */
333374bc19476536f2b5462eaa29e6f3029ee897c16dKristian Monsen        public static final AccessibilityAction ACTION_CUT =
333474bc19476536f2b5462eaa29e6f3029ee897c16dKristian Monsen                new AccessibilityAction(
333574bc19476536f2b5462eaa29e6f3029ee897c16dKristian Monsen                        AccessibilityNodeInfo.ACTION_CUT, null);
333674bc19476536f2b5462eaa29e6f3029ee897c16dKristian Monsen
333774bc19476536f2b5462eaa29e6f3029ee897c16dKristian Monsen        /**
333874bc19476536f2b5462eaa29e6f3029ee897c16dKristian Monsen         * Action to set the selection. Performing this action with no arguments
333974bc19476536f2b5462eaa29e6f3029ee897c16dKristian Monsen         * clears the selection.
334074bc19476536f2b5462eaa29e6f3029ee897c16dKristian Monsen         * <p>
334174bc19476536f2b5462eaa29e6f3029ee897c16dKristian Monsen         * <strong>Arguments:</strong>
334274bc19476536f2b5462eaa29e6f3029ee897c16dKristian Monsen         * {@link AccessibilityNodeInfo#ACTION_ARGUMENT_SELECTION_START_INT
334374bc19476536f2b5462eaa29e6f3029ee897c16dKristian Monsen         *  AccessibilityNodeInfo.ACTION_ARGUMENT_SELECTION_START_INT},
334474bc19476536f2b5462eaa29e6f3029ee897c16dKristian Monsen         * {@link AccessibilityNodeInfo#ACTION_ARGUMENT_SELECTION_END_INT
334574bc19476536f2b5462eaa29e6f3029ee897c16dKristian Monsen         *  AccessibilityNodeInfo.ACTION_ARGUMENT_SELECTION_END_INT}<br>
334674bc19476536f2b5462eaa29e6f3029ee897c16dKristian Monsen         * <strong>Example:</strong>
334774bc19476536f2b5462eaa29e6f3029ee897c16dKristian Monsen         * <code><pre><p>
334874bc19476536f2b5462eaa29e6f3029ee897c16dKristian Monsen         *   Bundle arguments = new Bundle();
334974bc19476536f2b5462eaa29e6f3029ee897c16dKristian Monsen         *   arguments.putInt(AccessibilityNodeInfo.ACTION_ARGUMENT_SELECTION_START_INT, 1);
335074bc19476536f2b5462eaa29e6f3029ee897c16dKristian Monsen         *   arguments.putInt(AccessibilityNodeInfo.ACTION_ARGUMENT_SELECTION_END_INT, 2);
335174bc19476536f2b5462eaa29e6f3029ee897c16dKristian Monsen         *   info.performAction(AccessibilityAction.ACTION_SET_SELECTION.getId(), arguments);
335274bc19476536f2b5462eaa29e6f3029ee897c16dKristian Monsen         * </code></pre></p>
335374bc19476536f2b5462eaa29e6f3029ee897c16dKristian Monsen         * </p>
335474bc19476536f2b5462eaa29e6f3029ee897c16dKristian Monsen         *
335574bc19476536f2b5462eaa29e6f3029ee897c16dKristian Monsen         * @see AccessibilityNodeInfo#ACTION_ARGUMENT_SELECTION_START_INT
335674bc19476536f2b5462eaa29e6f3029ee897c16dKristian Monsen         *  AccessibilityNodeInfo.ACTION_ARGUMENT_SELECTION_START_INT
335774bc19476536f2b5462eaa29e6f3029ee897c16dKristian Monsen         * @see AccessibilityNodeInfo#ACTION_ARGUMENT_SELECTION_END_INT
335874bc19476536f2b5462eaa29e6f3029ee897c16dKristian Monsen         *  AccessibilityNodeInfo.ACTION_ARGUMENT_SELECTION_END_INT
335974bc19476536f2b5462eaa29e6f3029ee897c16dKristian Monsen         */
336074bc19476536f2b5462eaa29e6f3029ee897c16dKristian Monsen        public static final AccessibilityAction ACTION_SET_SELECTION =
336174bc19476536f2b5462eaa29e6f3029ee897c16dKristian Monsen                new AccessibilityAction(
336274bc19476536f2b5462eaa29e6f3029ee897c16dKristian Monsen                        AccessibilityNodeInfo.ACTION_SET_SELECTION, null);
336374bc19476536f2b5462eaa29e6f3029ee897c16dKristian Monsen
336474bc19476536f2b5462eaa29e6f3029ee897c16dKristian Monsen        /**
336574bc19476536f2b5462eaa29e6f3029ee897c16dKristian Monsen         * Action to expand an expandable node.
336674bc19476536f2b5462eaa29e6f3029ee897c16dKristian Monsen         */
336774bc19476536f2b5462eaa29e6f3029ee897c16dKristian Monsen        public static final AccessibilityAction ACTION_EXPAND =
336874bc19476536f2b5462eaa29e6f3029ee897c16dKristian Monsen                new AccessibilityAction(
336974bc19476536f2b5462eaa29e6f3029ee897c16dKristian Monsen                        AccessibilityNodeInfo.ACTION_EXPAND, null);
337074bc19476536f2b5462eaa29e6f3029ee897c16dKristian Monsen
337174bc19476536f2b5462eaa29e6f3029ee897c16dKristian Monsen        /**
337274bc19476536f2b5462eaa29e6f3029ee897c16dKristian Monsen         * Action to collapse an expandable node.
337374bc19476536f2b5462eaa29e6f3029ee897c16dKristian Monsen         */
337474bc19476536f2b5462eaa29e6f3029ee897c16dKristian Monsen        public static final AccessibilityAction ACTION_COLLAPSE =
337574bc19476536f2b5462eaa29e6f3029ee897c16dKristian Monsen                new AccessibilityAction(
337674bc19476536f2b5462eaa29e6f3029ee897c16dKristian Monsen                        AccessibilityNodeInfo.ACTION_COLLAPSE, null);
337774bc19476536f2b5462eaa29e6f3029ee897c16dKristian Monsen
337874bc19476536f2b5462eaa29e6f3029ee897c16dKristian Monsen        /**
337974bc19476536f2b5462eaa29e6f3029ee897c16dKristian Monsen         * Action to dismiss a dismissable node.
338074bc19476536f2b5462eaa29e6f3029ee897c16dKristian Monsen         */
338174bc19476536f2b5462eaa29e6f3029ee897c16dKristian Monsen        public static final AccessibilityAction ACTION_DISMISS =
338274bc19476536f2b5462eaa29e6f3029ee897c16dKristian Monsen                new AccessibilityAction(
338374bc19476536f2b5462eaa29e6f3029ee897c16dKristian Monsen                        AccessibilityNodeInfo.ACTION_DISMISS, null);
338474bc19476536f2b5462eaa29e6f3029ee897c16dKristian Monsen
338574bc19476536f2b5462eaa29e6f3029ee897c16dKristian Monsen        /**
338674bc19476536f2b5462eaa29e6f3029ee897c16dKristian Monsen         * Action that sets the text of the node. Performing the action without argument,
338774bc19476536f2b5462eaa29e6f3029ee897c16dKristian Monsen         * using <code> null</code> or empty {@link CharSequence} will clear the text. This
338874bc19476536f2b5462eaa29e6f3029ee897c16dKristian Monsen         * action will also put the cursor at the end of text.
338974bc19476536f2b5462eaa29e6f3029ee897c16dKristian Monsen         * <p>
339074bc19476536f2b5462eaa29e6f3029ee897c16dKristian Monsen         * <strong>Arguments:</strong>
339174bc19476536f2b5462eaa29e6f3029ee897c16dKristian Monsen         * {@link AccessibilityNodeInfo#ACTION_ARGUMENT_SET_TEXT_CHARSEQUENCE
339274bc19476536f2b5462eaa29e6f3029ee897c16dKristian Monsen         *  AccessibilityNodeInfo.ACTION_ARGUMENT_SET_TEXT_CHARSEQUENCE}<br>
339374bc19476536f2b5462eaa29e6f3029ee897c16dKristian Monsen         * <strong>Example:</strong>
339474bc19476536f2b5462eaa29e6f3029ee897c16dKristian Monsen         * <code><pre><p>
339574bc19476536f2b5462eaa29e6f3029ee897c16dKristian Monsen         *   Bundle arguments = new Bundle();
339674bc19476536f2b5462eaa29e6f3029ee897c16dKristian Monsen         *   arguments.putCharSequence(AccessibilityNodeInfo.ACTION_ARGUMENT_SET_TEXT_CHARSEQUENCE,
339774bc19476536f2b5462eaa29e6f3029ee897c16dKristian Monsen         *       "android");
339874bc19476536f2b5462eaa29e6f3029ee897c16dKristian Monsen         *   info.performAction(AccessibilityAction.ACTION_SET_TEXT.getId(), arguments);
339974bc19476536f2b5462eaa29e6f3029ee897c16dKristian Monsen         * </code></pre></p>
340074bc19476536f2b5462eaa29e6f3029ee897c16dKristian Monsen         */
340174bc19476536f2b5462eaa29e6f3029ee897c16dKristian Monsen        public static final AccessibilityAction ACTION_SET_TEXT =
340274bc19476536f2b5462eaa29e6f3029ee897c16dKristian Monsen                new AccessibilityAction(
340374bc19476536f2b5462eaa29e6f3029ee897c16dKristian Monsen                        AccessibilityNodeInfo.ACTION_SET_TEXT, null);
340474bc19476536f2b5462eaa29e6f3029ee897c16dKristian Monsen
340574bc19476536f2b5462eaa29e6f3029ee897c16dKristian Monsen        private static final ArraySet<AccessibilityAction> sStandardActions = new ArraySet<AccessibilityAction>();
340674bc19476536f2b5462eaa29e6f3029ee897c16dKristian Monsen        static {
340774bc19476536f2b5462eaa29e6f3029ee897c16dKristian Monsen            sStandardActions.add(ACTION_FOCUS);
340874bc19476536f2b5462eaa29e6f3029ee897c16dKristian Monsen            sStandardActions.add(ACTION_CLEAR_FOCUS);
340974bc19476536f2b5462eaa29e6f3029ee897c16dKristian Monsen            sStandardActions.add(ACTION_SELECT);
341074bc19476536f2b5462eaa29e6f3029ee897c16dKristian Monsen            sStandardActions.add(ACTION_CLEAR_SELECTION);
341174bc19476536f2b5462eaa29e6f3029ee897c16dKristian Monsen            sStandardActions.add(ACTION_CLICK);
341274bc19476536f2b5462eaa29e6f3029ee897c16dKristian Monsen            sStandardActions.add(ACTION_LONG_CLICK);
341374bc19476536f2b5462eaa29e6f3029ee897c16dKristian Monsen            sStandardActions.add(ACTION_ACCESSIBILITY_FOCUS);
341474bc19476536f2b5462eaa29e6f3029ee897c16dKristian Monsen            sStandardActions.add(ACTION_CLEAR_ACCESSIBILITY_FOCUS);
341574bc19476536f2b5462eaa29e6f3029ee897c16dKristian Monsen            sStandardActions.add(ACTION_NEXT_AT_MOVEMENT_GRANULARITY);
341674bc19476536f2b5462eaa29e6f3029ee897c16dKristian Monsen            sStandardActions.add(ACTION_PREVIOUS_AT_MOVEMENT_GRANULARITY);
341774bc19476536f2b5462eaa29e6f3029ee897c16dKristian Monsen            sStandardActions.add(ACTION_NEXT_HTML_ELEMENT);
341874bc19476536f2b5462eaa29e6f3029ee897c16dKristian Monsen            sStandardActions.add(ACTION_PREVIOUS_HTML_ELEMENT);
341974bc19476536f2b5462eaa29e6f3029ee897c16dKristian Monsen            sStandardActions.add(ACTION_SCROLL_FORWARD);
342074bc19476536f2b5462eaa29e6f3029ee897c16dKristian Monsen            sStandardActions.add(ACTION_SCROLL_BACKWARD);
342174bc19476536f2b5462eaa29e6f3029ee897c16dKristian Monsen            sStandardActions.add(ACTION_COPY);
342274bc19476536f2b5462eaa29e6f3029ee897c16dKristian Monsen            sStandardActions.add(ACTION_PASTE);
342374bc19476536f2b5462eaa29e6f3029ee897c16dKristian Monsen            sStandardActions.add(ACTION_CUT);
342474bc19476536f2b5462eaa29e6f3029ee897c16dKristian Monsen            sStandardActions.add(ACTION_SET_SELECTION);
342574bc19476536f2b5462eaa29e6f3029ee897c16dKristian Monsen            sStandardActions.add(ACTION_EXPAND);
342674bc19476536f2b5462eaa29e6f3029ee897c16dKristian Monsen            sStandardActions.add(ACTION_COLLAPSE);
342774bc19476536f2b5462eaa29e6f3029ee897c16dKristian Monsen            sStandardActions.add(ACTION_DISMISS);
342874bc19476536f2b5462eaa29e6f3029ee897c16dKristian Monsen            sStandardActions.add(ACTION_SET_TEXT);
342974bc19476536f2b5462eaa29e6f3029ee897c16dKristian Monsen        }
343074bc19476536f2b5462eaa29e6f3029ee897c16dKristian Monsen
343174bc19476536f2b5462eaa29e6f3029ee897c16dKristian Monsen        private final int mActionId;
343274bc19476536f2b5462eaa29e6f3029ee897c16dKristian Monsen        private final CharSequence mLabel;
343374bc19476536f2b5462eaa29e6f3029ee897c16dKristian Monsen
343474bc19476536f2b5462eaa29e6f3029ee897c16dKristian Monsen        /**
343574bc19476536f2b5462eaa29e6f3029ee897c16dKristian Monsen         * Creates a new AccessibilityAction. For adding a standard action without a specific label,
343674bc19476536f2b5462eaa29e6f3029ee897c16dKristian Monsen         * use the static constants.
343774bc19476536f2b5462eaa29e6f3029ee897c16dKristian Monsen         *
343874bc19476536f2b5462eaa29e6f3029ee897c16dKristian Monsen         * You can also override the description for one the standard actions. Below is an example
343974bc19476536f2b5462eaa29e6f3029ee897c16dKristian Monsen         * how to override the standard click action by adding a custom label:
344074bc19476536f2b5462eaa29e6f3029ee897c16dKristian Monsen         * <pre>
344174bc19476536f2b5462eaa29e6f3029ee897c16dKristian Monsen         *   AccessibilityAction action = new AccessibilityAction(
344274bc19476536f2b5462eaa29e6f3029ee897c16dKristian Monsen         *           AccessibilityAction.ACTION_ACTION_CLICK, getLocalizedLabel());
344374bc19476536f2b5462eaa29e6f3029ee897c16dKristian Monsen         *   node.addAction(action);
344474bc19476536f2b5462eaa29e6f3029ee897c16dKristian Monsen         * </pre>
344574bc19476536f2b5462eaa29e6f3029ee897c16dKristian Monsen         *
344674bc19476536f2b5462eaa29e6f3029ee897c16dKristian Monsen         * @param actionId The id for this action. This should either be one of the
344774bc19476536f2b5462eaa29e6f3029ee897c16dKristian Monsen         *                 standard actions or a specific action for your app. In that case it is
344874bc19476536f2b5462eaa29e6f3029ee897c16dKristian Monsen         *                 required to use a resource identifier.
344974bc19476536f2b5462eaa29e6f3029ee897c16dKristian Monsen         * @param label The label for the new AccessibilityAction.
345074bc19476536f2b5462eaa29e6f3029ee897c16dKristian Monsen         */
345174bc19476536f2b5462eaa29e6f3029ee897c16dKristian Monsen        public AccessibilityAction(int actionId, @Nullable CharSequence label) {
34525c4cd189f298b3ddb9a5e8afc5f68546a9f96726Svetoslav            if ((actionId & ACTION_TYPE_MASK) == 0 && Integer.bitCount(actionId) != 1) {
345374bc19476536f2b5462eaa29e6f3029ee897c16dKristian Monsen                throw new IllegalArgumentException("Invalid standard action id");
34548643aa0179e598e78d938c59035389054535a229Svetoslav Ganov            }
345574bc19476536f2b5462eaa29e6f3029ee897c16dKristian Monsen
345674bc19476536f2b5462eaa29e6f3029ee897c16dKristian Monsen            mActionId = actionId;
345774bc19476536f2b5462eaa29e6f3029ee897c16dKristian Monsen            mLabel = label;
34588643aa0179e598e78d938c59035389054535a229Svetoslav Ganov        }
34598643aa0179e598e78d938c59035389054535a229Svetoslav Ganov
346074bc19476536f2b5462eaa29e6f3029ee897c16dKristian Monsen        /**
346174bc19476536f2b5462eaa29e6f3029ee897c16dKristian Monsen         * Gets the id for this action.
346274bc19476536f2b5462eaa29e6f3029ee897c16dKristian Monsen         *
346374bc19476536f2b5462eaa29e6f3029ee897c16dKristian Monsen         * @return The action id.
346474bc19476536f2b5462eaa29e6f3029ee897c16dKristian Monsen         */
346574bc19476536f2b5462eaa29e6f3029ee897c16dKristian Monsen        public int getId() {
346674bc19476536f2b5462eaa29e6f3029ee897c16dKristian Monsen            return mActionId;
346774bc19476536f2b5462eaa29e6f3029ee897c16dKristian Monsen        }
346874bc19476536f2b5462eaa29e6f3029ee897c16dKristian Monsen
346974bc19476536f2b5462eaa29e6f3029ee897c16dKristian Monsen        /**
347074bc19476536f2b5462eaa29e6f3029ee897c16dKristian Monsen         * Gets the label for this action. Its purpose is to describe the
347174bc19476536f2b5462eaa29e6f3029ee897c16dKristian Monsen         * action to user.
347274bc19476536f2b5462eaa29e6f3029ee897c16dKristian Monsen         *
347374bc19476536f2b5462eaa29e6f3029ee897c16dKristian Monsen         * @return The label.
347474bc19476536f2b5462eaa29e6f3029ee897c16dKristian Monsen         */
347574bc19476536f2b5462eaa29e6f3029ee897c16dKristian Monsen        public CharSequence getLabel() {
347674bc19476536f2b5462eaa29e6f3029ee897c16dKristian Monsen            return mLabel;
347774bc19476536f2b5462eaa29e6f3029ee897c16dKristian Monsen        }
347874bc19476536f2b5462eaa29e6f3029ee897c16dKristian Monsen
347974bc19476536f2b5462eaa29e6f3029ee897c16dKristian Monsen        @Override
348074bc19476536f2b5462eaa29e6f3029ee897c16dKristian Monsen        public int hashCode() {
348174bc19476536f2b5462eaa29e6f3029ee897c16dKristian Monsen            return mActionId;
348274bc19476536f2b5462eaa29e6f3029ee897c16dKristian Monsen        }
348374bc19476536f2b5462eaa29e6f3029ee897c16dKristian Monsen
348474bc19476536f2b5462eaa29e6f3029ee897c16dKristian Monsen        @Override
348574bc19476536f2b5462eaa29e6f3029ee897c16dKristian Monsen        public boolean equals(Object other) {
348674bc19476536f2b5462eaa29e6f3029ee897c16dKristian Monsen            if (other == null) {
348774bc19476536f2b5462eaa29e6f3029ee897c16dKristian Monsen                return false;
348874bc19476536f2b5462eaa29e6f3029ee897c16dKristian Monsen            }
348974bc19476536f2b5462eaa29e6f3029ee897c16dKristian Monsen
349074bc19476536f2b5462eaa29e6f3029ee897c16dKristian Monsen            if (other == this) {
349174bc19476536f2b5462eaa29e6f3029ee897c16dKristian Monsen                return true;
349274bc19476536f2b5462eaa29e6f3029ee897c16dKristian Monsen            }
349374bc19476536f2b5462eaa29e6f3029ee897c16dKristian Monsen
349474bc19476536f2b5462eaa29e6f3029ee897c16dKristian Monsen            if (getClass() != other.getClass()) {
349574bc19476536f2b5462eaa29e6f3029ee897c16dKristian Monsen                return false;
349674bc19476536f2b5462eaa29e6f3029ee897c16dKristian Monsen            }
349774bc19476536f2b5462eaa29e6f3029ee897c16dKristian Monsen
349874bc19476536f2b5462eaa29e6f3029ee897c16dKristian Monsen            return mActionId == ((AccessibilityAction)other).mActionId;
349974bc19476536f2b5462eaa29e6f3029ee897c16dKristian Monsen        }
350074bc19476536f2b5462eaa29e6f3029ee897c16dKristian Monsen
350174bc19476536f2b5462eaa29e6f3029ee897c16dKristian Monsen        @Override
350274bc19476536f2b5462eaa29e6f3029ee897c16dKristian Monsen        public String toString() {
350374bc19476536f2b5462eaa29e6f3029ee897c16dKristian Monsen            return "AccessibilityAction: " + getActionSymbolicName(mActionId) + " - " + mLabel;
350474bc19476536f2b5462eaa29e6f3029ee897c16dKristian Monsen        }
35058643aa0179e598e78d938c59035389054535a229Svetoslav Ganov    }
35068643aa0179e598e78d938c59035389054535a229Svetoslav Ganov
35078643aa0179e598e78d938c59035389054535a229Svetoslav Ganov    /**
35083577a283e1af3e14fe980c4fec55781a58cd8e3cSvetoslav     * Class with information if a node is a range. Use
350996844ed886cc887a34bfc2fd04fc569d9c098623Scott Main     * {@link RangeInfo#obtain(int, float, float, float)} to get an instance.
35103577a283e1af3e14fe980c4fec55781a58cd8e3cSvetoslav     */
35113577a283e1af3e14fe980c4fec55781a58cd8e3cSvetoslav    public static final class RangeInfo {
35123577a283e1af3e14fe980c4fec55781a58cd8e3cSvetoslav        private static final int MAX_POOL_SIZE = 10;
35133577a283e1af3e14fe980c4fec55781a58cd8e3cSvetoslav
35143577a283e1af3e14fe980c4fec55781a58cd8e3cSvetoslav        /** Range type: integer. */
35153577a283e1af3e14fe980c4fec55781a58cd8e3cSvetoslav        public static final int RANGE_TYPE_INT = 0;
35163577a283e1af3e14fe980c4fec55781a58cd8e3cSvetoslav        /** Range type: float. */
35173577a283e1af3e14fe980c4fec55781a58cd8e3cSvetoslav        public static final int RANGE_TYPE_FLOAT = 1;
35183577a283e1af3e14fe980c4fec55781a58cd8e3cSvetoslav        /** Range type: percent with values from zero to one.*/
35193577a283e1af3e14fe980c4fec55781a58cd8e3cSvetoslav        public static final int RANGE_TYPE_PERCENT = 2;
35203577a283e1af3e14fe980c4fec55781a58cd8e3cSvetoslav
35213577a283e1af3e14fe980c4fec55781a58cd8e3cSvetoslav        private static final SynchronizedPool<RangeInfo> sPool =
35223577a283e1af3e14fe980c4fec55781a58cd8e3cSvetoslav                new SynchronizedPool<AccessibilityNodeInfo.RangeInfo>(MAX_POOL_SIZE);
35233577a283e1af3e14fe980c4fec55781a58cd8e3cSvetoslav
35243577a283e1af3e14fe980c4fec55781a58cd8e3cSvetoslav        private int mType;
35253577a283e1af3e14fe980c4fec55781a58cd8e3cSvetoslav        private float mMin;
35263577a283e1af3e14fe980c4fec55781a58cd8e3cSvetoslav        private float mMax;
35273577a283e1af3e14fe980c4fec55781a58cd8e3cSvetoslav        private float mCurrent;
35283577a283e1af3e14fe980c4fec55781a58cd8e3cSvetoslav
35293577a283e1af3e14fe980c4fec55781a58cd8e3cSvetoslav        /**
35306685f1bacead5f765c71a49f5cf0dc88750344d5Svetoslav Ganov         * Obtains a pooled instance that is a clone of another one.
35316685f1bacead5f765c71a49f5cf0dc88750344d5Svetoslav Ganov         *
35326685f1bacead5f765c71a49f5cf0dc88750344d5Svetoslav Ganov         * @param other The instance to clone.
35336685f1bacead5f765c71a49f5cf0dc88750344d5Svetoslav Ganov         *
35346685f1bacead5f765c71a49f5cf0dc88750344d5Svetoslav Ganov         * @hide
35356685f1bacead5f765c71a49f5cf0dc88750344d5Svetoslav Ganov         */
35366685f1bacead5f765c71a49f5cf0dc88750344d5Svetoslav Ganov        public static RangeInfo obtain(RangeInfo other) {
35376685f1bacead5f765c71a49f5cf0dc88750344d5Svetoslav Ganov            return obtain(other.mType, other.mMin, other.mMax, other.mCurrent);
35386685f1bacead5f765c71a49f5cf0dc88750344d5Svetoslav Ganov        }
35396685f1bacead5f765c71a49f5cf0dc88750344d5Svetoslav Ganov
35406685f1bacead5f765c71a49f5cf0dc88750344d5Svetoslav Ganov        /**
35413577a283e1af3e14fe980c4fec55781a58cd8e3cSvetoslav         * Obtains a pooled instance.
35423577a283e1af3e14fe980c4fec55781a58cd8e3cSvetoslav         *
35433577a283e1af3e14fe980c4fec55781a58cd8e3cSvetoslav         * @param type The type of the range.
35443577a283e1af3e14fe980c4fec55781a58cd8e3cSvetoslav         * @param min The min value.
35453577a283e1af3e14fe980c4fec55781a58cd8e3cSvetoslav         * @param max The max value.
35463577a283e1af3e14fe980c4fec55781a58cd8e3cSvetoslav         * @param current The current value.
35473577a283e1af3e14fe980c4fec55781a58cd8e3cSvetoslav         */
35483577a283e1af3e14fe980c4fec55781a58cd8e3cSvetoslav        public static RangeInfo obtain(int type, float min, float max, float current) {
35493577a283e1af3e14fe980c4fec55781a58cd8e3cSvetoslav            RangeInfo info = sPool.acquire();
35503577a283e1af3e14fe980c4fec55781a58cd8e3cSvetoslav            return (info != null) ? info : new RangeInfo(type, min, max, current);
35513577a283e1af3e14fe980c4fec55781a58cd8e3cSvetoslav        }
35523577a283e1af3e14fe980c4fec55781a58cd8e3cSvetoslav
35533577a283e1af3e14fe980c4fec55781a58cd8e3cSvetoslav        /**
35543577a283e1af3e14fe980c4fec55781a58cd8e3cSvetoslav         * Creates a new range.
35553577a283e1af3e14fe980c4fec55781a58cd8e3cSvetoslav         *
35563577a283e1af3e14fe980c4fec55781a58cd8e3cSvetoslav         * @param type The type of the range.
35573577a283e1af3e14fe980c4fec55781a58cd8e3cSvetoslav         * @param min The min value.
35583577a283e1af3e14fe980c4fec55781a58cd8e3cSvetoslav         * @param max The max value.
35593577a283e1af3e14fe980c4fec55781a58cd8e3cSvetoslav         * @param current The current value.
35603577a283e1af3e14fe980c4fec55781a58cd8e3cSvetoslav         */
35613577a283e1af3e14fe980c4fec55781a58cd8e3cSvetoslav        private RangeInfo(int type, float min, float max, float current) {
35623577a283e1af3e14fe980c4fec55781a58cd8e3cSvetoslav            mType = type;
35633577a283e1af3e14fe980c4fec55781a58cd8e3cSvetoslav            mMin = min;
35643577a283e1af3e14fe980c4fec55781a58cd8e3cSvetoslav            mMax = max;
35653577a283e1af3e14fe980c4fec55781a58cd8e3cSvetoslav            mCurrent = current;
35663577a283e1af3e14fe980c4fec55781a58cd8e3cSvetoslav        }
35673577a283e1af3e14fe980c4fec55781a58cd8e3cSvetoslav
35683577a283e1af3e14fe980c4fec55781a58cd8e3cSvetoslav        /**
35693577a283e1af3e14fe980c4fec55781a58cd8e3cSvetoslav         * Gets the range type.
35703577a283e1af3e14fe980c4fec55781a58cd8e3cSvetoslav         *
35713577a283e1af3e14fe980c4fec55781a58cd8e3cSvetoslav         * @return The range type.
35723577a283e1af3e14fe980c4fec55781a58cd8e3cSvetoslav         *
35733577a283e1af3e14fe980c4fec55781a58cd8e3cSvetoslav         * @see #RANGE_TYPE_INT
35743577a283e1af3e14fe980c4fec55781a58cd8e3cSvetoslav         * @see #RANGE_TYPE_FLOAT
35753577a283e1af3e14fe980c4fec55781a58cd8e3cSvetoslav         * @see #RANGE_TYPE_PERCENT
35763577a283e1af3e14fe980c4fec55781a58cd8e3cSvetoslav         */
35773577a283e1af3e14fe980c4fec55781a58cd8e3cSvetoslav        public int getType() {
35783577a283e1af3e14fe980c4fec55781a58cd8e3cSvetoslav            return mType;
35793577a283e1af3e14fe980c4fec55781a58cd8e3cSvetoslav        }
35803577a283e1af3e14fe980c4fec55781a58cd8e3cSvetoslav
35813577a283e1af3e14fe980c4fec55781a58cd8e3cSvetoslav        /**
35823577a283e1af3e14fe980c4fec55781a58cd8e3cSvetoslav         * Gets the min value.
35833577a283e1af3e14fe980c4fec55781a58cd8e3cSvetoslav         *
35843577a283e1af3e14fe980c4fec55781a58cd8e3cSvetoslav         * @return The min value.
35853577a283e1af3e14fe980c4fec55781a58cd8e3cSvetoslav         */
35863577a283e1af3e14fe980c4fec55781a58cd8e3cSvetoslav        public float getMin() {
35873577a283e1af3e14fe980c4fec55781a58cd8e3cSvetoslav            return mMin;
35883577a283e1af3e14fe980c4fec55781a58cd8e3cSvetoslav        }
35893577a283e1af3e14fe980c4fec55781a58cd8e3cSvetoslav
35903577a283e1af3e14fe980c4fec55781a58cd8e3cSvetoslav        /**
35913577a283e1af3e14fe980c4fec55781a58cd8e3cSvetoslav         * Gets the max value.
35923577a283e1af3e14fe980c4fec55781a58cd8e3cSvetoslav         *
35933577a283e1af3e14fe980c4fec55781a58cd8e3cSvetoslav         * @return The max value.
35943577a283e1af3e14fe980c4fec55781a58cd8e3cSvetoslav         */
35953577a283e1af3e14fe980c4fec55781a58cd8e3cSvetoslav        public float getMax() {
35963577a283e1af3e14fe980c4fec55781a58cd8e3cSvetoslav            return mMax;
35973577a283e1af3e14fe980c4fec55781a58cd8e3cSvetoslav        }
35983577a283e1af3e14fe980c4fec55781a58cd8e3cSvetoslav
35993577a283e1af3e14fe980c4fec55781a58cd8e3cSvetoslav        /**
36003577a283e1af3e14fe980c4fec55781a58cd8e3cSvetoslav         * Gets the current value.
36013577a283e1af3e14fe980c4fec55781a58cd8e3cSvetoslav         *
36023577a283e1af3e14fe980c4fec55781a58cd8e3cSvetoslav         * @return The current value.
36033577a283e1af3e14fe980c4fec55781a58cd8e3cSvetoslav         */
36043577a283e1af3e14fe980c4fec55781a58cd8e3cSvetoslav        public float getCurrent() {
36053577a283e1af3e14fe980c4fec55781a58cd8e3cSvetoslav            return mCurrent;
36063577a283e1af3e14fe980c4fec55781a58cd8e3cSvetoslav        }
36073577a283e1af3e14fe980c4fec55781a58cd8e3cSvetoslav
36083577a283e1af3e14fe980c4fec55781a58cd8e3cSvetoslav        /**
36093577a283e1af3e14fe980c4fec55781a58cd8e3cSvetoslav         * Recycles this instance.
36103577a283e1af3e14fe980c4fec55781a58cd8e3cSvetoslav         */
36113577a283e1af3e14fe980c4fec55781a58cd8e3cSvetoslav        void recycle() {
36123577a283e1af3e14fe980c4fec55781a58cd8e3cSvetoslav            clear();
36133577a283e1af3e14fe980c4fec55781a58cd8e3cSvetoslav            sPool.release(this);
36143577a283e1af3e14fe980c4fec55781a58cd8e3cSvetoslav        }
36153577a283e1af3e14fe980c4fec55781a58cd8e3cSvetoslav
36163577a283e1af3e14fe980c4fec55781a58cd8e3cSvetoslav        private void clear() {
36173577a283e1af3e14fe980c4fec55781a58cd8e3cSvetoslav            mType = 0;
36183577a283e1af3e14fe980c4fec55781a58cd8e3cSvetoslav            mMin = 0;
36193577a283e1af3e14fe980c4fec55781a58cd8e3cSvetoslav            mMax = 0;
36203577a283e1af3e14fe980c4fec55781a58cd8e3cSvetoslav            mCurrent = 0;
36213577a283e1af3e14fe980c4fec55781a58cd8e3cSvetoslav        }
36223577a283e1af3e14fe980c4fec55781a58cd8e3cSvetoslav    }
36233577a283e1af3e14fe980c4fec55781a58cd8e3cSvetoslav
36243577a283e1af3e14fe980c4fec55781a58cd8e3cSvetoslav    /**
36253577a283e1af3e14fe980c4fec55781a58cd8e3cSvetoslav     * Class with information if a node is a collection. Use
3626cb8ed39b3fb591be60b9fb1799d4ea4530eab758Svetoslav Ganov     * {@link CollectionInfo#obtain(int, int, boolean)} to get an instance.
3627cb8ed39b3fb591be60b9fb1799d4ea4530eab758Svetoslav Ganov     * <p>
3628cb8ed39b3fb591be60b9fb1799d4ea4530eab758Svetoslav Ganov     * A collection of items has rows and columns and may be hierarchical.
3629cb8ed39b3fb591be60b9fb1799d4ea4530eab758Svetoslav Ganov     * For example, a horizontal list is a collection with one column, as
3630cb8ed39b3fb591be60b9fb1799d4ea4530eab758Svetoslav Ganov     * many rows as the list items, and is not hierarchical; A table is a
3631cb8ed39b3fb591be60b9fb1799d4ea4530eab758Svetoslav Ganov     * collection with several rows, several columns, and is not hierarchical;
3632cb8ed39b3fb591be60b9fb1799d4ea4530eab758Svetoslav Ganov     * A vertical tree is a hierarchical collection with one column and
3633cb8ed39b3fb591be60b9fb1799d4ea4530eab758Svetoslav Ganov     * as many rows as the first level children.
3634cb8ed39b3fb591be60b9fb1799d4ea4530eab758Svetoslav Ganov     * </p>
36353577a283e1af3e14fe980c4fec55781a58cd8e3cSvetoslav     */
36363577a283e1af3e14fe980c4fec55781a58cd8e3cSvetoslav    public static final class CollectionInfo {
363776769ae02e713f50816ee67ff618b748d95050a8Alan Viverette        /** Selection mode where items are not selectable. */
363876769ae02e713f50816ee67ff618b748d95050a8Alan Viverette        public static final int SELECTION_MODE_NONE = 0;
363976769ae02e713f50816ee67ff618b748d95050a8Alan Viverette
364076769ae02e713f50816ee67ff618b748d95050a8Alan Viverette        /** Selection mode where a single item may be selected. */
364176769ae02e713f50816ee67ff618b748d95050a8Alan Viverette        public static final int SELECTION_MODE_SINGLE = 1;
364276769ae02e713f50816ee67ff618b748d95050a8Alan Viverette
364376769ae02e713f50816ee67ff618b748d95050a8Alan Viverette        /** Selection mode where multiple items may be selected. */
364476769ae02e713f50816ee67ff618b748d95050a8Alan Viverette        public static final int SELECTION_MODE_MULTIPLE = 2;
364576769ae02e713f50816ee67ff618b748d95050a8Alan Viverette
36463577a283e1af3e14fe980c4fec55781a58cd8e3cSvetoslav        private static final int MAX_POOL_SIZE = 20;
36473577a283e1af3e14fe980c4fec55781a58cd8e3cSvetoslav
36483577a283e1af3e14fe980c4fec55781a58cd8e3cSvetoslav        private static final SynchronizedPool<CollectionInfo> sPool =
36493577a283e1af3e14fe980c4fec55781a58cd8e3cSvetoslav                new SynchronizedPool<CollectionInfo>(MAX_POOL_SIZE);
36503577a283e1af3e14fe980c4fec55781a58cd8e3cSvetoslav
3651cb8ed39b3fb591be60b9fb1799d4ea4530eab758Svetoslav Ganov        private int mRowCount;
3652cb8ed39b3fb591be60b9fb1799d4ea4530eab758Svetoslav Ganov        private int mColumnCount;
36533577a283e1af3e14fe980c4fec55781a58cd8e3cSvetoslav        private boolean mHierarchical;
365476769ae02e713f50816ee67ff618b748d95050a8Alan Viverette        private int mSelectionMode;
36553577a283e1af3e14fe980c4fec55781a58cd8e3cSvetoslav
36563577a283e1af3e14fe980c4fec55781a58cd8e3cSvetoslav        /**
36576685f1bacead5f765c71a49f5cf0dc88750344d5Svetoslav Ganov         * Obtains a pooled instance that is a clone of another one.
36586685f1bacead5f765c71a49f5cf0dc88750344d5Svetoslav Ganov         *
36596685f1bacead5f765c71a49f5cf0dc88750344d5Svetoslav Ganov         * @param other The instance to clone.
36606685f1bacead5f765c71a49f5cf0dc88750344d5Svetoslav Ganov         * @hide
36616685f1bacead5f765c71a49f5cf0dc88750344d5Svetoslav Ganov         */
36626685f1bacead5f765c71a49f5cf0dc88750344d5Svetoslav Ganov        public static CollectionInfo obtain(CollectionInfo other) {
366376769ae02e713f50816ee67ff618b748d95050a8Alan Viverette            return CollectionInfo.obtain(other.mRowCount, other.mColumnCount, other.mHierarchical,
366476769ae02e713f50816ee67ff618b748d95050a8Alan Viverette                    other.mSelectionMode);
366576769ae02e713f50816ee67ff618b748d95050a8Alan Viverette        }
366676769ae02e713f50816ee67ff618b748d95050a8Alan Viverette
366776769ae02e713f50816ee67ff618b748d95050a8Alan Viverette        /**
366876769ae02e713f50816ee67ff618b748d95050a8Alan Viverette         * Obtains a pooled instance.
366976769ae02e713f50816ee67ff618b748d95050a8Alan Viverette         *
367076769ae02e713f50816ee67ff618b748d95050a8Alan Viverette         * @param rowCount The number of rows.
367176769ae02e713f50816ee67ff618b748d95050a8Alan Viverette         * @param columnCount The number of columns.
367276769ae02e713f50816ee67ff618b748d95050a8Alan Viverette         * @param hierarchical Whether the collection is hierarchical.
367376769ae02e713f50816ee67ff618b748d95050a8Alan Viverette         */
367476769ae02e713f50816ee67ff618b748d95050a8Alan Viverette        public static CollectionInfo obtain(int rowCount, int columnCount,
367576769ae02e713f50816ee67ff618b748d95050a8Alan Viverette                boolean hierarchical) {
367676769ae02e713f50816ee67ff618b748d95050a8Alan Viverette            return obtain(rowCount, columnCount, hierarchical, SELECTION_MODE_NONE);
36776685f1bacead5f765c71a49f5cf0dc88750344d5Svetoslav Ganov        }
36786685f1bacead5f765c71a49f5cf0dc88750344d5Svetoslav Ganov
36796685f1bacead5f765c71a49f5cf0dc88750344d5Svetoslav Ganov        /**
36803577a283e1af3e14fe980c4fec55781a58cd8e3cSvetoslav         * Obtains a pooled instance.
36813577a283e1af3e14fe980c4fec55781a58cd8e3cSvetoslav         *
3682cb8ed39b3fb591be60b9fb1799d4ea4530eab758Svetoslav Ganov         * @param rowCount The number of rows.
3683cb8ed39b3fb591be60b9fb1799d4ea4530eab758Svetoslav Ganov         * @param columnCount The number of columns.
36843577a283e1af3e14fe980c4fec55781a58cd8e3cSvetoslav         * @param hierarchical Whether the collection is hierarchical.
368576769ae02e713f50816ee67ff618b748d95050a8Alan Viverette         * @param selectionMode The collection's selection mode, one of:
368676769ae02e713f50816ee67ff618b748d95050a8Alan Viverette         *            <ul>
368776769ae02e713f50816ee67ff618b748d95050a8Alan Viverette         *            <li>{@link #SELECTION_MODE_NONE}
368876769ae02e713f50816ee67ff618b748d95050a8Alan Viverette         *            <li>{@link #SELECTION_MODE_SINGLE}
368976769ae02e713f50816ee67ff618b748d95050a8Alan Viverette         *            <li>{@link #SELECTION_MODE_MULTIPLE}
369076769ae02e713f50816ee67ff618b748d95050a8Alan Viverette         *            </ul>
36913577a283e1af3e14fe980c4fec55781a58cd8e3cSvetoslav         */
369276769ae02e713f50816ee67ff618b748d95050a8Alan Viverette        public static CollectionInfo obtain(int rowCount, int columnCount,
369376769ae02e713f50816ee67ff618b748d95050a8Alan Viverette                boolean hierarchical, int selectionMode) {
369476769ae02e713f50816ee67ff618b748d95050a8Alan Viverette           final CollectionInfo info = sPool.acquire();
3695cdd2eddcb288763341172ead488e92cafb19bab6Alan Viverette            if (info == null) {
369676769ae02e713f50816ee67ff618b748d95050a8Alan Viverette                return new CollectionInfo(rowCount, columnCount, hierarchical, selectionMode);
3697cdd2eddcb288763341172ead488e92cafb19bab6Alan Viverette            }
3698cdd2eddcb288763341172ead488e92cafb19bab6Alan Viverette
3699cdd2eddcb288763341172ead488e92cafb19bab6Alan Viverette            info.mRowCount = rowCount;
3700cdd2eddcb288763341172ead488e92cafb19bab6Alan Viverette            info.mColumnCount = columnCount;
3701cdd2eddcb288763341172ead488e92cafb19bab6Alan Viverette            info.mHierarchical = hierarchical;
370276769ae02e713f50816ee67ff618b748d95050a8Alan Viverette            info.mSelectionMode = selectionMode;
3703cdd2eddcb288763341172ead488e92cafb19bab6Alan Viverette            return info;
37043577a283e1af3e14fe980c4fec55781a58cd8e3cSvetoslav        }
37053577a283e1af3e14fe980c4fec55781a58cd8e3cSvetoslav
37063577a283e1af3e14fe980c4fec55781a58cd8e3cSvetoslav        /**
37073577a283e1af3e14fe980c4fec55781a58cd8e3cSvetoslav         * Creates a new instance.
37083577a283e1af3e14fe980c4fec55781a58cd8e3cSvetoslav         *
3709cb8ed39b3fb591be60b9fb1799d4ea4530eab758Svetoslav Ganov         * @param rowCount The number of rows.
3710cb8ed39b3fb591be60b9fb1799d4ea4530eab758Svetoslav Ganov         * @param columnCount The number of columns.
37113577a283e1af3e14fe980c4fec55781a58cd8e3cSvetoslav         * @param hierarchical Whether the collection is hierarchical.
371276769ae02e713f50816ee67ff618b748d95050a8Alan Viverette         * @param selectionMode The collection's selection mode.
37133577a283e1af3e14fe980c4fec55781a58cd8e3cSvetoslav         */
371476769ae02e713f50816ee67ff618b748d95050a8Alan Viverette        private CollectionInfo(int rowCount, int columnCount, boolean hierarchical,
371576769ae02e713f50816ee67ff618b748d95050a8Alan Viverette                int selectionMode) {
3716cb8ed39b3fb591be60b9fb1799d4ea4530eab758Svetoslav Ganov            mRowCount = rowCount;
3717cb8ed39b3fb591be60b9fb1799d4ea4530eab758Svetoslav Ganov            mColumnCount = columnCount;
37183577a283e1af3e14fe980c4fec55781a58cd8e3cSvetoslav            mHierarchical = hierarchical;
371976769ae02e713f50816ee67ff618b748d95050a8Alan Viverette            mSelectionMode = selectionMode;
37203577a283e1af3e14fe980c4fec55781a58cd8e3cSvetoslav        }
37213577a283e1af3e14fe980c4fec55781a58cd8e3cSvetoslav
37223577a283e1af3e14fe980c4fec55781a58cd8e3cSvetoslav        /**
3723cb8ed39b3fb591be60b9fb1799d4ea4530eab758Svetoslav Ganov         * Gets the number of rows.
37243577a283e1af3e14fe980c4fec55781a58cd8e3cSvetoslav         *
3725cb8ed39b3fb591be60b9fb1799d4ea4530eab758Svetoslav Ganov         * @return The row count.
37263577a283e1af3e14fe980c4fec55781a58cd8e3cSvetoslav         */
3727cb8ed39b3fb591be60b9fb1799d4ea4530eab758Svetoslav Ganov        public int getRowCount() {
3728cb8ed39b3fb591be60b9fb1799d4ea4530eab758Svetoslav Ganov            return mRowCount;
37293577a283e1af3e14fe980c4fec55781a58cd8e3cSvetoslav        }
37303577a283e1af3e14fe980c4fec55781a58cd8e3cSvetoslav
37313577a283e1af3e14fe980c4fec55781a58cd8e3cSvetoslav        /**
3732cb8ed39b3fb591be60b9fb1799d4ea4530eab758Svetoslav Ganov         * Gets the number of columns.
37333577a283e1af3e14fe980c4fec55781a58cd8e3cSvetoslav         *
3734cb8ed39b3fb591be60b9fb1799d4ea4530eab758Svetoslav Ganov         * @return The column count.
37353577a283e1af3e14fe980c4fec55781a58cd8e3cSvetoslav         */
3736cb8ed39b3fb591be60b9fb1799d4ea4530eab758Svetoslav Ganov        public int getColumnCount() {
3737cb8ed39b3fb591be60b9fb1799d4ea4530eab758Svetoslav Ganov            return mColumnCount;
37383577a283e1af3e14fe980c4fec55781a58cd8e3cSvetoslav        }
37393577a283e1af3e14fe980c4fec55781a58cd8e3cSvetoslav
37403577a283e1af3e14fe980c4fec55781a58cd8e3cSvetoslav        /**
37413577a283e1af3e14fe980c4fec55781a58cd8e3cSvetoslav         * Gets if the collection is a hierarchically ordered.
37423577a283e1af3e14fe980c4fec55781a58cd8e3cSvetoslav         *
37433577a283e1af3e14fe980c4fec55781a58cd8e3cSvetoslav         * @return Whether the collection is hierarchical.
37443577a283e1af3e14fe980c4fec55781a58cd8e3cSvetoslav         */
37453577a283e1af3e14fe980c4fec55781a58cd8e3cSvetoslav        public boolean isHierarchical() {
37463577a283e1af3e14fe980c4fec55781a58cd8e3cSvetoslav            return mHierarchical;
37473577a283e1af3e14fe980c4fec55781a58cd8e3cSvetoslav        }
37483577a283e1af3e14fe980c4fec55781a58cd8e3cSvetoslav
37493577a283e1af3e14fe980c4fec55781a58cd8e3cSvetoslav        /**
375076769ae02e713f50816ee67ff618b748d95050a8Alan Viverette         * Gets the collection's selection mode.
375176769ae02e713f50816ee67ff618b748d95050a8Alan Viverette         *
375276769ae02e713f50816ee67ff618b748d95050a8Alan Viverette         * @return The collection's selection mode, one of:
375376769ae02e713f50816ee67ff618b748d95050a8Alan Viverette         *         <ul>
375476769ae02e713f50816ee67ff618b748d95050a8Alan Viverette         *         <li>{@link #SELECTION_MODE_NONE}
375576769ae02e713f50816ee67ff618b748d95050a8Alan Viverette         *         <li>{@link #SELECTION_MODE_SINGLE}
375676769ae02e713f50816ee67ff618b748d95050a8Alan Viverette         *         <li>{@link #SELECTION_MODE_MULTIPLE}
375776769ae02e713f50816ee67ff618b748d95050a8Alan Viverette         *         </ul>
375876769ae02e713f50816ee67ff618b748d95050a8Alan Viverette         */
375976769ae02e713f50816ee67ff618b748d95050a8Alan Viverette        public int getSelectionMode() {
376076769ae02e713f50816ee67ff618b748d95050a8Alan Viverette            return mSelectionMode;
376176769ae02e713f50816ee67ff618b748d95050a8Alan Viverette        }
376276769ae02e713f50816ee67ff618b748d95050a8Alan Viverette
376376769ae02e713f50816ee67ff618b748d95050a8Alan Viverette        /**
37643577a283e1af3e14fe980c4fec55781a58cd8e3cSvetoslav         * Recycles this instance.
37653577a283e1af3e14fe980c4fec55781a58cd8e3cSvetoslav         */
37663577a283e1af3e14fe980c4fec55781a58cd8e3cSvetoslav        void recycle() {
37673577a283e1af3e14fe980c4fec55781a58cd8e3cSvetoslav            clear();
37683577a283e1af3e14fe980c4fec55781a58cd8e3cSvetoslav            sPool.release(this);
37693577a283e1af3e14fe980c4fec55781a58cd8e3cSvetoslav        }
37703577a283e1af3e14fe980c4fec55781a58cd8e3cSvetoslav
37713577a283e1af3e14fe980c4fec55781a58cd8e3cSvetoslav        private void clear() {
3772cb8ed39b3fb591be60b9fb1799d4ea4530eab758Svetoslav Ganov            mRowCount = 0;
3773cb8ed39b3fb591be60b9fb1799d4ea4530eab758Svetoslav Ganov            mColumnCount = 0;
37743577a283e1af3e14fe980c4fec55781a58cd8e3cSvetoslav            mHierarchical = false;
377576769ae02e713f50816ee67ff618b748d95050a8Alan Viverette            mSelectionMode = SELECTION_MODE_NONE;
37763577a283e1af3e14fe980c4fec55781a58cd8e3cSvetoslav        }
37773577a283e1af3e14fe980c4fec55781a58cd8e3cSvetoslav    }
37783577a283e1af3e14fe980c4fec55781a58cd8e3cSvetoslav
37793577a283e1af3e14fe980c4fec55781a58cd8e3cSvetoslav    /**
37803577a283e1af3e14fe980c4fec55781a58cd8e3cSvetoslav     * Class with information if a node is a collection item. Use
3781cb8ed39b3fb591be60b9fb1799d4ea4530eab758Svetoslav Ganov     * {@link CollectionItemInfo#obtain(int, int, int, int, boolean)}
3782cb8ed39b3fb591be60b9fb1799d4ea4530eab758Svetoslav Ganov     * to get an instance.
3783cb8ed39b3fb591be60b9fb1799d4ea4530eab758Svetoslav Ganov     * <p>
3784cb8ed39b3fb591be60b9fb1799d4ea4530eab758Svetoslav Ganov     * A collection item is contained in a collection, it starts at
3785cb8ed39b3fb591be60b9fb1799d4ea4530eab758Svetoslav Ganov     * a given row and column in the collection, and spans one or
3786cb8ed39b3fb591be60b9fb1799d4ea4530eab758Svetoslav Ganov     * more rows and columns. For example, a header of two related
3787cb8ed39b3fb591be60b9fb1799d4ea4530eab758Svetoslav Ganov     * table columns starts at the first row and the first column,
3788cb8ed39b3fb591be60b9fb1799d4ea4530eab758Svetoslav Ganov     * spans one row and two columns.
3789cb8ed39b3fb591be60b9fb1799d4ea4530eab758Svetoslav Ganov     * </p>
37903577a283e1af3e14fe980c4fec55781a58cd8e3cSvetoslav     */
37913577a283e1af3e14fe980c4fec55781a58cd8e3cSvetoslav    public static final class CollectionItemInfo {
37923577a283e1af3e14fe980c4fec55781a58cd8e3cSvetoslav        private static final int MAX_POOL_SIZE = 20;
37933577a283e1af3e14fe980c4fec55781a58cd8e3cSvetoslav
37943577a283e1af3e14fe980c4fec55781a58cd8e3cSvetoslav        private static final SynchronizedPool<CollectionItemInfo> sPool =
37953577a283e1af3e14fe980c4fec55781a58cd8e3cSvetoslav                new SynchronizedPool<CollectionItemInfo>(MAX_POOL_SIZE);
37963577a283e1af3e14fe980c4fec55781a58cd8e3cSvetoslav
37973577a283e1af3e14fe980c4fec55781a58cd8e3cSvetoslav        /**
37986685f1bacead5f765c71a49f5cf0dc88750344d5Svetoslav Ganov         * Obtains a pooled instance that is a clone of another one.
37996685f1bacead5f765c71a49f5cf0dc88750344d5Svetoslav Ganov         *
38006685f1bacead5f765c71a49f5cf0dc88750344d5Svetoslav Ganov         * @param other The instance to clone.
38016685f1bacead5f765c71a49f5cf0dc88750344d5Svetoslav Ganov         * @hide
38026685f1bacead5f765c71a49f5cf0dc88750344d5Svetoslav Ganov         */
38036685f1bacead5f765c71a49f5cf0dc88750344d5Svetoslav Ganov        public static CollectionItemInfo obtain(CollectionItemInfo other) {
380476769ae02e713f50816ee67ff618b748d95050a8Alan Viverette            return CollectionItemInfo.obtain(other.mRowIndex, other.mRowSpan, other.mColumnIndex,
380576769ae02e713f50816ee67ff618b748d95050a8Alan Viverette                    other.mColumnSpan, other.mHeading, other.mSelected);
380676769ae02e713f50816ee67ff618b748d95050a8Alan Viverette        }
380776769ae02e713f50816ee67ff618b748d95050a8Alan Viverette
380876769ae02e713f50816ee67ff618b748d95050a8Alan Viverette        /**
380976769ae02e713f50816ee67ff618b748d95050a8Alan Viverette         * Obtains a pooled instance.
381076769ae02e713f50816ee67ff618b748d95050a8Alan Viverette         *
381176769ae02e713f50816ee67ff618b748d95050a8Alan Viverette         * @param rowIndex The row index at which the item is located.
381276769ae02e713f50816ee67ff618b748d95050a8Alan Viverette         * @param rowSpan The number of rows the item spans.
381376769ae02e713f50816ee67ff618b748d95050a8Alan Viverette         * @param columnIndex The column index at which the item is located.
381476769ae02e713f50816ee67ff618b748d95050a8Alan Viverette         * @param columnSpan The number of columns the item spans.
381576769ae02e713f50816ee67ff618b748d95050a8Alan Viverette         * @param heading Whether the item is a heading.
381676769ae02e713f50816ee67ff618b748d95050a8Alan Viverette         */
381776769ae02e713f50816ee67ff618b748d95050a8Alan Viverette        public static CollectionItemInfo obtain(int rowIndex, int rowSpan,
381876769ae02e713f50816ee67ff618b748d95050a8Alan Viverette                int columnIndex, int columnSpan, boolean heading) {
381976769ae02e713f50816ee67ff618b748d95050a8Alan Viverette            return obtain(rowIndex, rowSpan, columnIndex, columnSpan, heading, false);
38206685f1bacead5f765c71a49f5cf0dc88750344d5Svetoslav Ganov        }
38216685f1bacead5f765c71a49f5cf0dc88750344d5Svetoslav Ganov
38226685f1bacead5f765c71a49f5cf0dc88750344d5Svetoslav Ganov        /**
38233577a283e1af3e14fe980c4fec55781a58cd8e3cSvetoslav         * Obtains a pooled instance.
38243577a283e1af3e14fe980c4fec55781a58cd8e3cSvetoslav         *
3825cb8ed39b3fb591be60b9fb1799d4ea4530eab758Svetoslav Ganov         * @param rowIndex The row index at which the item is located.
3826cb8ed39b3fb591be60b9fb1799d4ea4530eab758Svetoslav Ganov         * @param rowSpan The number of rows the item spans.
3827cb8ed39b3fb591be60b9fb1799d4ea4530eab758Svetoslav Ganov         * @param columnIndex The column index at which the item is located.
3828cb8ed39b3fb591be60b9fb1799d4ea4530eab758Svetoslav Ganov         * @param columnSpan The number of columns the item spans.
38293577a283e1af3e14fe980c4fec55781a58cd8e3cSvetoslav         * @param heading Whether the item is a heading.
383076769ae02e713f50816ee67ff618b748d95050a8Alan Viverette         * @param selected Whether the item is selected.
38313577a283e1af3e14fe980c4fec55781a58cd8e3cSvetoslav         */
383276769ae02e713f50816ee67ff618b748d95050a8Alan Viverette        public static CollectionItemInfo obtain(int rowIndex, int rowSpan,
383376769ae02e713f50816ee67ff618b748d95050a8Alan Viverette                int columnIndex, int columnSpan, boolean heading, boolean selected) {
3834cdd2eddcb288763341172ead488e92cafb19bab6Alan Viverette            final CollectionItemInfo info = sPool.acquire();
3835cdd2eddcb288763341172ead488e92cafb19bab6Alan Viverette            if (info == null) {
383676769ae02e713f50816ee67ff618b748d95050a8Alan Viverette                return new CollectionItemInfo(
383776769ae02e713f50816ee67ff618b748d95050a8Alan Viverette                        rowIndex, rowSpan, columnIndex, columnSpan, heading, selected);
3838cdd2eddcb288763341172ead488e92cafb19bab6Alan Viverette            }
3839cdd2eddcb288763341172ead488e92cafb19bab6Alan Viverette
3840cdd2eddcb288763341172ead488e92cafb19bab6Alan Viverette            info.mRowIndex = rowIndex;
3841cdd2eddcb288763341172ead488e92cafb19bab6Alan Viverette            info.mRowSpan = rowSpan;
3842cdd2eddcb288763341172ead488e92cafb19bab6Alan Viverette            info.mColumnIndex = columnIndex;
3843cdd2eddcb288763341172ead488e92cafb19bab6Alan Viverette            info.mColumnSpan = columnSpan;
3844cdd2eddcb288763341172ead488e92cafb19bab6Alan Viverette            info.mHeading = heading;
384576769ae02e713f50816ee67ff618b748d95050a8Alan Viverette            info.mSelected = selected;
3846cdd2eddcb288763341172ead488e92cafb19bab6Alan Viverette            return info;
38473577a283e1af3e14fe980c4fec55781a58cd8e3cSvetoslav        }
38483577a283e1af3e14fe980c4fec55781a58cd8e3cSvetoslav
38493577a283e1af3e14fe980c4fec55781a58cd8e3cSvetoslav        private boolean mHeading;
3850cb8ed39b3fb591be60b9fb1799d4ea4530eab758Svetoslav Ganov        private int mColumnIndex;
3851cb8ed39b3fb591be60b9fb1799d4ea4530eab758Svetoslav Ganov        private int mRowIndex;
3852cb8ed39b3fb591be60b9fb1799d4ea4530eab758Svetoslav Ganov        private int mColumnSpan;
3853cb8ed39b3fb591be60b9fb1799d4ea4530eab758Svetoslav Ganov        private int mRowSpan;
385476769ae02e713f50816ee67ff618b748d95050a8Alan Viverette        private boolean mSelected;
38553577a283e1af3e14fe980c4fec55781a58cd8e3cSvetoslav
38563577a283e1af3e14fe980c4fec55781a58cd8e3cSvetoslav        /**
38573577a283e1af3e14fe980c4fec55781a58cd8e3cSvetoslav         * Creates a new instance.
38583577a283e1af3e14fe980c4fec55781a58cd8e3cSvetoslav         *
3859cb8ed39b3fb591be60b9fb1799d4ea4530eab758Svetoslav Ganov         * @param rowIndex The row index at which the item is located.
3860cb8ed39b3fb591be60b9fb1799d4ea4530eab758Svetoslav Ganov         * @param rowSpan The number of rows the item spans.
3861cb8ed39b3fb591be60b9fb1799d4ea4530eab758Svetoslav Ganov         * @param columnIndex The column index at which the item is located.
3862cb8ed39b3fb591be60b9fb1799d4ea4530eab758Svetoslav Ganov         * @param columnSpan The number of columns the item spans.
38633577a283e1af3e14fe980c4fec55781a58cd8e3cSvetoslav         * @param heading Whether the item is a heading.
38643577a283e1af3e14fe980c4fec55781a58cd8e3cSvetoslav         */
386576769ae02e713f50816ee67ff618b748d95050a8Alan Viverette        private CollectionItemInfo(int rowIndex, int rowSpan, int columnIndex, int columnSpan,
386676769ae02e713f50816ee67ff618b748d95050a8Alan Viverette                boolean heading, boolean selected) {
3867cb8ed39b3fb591be60b9fb1799d4ea4530eab758Svetoslav Ganov            mRowIndex = rowIndex;
3868cb8ed39b3fb591be60b9fb1799d4ea4530eab758Svetoslav Ganov            mRowSpan = rowSpan;
3869cb8ed39b3fb591be60b9fb1799d4ea4530eab758Svetoslav Ganov            mColumnIndex = columnIndex;
3870cb8ed39b3fb591be60b9fb1799d4ea4530eab758Svetoslav Ganov            mColumnSpan = columnSpan;
38713577a283e1af3e14fe980c4fec55781a58cd8e3cSvetoslav            mHeading = heading;
387276769ae02e713f50816ee67ff618b748d95050a8Alan Viverette            mSelected = selected;
38733577a283e1af3e14fe980c4fec55781a58cd8e3cSvetoslav        }
38743577a283e1af3e14fe980c4fec55781a58cd8e3cSvetoslav
38753577a283e1af3e14fe980c4fec55781a58cd8e3cSvetoslav        /**
3876cb8ed39b3fb591be60b9fb1799d4ea4530eab758Svetoslav Ganov         * Gets the column index at which the item is located.
38773577a283e1af3e14fe980c4fec55781a58cd8e3cSvetoslav         *
3878cb8ed39b3fb591be60b9fb1799d4ea4530eab758Svetoslav Ganov         * @return The column index.
38793577a283e1af3e14fe980c4fec55781a58cd8e3cSvetoslav         */
3880cb8ed39b3fb591be60b9fb1799d4ea4530eab758Svetoslav Ganov        public int getColumnIndex() {
3881cb8ed39b3fb591be60b9fb1799d4ea4530eab758Svetoslav Ganov            return mColumnIndex;
38823577a283e1af3e14fe980c4fec55781a58cd8e3cSvetoslav        }
38833577a283e1af3e14fe980c4fec55781a58cd8e3cSvetoslav
38843577a283e1af3e14fe980c4fec55781a58cd8e3cSvetoslav        /**
3885cb8ed39b3fb591be60b9fb1799d4ea4530eab758Svetoslav Ganov         * Gets the row index at which the item is located.
38863577a283e1af3e14fe980c4fec55781a58cd8e3cSvetoslav         *
3887cb8ed39b3fb591be60b9fb1799d4ea4530eab758Svetoslav Ganov         * @return The row index.
38883577a283e1af3e14fe980c4fec55781a58cd8e3cSvetoslav         */
3889cb8ed39b3fb591be60b9fb1799d4ea4530eab758Svetoslav Ganov        public int getRowIndex() {
3890cb8ed39b3fb591be60b9fb1799d4ea4530eab758Svetoslav Ganov            return mRowIndex;
38913577a283e1af3e14fe980c4fec55781a58cd8e3cSvetoslav        }
38923577a283e1af3e14fe980c4fec55781a58cd8e3cSvetoslav
38933577a283e1af3e14fe980c4fec55781a58cd8e3cSvetoslav        /**
3894cb8ed39b3fb591be60b9fb1799d4ea4530eab758Svetoslav Ganov         * Gets the number of columns the item spans.
38953577a283e1af3e14fe980c4fec55781a58cd8e3cSvetoslav         *
3896cb8ed39b3fb591be60b9fb1799d4ea4530eab758Svetoslav Ganov         * @return The column span.
38973577a283e1af3e14fe980c4fec55781a58cd8e3cSvetoslav         */
3898cb8ed39b3fb591be60b9fb1799d4ea4530eab758Svetoslav Ganov        public int getColumnSpan() {
3899cb8ed39b3fb591be60b9fb1799d4ea4530eab758Svetoslav Ganov            return mColumnSpan;
39003577a283e1af3e14fe980c4fec55781a58cd8e3cSvetoslav        }
39013577a283e1af3e14fe980c4fec55781a58cd8e3cSvetoslav
39023577a283e1af3e14fe980c4fec55781a58cd8e3cSvetoslav        /**
3903cb8ed39b3fb591be60b9fb1799d4ea4530eab758Svetoslav Ganov         * Gets the number of rows the item spans.
39043577a283e1af3e14fe980c4fec55781a58cd8e3cSvetoslav         *
3905cb8ed39b3fb591be60b9fb1799d4ea4530eab758Svetoslav Ganov         * @return The row span.
39063577a283e1af3e14fe980c4fec55781a58cd8e3cSvetoslav         */
3907cb8ed39b3fb591be60b9fb1799d4ea4530eab758Svetoslav Ganov        public int getRowSpan() {
3908cb8ed39b3fb591be60b9fb1799d4ea4530eab758Svetoslav Ganov            return mRowSpan;
39093577a283e1af3e14fe980c4fec55781a58cd8e3cSvetoslav        }
39103577a283e1af3e14fe980c4fec55781a58cd8e3cSvetoslav
39113577a283e1af3e14fe980c4fec55781a58cd8e3cSvetoslav        /**
39123577a283e1af3e14fe980c4fec55781a58cd8e3cSvetoslav         * Gets if the collection item is a heading. For example, section
39133577a283e1af3e14fe980c4fec55781a58cd8e3cSvetoslav         * heading, table header, etc.
39143577a283e1af3e14fe980c4fec55781a58cd8e3cSvetoslav         *
39153577a283e1af3e14fe980c4fec55781a58cd8e3cSvetoslav         * @return If the item is a heading.
39163577a283e1af3e14fe980c4fec55781a58cd8e3cSvetoslav         */
39173577a283e1af3e14fe980c4fec55781a58cd8e3cSvetoslav        public boolean isHeading() {
39183577a283e1af3e14fe980c4fec55781a58cd8e3cSvetoslav            return mHeading;
39193577a283e1af3e14fe980c4fec55781a58cd8e3cSvetoslav        }
39203577a283e1af3e14fe980c4fec55781a58cd8e3cSvetoslav
39213577a283e1af3e14fe980c4fec55781a58cd8e3cSvetoslav        /**
392276769ae02e713f50816ee67ff618b748d95050a8Alan Viverette         * Gets if the collection item is selected.
392376769ae02e713f50816ee67ff618b748d95050a8Alan Viverette         *
392476769ae02e713f50816ee67ff618b748d95050a8Alan Viverette         * @return If the item is selected.
392576769ae02e713f50816ee67ff618b748d95050a8Alan Viverette         */
392676769ae02e713f50816ee67ff618b748d95050a8Alan Viverette        public boolean isSelected() {
392776769ae02e713f50816ee67ff618b748d95050a8Alan Viverette            return mSelected;
392876769ae02e713f50816ee67ff618b748d95050a8Alan Viverette        }
392976769ae02e713f50816ee67ff618b748d95050a8Alan Viverette
393076769ae02e713f50816ee67ff618b748d95050a8Alan Viverette        /**
39313577a283e1af3e14fe980c4fec55781a58cd8e3cSvetoslav         * Recycles this instance.
39323577a283e1af3e14fe980c4fec55781a58cd8e3cSvetoslav         */
39333577a283e1af3e14fe980c4fec55781a58cd8e3cSvetoslav        void recycle() {
39343577a283e1af3e14fe980c4fec55781a58cd8e3cSvetoslav            clear();
39353577a283e1af3e14fe980c4fec55781a58cd8e3cSvetoslav            sPool.release(this);
39363577a283e1af3e14fe980c4fec55781a58cd8e3cSvetoslav        }
39373577a283e1af3e14fe980c4fec55781a58cd8e3cSvetoslav
39383577a283e1af3e14fe980c4fec55781a58cd8e3cSvetoslav        private void clear() {
3939cb8ed39b3fb591be60b9fb1799d4ea4530eab758Svetoslav Ganov            mColumnIndex = 0;
3940cb8ed39b3fb591be60b9fb1799d4ea4530eab758Svetoslav Ganov            mColumnSpan = 0;
3941cb8ed39b3fb591be60b9fb1799d4ea4530eab758Svetoslav Ganov            mRowIndex = 0;
3942cb8ed39b3fb591be60b9fb1799d4ea4530eab758Svetoslav Ganov            mRowSpan = 0;
39433577a283e1af3e14fe980c4fec55781a58cd8e3cSvetoslav            mHeading = false;
394476769ae02e713f50816ee67ff618b748d95050a8Alan Viverette            mSelected = false;
39453577a283e1af3e14fe980c4fec55781a58cd8e3cSvetoslav        }
39463577a283e1af3e14fe980c4fec55781a58cd8e3cSvetoslav    }
39473577a283e1af3e14fe980c4fec55781a58cd8e3cSvetoslav
39483577a283e1af3e14fe980c4fec55781a58cd8e3cSvetoslav    /**
3949f0aed09ed8153043e40b3ac99788d47ba0831306Alan Viverette     * @see android.os.Parcelable.Creator
39508643aa0179e598e78d938c59035389054535a229Svetoslav Ganov     */
39518643aa0179e598e78d938c59035389054535a229Svetoslav Ganov    public static final Parcelable.Creator<AccessibilityNodeInfo> CREATOR =
39528643aa0179e598e78d938c59035389054535a229Svetoslav Ganov            new Parcelable.Creator<AccessibilityNodeInfo>() {
3953f0aed09ed8153043e40b3ac99788d47ba0831306Alan Viverette        @Override
39548643aa0179e598e78d938c59035389054535a229Svetoslav Ganov        public AccessibilityNodeInfo createFromParcel(Parcel parcel) {
39558643aa0179e598e78d938c59035389054535a229Svetoslav Ganov            AccessibilityNodeInfo info = AccessibilityNodeInfo.obtain();
39568643aa0179e598e78d938c59035389054535a229Svetoslav Ganov            info.initFromParcel(parcel);
39578643aa0179e598e78d938c59035389054535a229Svetoslav Ganov            return info;
39588643aa0179e598e78d938c59035389054535a229Svetoslav Ganov        }
39598643aa0179e598e78d938c59035389054535a229Svetoslav Ganov
3960f0aed09ed8153043e40b3ac99788d47ba0831306Alan Viverette        @Override
39618643aa0179e598e78d938c59035389054535a229Svetoslav Ganov        public AccessibilityNodeInfo[] newArray(int size) {
39628643aa0179e598e78d938c59035389054535a229Svetoslav Ganov            return new AccessibilityNodeInfo[size];
39638643aa0179e598e78d938c59035389054535a229Svetoslav Ganov        }
39648643aa0179e598e78d938c59035389054535a229Svetoslav Ganov    };
39658643aa0179e598e78d938c59035389054535a229Svetoslav Ganov}
3966