AccessibilityEvent.java revision e4aa13b20166219a62916a92294055e7cc5c9f10
175986cf9bc57ef11ad70f36fb77fbbf5d63af6ecsvetoslavganov/*
275986cf9bc57ef11ad70f36fb77fbbf5d63af6ecsvetoslavganov * Copyright (C) 2009 The Android Open Source Project
375986cf9bc57ef11ad70f36fb77fbbf5d63af6ecsvetoslavganov *
475986cf9bc57ef11ad70f36fb77fbbf5d63af6ecsvetoslavganov * Licensed under the Apache License, Version 2.0 (the "License");
575986cf9bc57ef11ad70f36fb77fbbf5d63af6ecsvetoslavganov * you may not use this file except in compliance with the License.
675986cf9bc57ef11ad70f36fb77fbbf5d63af6ecsvetoslavganov * You may obtain a copy of the License at
775986cf9bc57ef11ad70f36fb77fbbf5d63af6ecsvetoslavganov *
875986cf9bc57ef11ad70f36fb77fbbf5d63af6ecsvetoslavganov *      http://www.apache.org/licenses/LICENSE-2.0
975986cf9bc57ef11ad70f36fb77fbbf5d63af6ecsvetoslavganov *
1075986cf9bc57ef11ad70f36fb77fbbf5d63af6ecsvetoslavganov * Unless required by applicable law or agreed to in writing, software
1175986cf9bc57ef11ad70f36fb77fbbf5d63af6ecsvetoslavganov * distributed under the License is distributed on an "AS IS" BASIS,
1275986cf9bc57ef11ad70f36fb77fbbf5d63af6ecsvetoslavganov * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1375986cf9bc57ef11ad70f36fb77fbbf5d63af6ecsvetoslavganov * See the License for the specific language governing permissions and
1475986cf9bc57ef11ad70f36fb77fbbf5d63af6ecsvetoslavganov * limitations under the License.
1575986cf9bc57ef11ad70f36fb77fbbf5d63af6ecsvetoslavganov */
1675986cf9bc57ef11ad70f36fb77fbbf5d63af6ecsvetoslavganov
1775986cf9bc57ef11ad70f36fb77fbbf5d63af6ecsvetoslavganovpackage android.view.accessibility;
1875986cf9bc57ef11ad70f36fb77fbbf5d63af6ecsvetoslavganov
198643aa0179e598e78d938c59035389054535a229Svetoslav Ganovimport android.accessibilityservice.IAccessibilityServiceConnection;
2075986cf9bc57ef11ad70f36fb77fbbf5d63af6ecsvetoslavganovimport android.os.Parcel;
2175986cf9bc57ef11ad70f36fb77fbbf5d63af6ecsvetoslavganovimport android.os.Parcelable;
2275986cf9bc57ef11ad70f36fb77fbbf5d63af6ecsvetoslavganovimport android.text.TextUtils;
2375986cf9bc57ef11ad70f36fb77fbbf5d63af6ecsvetoslavganov
2475986cf9bc57ef11ad70f36fb77fbbf5d63af6ecsvetoslavganovimport java.util.ArrayList;
25eeee4d2c01d3c4ed99e4891dbc75c7de69a803faSvetoslav Ganovimport java.util.List;
2675986cf9bc57ef11ad70f36fb77fbbf5d63af6ecsvetoslavganov
2775986cf9bc57ef11ad70f36fb77fbbf5d63af6ecsvetoslavganov/**
2838e8b4e5bc3c93affdffbc064fd9db5aeccc3e8eSvetoslav Ganov * <p>
2975986cf9bc57ef11ad70f36fb77fbbf5d63af6ecsvetoslavganov * This class represents accessibility events that are sent by the system when
3075986cf9bc57ef11ad70f36fb77fbbf5d63af6ecsvetoslavganov * something notable happens in the user interface. For example, when a
3175986cf9bc57ef11ad70f36fb77fbbf5d63af6ecsvetoslavganov * {@link android.widget.Button} is clicked, a {@link android.view.View} is focused, etc.
3238e8b4e5bc3c93affdffbc064fd9db5aeccc3e8eSvetoslav Ganov * </p>
3375986cf9bc57ef11ad70f36fb77fbbf5d63af6ecsvetoslavganov * <p>
34736c2756bf3c14ae9fef7255c119057f7a2be1edSvetoslav Ganov * An accessibility event is fired by an individual view which populates the event with
3538e8b4e5bc3c93affdffbc064fd9db5aeccc3e8eSvetoslav Ganov * data for its state and requests from its parent to send the event to interested
3638e8b4e5bc3c93affdffbc064fd9db5aeccc3e8eSvetoslav Ganov * parties. The parent can optionally add an {@link AccessibilityRecord} for itself before
3738e8b4e5bc3c93affdffbc064fd9db5aeccc3e8eSvetoslav Ganov * dispatching a similar request to its parent. A parent can also choose not to respect the
3838e8b4e5bc3c93affdffbc064fd9db5aeccc3e8eSvetoslav Ganov * request for sending an event. The accessibility event is sent by the topmost view in the
3938e8b4e5bc3c93affdffbc064fd9db5aeccc3e8eSvetoslav Ganov * view tree. Therefore, an {@link android.accessibilityservice.AccessibilityService} can
4038e8b4e5bc3c93affdffbc064fd9db5aeccc3e8eSvetoslav Ganov * explore all records in an accessibility event to obtain more information about the
4138e8b4e5bc3c93affdffbc064fd9db5aeccc3e8eSvetoslav Ganov * context in which the event was fired.
4238e8b4e5bc3c93affdffbc064fd9db5aeccc3e8eSvetoslav Ganov * </p>
43736c2756bf3c14ae9fef7255c119057f7a2be1edSvetoslav Ganov * <p>
4438e8b4e5bc3c93affdffbc064fd9db5aeccc3e8eSvetoslav Ganov * The main purpose of an accessibility event is to expose enough information for an
4538e8b4e5bc3c93affdffbc064fd9db5aeccc3e8eSvetoslav Ganov * {@link android.accessibilityservice.AccessibilityService} to provide meaningful feedback
4638e8b4e5bc3c93affdffbc064fd9db5aeccc3e8eSvetoslav Ganov * to the user. Sometimes however, an accessibility service may need more contextual
4738e8b4e5bc3c93affdffbc064fd9db5aeccc3e8eSvetoslav Ganov * information then the one in the event pay-load. In such cases the service can obtain
4838e8b4e5bc3c93affdffbc064fd9db5aeccc3e8eSvetoslav Ganov * the event source which is an {@link AccessibilityNodeInfo} (snapshot of a View state)
4938e8b4e5bc3c93affdffbc064fd9db5aeccc3e8eSvetoslav Ganov * which can be used for exploring the window content. Note that the privilege for accessing
5038e8b4e5bc3c93affdffbc064fd9db5aeccc3e8eSvetoslav Ganov * an event's source, thus the window content, has to be explicitly requested. For more
5138e8b4e5bc3c93affdffbc064fd9db5aeccc3e8eSvetoslav Ganov * details refer to {@link android.accessibilityservice.AccessibilityService}. If an
5238e8b4e5bc3c93affdffbc064fd9db5aeccc3e8eSvetoslav Ganov * accessibility service has not requested to retrieve the window content the event will
5338e8b4e5bc3c93affdffbc064fd9db5aeccc3e8eSvetoslav Ganov * not contain reference to its source. Also for events of type
5438e8b4e5bc3c93affdffbc064fd9db5aeccc3e8eSvetoslav Ganov * {@link #TYPE_NOTIFICATION_STATE_CHANGED} the source is never available.
5538e8b4e5bc3c93affdffbc064fd9db5aeccc3e8eSvetoslav Ganov * </p>
56736c2756bf3c14ae9fef7255c119057f7a2be1edSvetoslav Ganov * <p>
5775986cf9bc57ef11ad70f36fb77fbbf5d63af6ecsvetoslavganov * This class represents various semantically different accessibility event
5838e8b4e5bc3c93affdffbc064fd9db5aeccc3e8eSvetoslav Ganov * types. Each event type has an associated set of related properties. In other
5975986cf9bc57ef11ad70f36fb77fbbf5d63af6ecsvetoslavganov * words, each event type is characterized via a subset of the properties exposed
6075986cf9bc57ef11ad70f36fb77fbbf5d63af6ecsvetoslavganov * by this class. For each event type there is a corresponding constant defined
6138e8b4e5bc3c93affdffbc064fd9db5aeccc3e8eSvetoslav Ganov * in this class. Follows a specification of the event types and their associated properties:
6238e8b4e5bc3c93affdffbc064fd9db5aeccc3e8eSvetoslav Ganov * </p>
6375986cf9bc57ef11ad70f36fb77fbbf5d63af6ecsvetoslavganov * <p>
6438e8b4e5bc3c93affdffbc064fd9db5aeccc3e8eSvetoslav Ganov * <b>VIEW TYPES</b></br>
6538e8b4e5bc3c93affdffbc064fd9db5aeccc3e8eSvetoslav Ganov * </p>
6675986cf9bc57ef11ad70f36fb77fbbf5d63af6ecsvetoslavganov * <p>
6775986cf9bc57ef11ad70f36fb77fbbf5d63af6ecsvetoslavganov * <b>View clicked</b> - represents the event of clicking on a {@link android.view.View}
6838e8b4e5bc3c93affdffbc064fd9db5aeccc3e8eSvetoslav Ganov * like {@link android.widget.Button}, {@link android.widget.CompoundButton}, etc.</br>
6938e8b4e5bc3c93affdffbc064fd9db5aeccc3e8eSvetoslav Ganov * <em>Type:</em>{@link #TYPE_VIEW_CLICKED}</br>
7038e8b4e5bc3c93affdffbc064fd9db5aeccc3e8eSvetoslav Ganov * <em>Properties:</em></br>
71a0156177cdc809795dd8bc5a19943dd2b6f82b66Svetoslav Ganov * <ul>
7238e8b4e5bc3c93affdffbc064fd9db5aeccc3e8eSvetoslav Ganov *   <li>{@link #getSource()} - The source info (for registered clients).</li>
73a0156177cdc809795dd8bc5a19943dd2b6f82b66Svetoslav Ganov *   <li>{@link #getClassName()} - The class name of the source.</li>
74a0156177cdc809795dd8bc5a19943dd2b6f82b66Svetoslav Ganov *   <li>{@link #getPackageName()} - The package name of the source.</li>
75a0156177cdc809795dd8bc5a19943dd2b6f82b66Svetoslav Ganov *   <li>{@link #getEventTime()}  - The event time.</li>
76a0156177cdc809795dd8bc5a19943dd2b6f82b66Svetoslav Ganov *   <li>{@link #getText()} - The text of the source.</li>
77a0156177cdc809795dd8bc5a19943dd2b6f82b66Svetoslav Ganov *   <li>{@link #isEnabled()} - Whether the source is enabled.</li>
78a0156177cdc809795dd8bc5a19943dd2b6f82b66Svetoslav Ganov *   <li>{@link #isPassword()} - Whether the source is password.</li>
79a0156177cdc809795dd8bc5a19943dd2b6f82b66Svetoslav Ganov *   <li>{@link #isChecked()} - Whether the source is checked.</li>
80a0156177cdc809795dd8bc5a19943dd2b6f82b66Svetoslav Ganov * </ul>
8138e8b4e5bc3c93affdffbc064fd9db5aeccc3e8eSvetoslav Ganov * </p>
8275986cf9bc57ef11ad70f36fb77fbbf5d63af6ecsvetoslavganov * <p>
8375986cf9bc57ef11ad70f36fb77fbbf5d63af6ecsvetoslavganov * <b>View long clicked</b> - represents the event of long clicking on a {@link android.view.View}
8438e8b4e5bc3c93affdffbc064fd9db5aeccc3e8eSvetoslav Ganov * like {@link android.widget.Button}, {@link android.widget.CompoundButton}, etc </br>
8538e8b4e5bc3c93affdffbc064fd9db5aeccc3e8eSvetoslav Ganov * <em>Type:</em>{@link #TYPE_VIEW_LONG_CLICKED}</br>
8638e8b4e5bc3c93affdffbc064fd9db5aeccc3e8eSvetoslav Ganov * <em>Properties:</em></br>
87a0156177cdc809795dd8bc5a19943dd2b6f82b66Svetoslav Ganov * <ul>
8838e8b4e5bc3c93affdffbc064fd9db5aeccc3e8eSvetoslav Ganov *   <li>{@link #getSource()} - The source info (for registered clients).</li>
89a0156177cdc809795dd8bc5a19943dd2b6f82b66Svetoslav Ganov *   <li>{@link #getClassName()} - The class name of the source.</li>
90a0156177cdc809795dd8bc5a19943dd2b6f82b66Svetoslav Ganov *   <li>{@link #getPackageName()} - The package name of the source.</li>
91a0156177cdc809795dd8bc5a19943dd2b6f82b66Svetoslav Ganov *   <li>{@link #getEventTime()}  - The event time.</li>
92a0156177cdc809795dd8bc5a19943dd2b6f82b66Svetoslav Ganov *   <li>{@link #getText()} - The text of the source.</li>
93a0156177cdc809795dd8bc5a19943dd2b6f82b66Svetoslav Ganov *   <li>{@link #isEnabled()} - Whether the source is enabled.</li>
94a0156177cdc809795dd8bc5a19943dd2b6f82b66Svetoslav Ganov *   <li>{@link #isPassword()} - Whether the source is password.</li>
95a0156177cdc809795dd8bc5a19943dd2b6f82b66Svetoslav Ganov *   <li>{@link #isChecked()} - Whether the source is checked.</li>
96a0156177cdc809795dd8bc5a19943dd2b6f82b66Svetoslav Ganov * </ul>
9738e8b4e5bc3c93affdffbc064fd9db5aeccc3e8eSvetoslav Ganov * </p>
9875986cf9bc57ef11ad70f36fb77fbbf5d63af6ecsvetoslavganov * <p>
9975986cf9bc57ef11ad70f36fb77fbbf5d63af6ecsvetoslavganov * <b>View selected</b> - represents the event of selecting an item usually in
10038e8b4e5bc3c93affdffbc064fd9db5aeccc3e8eSvetoslav Ganov * the context of an {@link android.widget.AdapterView}.</br>
10138e8b4e5bc3c93affdffbc064fd9db5aeccc3e8eSvetoslav Ganov * <em>Type:</em> {@link #TYPE_VIEW_SELECTED}</br>
10238e8b4e5bc3c93affdffbc064fd9db5aeccc3e8eSvetoslav Ganov * <em>Properties:</em></br>
103a0156177cdc809795dd8bc5a19943dd2b6f82b66Svetoslav Ganov * <ul>
10438e8b4e5bc3c93affdffbc064fd9db5aeccc3e8eSvetoslav Ganov *   <li>{@link #getSource()} - The source info (for registered clients).</li>
105a0156177cdc809795dd8bc5a19943dd2b6f82b66Svetoslav Ganov *   <li>{@link #getClassName()} - The class name of the source.</li>
106a0156177cdc809795dd8bc5a19943dd2b6f82b66Svetoslav Ganov *   <li>{@link #getPackageName()} - The package name of the source.</li>
107a0156177cdc809795dd8bc5a19943dd2b6f82b66Svetoslav Ganov *   <li>{@link #getEventTime()}  - The event time.</li>
108a0156177cdc809795dd8bc5a19943dd2b6f82b66Svetoslav Ganov *   <li>{@link #getText()} - The text of the source.</li>
109a0156177cdc809795dd8bc5a19943dd2b6f82b66Svetoslav Ganov *   <li>{@link #isEnabled()} - Whether the source is enabled.</li>
110a0156177cdc809795dd8bc5a19943dd2b6f82b66Svetoslav Ganov *   <li>{@link #isPassword()} - Whether the source is password.</li>
111a0156177cdc809795dd8bc5a19943dd2b6f82b66Svetoslav Ganov *   <li>{@link #isChecked()} - Whether the source is checked.</li>
11238e8b4e5bc3c93affdffbc064fd9db5aeccc3e8eSvetoslav Ganov *   <li>{@link #getItemCount()} - The number of selectable items of the source.</li>
113a0156177cdc809795dd8bc5a19943dd2b6f82b66Svetoslav Ganov *   <li>{@link #getCurrentItemIndex()} - The currently selected item index.</li>
114a0156177cdc809795dd8bc5a19943dd2b6f82b66Svetoslav Ganov * </ul>
11538e8b4e5bc3c93affdffbc064fd9db5aeccc3e8eSvetoslav Ganov * </p>
11675986cf9bc57ef11ad70f36fb77fbbf5d63af6ecsvetoslavganov * <p>
11775986cf9bc57ef11ad70f36fb77fbbf5d63af6ecsvetoslavganov * <b>View focused</b> - represents the event of focusing a
11838e8b4e5bc3c93affdffbc064fd9db5aeccc3e8eSvetoslav Ganov * {@link android.view.View}.</br>
11938e8b4e5bc3c93affdffbc064fd9db5aeccc3e8eSvetoslav Ganov * <em>Type:</em> {@link #TYPE_VIEW_FOCUSED}</br>
12038e8b4e5bc3c93affdffbc064fd9db5aeccc3e8eSvetoslav Ganov * <em>Properties:</em></br>
121a0156177cdc809795dd8bc5a19943dd2b6f82b66Svetoslav Ganov * <ul>
12238e8b4e5bc3c93affdffbc064fd9db5aeccc3e8eSvetoslav Ganov *   <li>{@link #getSource()} - The source info (for registered clients).</li>
123a0156177cdc809795dd8bc5a19943dd2b6f82b66Svetoslav Ganov *   <li>{@link #getClassName()} - The class name of the source.</li>
124a0156177cdc809795dd8bc5a19943dd2b6f82b66Svetoslav Ganov *   <li>{@link #getPackageName()} - The package name of the source.</li>
125a0156177cdc809795dd8bc5a19943dd2b6f82b66Svetoslav Ganov *   <li>{@link #getEventTime()}  - The event time.</li>
126a0156177cdc809795dd8bc5a19943dd2b6f82b66Svetoslav Ganov *   <li>{@link #getText()} - The text of the source.</li>
127a0156177cdc809795dd8bc5a19943dd2b6f82b66Svetoslav Ganov *   <li>{@link #isEnabled()} - Whether the source is enabled.</li>
128a0156177cdc809795dd8bc5a19943dd2b6f82b66Svetoslav Ganov *   <li>{@link #isPassword()} - Whether the source is password.</li>
129a0156177cdc809795dd8bc5a19943dd2b6f82b66Svetoslav Ganov *   <li>{@link #isChecked()} - Whether the source is checked.</li>
13038e8b4e5bc3c93affdffbc064fd9db5aeccc3e8eSvetoslav Ganov *   <li>{@link #getItemCount()} - The number of focusable items on the screen.</li>
131a0156177cdc809795dd8bc5a19943dd2b6f82b66Svetoslav Ganov *   <li>{@link #getCurrentItemIndex()} - The currently focused item index.</li>
132a0156177cdc809795dd8bc5a19943dd2b6f82b66Svetoslav Ganov * </ul>
13338e8b4e5bc3c93affdffbc064fd9db5aeccc3e8eSvetoslav Ganov * </p>
13475986cf9bc57ef11ad70f36fb77fbbf5d63af6ecsvetoslavganov * <p>
13575986cf9bc57ef11ad70f36fb77fbbf5d63af6ecsvetoslavganov * <b>View text changed</b> - represents the event of changing the text of an
13638e8b4e5bc3c93affdffbc064fd9db5aeccc3e8eSvetoslav Ganov * {@link android.widget.EditText}.</br>
13738e8b4e5bc3c93affdffbc064fd9db5aeccc3e8eSvetoslav Ganov * <em>Type:</em> {@link #TYPE_VIEW_TEXT_CHANGED}</br>
13838e8b4e5bc3c93affdffbc064fd9db5aeccc3e8eSvetoslav Ganov * <em>Properties:</em></br>
139a0156177cdc809795dd8bc5a19943dd2b6f82b66Svetoslav Ganov * <ul>
14038e8b4e5bc3c93affdffbc064fd9db5aeccc3e8eSvetoslav Ganov *   <li>{@link #getSource()} - The source info (for registered clients).</li>
141a0156177cdc809795dd8bc5a19943dd2b6f82b66Svetoslav Ganov *   <li>{@link #getClassName()} - The class name of the source.</li>
142a0156177cdc809795dd8bc5a19943dd2b6f82b66Svetoslav Ganov *   <li>{@link #getPackageName()} - The package name of the source.</li>
143a0156177cdc809795dd8bc5a19943dd2b6f82b66Svetoslav Ganov *   <li>{@link #getEventTime()}  - The event time.</li>
144a0156177cdc809795dd8bc5a19943dd2b6f82b66Svetoslav Ganov *   <li>{@link #getText()} - The text of the source.</li>
145a0156177cdc809795dd8bc5a19943dd2b6f82b66Svetoslav Ganov *   <li>{@link #isEnabled()} - Whether the source is enabled.</li>
146a0156177cdc809795dd8bc5a19943dd2b6f82b66Svetoslav Ganov *   <li>{@link #isPassword()} - Whether the source is password.</li>
147a0156177cdc809795dd8bc5a19943dd2b6f82b66Svetoslav Ganov *   <li>{@link #isChecked()} - Whether the source is checked.</li>
148a0156177cdc809795dd8bc5a19943dd2b6f82b66Svetoslav Ganov *   <li>{@link #getFromIndex()} - The text change start index.</li>
149a0156177cdc809795dd8bc5a19943dd2b6f82b66Svetoslav Ganov *   <li>{@link #getAddedCount()} - The number of added characters.</li>
150a0156177cdc809795dd8bc5a19943dd2b6f82b66Svetoslav Ganov *   <li>{@link #getRemovedCount()} - The number of removed characters.</li>
151a0156177cdc809795dd8bc5a19943dd2b6f82b66Svetoslav Ganov *   <li>{@link #getBeforeText()} - The text of the source before the change.</li>
152a0156177cdc809795dd8bc5a19943dd2b6f82b66Svetoslav Ganov * </ul>
15338e8b4e5bc3c93affdffbc064fd9db5aeccc3e8eSvetoslav Ganov * </p>
154a0156177cdc809795dd8bc5a19943dd2b6f82b66Svetoslav Ganov * <p>
155a0156177cdc809795dd8bc5a19943dd2b6f82b66Svetoslav Ganov * <b>View text selection changed</b> - represents the event of changing the text
15638e8b4e5bc3c93affdffbc064fd9db5aeccc3e8eSvetoslav Ganov * selection of an {@link android.widget.EditText}.</br>
15738e8b4e5bc3c93affdffbc064fd9db5aeccc3e8eSvetoslav Ganov * <em>Type:</em> {@link #TYPE_VIEW_TEXT_SELECTION_CHANGED} </br>
15838e8b4e5bc3c93affdffbc064fd9db5aeccc3e8eSvetoslav Ganov * <em>Properties:</em></br>
159a0156177cdc809795dd8bc5a19943dd2b6f82b66Svetoslav Ganov * <ul>
16038e8b4e5bc3c93affdffbc064fd9db5aeccc3e8eSvetoslav Ganov *   <li>{@link #getSource()} - The source info (for registered clients).</li>
161a0156177cdc809795dd8bc5a19943dd2b6f82b66Svetoslav Ganov *   <li>{@link #getClassName()} - The class name of the source.</li>
162a0156177cdc809795dd8bc5a19943dd2b6f82b66Svetoslav Ganov *   <li>{@link #getPackageName()} - The package name of the source.</li>
163a0156177cdc809795dd8bc5a19943dd2b6f82b66Svetoslav Ganov *   <li>{@link #getEventTime()}  - The event time.</li>
164a0156177cdc809795dd8bc5a19943dd2b6f82b66Svetoslav Ganov *   <li>{@link #getText()} - The text of the source.</li>
165a0156177cdc809795dd8bc5a19943dd2b6f82b66Svetoslav Ganov *   <li>{@link #isEnabled()} - Whether the source is enabled.</li>
166a0156177cdc809795dd8bc5a19943dd2b6f82b66Svetoslav Ganov *   <li>{@link #isPassword()} - Whether the source is password.</li>
167a0156177cdc809795dd8bc5a19943dd2b6f82b66Svetoslav Ganov *   <li>{@link #getFromIndex()} - The selection start index.</li>
168a0156177cdc809795dd8bc5a19943dd2b6f82b66Svetoslav Ganov *   <li>{@link #getToIndex()} - The selection end index.</li>
169a0156177cdc809795dd8bc5a19943dd2b6f82b66Svetoslav Ganov *   <li>{@link #getItemCount()} - The length of the source text.</li>
17038e8b4e5bc3c93affdffbc064fd9db5aeccc3e8eSvetoslav Ganov * </ul>
17138e8b4e5bc3c93affdffbc064fd9db5aeccc3e8eSvetoslav Ganov * </p>
172a0156177cdc809795dd8bc5a19943dd2b6f82b66Svetoslav Ganov * <p>
173a0156177cdc809795dd8bc5a19943dd2b6f82b66Svetoslav Ganov * <b>View scrolled</b> - represents the event of scrolling a view. If
174a0156177cdc809795dd8bc5a19943dd2b6f82b66Svetoslav Ganov * the source is a descendant of {@link android.widget.AdapterView} the
175a0156177cdc809795dd8bc5a19943dd2b6f82b66Svetoslav Ganov * scroll is reported in terms of visible items - the first visible item,
176a0156177cdc809795dd8bc5a19943dd2b6f82b66Svetoslav Ganov * the last visible item, and the total items - because the the source
177a0156177cdc809795dd8bc5a19943dd2b6f82b66Svetoslav Ganov * is unaware if its pixel size since its adapter is responsible for
178a0156177cdc809795dd8bc5a19943dd2b6f82b66Svetoslav Ganov * creating views. In all other cases the scroll is reported as the current
179a0156177cdc809795dd8bc5a19943dd2b6f82b66Svetoslav Ganov * scroll on the X and Y axis respectively plus the height of the source in
18038e8b4e5bc3c93affdffbc064fd9db5aeccc3e8eSvetoslav Ganov * pixels.</br>
18138e8b4e5bc3c93affdffbc064fd9db5aeccc3e8eSvetoslav Ganov * <em>Type:</em> {@link #TYPE_VIEW_SCROLLED}</br>
18238e8b4e5bc3c93affdffbc064fd9db5aeccc3e8eSvetoslav Ganov * <em>Properties:</em></br>
183a0156177cdc809795dd8bc5a19943dd2b6f82b66Svetoslav Ganov * <ul>
18438e8b4e5bc3c93affdffbc064fd9db5aeccc3e8eSvetoslav Ganov *   <li>{@link #getSource()} - The source info (for registered clients).</li>
185a0156177cdc809795dd8bc5a19943dd2b6f82b66Svetoslav Ganov *   <li>{@link #getClassName()} - The class name of the source.</li>
186a0156177cdc809795dd8bc5a19943dd2b6f82b66Svetoslav Ganov *   <li>{@link #getPackageName()} - The package name of the source.</li>
187a0156177cdc809795dd8bc5a19943dd2b6f82b66Svetoslav Ganov *   <li>{@link #getEventTime()}  - The event time.</li>
188a0156177cdc809795dd8bc5a19943dd2b6f82b66Svetoslav Ganov *   <li>{@link #getText()} - The text of the source.</li>
189a0156177cdc809795dd8bc5a19943dd2b6f82b66Svetoslav Ganov *   <li>{@link #isEnabled()} - Whether the source is enabled.</li>
190a20cdc06e599c6fef784a0a479e8329f95e4bd09Svetoslav Ganov *   <li>{@link #getScrollX()} - The horizontal offset of the source
191a0156177cdc809795dd8bc5a19943dd2b6f82b66Svetoslav Ganov *                                (without descendants of AdapterView)).</li>
192a20cdc06e599c6fef784a0a479e8329f95e4bd09Svetoslav Ganov *   <li>{@link #getScrollY()} - The vertical offset of the source
193a0156177cdc809795dd8bc5a19943dd2b6f82b66Svetoslav Ganov *                                (without descendants of AdapterView)).</li>
194a0156177cdc809795dd8bc5a19943dd2b6f82b66Svetoslav Ganov *   <li>{@link #getFromIndex()} - The index of the first visible item of the source
195a0156177cdc809795dd8bc5a19943dd2b6f82b66Svetoslav Ganov *                                 (for descendants of AdapterView).</li>
196a0156177cdc809795dd8bc5a19943dd2b6f82b66Svetoslav Ganov *   <li>{@link #getToIndex()} - The index of the last visible item of the source
197a0156177cdc809795dd8bc5a19943dd2b6f82b66Svetoslav Ganov *                               (for descendants of AdapterView).</li>
198a0156177cdc809795dd8bc5a19943dd2b6f82b66Svetoslav Ganov *   <li>{@link #getItemCount()} - The total items of the source (for descendants of AdapterView)
199a0156177cdc809795dd8bc5a19943dd2b6f82b66Svetoslav Ganov *                                 or the height of the source in pixels (all other cases).</li>
20038e8b4e5bc3c93affdffbc064fd9db5aeccc3e8eSvetoslav Ganov * </ul>
20138e8b4e5bc3c93affdffbc064fd9db5aeccc3e8eSvetoslav Ganov * </p>
20275986cf9bc57ef11ad70f36fb77fbbf5d63af6ecsvetoslavganov * <p>
20338e8b4e5bc3c93affdffbc064fd9db5aeccc3e8eSvetoslav Ganov * <b>TRANSITION TYPES</b></br>
20438e8b4e5bc3c93affdffbc064fd9db5aeccc3e8eSvetoslav Ganov * </p>
205eeee4d2c01d3c4ed99e4891dbc75c7de69a803faSvetoslav Ganov * <b>Window state changed</b> - represents the event of opening a
20675986cf9bc57ef11ad70f36fb77fbbf5d63af6ecsvetoslavganov * {@link android.widget.PopupWindow}, {@link android.view.Menu},
20738e8b4e5bc3c93affdffbc064fd9db5aeccc3e8eSvetoslav Ganov * {@link android.app.Dialog}, etc.</br>
20838e8b4e5bc3c93affdffbc064fd9db5aeccc3e8eSvetoslav Ganov * <em>Type:</em> {@link #TYPE_WINDOW_STATE_CHANGED}</br>
20938e8b4e5bc3c93affdffbc064fd9db5aeccc3e8eSvetoslav Ganov * <em>Properties:</em></br>
210a0156177cdc809795dd8bc5a19943dd2b6f82b66Svetoslav Ganov * <ul>
21138e8b4e5bc3c93affdffbc064fd9db5aeccc3e8eSvetoslav Ganov *   <li>{@link #getSource()} - The source info (for registered clients).</li>
212a0156177cdc809795dd8bc5a19943dd2b6f82b66Svetoslav Ganov *   <li>{@link #getClassName()} - The class name of the source.</li>
213a0156177cdc809795dd8bc5a19943dd2b6f82b66Svetoslav Ganov *   <li>{@link #getPackageName()} - The package name of the source.</li>
214a0156177cdc809795dd8bc5a19943dd2b6f82b66Svetoslav Ganov *   <li>{@link #getEventTime()}  - The event time.</li>
215a0156177cdc809795dd8bc5a19943dd2b6f82b66Svetoslav Ganov *   <li>{@link #getText()} - The text of the source.</li>
216a0156177cdc809795dd8bc5a19943dd2b6f82b66Svetoslav Ganov * </ul>
21738e8b4e5bc3c93affdffbc064fd9db5aeccc3e8eSvetoslav Ganov * </p>
21875986cf9bc57ef11ad70f36fb77fbbf5d63af6ecsvetoslavganov * <p>
219eeee4d2c01d3c4ed99e4891dbc75c7de69a803faSvetoslav Ganov * <b>Window content changed</b> - represents the event of change in the
220eeee4d2c01d3c4ed99e4891dbc75c7de69a803faSvetoslav Ganov * content of a window. This change can be adding/removing view, changing
22138e8b4e5bc3c93affdffbc064fd9db5aeccc3e8eSvetoslav Ganov * a view size, etc.</br>
22238e8b4e5bc3c93affdffbc064fd9db5aeccc3e8eSvetoslav Ganov * <p>
22338e8b4e5bc3c93affdffbc064fd9db5aeccc3e8eSvetoslav Ganov * <strong>Note:</strong> This event is fired only for the window source of the
22438e8b4e5bc3c93affdffbc064fd9db5aeccc3e8eSvetoslav Ganov * last accessibility event different from {@link #TYPE_NOTIFICATION_STATE_CHANGED})
22538e8b4e5bc3c93affdffbc064fd9db5aeccc3e8eSvetoslav Ganov * and its purpose is to notify clients that the content of the user interaction
22638e8b4e5bc3c93affdffbc064fd9db5aeccc3e8eSvetoslav Ganov * window has changed.
22738e8b4e5bc3c93affdffbc064fd9db5aeccc3e8eSvetoslav Ganov * </p>
22838e8b4e5bc3c93affdffbc064fd9db5aeccc3e8eSvetoslav Ganov * <em>Type:</em> {@link #TYPE_WINDOW_CONTENT_CHANGED}</br>
22938e8b4e5bc3c93affdffbc064fd9db5aeccc3e8eSvetoslav Ganov * <em>Properties:</em></br>
230a0156177cdc809795dd8bc5a19943dd2b6f82b66Svetoslav Ganov * <ul>
23138e8b4e5bc3c93affdffbc064fd9db5aeccc3e8eSvetoslav Ganov *   <li>{@link #getSource()} - The source info (for registered clients).</li>
232a0156177cdc809795dd8bc5a19943dd2b6f82b66Svetoslav Ganov *   <li>{@link #getClassName()} - The class name of the source.</li>
233a0156177cdc809795dd8bc5a19943dd2b6f82b66Svetoslav Ganov *   <li>{@link #getPackageName()} - The package name of the source.</li>
234a0156177cdc809795dd8bc5a19943dd2b6f82b66Svetoslav Ganov *   <li>{@link #getEventTime()}  - The event time.</li>
23538e8b4e5bc3c93affdffbc064fd9db5aeccc3e8eSvetoslav Ganov * </ul>
236eeee4d2c01d3c4ed99e4891dbc75c7de69a803faSvetoslav Ganov * <p>
23738e8b4e5bc3c93affdffbc064fd9db5aeccc3e8eSvetoslav Ganov * <b>NOTIFICATION TYPES</b></br>
23875986cf9bc57ef11ad70f36fb77fbbf5d63af6ecsvetoslavganov * <p>
23938e8b4e5bc3c93affdffbc064fd9db5aeccc3e8eSvetoslav Ganov * <b>Notification state changed</b> - represents the event showing
24075986cf9bc57ef11ad70f36fb77fbbf5d63af6ecsvetoslavganov * {@link android.app.Notification}.
24138e8b4e5bc3c93affdffbc064fd9db5aeccc3e8eSvetoslav Ganov * <em>Type:</em> {@link #TYPE_NOTIFICATION_STATE_CHANGED}</br>
24238e8b4e5bc3c93affdffbc064fd9db5aeccc3e8eSvetoslav Ganov * <em>Properties:</em></br>
243a0156177cdc809795dd8bc5a19943dd2b6f82b66Svetoslav Ganov * <ul>
244a0156177cdc809795dd8bc5a19943dd2b6f82b66Svetoslav Ganov *   <li>{@link #getClassName()} - The class name of the source.</li>
245a0156177cdc809795dd8bc5a19943dd2b6f82b66Svetoslav Ganov *   <li>{@link #getPackageName()} - The package name of the source.</li>
246a0156177cdc809795dd8bc5a19943dd2b6f82b66Svetoslav Ganov *   <li>{@link #getEventTime()}  - The event time.</li>
247a0156177cdc809795dd8bc5a19943dd2b6f82b66Svetoslav Ganov *   <li>{@link #getText()} - The text of the source.</li>
248a0156177cdc809795dd8bc5a19943dd2b6f82b66Svetoslav Ganov *   <li>{@link #getParcelableData()} - The posted {@link android.app.Notification}.</li>
249a0156177cdc809795dd8bc5a19943dd2b6f82b66Svetoslav Ganov * </ul>
25038e8b4e5bc3c93affdffbc064fd9db5aeccc3e8eSvetoslav Ganov * </p>
25175986cf9bc57ef11ad70f36fb77fbbf5d63af6ecsvetoslavganov * <p>
25275986cf9bc57ef11ad70f36fb77fbbf5d63af6ecsvetoslavganov * <b>Security note</b>
25375986cf9bc57ef11ad70f36fb77fbbf5d63af6ecsvetoslavganov * <p>
25438e8b4e5bc3c93affdffbc064fd9db5aeccc3e8eSvetoslav Ganov * Since an event contains the text of its source privacy can be compromised by leaking
25575986cf9bc57ef11ad70f36fb77fbbf5d63af6ecsvetoslavganov * sensitive information such as passwords. To address this issue any event fired in response
25675986cf9bc57ef11ad70f36fb77fbbf5d63af6ecsvetoslavganov * to manipulation of a PASSWORD field does NOT CONTAIN the text of the password.
25775986cf9bc57ef11ad70f36fb77fbbf5d63af6ecsvetoslavganov *
25875986cf9bc57ef11ad70f36fb77fbbf5d63af6ecsvetoslavganov * @see android.view.accessibility.AccessibilityManager
25975986cf9bc57ef11ad70f36fb77fbbf5d63af6ecsvetoslavganov * @see android.accessibilityservice.AccessibilityService
26038e8b4e5bc3c93affdffbc064fd9db5aeccc3e8eSvetoslav Ganov * @see AccessibilityNodeInfo
26175986cf9bc57ef11ad70f36fb77fbbf5d63af6ecsvetoslavganov */
262736c2756bf3c14ae9fef7255c119057f7a2be1edSvetoslav Ganovpublic final class AccessibilityEvent extends AccessibilityRecord implements Parcelable {
2638643aa0179e598e78d938c59035389054535a229Svetoslav Ganov    private static final boolean DEBUG = false;
26475986cf9bc57ef11ad70f36fb77fbbf5d63af6ecsvetoslavganov
26575986cf9bc57ef11ad70f36fb77fbbf5d63af6ecsvetoslavganov    /**
26675986cf9bc57ef11ad70f36fb77fbbf5d63af6ecsvetoslavganov     * Invalid selection/focus position.
26775986cf9bc57ef11ad70f36fb77fbbf5d63af6ecsvetoslavganov     *
26875986cf9bc57ef11ad70f36fb77fbbf5d63af6ecsvetoslavganov     * @see #getCurrentItemIndex()
26975986cf9bc57ef11ad70f36fb77fbbf5d63af6ecsvetoslavganov     */
27075986cf9bc57ef11ad70f36fb77fbbf5d63af6ecsvetoslavganov    public static final int INVALID_POSITION = -1;
27175986cf9bc57ef11ad70f36fb77fbbf5d63af6ecsvetoslavganov
27275986cf9bc57ef11ad70f36fb77fbbf5d63af6ecsvetoslavganov    /**
27375986cf9bc57ef11ad70f36fb77fbbf5d63af6ecsvetoslavganov     * Maximum length of the text fields.
27475986cf9bc57ef11ad70f36fb77fbbf5d63af6ecsvetoslavganov     *
27575986cf9bc57ef11ad70f36fb77fbbf5d63af6ecsvetoslavganov     * @see #getBeforeText()
27675986cf9bc57ef11ad70f36fb77fbbf5d63af6ecsvetoslavganov     * @see #getText()
277c0a8cd10a5829bf4e94ee073ba6f553128e9d8e9Svetoslav Ganov     * </br>
278c0a8cd10a5829bf4e94ee073ba6f553128e9d8e9Svetoslav Ganov     * Note: This constant is no longer needed since there
279c0a8cd10a5829bf4e94ee073ba6f553128e9d8e9Svetoslav Ganov     *       is no limit on the length of text that is contained
280c0a8cd10a5829bf4e94ee073ba6f553128e9d8e9Svetoslav Ganov     *       in an accessibility event anymore.
28175986cf9bc57ef11ad70f36fb77fbbf5d63af6ecsvetoslavganov     */
282c0a8cd10a5829bf4e94ee073ba6f553128e9d8e9Svetoslav Ganov    @Deprecated
28375986cf9bc57ef11ad70f36fb77fbbf5d63af6ecsvetoslavganov    public static final int MAX_TEXT_LENGTH = 500;
28475986cf9bc57ef11ad70f36fb77fbbf5d63af6ecsvetoslavganov
28575986cf9bc57ef11ad70f36fb77fbbf5d63af6ecsvetoslavganov    /**
28675986cf9bc57ef11ad70f36fb77fbbf5d63af6ecsvetoslavganov     * Represents the event of clicking on a {@link android.view.View} like
28775986cf9bc57ef11ad70f36fb77fbbf5d63af6ecsvetoslavganov     * {@link android.widget.Button}, {@link android.widget.CompoundButton}, etc.
28875986cf9bc57ef11ad70f36fb77fbbf5d63af6ecsvetoslavganov     */
28975986cf9bc57ef11ad70f36fb77fbbf5d63af6ecsvetoslavganov    public static final int TYPE_VIEW_CLICKED = 0x00000001;
29075986cf9bc57ef11ad70f36fb77fbbf5d63af6ecsvetoslavganov
29175986cf9bc57ef11ad70f36fb77fbbf5d63af6ecsvetoslavganov    /**
29275986cf9bc57ef11ad70f36fb77fbbf5d63af6ecsvetoslavganov     * Represents the event of long clicking on a {@link android.view.View} like
29375986cf9bc57ef11ad70f36fb77fbbf5d63af6ecsvetoslavganov     * {@link android.widget.Button}, {@link android.widget.CompoundButton}, etc.
29475986cf9bc57ef11ad70f36fb77fbbf5d63af6ecsvetoslavganov     */
29575986cf9bc57ef11ad70f36fb77fbbf5d63af6ecsvetoslavganov    public static final int TYPE_VIEW_LONG_CLICKED = 0x00000002;
29675986cf9bc57ef11ad70f36fb77fbbf5d63af6ecsvetoslavganov
29775986cf9bc57ef11ad70f36fb77fbbf5d63af6ecsvetoslavganov    /**
29875986cf9bc57ef11ad70f36fb77fbbf5d63af6ecsvetoslavganov     * Represents the event of selecting an item usually in the context of an
29975986cf9bc57ef11ad70f36fb77fbbf5d63af6ecsvetoslavganov     * {@link android.widget.AdapterView}.
30075986cf9bc57ef11ad70f36fb77fbbf5d63af6ecsvetoslavganov     */
30175986cf9bc57ef11ad70f36fb77fbbf5d63af6ecsvetoslavganov    public static final int TYPE_VIEW_SELECTED = 0x00000004;
30275986cf9bc57ef11ad70f36fb77fbbf5d63af6ecsvetoslavganov
30375986cf9bc57ef11ad70f36fb77fbbf5d63af6ecsvetoslavganov    /**
30475986cf9bc57ef11ad70f36fb77fbbf5d63af6ecsvetoslavganov     * Represents the event of focusing a {@link android.view.View}.
30575986cf9bc57ef11ad70f36fb77fbbf5d63af6ecsvetoslavganov     */
30675986cf9bc57ef11ad70f36fb77fbbf5d63af6ecsvetoslavganov    public static final int TYPE_VIEW_FOCUSED = 0x00000008;
30775986cf9bc57ef11ad70f36fb77fbbf5d63af6ecsvetoslavganov
30875986cf9bc57ef11ad70f36fb77fbbf5d63af6ecsvetoslavganov    /**
30975986cf9bc57ef11ad70f36fb77fbbf5d63af6ecsvetoslavganov     * Represents the event of changing the text of an {@link android.widget.EditText}.
31075986cf9bc57ef11ad70f36fb77fbbf5d63af6ecsvetoslavganov     */
31175986cf9bc57ef11ad70f36fb77fbbf5d63af6ecsvetoslavganov    public static final int TYPE_VIEW_TEXT_CHANGED = 0x00000010;
31275986cf9bc57ef11ad70f36fb77fbbf5d63af6ecsvetoslavganov
31375986cf9bc57ef11ad70f36fb77fbbf5d63af6ecsvetoslavganov    /**
31438e8b4e5bc3c93affdffbc064fd9db5aeccc3e8eSvetoslav Ganov     * Represents the event of opening a {@link android.widget.PopupWindow},
31575986cf9bc57ef11ad70f36fb77fbbf5d63af6ecsvetoslavganov     * {@link android.view.Menu}, {@link android.app.Dialog}, etc.
31675986cf9bc57ef11ad70f36fb77fbbf5d63af6ecsvetoslavganov     */
31775986cf9bc57ef11ad70f36fb77fbbf5d63af6ecsvetoslavganov    public static final int TYPE_WINDOW_STATE_CHANGED = 0x00000020;
31875986cf9bc57ef11ad70f36fb77fbbf5d63af6ecsvetoslavganov
31975986cf9bc57ef11ad70f36fb77fbbf5d63af6ecsvetoslavganov    /**
32038e8b4e5bc3c93affdffbc064fd9db5aeccc3e8eSvetoslav Ganov     * Represents the event showing a {@link android.app.Notification}.
32175986cf9bc57ef11ad70f36fb77fbbf5d63af6ecsvetoslavganov     */
32275986cf9bc57ef11ad70f36fb77fbbf5d63af6ecsvetoslavganov    public static final int TYPE_NOTIFICATION_STATE_CHANGED = 0x00000040;
32375986cf9bc57ef11ad70f36fb77fbbf5d63af6ecsvetoslavganov
32475986cf9bc57ef11ad70f36fb77fbbf5d63af6ecsvetoslavganov    /**
325736c2756bf3c14ae9fef7255c119057f7a2be1edSvetoslav Ganov     * Represents the event of a hover enter over a {@link android.view.View}.
326736c2756bf3c14ae9fef7255c119057f7a2be1edSvetoslav Ganov     */
327736c2756bf3c14ae9fef7255c119057f7a2be1edSvetoslav Ganov    public static final int TYPE_VIEW_HOVER_ENTER = 0x00000080;
328736c2756bf3c14ae9fef7255c119057f7a2be1edSvetoslav Ganov
329736c2756bf3c14ae9fef7255c119057f7a2be1edSvetoslav Ganov    /**
330736c2756bf3c14ae9fef7255c119057f7a2be1edSvetoslav Ganov     * Represents the event of a hover exit over a {@link android.view.View}.
331736c2756bf3c14ae9fef7255c119057f7a2be1edSvetoslav Ganov     */
332736c2756bf3c14ae9fef7255c119057f7a2be1edSvetoslav Ganov    public static final int TYPE_VIEW_HOVER_EXIT = 0x00000100;
333736c2756bf3c14ae9fef7255c119057f7a2be1edSvetoslav Ganov
334736c2756bf3c14ae9fef7255c119057f7a2be1edSvetoslav Ganov    /**
335736c2756bf3c14ae9fef7255c119057f7a2be1edSvetoslav Ganov     * Represents the event of starting a touch exploration gesture.
336736c2756bf3c14ae9fef7255c119057f7a2be1edSvetoslav Ganov     */
337736c2756bf3c14ae9fef7255c119057f7a2be1edSvetoslav Ganov    public static final int TYPE_TOUCH_EXPLORATION_GESTURE_START = 0x00000200;
338736c2756bf3c14ae9fef7255c119057f7a2be1edSvetoslav Ganov
339736c2756bf3c14ae9fef7255c119057f7a2be1edSvetoslav Ganov    /**
340736c2756bf3c14ae9fef7255c119057f7a2be1edSvetoslav Ganov     * Represents the event of ending a touch exploration gesture.
341736c2756bf3c14ae9fef7255c119057f7a2be1edSvetoslav Ganov     */
342736c2756bf3c14ae9fef7255c119057f7a2be1edSvetoslav Ganov    public static final int TYPE_TOUCH_EXPLORATION_GESTURE_END = 0x00000400;
343736c2756bf3c14ae9fef7255c119057f7a2be1edSvetoslav Ganov
344736c2756bf3c14ae9fef7255c119057f7a2be1edSvetoslav Ganov    /**
345eeee4d2c01d3c4ed99e4891dbc75c7de69a803faSvetoslav Ganov     * Represents the event of changing the content of a window.
346eeee4d2c01d3c4ed99e4891dbc75c7de69a803faSvetoslav Ganov     */
347eeee4d2c01d3c4ed99e4891dbc75c7de69a803faSvetoslav Ganov    public static final int TYPE_WINDOW_CONTENT_CHANGED = 0x00000800;
348eeee4d2c01d3c4ed99e4891dbc75c7de69a803faSvetoslav Ganov
349eeee4d2c01d3c4ed99e4891dbc75c7de69a803faSvetoslav Ganov    /**
350a0156177cdc809795dd8bc5a19943dd2b6f82b66Svetoslav Ganov     * Represents the event of scrolling a view.
351a0156177cdc809795dd8bc5a19943dd2b6f82b66Svetoslav Ganov     */
352a0156177cdc809795dd8bc5a19943dd2b6f82b66Svetoslav Ganov    public static final int TYPE_VIEW_SCROLLED = 0x00001000;
353a0156177cdc809795dd8bc5a19943dd2b6f82b66Svetoslav Ganov
354a0156177cdc809795dd8bc5a19943dd2b6f82b66Svetoslav Ganov    /**
355a0156177cdc809795dd8bc5a19943dd2b6f82b66Svetoslav Ganov     * Represents the event of changing the selection in an {@link android.widget.EditText}.
356a0156177cdc809795dd8bc5a19943dd2b6f82b66Svetoslav Ganov     */
357a0156177cdc809795dd8bc5a19943dd2b6f82b66Svetoslav Ganov    public static final int TYPE_VIEW_TEXT_SELECTION_CHANGED = 0x00002000;
358a0156177cdc809795dd8bc5a19943dd2b6f82b66Svetoslav Ganov
359a0156177cdc809795dd8bc5a19943dd2b6f82b66Svetoslav Ganov    /**
36075986cf9bc57ef11ad70f36fb77fbbf5d63af6ecsvetoslavganov     * Mask for {@link AccessibilityEvent} all types.
36175986cf9bc57ef11ad70f36fb77fbbf5d63af6ecsvetoslavganov     *
36275986cf9bc57ef11ad70f36fb77fbbf5d63af6ecsvetoslavganov     * @see #TYPE_VIEW_CLICKED
36375986cf9bc57ef11ad70f36fb77fbbf5d63af6ecsvetoslavganov     * @see #TYPE_VIEW_LONG_CLICKED
36475986cf9bc57ef11ad70f36fb77fbbf5d63af6ecsvetoslavganov     * @see #TYPE_VIEW_SELECTED
36575986cf9bc57ef11ad70f36fb77fbbf5d63af6ecsvetoslavganov     * @see #TYPE_VIEW_FOCUSED
36675986cf9bc57ef11ad70f36fb77fbbf5d63af6ecsvetoslavganov     * @see #TYPE_VIEW_TEXT_CHANGED
36775986cf9bc57ef11ad70f36fb77fbbf5d63af6ecsvetoslavganov     * @see #TYPE_WINDOW_STATE_CHANGED
36875986cf9bc57ef11ad70f36fb77fbbf5d63af6ecsvetoslavganov     * @see #TYPE_NOTIFICATION_STATE_CHANGED
36938e8b4e5bc3c93affdffbc064fd9db5aeccc3e8eSvetoslav Ganov     * @see #TYPE_VIEW_HOVER_ENTER
37038e8b4e5bc3c93affdffbc064fd9db5aeccc3e8eSvetoslav Ganov     * @see #TYPE_VIEW_HOVER_EXIT
37138e8b4e5bc3c93affdffbc064fd9db5aeccc3e8eSvetoslav Ganov     * @see #TYPE_TOUCH_EXPLORATION_GESTURE_START
37238e8b4e5bc3c93affdffbc064fd9db5aeccc3e8eSvetoslav Ganov     * @see #TYPE_TOUCH_EXPLORATION_GESTURE_END
37338e8b4e5bc3c93affdffbc064fd9db5aeccc3e8eSvetoslav Ganov     * @see #TYPE_WINDOW_CONTENT_CHANGED
37438e8b4e5bc3c93affdffbc064fd9db5aeccc3e8eSvetoslav Ganov     * @see #TYPE_VIEW_SCROLLED
37538e8b4e5bc3c93affdffbc064fd9db5aeccc3e8eSvetoslav Ganov     * @see #TYPE_VIEW_TEXT_SELECTION_CHANGED
37675986cf9bc57ef11ad70f36fb77fbbf5d63af6ecsvetoslavganov     */
37775986cf9bc57ef11ad70f36fb77fbbf5d63af6ecsvetoslavganov    public static final int TYPES_ALL_MASK = 0xFFFFFFFF;
37875986cf9bc57ef11ad70f36fb77fbbf5d63af6ecsvetoslavganov
379736c2756bf3c14ae9fef7255c119057f7a2be1edSvetoslav Ganov    private static final int MAX_POOL_SIZE = 10;
380887e1a17eb9b12448f5929791b564565b2665aabSvetoslav Ganov    private static final Object sPoolLock = new Object();
38175986cf9bc57ef11ad70f36fb77fbbf5d63af6ecsvetoslavganov    private static AccessibilityEvent sPool;
38275986cf9bc57ef11ad70f36fb77fbbf5d63af6ecsvetoslavganov    private static int sPoolSize;
38375986cf9bc57ef11ad70f36fb77fbbf5d63af6ecsvetoslavganov    private AccessibilityEvent mNext;
384736c2756bf3c14ae9fef7255c119057f7a2be1edSvetoslav Ganov    private boolean mIsInPool;
38575986cf9bc57ef11ad70f36fb77fbbf5d63af6ecsvetoslavganov
38675986cf9bc57ef11ad70f36fb77fbbf5d63af6ecsvetoslavganov    private int mEventType;
3873fb3d7c4e756bd32d5abde0abca9ab52d559bc84Adam Powell    private CharSequence mPackageName;
388736c2756bf3c14ae9fef7255c119057f7a2be1edSvetoslav Ganov    private long mEventTime;
3893fb3d7c4e756bd32d5abde0abca9ab52d559bc84Adam Powell
390736c2756bf3c14ae9fef7255c119057f7a2be1edSvetoslav Ganov    private final ArrayList<AccessibilityRecord> mRecords = new ArrayList<AccessibilityRecord>();
39175986cf9bc57ef11ad70f36fb77fbbf5d63af6ecsvetoslavganov
39275986cf9bc57ef11ad70f36fb77fbbf5d63af6ecsvetoslavganov    /*
39375986cf9bc57ef11ad70f36fb77fbbf5d63af6ecsvetoslavganov     * Hide constructor from clients.
39475986cf9bc57ef11ad70f36fb77fbbf5d63af6ecsvetoslavganov     */
39575986cf9bc57ef11ad70f36fb77fbbf5d63af6ecsvetoslavganov    private AccessibilityEvent() {
3968643aa0179e598e78d938c59035389054535a229Svetoslav Ganov    }
39775986cf9bc57ef11ad70f36fb77fbbf5d63af6ecsvetoslavganov
3988643aa0179e598e78d938c59035389054535a229Svetoslav Ganov    /**
3998643aa0179e598e78d938c59035389054535a229Svetoslav Ganov     * Initialize an event from another one.
4008643aa0179e598e78d938c59035389054535a229Svetoslav Ganov     *
4018643aa0179e598e78d938c59035389054535a229Svetoslav Ganov     * @param event The event to initialize from.
4028643aa0179e598e78d938c59035389054535a229Svetoslav Ganov     */
4038643aa0179e598e78d938c59035389054535a229Svetoslav Ganov    void init(AccessibilityEvent event) {
4048643aa0179e598e78d938c59035389054535a229Svetoslav Ganov        super.init(event);
4058643aa0179e598e78d938c59035389054535a229Svetoslav Ganov        mEventType = event.mEventType;
4068643aa0179e598e78d938c59035389054535a229Svetoslav Ganov        mEventTime = event.mEventTime;
4078643aa0179e598e78d938c59035389054535a229Svetoslav Ganov        mPackageName = event.mPackageName;
408eeee4d2c01d3c4ed99e4891dbc75c7de69a803faSvetoslav Ganov    }
409eeee4d2c01d3c4ed99e4891dbc75c7de69a803faSvetoslav Ganov
410eeee4d2c01d3c4ed99e4891dbc75c7de69a803faSvetoslav Ganov    /**
411eeee4d2c01d3c4ed99e4891dbc75c7de69a803faSvetoslav Ganov     * Sets the connection for interacting with the AccessibilityManagerService.
412eeee4d2c01d3c4ed99e4891dbc75c7de69a803faSvetoslav Ganov     *
413eeee4d2c01d3c4ed99e4891dbc75c7de69a803faSvetoslav Ganov     * @param connection The connection.
414eeee4d2c01d3c4ed99e4891dbc75c7de69a803faSvetoslav Ganov     *
415eeee4d2c01d3c4ed99e4891dbc75c7de69a803faSvetoslav Ganov     * @hide
416eeee4d2c01d3c4ed99e4891dbc75c7de69a803faSvetoslav Ganov     */
417eeee4d2c01d3c4ed99e4891dbc75c7de69a803faSvetoslav Ganov    @Override
418eeee4d2c01d3c4ed99e4891dbc75c7de69a803faSvetoslav Ganov    public void setConnection(IAccessibilityServiceConnection connection) {
419eeee4d2c01d3c4ed99e4891dbc75c7de69a803faSvetoslav Ganov        super.setConnection(connection);
420eeee4d2c01d3c4ed99e4891dbc75c7de69a803faSvetoslav Ganov        List<AccessibilityRecord> records = mRecords;
421eeee4d2c01d3c4ed99e4891dbc75c7de69a803faSvetoslav Ganov        final int recordCount = records.size();
422eeee4d2c01d3c4ed99e4891dbc75c7de69a803faSvetoslav Ganov        for (int i = 0; i < recordCount; i++) {
423eeee4d2c01d3c4ed99e4891dbc75c7de69a803faSvetoslav Ganov            AccessibilityRecord record = records.get(i);
424eeee4d2c01d3c4ed99e4891dbc75c7de69a803faSvetoslav Ganov            record.setConnection(connection);
425eeee4d2c01d3c4ed99e4891dbc75c7de69a803faSvetoslav Ganov        }
426eeee4d2c01d3c4ed99e4891dbc75c7de69a803faSvetoslav Ganov    }
427eeee4d2c01d3c4ed99e4891dbc75c7de69a803faSvetoslav Ganov
428eeee4d2c01d3c4ed99e4891dbc75c7de69a803faSvetoslav Ganov    /**
429eeee4d2c01d3c4ed99e4891dbc75c7de69a803faSvetoslav Ganov     * Sets if this instance is sealed.
430eeee4d2c01d3c4ed99e4891dbc75c7de69a803faSvetoslav Ganov     *
431eeee4d2c01d3c4ed99e4891dbc75c7de69a803faSvetoslav Ganov     * @param sealed Whether is sealed.
432eeee4d2c01d3c4ed99e4891dbc75c7de69a803faSvetoslav Ganov     *
433eeee4d2c01d3c4ed99e4891dbc75c7de69a803faSvetoslav Ganov     * @hide
434eeee4d2c01d3c4ed99e4891dbc75c7de69a803faSvetoslav Ganov     */
435eeee4d2c01d3c4ed99e4891dbc75c7de69a803faSvetoslav Ganov    @Override
436eeee4d2c01d3c4ed99e4891dbc75c7de69a803faSvetoslav Ganov    public void setSealed(boolean sealed) {
437eeee4d2c01d3c4ed99e4891dbc75c7de69a803faSvetoslav Ganov        super.setSealed(sealed);
438eeee4d2c01d3c4ed99e4891dbc75c7de69a803faSvetoslav Ganov        List<AccessibilityRecord> records = mRecords;
439eeee4d2c01d3c4ed99e4891dbc75c7de69a803faSvetoslav Ganov        final int recordCount = records.size();
440eeee4d2c01d3c4ed99e4891dbc75c7de69a803faSvetoslav Ganov        for (int i = 0; i < recordCount; i++) {
441eeee4d2c01d3c4ed99e4891dbc75c7de69a803faSvetoslav Ganov            AccessibilityRecord record = records.get(i);
442eeee4d2c01d3c4ed99e4891dbc75c7de69a803faSvetoslav Ganov            record.setSealed(sealed);
443eeee4d2c01d3c4ed99e4891dbc75c7de69a803faSvetoslav Ganov        }
44475986cf9bc57ef11ad70f36fb77fbbf5d63af6ecsvetoslavganov    }
44575986cf9bc57ef11ad70f36fb77fbbf5d63af6ecsvetoslavganov
44675986cf9bc57ef11ad70f36fb77fbbf5d63af6ecsvetoslavganov    /**
447736c2756bf3c14ae9fef7255c119057f7a2be1edSvetoslav Ganov     * Gets the number of records contained in the event.
44875986cf9bc57ef11ad70f36fb77fbbf5d63af6ecsvetoslavganov     *
449736c2756bf3c14ae9fef7255c119057f7a2be1edSvetoslav Ganov     * @return The number of records.
45075986cf9bc57ef11ad70f36fb77fbbf5d63af6ecsvetoslavganov     */
451736c2756bf3c14ae9fef7255c119057f7a2be1edSvetoslav Ganov    public int getRecordCount() {
452736c2756bf3c14ae9fef7255c119057f7a2be1edSvetoslav Ganov        return mRecords.size();
45375986cf9bc57ef11ad70f36fb77fbbf5d63af6ecsvetoslavganov    }
45475986cf9bc57ef11ad70f36fb77fbbf5d63af6ecsvetoslavganov
45575986cf9bc57ef11ad70f36fb77fbbf5d63af6ecsvetoslavganov    /**
456736c2756bf3c14ae9fef7255c119057f7a2be1edSvetoslav Ganov     * Appends an {@link AccessibilityRecord} to the end of event records.
45775986cf9bc57ef11ad70f36fb77fbbf5d63af6ecsvetoslavganov     *
458736c2756bf3c14ae9fef7255c119057f7a2be1edSvetoslav Ganov     * @param record The record to append.
4598643aa0179e598e78d938c59035389054535a229Svetoslav Ganov     *
4608643aa0179e598e78d938c59035389054535a229Svetoslav Ganov     * @throws IllegalStateException If called from an AccessibilityService.
46175986cf9bc57ef11ad70f36fb77fbbf5d63af6ecsvetoslavganov     */
462736c2756bf3c14ae9fef7255c119057f7a2be1edSvetoslav Ganov    public void appendRecord(AccessibilityRecord record) {
4638643aa0179e598e78d938c59035389054535a229Svetoslav Ganov        enforceNotSealed();
464736c2756bf3c14ae9fef7255c119057f7a2be1edSvetoslav Ganov        mRecords.add(record);
46575986cf9bc57ef11ad70f36fb77fbbf5d63af6ecsvetoslavganov    }
46675986cf9bc57ef11ad70f36fb77fbbf5d63af6ecsvetoslavganov
46775986cf9bc57ef11ad70f36fb77fbbf5d63af6ecsvetoslavganov    /**
46838e8b4e5bc3c93affdffbc064fd9db5aeccc3e8eSvetoslav Ganov     * Gets the record at a given index.
46975986cf9bc57ef11ad70f36fb77fbbf5d63af6ecsvetoslavganov     *
470736c2756bf3c14ae9fef7255c119057f7a2be1edSvetoslav Ganov     * @param index The index.
47138e8b4e5bc3c93affdffbc064fd9db5aeccc3e8eSvetoslav Ganov     * @return The record at the specified index.
47275986cf9bc57ef11ad70f36fb77fbbf5d63af6ecsvetoslavganov     */
473736c2756bf3c14ae9fef7255c119057f7a2be1edSvetoslav Ganov    public AccessibilityRecord getRecord(int index) {
474736c2756bf3c14ae9fef7255c119057f7a2be1edSvetoslav Ganov        return mRecords.get(index);
47575986cf9bc57ef11ad70f36fb77fbbf5d63af6ecsvetoslavganov    }
47675986cf9bc57ef11ad70f36fb77fbbf5d63af6ecsvetoslavganov
47775986cf9bc57ef11ad70f36fb77fbbf5d63af6ecsvetoslavganov    /**
47875986cf9bc57ef11ad70f36fb77fbbf5d63af6ecsvetoslavganov     * Gets the event type.
47975986cf9bc57ef11ad70f36fb77fbbf5d63af6ecsvetoslavganov     *
48075986cf9bc57ef11ad70f36fb77fbbf5d63af6ecsvetoslavganov     * @return The event type.
48175986cf9bc57ef11ad70f36fb77fbbf5d63af6ecsvetoslavganov     */
48275986cf9bc57ef11ad70f36fb77fbbf5d63af6ecsvetoslavganov    public int getEventType() {
48375986cf9bc57ef11ad70f36fb77fbbf5d63af6ecsvetoslavganov        return mEventType;
48475986cf9bc57ef11ad70f36fb77fbbf5d63af6ecsvetoslavganov    }
48575986cf9bc57ef11ad70f36fb77fbbf5d63af6ecsvetoslavganov
48675986cf9bc57ef11ad70f36fb77fbbf5d63af6ecsvetoslavganov    /**
48775986cf9bc57ef11ad70f36fb77fbbf5d63af6ecsvetoslavganov     * Sets the event type.
48875986cf9bc57ef11ad70f36fb77fbbf5d63af6ecsvetoslavganov     *
48975986cf9bc57ef11ad70f36fb77fbbf5d63af6ecsvetoslavganov     * @param eventType The event type.
4908643aa0179e598e78d938c59035389054535a229Svetoslav Ganov     *
4918643aa0179e598e78d938c59035389054535a229Svetoslav Ganov     * @throws IllegalStateException If called from an AccessibilityService.
49275986cf9bc57ef11ad70f36fb77fbbf5d63af6ecsvetoslavganov     */
49375986cf9bc57ef11ad70f36fb77fbbf5d63af6ecsvetoslavganov    public void setEventType(int eventType) {
4948643aa0179e598e78d938c59035389054535a229Svetoslav Ganov        enforceNotSealed();
49575986cf9bc57ef11ad70f36fb77fbbf5d63af6ecsvetoslavganov        mEventType = eventType;
49675986cf9bc57ef11ad70f36fb77fbbf5d63af6ecsvetoslavganov    }
49775986cf9bc57ef11ad70f36fb77fbbf5d63af6ecsvetoslavganov
49875986cf9bc57ef11ad70f36fb77fbbf5d63af6ecsvetoslavganov    /**
49975986cf9bc57ef11ad70f36fb77fbbf5d63af6ecsvetoslavganov     * Gets the time in which this event was sent.
50075986cf9bc57ef11ad70f36fb77fbbf5d63af6ecsvetoslavganov     *
50175986cf9bc57ef11ad70f36fb77fbbf5d63af6ecsvetoslavganov     * @return The event time.
50275986cf9bc57ef11ad70f36fb77fbbf5d63af6ecsvetoslavganov     */
50375986cf9bc57ef11ad70f36fb77fbbf5d63af6ecsvetoslavganov    public long getEventTime() {
50475986cf9bc57ef11ad70f36fb77fbbf5d63af6ecsvetoslavganov        return mEventTime;
50575986cf9bc57ef11ad70f36fb77fbbf5d63af6ecsvetoslavganov    }
50675986cf9bc57ef11ad70f36fb77fbbf5d63af6ecsvetoslavganov
50775986cf9bc57ef11ad70f36fb77fbbf5d63af6ecsvetoslavganov    /**
50875986cf9bc57ef11ad70f36fb77fbbf5d63af6ecsvetoslavganov     * Sets the time in which this event was sent.
50975986cf9bc57ef11ad70f36fb77fbbf5d63af6ecsvetoslavganov     *
51075986cf9bc57ef11ad70f36fb77fbbf5d63af6ecsvetoslavganov     * @param eventTime The event time.
5118643aa0179e598e78d938c59035389054535a229Svetoslav Ganov     *
5128643aa0179e598e78d938c59035389054535a229Svetoslav Ganov     * @throws IllegalStateException If called from an AccessibilityService.
51375986cf9bc57ef11ad70f36fb77fbbf5d63af6ecsvetoslavganov     */
51475986cf9bc57ef11ad70f36fb77fbbf5d63af6ecsvetoslavganov    public void setEventTime(long eventTime) {
5158643aa0179e598e78d938c59035389054535a229Svetoslav Ganov        enforceNotSealed();
51675986cf9bc57ef11ad70f36fb77fbbf5d63af6ecsvetoslavganov        mEventTime = eventTime;
51775986cf9bc57ef11ad70f36fb77fbbf5d63af6ecsvetoslavganov    }
51875986cf9bc57ef11ad70f36fb77fbbf5d63af6ecsvetoslavganov
51975986cf9bc57ef11ad70f36fb77fbbf5d63af6ecsvetoslavganov    /**
52075986cf9bc57ef11ad70f36fb77fbbf5d63af6ecsvetoslavganov     * Gets the package name of the source.
52175986cf9bc57ef11ad70f36fb77fbbf5d63af6ecsvetoslavganov     *
52275986cf9bc57ef11ad70f36fb77fbbf5d63af6ecsvetoslavganov     * @return The package name.
52375986cf9bc57ef11ad70f36fb77fbbf5d63af6ecsvetoslavganov     */
52475986cf9bc57ef11ad70f36fb77fbbf5d63af6ecsvetoslavganov    public CharSequence getPackageName() {
52575986cf9bc57ef11ad70f36fb77fbbf5d63af6ecsvetoslavganov        return mPackageName;
52675986cf9bc57ef11ad70f36fb77fbbf5d63af6ecsvetoslavganov    }
52775986cf9bc57ef11ad70f36fb77fbbf5d63af6ecsvetoslavganov
52875986cf9bc57ef11ad70f36fb77fbbf5d63af6ecsvetoslavganov    /**
52975986cf9bc57ef11ad70f36fb77fbbf5d63af6ecsvetoslavganov     * Sets the package name of the source.
53075986cf9bc57ef11ad70f36fb77fbbf5d63af6ecsvetoslavganov     *
53175986cf9bc57ef11ad70f36fb77fbbf5d63af6ecsvetoslavganov     * @param packageName The package name.
5328643aa0179e598e78d938c59035389054535a229Svetoslav Ganov     *
5338643aa0179e598e78d938c59035389054535a229Svetoslav Ganov     * @throws IllegalStateException If called from an AccessibilityService.
53475986cf9bc57ef11ad70f36fb77fbbf5d63af6ecsvetoslavganov     */
53575986cf9bc57ef11ad70f36fb77fbbf5d63af6ecsvetoslavganov    public void setPackageName(CharSequence packageName) {
5368643aa0179e598e78d938c59035389054535a229Svetoslav Ganov        enforceNotSealed();
53775986cf9bc57ef11ad70f36fb77fbbf5d63af6ecsvetoslavganov        mPackageName = packageName;
53875986cf9bc57ef11ad70f36fb77fbbf5d63af6ecsvetoslavganov    }
53975986cf9bc57ef11ad70f36fb77fbbf5d63af6ecsvetoslavganov
54075986cf9bc57ef11ad70f36fb77fbbf5d63af6ecsvetoslavganov    /**
54175986cf9bc57ef11ad70f36fb77fbbf5d63af6ecsvetoslavganov     * Returns a cached instance if such is available or a new one is
54238e8b4e5bc3c93affdffbc064fd9db5aeccc3e8eSvetoslav Ganov     * instantiated with its type property set.
54375986cf9bc57ef11ad70f36fb77fbbf5d63af6ecsvetoslavganov     *
54475986cf9bc57ef11ad70f36fb77fbbf5d63af6ecsvetoslavganov     * @param eventType The event type.
54575986cf9bc57ef11ad70f36fb77fbbf5d63af6ecsvetoslavganov     * @return An instance.
54675986cf9bc57ef11ad70f36fb77fbbf5d63af6ecsvetoslavganov     */
54775986cf9bc57ef11ad70f36fb77fbbf5d63af6ecsvetoslavganov    public static AccessibilityEvent obtain(int eventType) {
54875986cf9bc57ef11ad70f36fb77fbbf5d63af6ecsvetoslavganov        AccessibilityEvent event = AccessibilityEvent.obtain();
54975986cf9bc57ef11ad70f36fb77fbbf5d63af6ecsvetoslavganov        event.setEventType(eventType);
55075986cf9bc57ef11ad70f36fb77fbbf5d63af6ecsvetoslavganov        return event;
55175986cf9bc57ef11ad70f36fb77fbbf5d63af6ecsvetoslavganov    }
55275986cf9bc57ef11ad70f36fb77fbbf5d63af6ecsvetoslavganov
55375986cf9bc57ef11ad70f36fb77fbbf5d63af6ecsvetoslavganov    /**
55475986cf9bc57ef11ad70f36fb77fbbf5d63af6ecsvetoslavganov     * Returns a cached instance if such is available or a new one is
55535bfedeaba724aeadc6f6c890269cb6bf7ef42f5Svetoslav Ganov     * created. The returned instance is initialized from the given
55635bfedeaba724aeadc6f6c890269cb6bf7ef42f5Svetoslav Ganov     * <code>event</code>.
5578643aa0179e598e78d938c59035389054535a229Svetoslav Ganov     *
5588643aa0179e598e78d938c59035389054535a229Svetoslav Ganov     * @param event The other event.
5598643aa0179e598e78d938c59035389054535a229Svetoslav Ganov     * @return An instance.
5608643aa0179e598e78d938c59035389054535a229Svetoslav Ganov     */
5618643aa0179e598e78d938c59035389054535a229Svetoslav Ganov    public static AccessibilityEvent obtain(AccessibilityEvent event) {
5628643aa0179e598e78d938c59035389054535a229Svetoslav Ganov        AccessibilityEvent eventClone = AccessibilityEvent.obtain();
5638643aa0179e598e78d938c59035389054535a229Svetoslav Ganov        eventClone.init(event);
5648643aa0179e598e78d938c59035389054535a229Svetoslav Ganov
5658643aa0179e598e78d938c59035389054535a229Svetoslav Ganov        final int recordCount = event.mRecords.size();
5668643aa0179e598e78d938c59035389054535a229Svetoslav Ganov        for (int i = 0; i < recordCount; i++) {
5678643aa0179e598e78d938c59035389054535a229Svetoslav Ganov            AccessibilityRecord record = event.mRecords.get(i);
5688643aa0179e598e78d938c59035389054535a229Svetoslav Ganov            AccessibilityRecord recordClone = AccessibilityRecord.obtain(record);
5698643aa0179e598e78d938c59035389054535a229Svetoslav Ganov            eventClone.mRecords.add(recordClone);
5708643aa0179e598e78d938c59035389054535a229Svetoslav Ganov        }
5718643aa0179e598e78d938c59035389054535a229Svetoslav Ganov
5728643aa0179e598e78d938c59035389054535a229Svetoslav Ganov        return eventClone;
5738643aa0179e598e78d938c59035389054535a229Svetoslav Ganov    }
5748643aa0179e598e78d938c59035389054535a229Svetoslav Ganov
5758643aa0179e598e78d938c59035389054535a229Svetoslav Ganov    /**
5768643aa0179e598e78d938c59035389054535a229Svetoslav Ganov     * Returns a cached instance if such is available or a new one is
57775986cf9bc57ef11ad70f36fb77fbbf5d63af6ecsvetoslavganov     * instantiated.
57875986cf9bc57ef11ad70f36fb77fbbf5d63af6ecsvetoslavganov     *
57975986cf9bc57ef11ad70f36fb77fbbf5d63af6ecsvetoslavganov     * @return An instance.
58075986cf9bc57ef11ad70f36fb77fbbf5d63af6ecsvetoslavganov     */
58175986cf9bc57ef11ad70f36fb77fbbf5d63af6ecsvetoslavganov    public static AccessibilityEvent obtain() {
582887e1a17eb9b12448f5929791b564565b2665aabSvetoslav Ganov        synchronized (sPoolLock) {
58375986cf9bc57ef11ad70f36fb77fbbf5d63af6ecsvetoslavganov            if (sPool != null) {
58475986cf9bc57ef11ad70f36fb77fbbf5d63af6ecsvetoslavganov                AccessibilityEvent event = sPool;
58575986cf9bc57ef11ad70f36fb77fbbf5d63af6ecsvetoslavganov                sPool = sPool.mNext;
58675986cf9bc57ef11ad70f36fb77fbbf5d63af6ecsvetoslavganov                sPoolSize--;
58775986cf9bc57ef11ad70f36fb77fbbf5d63af6ecsvetoslavganov                event.mNext = null;
58875986cf9bc57ef11ad70f36fb77fbbf5d63af6ecsvetoslavganov                event.mIsInPool = false;
58975986cf9bc57ef11ad70f36fb77fbbf5d63af6ecsvetoslavganov                return event;
59075986cf9bc57ef11ad70f36fb77fbbf5d63af6ecsvetoslavganov            }
59175986cf9bc57ef11ad70f36fb77fbbf5d63af6ecsvetoslavganov            return new AccessibilityEvent();
59275986cf9bc57ef11ad70f36fb77fbbf5d63af6ecsvetoslavganov        }
59375986cf9bc57ef11ad70f36fb77fbbf5d63af6ecsvetoslavganov    }
59475986cf9bc57ef11ad70f36fb77fbbf5d63af6ecsvetoslavganov
59575986cf9bc57ef11ad70f36fb77fbbf5d63af6ecsvetoslavganov    /**
59638e8b4e5bc3c93affdffbc064fd9db5aeccc3e8eSvetoslav Ganov     * Recycles an instance back to be reused.
59775986cf9bc57ef11ad70f36fb77fbbf5d63af6ecsvetoslavganov     * <p>
59838e8b4e5bc3c93affdffbc064fd9db5aeccc3e8eSvetoslav Ganov     *   <b>Note: You must not touch the object after calling this function.</b>
59938e8b4e5bc3c93affdffbc064fd9db5aeccc3e8eSvetoslav Ganov     * </p>
600887e1a17eb9b12448f5929791b564565b2665aabSvetoslav Ganov     *
601887e1a17eb9b12448f5929791b564565b2665aabSvetoslav Ganov     * @throws IllegalStateException If the event is already recycled.
60275986cf9bc57ef11ad70f36fb77fbbf5d63af6ecsvetoslavganov     */
603736c2756bf3c14ae9fef7255c119057f7a2be1edSvetoslav Ganov    @Override
60475986cf9bc57ef11ad70f36fb77fbbf5d63af6ecsvetoslavganov    public void recycle() {
60575986cf9bc57ef11ad70f36fb77fbbf5d63af6ecsvetoslavganov        if (mIsInPool) {
606887e1a17eb9b12448f5929791b564565b2665aabSvetoslav Ganov            throw new IllegalStateException("Event already recycled!");
60775986cf9bc57ef11ad70f36fb77fbbf5d63af6ecsvetoslavganov        }
60875986cf9bc57ef11ad70f36fb77fbbf5d63af6ecsvetoslavganov        clear();
609887e1a17eb9b12448f5929791b564565b2665aabSvetoslav Ganov        synchronized (sPoolLock) {
61075986cf9bc57ef11ad70f36fb77fbbf5d63af6ecsvetoslavganov            if (sPoolSize <= MAX_POOL_SIZE) {
61175986cf9bc57ef11ad70f36fb77fbbf5d63af6ecsvetoslavganov                mNext = sPool;
61275986cf9bc57ef11ad70f36fb77fbbf5d63af6ecsvetoslavganov                sPool = this;
61375986cf9bc57ef11ad70f36fb77fbbf5d63af6ecsvetoslavganov                mIsInPool = true;
61475986cf9bc57ef11ad70f36fb77fbbf5d63af6ecsvetoslavganov                sPoolSize++;
61575986cf9bc57ef11ad70f36fb77fbbf5d63af6ecsvetoslavganov            }
61675986cf9bc57ef11ad70f36fb77fbbf5d63af6ecsvetoslavganov        }
61775986cf9bc57ef11ad70f36fb77fbbf5d63af6ecsvetoslavganov    }
61875986cf9bc57ef11ad70f36fb77fbbf5d63af6ecsvetoslavganov
61975986cf9bc57ef11ad70f36fb77fbbf5d63af6ecsvetoslavganov    /**
62075986cf9bc57ef11ad70f36fb77fbbf5d63af6ecsvetoslavganov     * Clears the state of this instance.
6218643aa0179e598e78d938c59035389054535a229Svetoslav Ganov     *
6228643aa0179e598e78d938c59035389054535a229Svetoslav Ganov     * @hide
62375986cf9bc57ef11ad70f36fb77fbbf5d63af6ecsvetoslavganov     */
624736c2756bf3c14ae9fef7255c119057f7a2be1edSvetoslav Ganov    @Override
625736c2756bf3c14ae9fef7255c119057f7a2be1edSvetoslav Ganov    protected void clear() {
626736c2756bf3c14ae9fef7255c119057f7a2be1edSvetoslav Ganov        super.clear();
62775986cf9bc57ef11ad70f36fb77fbbf5d63af6ecsvetoslavganov        mEventType = 0;
6283fb3d7c4e756bd32d5abde0abca9ab52d559bc84Adam Powell        mPackageName = null;
629736c2756bf3c14ae9fef7255c119057f7a2be1edSvetoslav Ganov        mEventTime = 0;
630736c2756bf3c14ae9fef7255c119057f7a2be1edSvetoslav Ganov        while (!mRecords.isEmpty()) {
631736c2756bf3c14ae9fef7255c119057f7a2be1edSvetoslav Ganov            AccessibilityRecord record = mRecords.remove(0);
632736c2756bf3c14ae9fef7255c119057f7a2be1edSvetoslav Ganov            record.recycle();
6333fb3d7c4e756bd32d5abde0abca9ab52d559bc84Adam Powell        }
634ac84d3ba81f08036308b17e1ab919e43987a3df5Svetoslav Ganov    }
635ac84d3ba81f08036308b17e1ab919e43987a3df5Svetoslav Ganov
636ac84d3ba81f08036308b17e1ab919e43987a3df5Svetoslav Ganov    /**
6373fb3d7c4e756bd32d5abde0abca9ab52d559bc84Adam Powell     * Creates a new instance from a {@link Parcel}.
6383fb3d7c4e756bd32d5abde0abca9ab52d559bc84Adam Powell     *
6393fb3d7c4e756bd32d5abde0abca9ab52d559bc84Adam Powell     * @param parcel A parcel containing the state of a {@link AccessibilityEvent}.
640ac84d3ba81f08036308b17e1ab919e43987a3df5Svetoslav Ganov     */
6413fb3d7c4e756bd32d5abde0abca9ab52d559bc84Adam Powell    public void initFromParcel(Parcel parcel) {
6428643aa0179e598e78d938c59035389054535a229Svetoslav Ganov        if (parcel.readInt() == 1) {
6438643aa0179e598e78d938c59035389054535a229Svetoslav Ganov            mConnection = IAccessibilityServiceConnection.Stub.asInterface(
6448643aa0179e598e78d938c59035389054535a229Svetoslav Ganov                    parcel.readStrongBinder());
6458643aa0179e598e78d938c59035389054535a229Svetoslav Ganov        }
6468643aa0179e598e78d938c59035389054535a229Svetoslav Ganov        setSealed(parcel.readInt() == 1);
6473fb3d7c4e756bd32d5abde0abca9ab52d559bc84Adam Powell        mEventType = parcel.readInt();
6483fb3d7c4e756bd32d5abde0abca9ab52d559bc84Adam Powell        mPackageName = TextUtils.CHAR_SEQUENCE_CREATOR.createFromParcel(parcel);
649736c2756bf3c14ae9fef7255c119057f7a2be1edSvetoslav Ganov        mEventTime = parcel.readLong();
650736c2756bf3c14ae9fef7255c119057f7a2be1edSvetoslav Ganov        readAccessibilityRecordFromParcel(this, parcel);
651736c2756bf3c14ae9fef7255c119057f7a2be1edSvetoslav Ganov
652736c2756bf3c14ae9fef7255c119057f7a2be1edSvetoslav Ganov        // Read the records.
653736c2756bf3c14ae9fef7255c119057f7a2be1edSvetoslav Ganov        final int recordCount = parcel.readInt();
654736c2756bf3c14ae9fef7255c119057f7a2be1edSvetoslav Ganov        for (int i = 0; i < recordCount; i++) {
655736c2756bf3c14ae9fef7255c119057f7a2be1edSvetoslav Ganov            AccessibilityRecord record = AccessibilityRecord.obtain();
656eeee4d2c01d3c4ed99e4891dbc75c7de69a803faSvetoslav Ganov            // Do this to write the connection only once.
657eeee4d2c01d3c4ed99e4891dbc75c7de69a803faSvetoslav Ganov            record.setConnection(mConnection);
65834e350daf89aed09ac748c2185f4506772a63b3fSvetoslav Ganov            readAccessibilityRecordFromParcel(record, parcel);
659736c2756bf3c14ae9fef7255c119057f7a2be1edSvetoslav Ganov            mRecords.add(record);
660736c2756bf3c14ae9fef7255c119057f7a2be1edSvetoslav Ganov        }
6613fb3d7c4e756bd32d5abde0abca9ab52d559bc84Adam Powell    }
6623fb3d7c4e756bd32d5abde0abca9ab52d559bc84Adam Powell
663736c2756bf3c14ae9fef7255c119057f7a2be1edSvetoslav Ganov    /**
664736c2756bf3c14ae9fef7255c119057f7a2be1edSvetoslav Ganov     * Reads an {@link AccessibilityRecord} from a parcel.
665736c2756bf3c14ae9fef7255c119057f7a2be1edSvetoslav Ganov     *
666736c2756bf3c14ae9fef7255c119057f7a2be1edSvetoslav Ganov     * @param record The record to initialize.
667736c2756bf3c14ae9fef7255c119057f7a2be1edSvetoslav Ganov     * @param parcel The parcel to read from.
668736c2756bf3c14ae9fef7255c119057f7a2be1edSvetoslav Ganov     */
669736c2756bf3c14ae9fef7255c119057f7a2be1edSvetoslav Ganov    private void readAccessibilityRecordFromParcel(AccessibilityRecord record,
670736c2756bf3c14ae9fef7255c119057f7a2be1edSvetoslav Ganov            Parcel parcel) {
671736c2756bf3c14ae9fef7255c119057f7a2be1edSvetoslav Ganov        record.mBooleanProperties = parcel.readInt();
672736c2756bf3c14ae9fef7255c119057f7a2be1edSvetoslav Ganov        record.mCurrentItemIndex = parcel.readInt();
673736c2756bf3c14ae9fef7255c119057f7a2be1edSvetoslav Ganov        record.mItemCount = parcel.readInt();
674736c2756bf3c14ae9fef7255c119057f7a2be1edSvetoslav Ganov        record.mFromIndex = parcel.readInt();
675a0156177cdc809795dd8bc5a19943dd2b6f82b66Svetoslav Ganov        record.mToIndex = parcel.readInt();
676a0156177cdc809795dd8bc5a19943dd2b6f82b66Svetoslav Ganov        record.mScrollX = parcel.readInt();
677a0156177cdc809795dd8bc5a19943dd2b6f82b66Svetoslav Ganov        record.mScrollY =  parcel.readInt();
678736c2756bf3c14ae9fef7255c119057f7a2be1edSvetoslav Ganov        record.mAddedCount = parcel.readInt();
679736c2756bf3c14ae9fef7255c119057f7a2be1edSvetoslav Ganov        record.mRemovedCount = parcel.readInt();
680736c2756bf3c14ae9fef7255c119057f7a2be1edSvetoslav Ganov        record.mClassName = TextUtils.CHAR_SEQUENCE_CREATOR.createFromParcel(parcel);
681736c2756bf3c14ae9fef7255c119057f7a2be1edSvetoslav Ganov        record.mContentDescription = TextUtils.CHAR_SEQUENCE_CREATOR.createFromParcel(parcel);
682736c2756bf3c14ae9fef7255c119057f7a2be1edSvetoslav Ganov        record.mBeforeText = TextUtils.CHAR_SEQUENCE_CREATOR.createFromParcel(parcel);
683736c2756bf3c14ae9fef7255c119057f7a2be1edSvetoslav Ganov        record.mParcelableData = parcel.readParcelable(null);
684736c2756bf3c14ae9fef7255c119057f7a2be1edSvetoslav Ganov        parcel.readList(record.mText, null);
685eeee4d2c01d3c4ed99e4891dbc75c7de69a803faSvetoslav Ganov        record.mSourceWindowId = parcel.readInt();
686eeee4d2c01d3c4ed99e4891dbc75c7de69a803faSvetoslav Ganov        record.mSourceViewId = parcel.readInt();
687eeee4d2c01d3c4ed99e4891dbc75c7de69a803faSvetoslav Ganov        record.mSealed = (parcel.readInt() == 1);
688736c2756bf3c14ae9fef7255c119057f7a2be1edSvetoslav Ganov    }
689736c2756bf3c14ae9fef7255c119057f7a2be1edSvetoslav Ganov
690736c2756bf3c14ae9fef7255c119057f7a2be1edSvetoslav Ganov    /**
691736c2756bf3c14ae9fef7255c119057f7a2be1edSvetoslav Ganov     * {@inheritDoc}
692736c2756bf3c14ae9fef7255c119057f7a2be1edSvetoslav Ganov     */
69375986cf9bc57ef11ad70f36fb77fbbf5d63af6ecsvetoslavganov    public void writeToParcel(Parcel parcel, int flags) {
6948643aa0179e598e78d938c59035389054535a229Svetoslav Ganov        if (mConnection == null) {
6958643aa0179e598e78d938c59035389054535a229Svetoslav Ganov            parcel.writeInt(0);
6968643aa0179e598e78d938c59035389054535a229Svetoslav Ganov        } else {
6978643aa0179e598e78d938c59035389054535a229Svetoslav Ganov            parcel.writeInt(1);
6988643aa0179e598e78d938c59035389054535a229Svetoslav Ganov            parcel.writeStrongBinder(mConnection.asBinder());
6998643aa0179e598e78d938c59035389054535a229Svetoslav Ganov        }
7008643aa0179e598e78d938c59035389054535a229Svetoslav Ganov        parcel.writeInt(isSealed() ? 1 : 0);
70175986cf9bc57ef11ad70f36fb77fbbf5d63af6ecsvetoslavganov        parcel.writeInt(mEventType);
7023fb3d7c4e756bd32d5abde0abca9ab52d559bc84Adam Powell        TextUtils.writeToParcel(mPackageName, parcel, 0);
703736c2756bf3c14ae9fef7255c119057f7a2be1edSvetoslav Ganov        parcel.writeLong(mEventTime);
704736c2756bf3c14ae9fef7255c119057f7a2be1edSvetoslav Ganov        writeAccessibilityRecordToParcel(this, parcel, flags);
705736c2756bf3c14ae9fef7255c119057f7a2be1edSvetoslav Ganov
706736c2756bf3c14ae9fef7255c119057f7a2be1edSvetoslav Ganov        // Write the records.
707736c2756bf3c14ae9fef7255c119057f7a2be1edSvetoslav Ganov        final int recordCount = getRecordCount();
708736c2756bf3c14ae9fef7255c119057f7a2be1edSvetoslav Ganov        parcel.writeInt(recordCount);
709736c2756bf3c14ae9fef7255c119057f7a2be1edSvetoslav Ganov        for (int i = 0; i < recordCount; i++) {
710736c2756bf3c14ae9fef7255c119057f7a2be1edSvetoslav Ganov            AccessibilityRecord record = mRecords.get(i);
711736c2756bf3c14ae9fef7255c119057f7a2be1edSvetoslav Ganov            writeAccessibilityRecordToParcel(record, parcel, flags);
712736c2756bf3c14ae9fef7255c119057f7a2be1edSvetoslav Ganov        }
713736c2756bf3c14ae9fef7255c119057f7a2be1edSvetoslav Ganov    }
714736c2756bf3c14ae9fef7255c119057f7a2be1edSvetoslav Ganov
715736c2756bf3c14ae9fef7255c119057f7a2be1edSvetoslav Ganov    /**
716736c2756bf3c14ae9fef7255c119057f7a2be1edSvetoslav Ganov     * Writes an {@link AccessibilityRecord} to a parcel.
717736c2756bf3c14ae9fef7255c119057f7a2be1edSvetoslav Ganov     *
718736c2756bf3c14ae9fef7255c119057f7a2be1edSvetoslav Ganov     * @param record The record to write.
719736c2756bf3c14ae9fef7255c119057f7a2be1edSvetoslav Ganov     * @param parcel The parcel to which to write.
720736c2756bf3c14ae9fef7255c119057f7a2be1edSvetoslav Ganov     */
721736c2756bf3c14ae9fef7255c119057f7a2be1edSvetoslav Ganov    private void writeAccessibilityRecordToParcel(AccessibilityRecord record, Parcel parcel,
722736c2756bf3c14ae9fef7255c119057f7a2be1edSvetoslav Ganov            int flags) {
723736c2756bf3c14ae9fef7255c119057f7a2be1edSvetoslav Ganov        parcel.writeInt(record.mBooleanProperties);
724736c2756bf3c14ae9fef7255c119057f7a2be1edSvetoslav Ganov        parcel.writeInt(record.mCurrentItemIndex);
725736c2756bf3c14ae9fef7255c119057f7a2be1edSvetoslav Ganov        parcel.writeInt(record.mItemCount);
726736c2756bf3c14ae9fef7255c119057f7a2be1edSvetoslav Ganov        parcel.writeInt(record.mFromIndex);
727a0156177cdc809795dd8bc5a19943dd2b6f82b66Svetoslav Ganov        parcel.writeInt(record.mToIndex);
728a0156177cdc809795dd8bc5a19943dd2b6f82b66Svetoslav Ganov        parcel.writeInt(record.mScrollX);
729a0156177cdc809795dd8bc5a19943dd2b6f82b66Svetoslav Ganov        parcel.writeInt(record.mScrollY);
730736c2756bf3c14ae9fef7255c119057f7a2be1edSvetoslav Ganov        parcel.writeInt(record.mAddedCount);
731736c2756bf3c14ae9fef7255c119057f7a2be1edSvetoslav Ganov        parcel.writeInt(record.mRemovedCount);
732736c2756bf3c14ae9fef7255c119057f7a2be1edSvetoslav Ganov        TextUtils.writeToParcel(record.mClassName, parcel, flags);
733736c2756bf3c14ae9fef7255c119057f7a2be1edSvetoslav Ganov        TextUtils.writeToParcel(record.mContentDescription, parcel, flags);
734736c2756bf3c14ae9fef7255c119057f7a2be1edSvetoslav Ganov        TextUtils.writeToParcel(record.mBeforeText, parcel, flags);
735736c2756bf3c14ae9fef7255c119057f7a2be1edSvetoslav Ganov        parcel.writeParcelable(record.mParcelableData, flags);
736736c2756bf3c14ae9fef7255c119057f7a2be1edSvetoslav Ganov        parcel.writeList(record.mText);
737eeee4d2c01d3c4ed99e4891dbc75c7de69a803faSvetoslav Ganov        parcel.writeInt(record.mSourceWindowId);
738eeee4d2c01d3c4ed99e4891dbc75c7de69a803faSvetoslav Ganov        parcel.writeInt(record.mSourceViewId);
739eeee4d2c01d3c4ed99e4891dbc75c7de69a803faSvetoslav Ganov        parcel.writeInt(record.mSealed ? 1 : 0);
74075986cf9bc57ef11ad70f36fb77fbbf5d63af6ecsvetoslavganov    }
74175986cf9bc57ef11ad70f36fb77fbbf5d63af6ecsvetoslavganov
742736c2756bf3c14ae9fef7255c119057f7a2be1edSvetoslav Ganov    /**
743736c2756bf3c14ae9fef7255c119057f7a2be1edSvetoslav Ganov     * {@inheritDoc}
744736c2756bf3c14ae9fef7255c119057f7a2be1edSvetoslav Ganov     */
74575986cf9bc57ef11ad70f36fb77fbbf5d63af6ecsvetoslavganov    public int describeContents() {
74675986cf9bc57ef11ad70f36fb77fbbf5d63af6ecsvetoslavganov        return 0;
74775986cf9bc57ef11ad70f36fb77fbbf5d63af6ecsvetoslavganov    }
74875986cf9bc57ef11ad70f36fb77fbbf5d63af6ecsvetoslavganov
74975986cf9bc57ef11ad70f36fb77fbbf5d63af6ecsvetoslavganov    @Override
75075986cf9bc57ef11ad70f36fb77fbbf5d63af6ecsvetoslavganov    public String toString() {
75175986cf9bc57ef11ad70f36fb77fbbf5d63af6ecsvetoslavganov        StringBuilder builder = new StringBuilder();
75238e8b4e5bc3c93affdffbc064fd9db5aeccc3e8eSvetoslav Ganov        builder.append("EventType: ").append(eventTypeToString(mEventType));
753cc4053e031371456fe54d51bbad1db721db4ae38Svetoslav Ganov        builder.append("; EventTime: ").append(mEventTime);
754cc4053e031371456fe54d51bbad1db721db4ae38Svetoslav Ganov        builder.append("; PackageName: ").append(mPackageName);
755736c2756bf3c14ae9fef7255c119057f7a2be1edSvetoslav Ganov        builder.append(super.toString());
7568643aa0179e598e78d938c59035389054535a229Svetoslav Ganov        if (DEBUG) {
757736c2756bf3c14ae9fef7255c119057f7a2be1edSvetoslav Ganov            builder.append("\n");
758eeee4d2c01d3c4ed99e4891dbc75c7de69a803faSvetoslav Ganov            builder.append("; sourceWindowId: ").append(mSourceWindowId);
759eeee4d2c01d3c4ed99e4891dbc75c7de69a803faSvetoslav Ganov            builder.append("; sourceViewId: ").append(mSourceViewId);
7608643aa0179e598e78d938c59035389054535a229Svetoslav Ganov            for (int i = 0; i < mRecords.size(); i++) {
7618643aa0179e598e78d938c59035389054535a229Svetoslav Ganov                AccessibilityRecord record = mRecords.get(i);
7628643aa0179e598e78d938c59035389054535a229Svetoslav Ganov                builder.append("  Record ");
7638643aa0179e598e78d938c59035389054535a229Svetoslav Ganov                builder.append(i);
7648643aa0179e598e78d938c59035389054535a229Svetoslav Ganov                builder.append(":");
7658643aa0179e598e78d938c59035389054535a229Svetoslav Ganov                builder.append(" [ ClassName: " + record.mClassName);
7668643aa0179e598e78d938c59035389054535a229Svetoslav Ganov                builder.append("; Text: " + record.mText);
7678643aa0179e598e78d938c59035389054535a229Svetoslav Ganov                builder.append("; ContentDescription: " + record.mContentDescription);
7688643aa0179e598e78d938c59035389054535a229Svetoslav Ganov                builder.append("; ItemCount: " + record.mItemCount);
7698643aa0179e598e78d938c59035389054535a229Svetoslav Ganov                builder.append("; CurrentItemIndex: " + record.mCurrentItemIndex);
7708643aa0179e598e78d938c59035389054535a229Svetoslav Ganov                builder.append("; IsEnabled: " + record.isEnabled());
7718643aa0179e598e78d938c59035389054535a229Svetoslav Ganov                builder.append("; IsPassword: " + record.isPassword());
7728643aa0179e598e78d938c59035389054535a229Svetoslav Ganov                builder.append("; IsChecked: " + record.isChecked());
7738643aa0179e598e78d938c59035389054535a229Svetoslav Ganov                builder.append("; IsFullScreen: " + record.isFullScreen());
774a0156177cdc809795dd8bc5a19943dd2b6f82b66Svetoslav Ganov                builder.append("; Scrollable: " + record.isScrollable());
7758643aa0179e598e78d938c59035389054535a229Svetoslav Ganov                builder.append("; BeforeText: " + record.mBeforeText);
7768643aa0179e598e78d938c59035389054535a229Svetoslav Ganov                builder.append("; FromIndex: " + record.mFromIndex);
777a0156177cdc809795dd8bc5a19943dd2b6f82b66Svetoslav Ganov                builder.append("; ToIndex: " + record.mToIndex);
778a0156177cdc809795dd8bc5a19943dd2b6f82b66Svetoslav Ganov                builder.append("; ScrollX: " + record.mScrollX);
779a0156177cdc809795dd8bc5a19943dd2b6f82b66Svetoslav Ganov                builder.append("; ScrollY: " + record.mScrollY);
7808643aa0179e598e78d938c59035389054535a229Svetoslav Ganov                builder.append("; AddedCount: " + record.mAddedCount);
7818643aa0179e598e78d938c59035389054535a229Svetoslav Ganov                builder.append("; RemovedCount: " + record.mRemovedCount);
7828643aa0179e598e78d938c59035389054535a229Svetoslav Ganov                builder.append("; ParcelableData: " + record.mParcelableData);
7838643aa0179e598e78d938c59035389054535a229Svetoslav Ganov                builder.append(" ]");
7848643aa0179e598e78d938c59035389054535a229Svetoslav Ganov                builder.append("\n");
7858643aa0179e598e78d938c59035389054535a229Svetoslav Ganov            }
7868643aa0179e598e78d938c59035389054535a229Svetoslav Ganov        } else {
787e4aa13b20166219a62916a92294055e7cc5c9f10Svetoslav Ganov            builder.append("; recordCount: ").append(getRecordCount());
788736c2756bf3c14ae9fef7255c119057f7a2be1edSvetoslav Ganov        }
78975986cf9bc57ef11ad70f36fb77fbbf5d63af6ecsvetoslavganov        return builder.toString();
79075986cf9bc57ef11ad70f36fb77fbbf5d63af6ecsvetoslavganov    }
79175986cf9bc57ef11ad70f36fb77fbbf5d63af6ecsvetoslavganov
79275986cf9bc57ef11ad70f36fb77fbbf5d63af6ecsvetoslavganov    /**
793cc4053e031371456fe54d51bbad1db721db4ae38Svetoslav Ganov     * Returns the string representation of an event type. For example,
794cc4053e031371456fe54d51bbad1db721db4ae38Svetoslav Ganov     * {@link #TYPE_VIEW_CLICKED} is represented by the string TYPE_VIEW_CLICKED.
795cc4053e031371456fe54d51bbad1db721db4ae38Svetoslav Ganov     *
79638e8b4e5bc3c93affdffbc064fd9db5aeccc3e8eSvetoslav Ganov     * @param eventType The event type
797cc4053e031371456fe54d51bbad1db721db4ae38Svetoslav Ganov     * @return The string representation.
798cc4053e031371456fe54d51bbad1db721db4ae38Svetoslav Ganov     */
79938e8b4e5bc3c93affdffbc064fd9db5aeccc3e8eSvetoslav Ganov    public static String eventTypeToString(int eventType) {
80038e8b4e5bc3c93affdffbc064fd9db5aeccc3e8eSvetoslav Ganov        switch (eventType) {
801cc4053e031371456fe54d51bbad1db721db4ae38Svetoslav Ganov            case TYPE_VIEW_CLICKED:
802cc4053e031371456fe54d51bbad1db721db4ae38Svetoslav Ganov                return "TYPE_VIEW_CLICKED";
803cc4053e031371456fe54d51bbad1db721db4ae38Svetoslav Ganov            case TYPE_VIEW_LONG_CLICKED:
804cc4053e031371456fe54d51bbad1db721db4ae38Svetoslav Ganov                return "TYPE_VIEW_LONG_CLICKED";
805cc4053e031371456fe54d51bbad1db721db4ae38Svetoslav Ganov            case TYPE_VIEW_SELECTED:
806cc4053e031371456fe54d51bbad1db721db4ae38Svetoslav Ganov                return "TYPE_VIEW_SELECTED";
807cc4053e031371456fe54d51bbad1db721db4ae38Svetoslav Ganov            case TYPE_VIEW_FOCUSED:
808cc4053e031371456fe54d51bbad1db721db4ae38Svetoslav Ganov                return "TYPE_VIEW_FOCUSED";
809cc4053e031371456fe54d51bbad1db721db4ae38Svetoslav Ganov            case TYPE_VIEW_TEXT_CHANGED:
810cc4053e031371456fe54d51bbad1db721db4ae38Svetoslav Ganov                return "TYPE_VIEW_TEXT_CHANGED";
811cc4053e031371456fe54d51bbad1db721db4ae38Svetoslav Ganov            case TYPE_WINDOW_STATE_CHANGED:
812cc4053e031371456fe54d51bbad1db721db4ae38Svetoslav Ganov                return "TYPE_WINDOW_STATE_CHANGED";
813cc4053e031371456fe54d51bbad1db721db4ae38Svetoslav Ganov            case TYPE_VIEW_HOVER_ENTER:
814cc4053e031371456fe54d51bbad1db721db4ae38Svetoslav Ganov                return "TYPE_VIEW_HOVER_ENTER";
815cc4053e031371456fe54d51bbad1db721db4ae38Svetoslav Ganov            case TYPE_VIEW_HOVER_EXIT:
816cc4053e031371456fe54d51bbad1db721db4ae38Svetoslav Ganov                return "TYPE_VIEW_HOVER_EXIT";
817cc4053e031371456fe54d51bbad1db721db4ae38Svetoslav Ganov            case TYPE_NOTIFICATION_STATE_CHANGED:
818cc4053e031371456fe54d51bbad1db721db4ae38Svetoslav Ganov                return "TYPE_NOTIFICATION_STATE_CHANGED";
819cc4053e031371456fe54d51bbad1db721db4ae38Svetoslav Ganov            case TYPE_TOUCH_EXPLORATION_GESTURE_START:
820cc4053e031371456fe54d51bbad1db721db4ae38Svetoslav Ganov                return "TYPE_TOUCH_EXPLORATION_GESTURE_START";
821cc4053e031371456fe54d51bbad1db721db4ae38Svetoslav Ganov            case TYPE_TOUCH_EXPLORATION_GESTURE_END:
822cc4053e031371456fe54d51bbad1db721db4ae38Svetoslav Ganov                return "TYPE_TOUCH_EXPLORATION_GESTURE_END";
823eeee4d2c01d3c4ed99e4891dbc75c7de69a803faSvetoslav Ganov            case TYPE_WINDOW_CONTENT_CHANGED:
824eeee4d2c01d3c4ed99e4891dbc75c7de69a803faSvetoslav Ganov                return "TYPE_WINDOW_CONTENT_CHANGED";
825a0156177cdc809795dd8bc5a19943dd2b6f82b66Svetoslav Ganov            case TYPE_VIEW_TEXT_SELECTION_CHANGED:
826a0156177cdc809795dd8bc5a19943dd2b6f82b66Svetoslav Ganov                return "TYPE_VIEW_TEXT_SELECTION_CHANGED";
827a0156177cdc809795dd8bc5a19943dd2b6f82b66Svetoslav Ganov            case TYPE_VIEW_SCROLLED:
828a0156177cdc809795dd8bc5a19943dd2b6f82b66Svetoslav Ganov                return "TYPE_VIEW_SCROLLED";
829cc4053e031371456fe54d51bbad1db721db4ae38Svetoslav Ganov            default:
830cc4053e031371456fe54d51bbad1db721db4ae38Svetoslav Ganov                return null;
831cc4053e031371456fe54d51bbad1db721db4ae38Svetoslav Ganov        }
832cc4053e031371456fe54d51bbad1db721db4ae38Svetoslav Ganov    }
833cc4053e031371456fe54d51bbad1db721db4ae38Svetoslav Ganov
834cc4053e031371456fe54d51bbad1db721db4ae38Svetoslav Ganov    /**
83575986cf9bc57ef11ad70f36fb77fbbf5d63af6ecsvetoslavganov     * @see Parcelable.Creator
83675986cf9bc57ef11ad70f36fb77fbbf5d63af6ecsvetoslavganov     */
83775986cf9bc57ef11ad70f36fb77fbbf5d63af6ecsvetoslavganov    public static final Parcelable.Creator<AccessibilityEvent> CREATOR =
83875986cf9bc57ef11ad70f36fb77fbbf5d63af6ecsvetoslavganov            new Parcelable.Creator<AccessibilityEvent>() {
83975986cf9bc57ef11ad70f36fb77fbbf5d63af6ecsvetoslavganov        public AccessibilityEvent createFromParcel(Parcel parcel) {
84075986cf9bc57ef11ad70f36fb77fbbf5d63af6ecsvetoslavganov            AccessibilityEvent event = AccessibilityEvent.obtain();
84175986cf9bc57ef11ad70f36fb77fbbf5d63af6ecsvetoslavganov            event.initFromParcel(parcel);
84275986cf9bc57ef11ad70f36fb77fbbf5d63af6ecsvetoslavganov            return event;
84375986cf9bc57ef11ad70f36fb77fbbf5d63af6ecsvetoslavganov        }
84475986cf9bc57ef11ad70f36fb77fbbf5d63af6ecsvetoslavganov
84575986cf9bc57ef11ad70f36fb77fbbf5d63af6ecsvetoslavganov        public AccessibilityEvent[] newArray(int size) {
84675986cf9bc57ef11ad70f36fb77fbbf5d63af6ecsvetoslavganov            return new AccessibilityEvent[size];
84775986cf9bc57ef11ad70f36fb77fbbf5d63af6ecsvetoslavganov        }
84875986cf9bc57ef11ad70f36fb77fbbf5d63af6ecsvetoslavganov    };
84975986cf9bc57ef11ad70f36fb77fbbf5d63af6ecsvetoslavganov}
850