svetoslavganov | 75986cf | 2009-05-14 22:28:01 -0700 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) 2009 The Android Open Source Project |
| 3 | * |
| 4 | * Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | * you may not use this file except in compliance with the License. |
| 6 | * You may obtain a copy of the License at |
| 7 | * |
| 8 | * http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | * |
| 10 | * Unless required by applicable law or agreed to in writing, software |
| 11 | * distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | * See the License for the specific language governing permissions and |
| 14 | * limitations under the License. |
| 15 | */ |
| 16 | |
| 17 | package android.view.accessibility; |
| 18 | |
| 19 | import android.os.Parcel; |
| 20 | import android.os.Parcelable; |
| 21 | import android.text.TextUtils; |
Svetoslav Ganov | f4782ec | 2012-11-28 09:11:41 -0800 | [diff] [blame] | 22 | import android.util.Pools.SynchronizedPool; |
svetoslavganov | 75986cf | 2009-05-14 22:28:01 -0700 | [diff] [blame] | 23 | |
Eugene Susla | 4a34f9c | 2017-05-16 14:16:38 -0700 | [diff] [blame] | 24 | import com.android.internal.util.BitUtils; |
| 25 | |
svetoslavganov | 75986cf | 2009-05-14 22:28:01 -0700 | [diff] [blame] | 26 | import java.util.ArrayList; |
Svetoslav Ganov | eeee4d2 | 2011-06-10 20:51:30 -0700 | [diff] [blame] | 27 | import java.util.List; |
svetoslavganov | 75986cf | 2009-05-14 22:28:01 -0700 | [diff] [blame] | 28 | |
| 29 | /** |
Svetoslav Ganov | 38e8b4e | 2011-06-29 20:00:53 -0700 | [diff] [blame] | 30 | * <p> |
svetoslavganov | 75986cf | 2009-05-14 22:28:01 -0700 | [diff] [blame] | 31 | * This class represents accessibility events that are sent by the system when |
| 32 | * something notable happens in the user interface. For example, when a |
| 33 | * {@link android.widget.Button} is clicked, a {@link android.view.View} is focused, etc. |
Svetoslav Ganov | 38e8b4e | 2011-06-29 20:00:53 -0700 | [diff] [blame] | 34 | * </p> |
svetoslavganov | 75986cf | 2009-05-14 22:28:01 -0700 | [diff] [blame] | 35 | * <p> |
Svetoslav Ganov | 736c275 | 2011-04-22 18:30:36 -0700 | [diff] [blame] | 36 | * An accessibility event is fired by an individual view which populates the event with |
Svetoslav Ganov | 38e8b4e | 2011-06-29 20:00:53 -0700 | [diff] [blame] | 37 | * data for its state and requests from its parent to send the event to interested |
| 38 | * parties. The parent can optionally add an {@link AccessibilityRecord} for itself before |
| 39 | * dispatching a similar request to its parent. A parent can also choose not to respect the |
| 40 | * request for sending an event. The accessibility event is sent by the topmost view in the |
| 41 | * view tree. Therefore, an {@link android.accessibilityservice.AccessibilityService} can |
| 42 | * explore all records in an accessibility event to obtain more information about the |
| 43 | * context in which the event was fired. |
| 44 | * </p> |
Svetoslav Ganov | 736c275 | 2011-04-22 18:30:36 -0700 | [diff] [blame] | 45 | * <p> |
Svetoslav Ganov | 38e8b4e | 2011-06-29 20:00:53 -0700 | [diff] [blame] | 46 | * The main purpose of an accessibility event is to expose enough information for an |
| 47 | * {@link android.accessibilityservice.AccessibilityService} to provide meaningful feedback |
| 48 | * to the user. Sometimes however, an accessibility service may need more contextual |
| 49 | * information then the one in the event pay-load. In such cases the service can obtain |
| 50 | * the event source which is an {@link AccessibilityNodeInfo} (snapshot of a View state) |
| 51 | * which can be used for exploring the window content. Note that the privilege for accessing |
| 52 | * an event's source, thus the window content, has to be explicitly requested. For more |
| 53 | * details refer to {@link android.accessibilityservice.AccessibilityService}. If an |
| 54 | * accessibility service has not requested to retrieve the window content the event will |
| 55 | * not contain reference to its source. Also for events of type |
| 56 | * {@link #TYPE_NOTIFICATION_STATE_CHANGED} the source is never available. |
| 57 | * </p> |
Svetoslav Ganov | 736c275 | 2011-04-22 18:30:36 -0700 | [diff] [blame] | 58 | * <p> |
svetoslavganov | 75986cf | 2009-05-14 22:28:01 -0700 | [diff] [blame] | 59 | * This class represents various semantically different accessibility event |
Svetoslav Ganov | 38e8b4e | 2011-06-29 20:00:53 -0700 | [diff] [blame] | 60 | * types. Each event type has an associated set of related properties. In other |
svetoslavganov | 75986cf | 2009-05-14 22:28:01 -0700 | [diff] [blame] | 61 | * words, each event type is characterized via a subset of the properties exposed |
| 62 | * by this class. For each event type there is a corresponding constant defined |
Svetoslav Ganov | 38e8b4e | 2011-06-29 20:00:53 -0700 | [diff] [blame] | 63 | * in this class. Follows a specification of the event types and their associated properties: |
| 64 | * </p> |
Joe Fernandez | e1302ed | 2012-02-06 14:30:15 -0800 | [diff] [blame] | 65 | * <div class="special reference"> |
| 66 | * <h3>Developer Guides</h3> |
| 67 | * <p>For more information about creating and processing AccessibilityEvents, read the |
| 68 | * <a href="{@docRoot}guide/topics/ui/accessibility/index.html">Accessibility</a> |
| 69 | * developer guide.</p> |
| 70 | * </div> |
svetoslavganov | 75986cf | 2009-05-14 22:28:01 -0700 | [diff] [blame] | 71 | * <p> |
Svetoslav Ganov | 38e8b4e | 2011-06-29 20:00:53 -0700 | [diff] [blame] | 72 | * <b>VIEW TYPES</b></br> |
| 73 | * </p> |
svetoslavganov | 75986cf | 2009-05-14 22:28:01 -0700 | [diff] [blame] | 74 | * <p> |
| 75 | * <b>View clicked</b> - represents the event of clicking on a {@link android.view.View} |
Svetoslav Ganov | 38e8b4e | 2011-06-29 20:00:53 -0700 | [diff] [blame] | 76 | * like {@link android.widget.Button}, {@link android.widget.CompoundButton}, etc.</br> |
| 77 | * <em>Type:</em>{@link #TYPE_VIEW_CLICKED}</br> |
| 78 | * <em>Properties:</em></br> |
Svetoslav Ganov | a015617 | 2011-06-26 17:55:44 -0700 | [diff] [blame] | 79 | * <ul> |
Svetoslav Ganov | 82e236d | 2011-09-29 19:31:06 -0700 | [diff] [blame] | 80 | * <li>{@link #getEventType()} - The type of the event.</li> |
Svetoslav Ganov | 38e8b4e | 2011-06-29 20:00:53 -0700 | [diff] [blame] | 81 | * <li>{@link #getSource()} - The source info (for registered clients).</li> |
Svetoslav Ganov | a015617 | 2011-06-26 17:55:44 -0700 | [diff] [blame] | 82 | * <li>{@link #getClassName()} - The class name of the source.</li> |
| 83 | * <li>{@link #getPackageName()} - The package name of the source.</li> |
| 84 | * <li>{@link #getEventTime()} - The event time.</li> |
Svetoslav Ganov | 82e236d | 2011-09-29 19:31:06 -0700 | [diff] [blame] | 85 | * <li>{@link #getText()} - The text of the source's sub-tree.</li> |
Svetoslav Ganov | a015617 | 2011-06-26 17:55:44 -0700 | [diff] [blame] | 86 | * <li>{@link #isEnabled()} - Whether the source is enabled.</li> |
| 87 | * <li>{@link #isPassword()} - Whether the source is password.</li> |
| 88 | * <li>{@link #isChecked()} - Whether the source is checked.</li> |
Svetoslav Ganov | 82e236d | 2011-09-29 19:31:06 -0700 | [diff] [blame] | 89 | * <li>{@link #getContentDescription()} - The content description of the source.</li> |
Svetoslav Ganov | d9ee72f | 2011-10-05 22:26:05 -0700 | [diff] [blame] | 90 | * <li>{@link #getScrollX()} - The offset of the source left edge in pixels |
| 91 | * (without descendants of AdapterView).</li> |
| 92 | * <li>{@link #getScrollY()} - The offset of the source top edge in pixels |
| 93 | * (without descendants of AdapterView).</li> |
| 94 | * <li>{@link #getFromIndex()} - The zero based index of the first visible item of the source, |
| 95 | * inclusive (for descendants of AdapterView).</li> |
| 96 | * <li>{@link #getToIndex()} - The zero based index of the last visible item of the source, |
| 97 | * inclusive (for descendants of AdapterView).</li> |
| 98 | * <li>{@link #getItemCount()} - The total items of the source |
| 99 | * (for descendants of AdapterView).</li> |
Svetoslav Ganov | a015617 | 2011-06-26 17:55:44 -0700 | [diff] [blame] | 100 | * </ul> |
Svetoslav Ganov | 38e8b4e | 2011-06-29 20:00:53 -0700 | [diff] [blame] | 101 | * </p> |
svetoslavganov | 75986cf | 2009-05-14 22:28:01 -0700 | [diff] [blame] | 102 | * <p> |
| 103 | * <b>View long clicked</b> - represents the event of long clicking on a {@link android.view.View} |
Svetoslav Ganov | 38e8b4e | 2011-06-29 20:00:53 -0700 | [diff] [blame] | 104 | * like {@link android.widget.Button}, {@link android.widget.CompoundButton}, etc </br> |
| 105 | * <em>Type:</em>{@link #TYPE_VIEW_LONG_CLICKED}</br> |
| 106 | * <em>Properties:</em></br> |
Svetoslav Ganov | a015617 | 2011-06-26 17:55:44 -0700 | [diff] [blame] | 107 | * <ul> |
Svetoslav Ganov | 82e236d | 2011-09-29 19:31:06 -0700 | [diff] [blame] | 108 | * <li>{@link #getEventType()} - The type of the event.</li> |
Svetoslav Ganov | 38e8b4e | 2011-06-29 20:00:53 -0700 | [diff] [blame] | 109 | * <li>{@link #getSource()} - The source info (for registered clients).</li> |
Svetoslav Ganov | a015617 | 2011-06-26 17:55:44 -0700 | [diff] [blame] | 110 | * <li>{@link #getClassName()} - The class name of the source.</li> |
| 111 | * <li>{@link #getPackageName()} - The package name of the source.</li> |
| 112 | * <li>{@link #getEventTime()} - The event time.</li> |
Svetoslav Ganov | 82e236d | 2011-09-29 19:31:06 -0700 | [diff] [blame] | 113 | * <li>{@link #getText()} - The text of the source's sub-tree.</li> |
Svetoslav Ganov | a015617 | 2011-06-26 17:55:44 -0700 | [diff] [blame] | 114 | * <li>{@link #isEnabled()} - Whether the source is enabled.</li> |
| 115 | * <li>{@link #isPassword()} - Whether the source is password.</li> |
| 116 | * <li>{@link #isChecked()} - Whether the source is checked.</li> |
Svetoslav Ganov | 82e236d | 2011-09-29 19:31:06 -0700 | [diff] [blame] | 117 | * <li>{@link #getContentDescription()} - The content description of the source.</li> |
Svetoslav Ganov | d9ee72f | 2011-10-05 22:26:05 -0700 | [diff] [blame] | 118 | * <li>{@link #getScrollX()} - The offset of the source left edge in pixels |
| 119 | * (without descendants of AdapterView).</li> |
| 120 | * <li>{@link #getScrollY()} - The offset of the source top edge in pixels |
| 121 | * (without descendants of AdapterView).</li> |
| 122 | * <li>{@link #getFromIndex()} - The zero based index of the first visible item of the source, |
| 123 | * inclusive (for descendants of AdapterView).</li> |
| 124 | * <li>{@link #getToIndex()} - The zero based index of the last visible item of the source, |
| 125 | * inclusive (for descendants of AdapterView).</li> |
| 126 | * <li>{@link #getItemCount()} - The total items of the source |
| 127 | * (for descendants of AdapterView).</li> |
Svetoslav Ganov | a015617 | 2011-06-26 17:55:44 -0700 | [diff] [blame] | 128 | * </ul> |
Svetoslav Ganov | 38e8b4e | 2011-06-29 20:00:53 -0700 | [diff] [blame] | 129 | * </p> |
svetoslavganov | 75986cf | 2009-05-14 22:28:01 -0700 | [diff] [blame] | 130 | * <p> |
| 131 | * <b>View selected</b> - represents the event of selecting an item usually in |
Svetoslav Ganov | 38e8b4e | 2011-06-29 20:00:53 -0700 | [diff] [blame] | 132 | * the context of an {@link android.widget.AdapterView}.</br> |
| 133 | * <em>Type:</em> {@link #TYPE_VIEW_SELECTED}</br> |
| 134 | * <em>Properties:</em></br> |
Svetoslav Ganov | a015617 | 2011-06-26 17:55:44 -0700 | [diff] [blame] | 135 | * <ul> |
Svetoslav Ganov | 82e236d | 2011-09-29 19:31:06 -0700 | [diff] [blame] | 136 | * <li>{@link #getEventType()} - The type of the event.</li> |
Svetoslav Ganov | 38e8b4e | 2011-06-29 20:00:53 -0700 | [diff] [blame] | 137 | * <li>{@link #getSource()} - The source info (for registered clients).</li> |
Svetoslav Ganov | a015617 | 2011-06-26 17:55:44 -0700 | [diff] [blame] | 138 | * <li>{@link #getClassName()} - The class name of the source.</li> |
| 139 | * <li>{@link #getPackageName()} - The package name of the source.</li> |
| 140 | * <li>{@link #getEventTime()} - The event time.</li> |
Svetoslav Ganov | 82e236d | 2011-09-29 19:31:06 -0700 | [diff] [blame] | 141 | * <li>{@link #getText()} - The text of the source's sub-tree.</li> |
Svetoslav Ganov | a015617 | 2011-06-26 17:55:44 -0700 | [diff] [blame] | 142 | * <li>{@link #isEnabled()} - Whether the source is enabled.</li> |
| 143 | * <li>{@link #isPassword()} - Whether the source is password.</li> |
| 144 | * <li>{@link #isChecked()} - Whether the source is checked.</li> |
Svetoslav Ganov | 38e8b4e | 2011-06-29 20:00:53 -0700 | [diff] [blame] | 145 | * <li>{@link #getItemCount()} - The number of selectable items of the source.</li> |
Svetoslav Ganov | a015617 | 2011-06-26 17:55:44 -0700 | [diff] [blame] | 146 | * <li>{@link #getCurrentItemIndex()} - The currently selected item index.</li> |
Svetoslav Ganov | 82e236d | 2011-09-29 19:31:06 -0700 | [diff] [blame] | 147 | * <li>{@link #getContentDescription()} - The content description of the source.</li> |
Svetoslav Ganov | d9ee72f | 2011-10-05 22:26:05 -0700 | [diff] [blame] | 148 | * <li>{@link #getScrollX()} - The offset of the source left edge in pixels |
| 149 | * (without descendants of AdapterView).</li> |
| 150 | * <li>{@link #getScrollY()} - The offset of the source top edge in pixels |
| 151 | * (without descendants of AdapterView).</li> |
| 152 | * <li>{@link #getFromIndex()} - The zero based index of the first visible item of the source, |
| 153 | * inclusive (for descendants of AdapterView).</li> |
| 154 | * <li>{@link #getToIndex()} - The zero based index of the last visible item of the source, |
| 155 | * inclusive (for descendants of AdapterView).</li> |
| 156 | * <li>{@link #getItemCount()} - The total items of the source |
| 157 | * (for descendants of AdapterView).</li> |
Svetoslav Ganov | a015617 | 2011-06-26 17:55:44 -0700 | [diff] [blame] | 158 | * </ul> |
Svetoslav Ganov | 38e8b4e | 2011-06-29 20:00:53 -0700 | [diff] [blame] | 159 | * </p> |
svetoslavganov | 75986cf | 2009-05-14 22:28:01 -0700 | [diff] [blame] | 160 | * <p> |
| 161 | * <b>View focused</b> - represents the event of focusing a |
Svetoslav Ganov | 38e8b4e | 2011-06-29 20:00:53 -0700 | [diff] [blame] | 162 | * {@link android.view.View}.</br> |
| 163 | * <em>Type:</em> {@link #TYPE_VIEW_FOCUSED}</br> |
| 164 | * <em>Properties:</em></br> |
Svetoslav Ganov | a015617 | 2011-06-26 17:55:44 -0700 | [diff] [blame] | 165 | * <ul> |
Svetoslav Ganov | 82e236d | 2011-09-29 19:31:06 -0700 | [diff] [blame] | 166 | * <li>{@link #getEventType()} - The type of the event.</li> |
Svetoslav Ganov | 38e8b4e | 2011-06-29 20:00:53 -0700 | [diff] [blame] | 167 | * <li>{@link #getSource()} - The source info (for registered clients).</li> |
Svetoslav Ganov | a015617 | 2011-06-26 17:55:44 -0700 | [diff] [blame] | 168 | * <li>{@link #getClassName()} - The class name of the source.</li> |
| 169 | * <li>{@link #getPackageName()} - The package name of the source.</li> |
| 170 | * <li>{@link #getEventTime()} - The event time.</li> |
Svetoslav Ganov | 82e236d | 2011-09-29 19:31:06 -0700 | [diff] [blame] | 171 | * <li>{@link #getText()} - The text of the source's sub-tree.</li> |
Svetoslav Ganov | a015617 | 2011-06-26 17:55:44 -0700 | [diff] [blame] | 172 | * <li>{@link #isEnabled()} - Whether the source is enabled.</li> |
| 173 | * <li>{@link #isPassword()} - Whether the source is password.</li> |
| 174 | * <li>{@link #isChecked()} - Whether the source is checked.</li> |
Svetoslav Ganov | 38e8b4e | 2011-06-29 20:00:53 -0700 | [diff] [blame] | 175 | * <li>{@link #getItemCount()} - The number of focusable items on the screen.</li> |
Svetoslav Ganov | a015617 | 2011-06-26 17:55:44 -0700 | [diff] [blame] | 176 | * <li>{@link #getCurrentItemIndex()} - The currently focused item index.</li> |
Svetoslav Ganov | 82e236d | 2011-09-29 19:31:06 -0700 | [diff] [blame] | 177 | * <li>{@link #getContentDescription()} - The content description of the source.</li> |
Svetoslav Ganov | d9ee72f | 2011-10-05 22:26:05 -0700 | [diff] [blame] | 178 | * <li>{@link #getScrollX()} - The offset of the source left edge in pixels |
| 179 | * (without descendants of AdapterView).</li> |
| 180 | * <li>{@link #getScrollY()} - The offset of the source top edge in pixels |
| 181 | * (without descendants of AdapterView).</li> |
| 182 | * <li>{@link #getFromIndex()} - The zero based index of the first visible item of the source, |
| 183 | * inclusive (for descendants of AdapterView).</li> |
| 184 | * <li>{@link #getToIndex()} - The zero based index of the last visible item of the source, |
| 185 | * inclusive (for descendants of AdapterView).</li> |
| 186 | * <li>{@link #getItemCount()} - The total items of the source |
| 187 | * (for descendants of AdapterView).</li> |
Svetoslav Ganov | a015617 | 2011-06-26 17:55:44 -0700 | [diff] [blame] | 188 | * </ul> |
Svetoslav Ganov | 38e8b4e | 2011-06-29 20:00:53 -0700 | [diff] [blame] | 189 | * </p> |
svetoslavganov | 75986cf | 2009-05-14 22:28:01 -0700 | [diff] [blame] | 190 | * <p> |
| 191 | * <b>View text changed</b> - represents the event of changing the text of an |
Svetoslav Ganov | 38e8b4e | 2011-06-29 20:00:53 -0700 | [diff] [blame] | 192 | * {@link android.widget.EditText}.</br> |
| 193 | * <em>Type:</em> {@link #TYPE_VIEW_TEXT_CHANGED}</br> |
| 194 | * <em>Properties:</em></br> |
Svetoslav Ganov | a015617 | 2011-06-26 17:55:44 -0700 | [diff] [blame] | 195 | * <ul> |
Svetoslav Ganov | 82e236d | 2011-09-29 19:31:06 -0700 | [diff] [blame] | 196 | * <li>{@link #getEventType()} - The type of the event.</li> |
Svetoslav Ganov | 38e8b4e | 2011-06-29 20:00:53 -0700 | [diff] [blame] | 197 | * <li>{@link #getSource()} - The source info (for registered clients).</li> |
Svetoslav Ganov | a015617 | 2011-06-26 17:55:44 -0700 | [diff] [blame] | 198 | * <li>{@link #getClassName()} - The class name of the source.</li> |
| 199 | * <li>{@link #getPackageName()} - The package name of the source.</li> |
| 200 | * <li>{@link #getEventTime()} - The event time.</li> |
| 201 | * <li>{@link #getText()} - The text of the source.</li> |
| 202 | * <li>{@link #isEnabled()} - Whether the source is enabled.</li> |
| 203 | * <li>{@link #isPassword()} - Whether the source is password.</li> |
| 204 | * <li>{@link #isChecked()} - Whether the source is checked.</li> |
| 205 | * <li>{@link #getFromIndex()} - The text change start index.</li> |
| 206 | * <li>{@link #getAddedCount()} - The number of added characters.</li> |
| 207 | * <li>{@link #getRemovedCount()} - The number of removed characters.</li> |
| 208 | * <li>{@link #getBeforeText()} - The text of the source before the change.</li> |
Svetoslav Ganov | 82e236d | 2011-09-29 19:31:06 -0700 | [diff] [blame] | 209 | * <li>{@link #getContentDescription()} - The content description of the source.</li> |
Svetoslav Ganov | a015617 | 2011-06-26 17:55:44 -0700 | [diff] [blame] | 210 | * </ul> |
Svetoslav Ganov | 38e8b4e | 2011-06-29 20:00:53 -0700 | [diff] [blame] | 211 | * </p> |
Svetoslav Ganov | a015617 | 2011-06-26 17:55:44 -0700 | [diff] [blame] | 212 | * <p> |
| 213 | * <b>View text selection changed</b> - represents the event of changing the text |
Svetoslav Ganov | 38e8b4e | 2011-06-29 20:00:53 -0700 | [diff] [blame] | 214 | * selection of an {@link android.widget.EditText}.</br> |
| 215 | * <em>Type:</em> {@link #TYPE_VIEW_TEXT_SELECTION_CHANGED} </br> |
| 216 | * <em>Properties:</em></br> |
Svetoslav Ganov | a015617 | 2011-06-26 17:55:44 -0700 | [diff] [blame] | 217 | * <ul> |
Svetoslav Ganov | 82e236d | 2011-09-29 19:31:06 -0700 | [diff] [blame] | 218 | * <li>{@link #getEventType()} - The type of the event.</li> |
Svetoslav Ganov | 38e8b4e | 2011-06-29 20:00:53 -0700 | [diff] [blame] | 219 | * <li>{@link #getSource()} - The source info (for registered clients).</li> |
Svetoslav Ganov | a015617 | 2011-06-26 17:55:44 -0700 | [diff] [blame] | 220 | * <li>{@link #getClassName()} - The class name of the source.</li> |
| 221 | * <li>{@link #getPackageName()} - The package name of the source.</li> |
| 222 | * <li>{@link #getEventTime()} - The event time.</li> |
| 223 | * <li>{@link #getText()} - The text of the source.</li> |
Svetoslav Ganov | a015617 | 2011-06-26 17:55:44 -0700 | [diff] [blame] | 224 | * <li>{@link #isPassword()} - Whether the source is password.</li> |
| 225 | * <li>{@link #getFromIndex()} - The selection start index.</li> |
| 226 | * <li>{@link #getToIndex()} - The selection end index.</li> |
| 227 | * <li>{@link #getItemCount()} - The length of the source text.</li> |
Svetoslav Ganov | 82e236d | 2011-09-29 19:31:06 -0700 | [diff] [blame] | 228 | * <li>{@link #isEnabled()} - Whether the source is enabled.</li> |
| 229 | * <li>{@link #getContentDescription()} - The content description of the source.</li> |
Svetoslav Ganov | 38e8b4e | 2011-06-29 20:00:53 -0700 | [diff] [blame] | 230 | * </ul> |
| 231 | * </p> |
Svetoslav Ganov | 2b435aa | 2012-05-04 17:16:37 -0700 | [diff] [blame] | 232 | * <b>View text traversed at movement granularity</b> - represents the event of traversing the |
Svetoslav Ganov | b7ff325 | 2012-04-24 18:40:07 -0700 | [diff] [blame] | 233 | * text of a view at a given granularity. For example, moving to the next word.</br> |
Svetoslav Ganov | 2b435aa | 2012-05-04 17:16:37 -0700 | [diff] [blame] | 234 | * <em>Type:</em> {@link #TYPE_VIEW_TEXT_TRAVERSED_AT_MOVEMENT_GRANULARITY} </br> |
Svetoslav Ganov | b7ff325 | 2012-04-24 18:40:07 -0700 | [diff] [blame] | 235 | * <em>Properties:</em></br> |
| 236 | * <ul> |
| 237 | * <li>{@link #getEventType()} - The type of the event.</li> |
| 238 | * <li>{@link #getSource()} - The source info (for registered clients).</li> |
| 239 | * <li>{@link #getClassName()} - The class name of the source.</li> |
| 240 | * <li>{@link #getPackageName()} - The package name of the source.</li> |
| 241 | * <li>{@link #getEventTime()} - The event time.</li> |
Svetoslav Ganov | 6d17a93 | 2012-04-27 19:30:38 -0700 | [diff] [blame] | 242 | * <li>{@link #getMovementGranularity()} - Sets the granularity at which a view's text |
| 243 | * was traversed.</li> |
| 244 | * <li>{@link #getText()} - The text of the source's sub-tree.</li> |
Phil Weaver | b12a57d | 2016-03-08 09:35:00 -0800 | [diff] [blame] | 245 | * <li>{@link #getFromIndex()} - The start the text that was skipped over in this movement. |
| 246 | * This is the starting point when moving forward through the text, but not when moving |
| 247 | * back.</li> |
| 248 | * <li>{@link #getToIndex()} - The end of the text that was skipped over in this movement. |
| 249 | * This is the ending point when moving forward through the text, but not when moving |
| 250 | * back.</li> |
Svetoslav Ganov | b7ff325 | 2012-04-24 18:40:07 -0700 | [diff] [blame] | 251 | * <li>{@link #isPassword()} - Whether the source is password.</li> |
| 252 | * <li>{@link #isEnabled()} - Whether the source is enabled.</li> |
| 253 | * <li>{@link #getContentDescription()} - The content description of the source.</li> |
Svetoslav Ganov | 2b435aa | 2012-05-04 17:16:37 -0700 | [diff] [blame] | 254 | * <li>{@link #getMovementGranularity()} - Sets the granularity at which a view's text |
| 255 | * was traversed.</li> |
Svetoslav Ganov | 6d17a93 | 2012-04-27 19:30:38 -0700 | [diff] [blame] | 256 | * <li>{@link #getAction()} - Gets traversal action which specifies the direction.</li> |
Svetoslav Ganov | b7ff325 | 2012-04-24 18:40:07 -0700 | [diff] [blame] | 257 | * </ul> |
| 258 | * </p> |
Svetoslav Ganov | a015617 | 2011-06-26 17:55:44 -0700 | [diff] [blame] | 259 | * <p> |
| 260 | * <b>View scrolled</b> - represents the event of scrolling a view. If |
| 261 | * the source is a descendant of {@link android.widget.AdapterView} the |
| 262 | * scroll is reported in terms of visible items - the first visible item, |
| 263 | * the last visible item, and the total items - because the the source |
Svetoslav Ganov | 82e236d | 2011-09-29 19:31:06 -0700 | [diff] [blame] | 264 | * is unaware of its pixel size since its adapter is responsible for |
Svetoslav Ganov | a015617 | 2011-06-26 17:55:44 -0700 | [diff] [blame] | 265 | * creating views. In all other cases the scroll is reported as the current |
| 266 | * scroll on the X and Y axis respectively plus the height of the source in |
Svetoslav Ganov | 38e8b4e | 2011-06-29 20:00:53 -0700 | [diff] [blame] | 267 | * pixels.</br> |
| 268 | * <em>Type:</em> {@link #TYPE_VIEW_SCROLLED}</br> |
| 269 | * <em>Properties:</em></br> |
Svetoslav Ganov | a015617 | 2011-06-26 17:55:44 -0700 | [diff] [blame] | 270 | * <ul> |
Svetoslav Ganov | 82e236d | 2011-09-29 19:31:06 -0700 | [diff] [blame] | 271 | * <li>{@link #getEventType()} - The type of the event.</li> |
Svetoslav Ganov | 38e8b4e | 2011-06-29 20:00:53 -0700 | [diff] [blame] | 272 | * <li>{@link #getSource()} - The source info (for registered clients).</li> |
Svetoslav Ganov | a015617 | 2011-06-26 17:55:44 -0700 | [diff] [blame] | 273 | * <li>{@link #getClassName()} - The class name of the source.</li> |
| 274 | * <li>{@link #getPackageName()} - The package name of the source.</li> |
| 275 | * <li>{@link #getEventTime()} - The event time.</li> |
Svetoslav Ganov | 82e236d | 2011-09-29 19:31:06 -0700 | [diff] [blame] | 276 | * <li>{@link #getText()} - The text of the source's sub-tree.</li> |
Svetoslav Ganov | a015617 | 2011-06-26 17:55:44 -0700 | [diff] [blame] | 277 | * <li>{@link #isEnabled()} - Whether the source is enabled.</li> |
Svetoslav Ganov | 82e236d | 2011-09-29 19:31:06 -0700 | [diff] [blame] | 278 | * <li>{@link #getContentDescription()} - The content description of the source.</li> |
Svetoslav Ganov | d9ee72f | 2011-10-05 22:26:05 -0700 | [diff] [blame] | 279 | * <li>{@link #getScrollX()} - The offset of the source left edge in pixels |
| 280 | * (without descendants of AdapterView).</li> |
| 281 | * <li>{@link #getScrollY()} - The offset of the source top edge in pixels |
| 282 | * (without descendants of AdapterView).</li> |
| 283 | * <li>{@link #getFromIndex()} - The zero based index of the first visible item of the source, |
| 284 | * inclusive (for descendants of AdapterView).</li> |
| 285 | * <li>{@link #getToIndex()} - The zero based index of the last visible item of the source, |
| 286 | * inclusive (for descendants of AdapterView).</li> |
| 287 | * <li>{@link #getItemCount()} - The total items of the source |
| 288 | * (for descendants of AdapterView).</li> |
Svetoslav Ganov | 38e8b4e | 2011-06-29 20:00:53 -0700 | [diff] [blame] | 289 | * </ul> |
Svetoslav Ganov | 82e236d | 2011-09-29 19:31:06 -0700 | [diff] [blame] | 290 | * <em>Note:</em> This event type is not dispatched to descendants though |
| 291 | * {@link android.view.View#dispatchPopulateAccessibilityEvent(AccessibilityEvent) |
| 292 | * View.dispatchPopulateAccessibilityEvent(AccessibilityEvent)}, hence the event |
| 293 | * source {@link android.view.View} and the sub-tree rooted at it will not receive |
| 294 | * calls to {@link android.view.View#onPopulateAccessibilityEvent(AccessibilityEvent) |
| 295 | * View.onPopulateAccessibilityEvent(AccessibilityEvent)}. The preferred way to add |
| 296 | * text content to such events is by setting the |
| 297 | * {@link android.R.styleable#View_contentDescription contentDescription} of the source |
| 298 | * view.</br> |
Svetoslav Ganov | 38e8b4e | 2011-06-29 20:00:53 -0700 | [diff] [blame] | 299 | * </p> |
svetoslavganov | 75986cf | 2009-05-14 22:28:01 -0700 | [diff] [blame] | 300 | * <p> |
Svetoslav Ganov | 38e8b4e | 2011-06-29 20:00:53 -0700 | [diff] [blame] | 301 | * <b>TRANSITION TYPES</b></br> |
| 302 | * </p> |
Svetoslav Ganov | 82e236d | 2011-09-29 19:31:06 -0700 | [diff] [blame] | 303 | * <p> |
Svetoslav Ganov | eeee4d2 | 2011-06-10 20:51:30 -0700 | [diff] [blame] | 304 | * <b>Window state changed</b> - represents the event of opening a |
svetoslavganov | 75986cf | 2009-05-14 22:28:01 -0700 | [diff] [blame] | 305 | * {@link android.widget.PopupWindow}, {@link android.view.Menu}, |
Svetoslav Ganov | 38e8b4e | 2011-06-29 20:00:53 -0700 | [diff] [blame] | 306 | * {@link android.app.Dialog}, etc.</br> |
| 307 | * <em>Type:</em> {@link #TYPE_WINDOW_STATE_CHANGED}</br> |
| 308 | * <em>Properties:</em></br> |
Svetoslav Ganov | a015617 | 2011-06-26 17:55:44 -0700 | [diff] [blame] | 309 | * <ul> |
Svetoslav Ganov | 82e236d | 2011-09-29 19:31:06 -0700 | [diff] [blame] | 310 | * <li>{@link #getEventType()} - The type of the event.</li> |
Svetoslav Ganov | 38e8b4e | 2011-06-29 20:00:53 -0700 | [diff] [blame] | 311 | * <li>{@link #getSource()} - The source info (for registered clients).</li> |
Svetoslav Ganov | a015617 | 2011-06-26 17:55:44 -0700 | [diff] [blame] | 312 | * <li>{@link #getClassName()} - The class name of the source.</li> |
| 313 | * <li>{@link #getPackageName()} - The package name of the source.</li> |
| 314 | * <li>{@link #getEventTime()} - The event time.</li> |
Svetoslav Ganov | 82e236d | 2011-09-29 19:31:06 -0700 | [diff] [blame] | 315 | * <li>{@link #getText()} - The text of the source's sub-tree.</li> |
| 316 | * <li>{@link #isEnabled()} - Whether the source is enabled.</li> |
Svetoslav Ganov | a015617 | 2011-06-26 17:55:44 -0700 | [diff] [blame] | 317 | * </ul> |
Svetoslav Ganov | 38e8b4e | 2011-06-29 20:00:53 -0700 | [diff] [blame] | 318 | * </p> |
svetoslavganov | 75986cf | 2009-05-14 22:28:01 -0700 | [diff] [blame] | 319 | * <p> |
Svetoslav Ganov | eeee4d2 | 2011-06-10 20:51:30 -0700 | [diff] [blame] | 320 | * <b>Window content changed</b> - represents the event of change in the |
| 321 | * content of a window. This change can be adding/removing view, changing |
Svetoslav Ganov | 38e8b4e | 2011-06-29 20:00:53 -0700 | [diff] [blame] | 322 | * a view size, etc.</br> |
Svetoslav Ganov | 82e236d | 2011-09-29 19:31:06 -0700 | [diff] [blame] | 323 | * </p> |
Svetoslav Ganov | 38e8b4e | 2011-06-29 20:00:53 -0700 | [diff] [blame] | 324 | * <p> |
| 325 | * <strong>Note:</strong> This event is fired only for the window source of the |
Svetoslav Ganov | 82e236d | 2011-09-29 19:31:06 -0700 | [diff] [blame] | 326 | * last accessibility event different from {@link #TYPE_NOTIFICATION_STATE_CHANGED} |
Svetoslav Ganov | 38e8b4e | 2011-06-29 20:00:53 -0700 | [diff] [blame] | 327 | * and its purpose is to notify clients that the content of the user interaction |
Svetoslav Ganov | 82e236d | 2011-09-29 19:31:06 -0700 | [diff] [blame] | 328 | * window has changed.</br> |
Svetoslav Ganov | 38e8b4e | 2011-06-29 20:00:53 -0700 | [diff] [blame] | 329 | * <em>Type:</em> {@link #TYPE_WINDOW_CONTENT_CHANGED}</br> |
| 330 | * <em>Properties:</em></br> |
Svetoslav Ganov | a015617 | 2011-06-26 17:55:44 -0700 | [diff] [blame] | 331 | * <ul> |
Svetoslav Ganov | 82e236d | 2011-09-29 19:31:06 -0700 | [diff] [blame] | 332 | * <li>{@link #getEventType()} - The type of the event.</li> |
Alan Viverette | 77e9a28 | 2013-09-12 17:16:09 -0700 | [diff] [blame] | 333 | * <li>{@link #getContentChangeTypes()} - The type of content changes.</li> |
Svetoslav Ganov | 38e8b4e | 2011-06-29 20:00:53 -0700 | [diff] [blame] | 334 | * <li>{@link #getSource()} - The source info (for registered clients).</li> |
Svetoslav Ganov | a015617 | 2011-06-26 17:55:44 -0700 | [diff] [blame] | 335 | * <li>{@link #getClassName()} - The class name of the source.</li> |
| 336 | * <li>{@link #getPackageName()} - The package name of the source.</li> |
| 337 | * <li>{@link #getEventTime()} - The event time.</li> |
Svetoslav Ganov | 38e8b4e | 2011-06-29 20:00:53 -0700 | [diff] [blame] | 338 | * </ul> |
Svetoslav Ganov | 82e236d | 2011-09-29 19:31:06 -0700 | [diff] [blame] | 339 | * <em>Note:</em> This event type is not dispatched to descendants though |
| 340 | * {@link android.view.View#dispatchPopulateAccessibilityEvent(AccessibilityEvent) |
| 341 | * View.dispatchPopulateAccessibilityEvent(AccessibilityEvent)}, hence the event |
| 342 | * source {@link android.view.View} and the sub-tree rooted at it will not receive |
| 343 | * calls to {@link android.view.View#onPopulateAccessibilityEvent(AccessibilityEvent) |
| 344 | * View.onPopulateAccessibilityEvent(AccessibilityEvent)}. The preferred way to add |
| 345 | * text content to such events is by setting the |
| 346 | * {@link android.R.styleable#View_contentDescription contentDescription} of the source |
| 347 | * view.</br> |
| 348 | * </p> |
Svetoslav Ganov | eeee4d2 | 2011-06-10 20:51:30 -0700 | [diff] [blame] | 349 | * <p> |
Svetoslav | 8e3feb1 | 2014-02-24 13:46:47 -0800 | [diff] [blame] | 350 | * <b>Windows changed</b> - represents the event of changes in the windows shown on |
| 351 | * the screen such as a window appeared, a window disappeared, a window size changed, |
| 352 | * a window layer changed, etc.</br> |
| 353 | * <em>Type:</em> {@link #TYPE_WINDOWS_CHANGED}</br> |
| 354 | * <em>Properties:</em></br> |
| 355 | * <ul> |
| 356 | * <li>{@link #getEventType()} - The type of the event.</li> |
| 357 | * <li>{@link #getEventTime()} - The event time.</li> |
| 358 | * </ul> |
| 359 | * <em>Note:</em> You can retrieve the {@link AccessibilityWindowInfo} for the window |
| 360 | * source of the event via {@link AccessibilityEvent#getSource()} to get the source |
| 361 | * node on which then call {@link AccessibilityNodeInfo#getWindow() |
| 362 | * AccessibilityNodeInfo.getWindow()} to get the window. Also all windows on the screen can |
| 363 | * be retrieved by a call to {@link android.accessibilityservice.AccessibilityService#getWindows() |
| 364 | * android.accessibilityservice.AccessibilityService.getWindows()}. |
| 365 | * </p> |
| 366 | * <p> |
Svetoslav Ganov | 38e8b4e | 2011-06-29 20:00:53 -0700 | [diff] [blame] | 367 | * <b>NOTIFICATION TYPES</b></br> |
Svetoslav Ganov | 82e236d | 2011-09-29 19:31:06 -0700 | [diff] [blame] | 368 | * </p> |
svetoslavganov | 75986cf | 2009-05-14 22:28:01 -0700 | [diff] [blame] | 369 | * <p> |
Phil Weaver | 33c7136 | 2017-05-09 16:17:02 -0700 | [diff] [blame] | 370 | * <b>Notification state changed</b> - represents the event showing a transient piece of information |
| 371 | * to the user. This information may be a {@link android.app.Notification} or |
| 372 | * {@link android.widget.Toast}.</br> |
Svetoslav Ganov | 38e8b4e | 2011-06-29 20:00:53 -0700 | [diff] [blame] | 373 | * <em>Type:</em> {@link #TYPE_NOTIFICATION_STATE_CHANGED}</br> |
| 374 | * <em>Properties:</em></br> |
Svetoslav Ganov | a015617 | 2011-06-26 17:55:44 -0700 | [diff] [blame] | 375 | * <ul> |
Svetoslav Ganov | 82e236d | 2011-09-29 19:31:06 -0700 | [diff] [blame] | 376 | * <li>{@link #getEventType()} - The type of the event.</li> |
Svetoslav Ganov | a015617 | 2011-06-26 17:55:44 -0700 | [diff] [blame] | 377 | * <li>{@link #getClassName()} - The class name of the source.</li> |
| 378 | * <li>{@link #getPackageName()} - The package name of the source.</li> |
| 379 | * <li>{@link #getEventTime()} - The event time.</li> |
Phil Weaver | 33c7136 | 2017-05-09 16:17:02 -0700 | [diff] [blame] | 380 | * <li>{@link #getParcelableData()} - The posted {@link android.app.Notification}, if |
| 381 | * applicable.</li> |
| 382 | * <li>{@link #getText()} - Displayed text of the {@link android.widget.Toast}, if applicable, |
| 383 | * or may contain text from the {@link android.app.Notification}, although |
| 384 | * {@link #getParcelableData()} is a richer set of data for {@link android.app.Notification}.</li> |
Svetoslav Ganov | a015617 | 2011-06-26 17:55:44 -0700 | [diff] [blame] | 385 | * </ul> |
Svetoslav Ganov | 82e236d | 2011-09-29 19:31:06 -0700 | [diff] [blame] | 386 | * </p> |
| 387 | * <p> |
| 388 | * <b>EXPLORATION TYPES</b></br> |
| 389 | * </p> |
| 390 | * <p> |
| 391 | * <b>View hover enter</b> - represents the event of beginning to hover |
| 392 | * over a {@link android.view.View}. The hover may be generated via |
| 393 | * exploring the screen by touch or via a pointing device.</br> |
| 394 | * <em>Type:</em> {@link #TYPE_VIEW_HOVER_ENTER}</br> |
| 395 | * <em>Properties:</em></br> |
| 396 | * <ul> |
| 397 | * <li>{@link #getEventType()} - The type of the event.</li> |
| 398 | * <li>{@link #getSource()} - The source info (for registered clients).</li> |
| 399 | * <li>{@link #getClassName()} - The class name of the source.</li> |
| 400 | * <li>{@link #getPackageName()} - The package name of the source.</li> |
| 401 | * <li>{@link #getEventTime()} - The event time.</li> |
| 402 | * <li>{@link #getText()} - The text of the source's sub-tree.</li> |
| 403 | * <li>{@link #isEnabled()} - Whether the source is enabled.</li> |
| 404 | * <li>{@link #getContentDescription()} - The content description of the source.</li> |
Svetoslav Ganov | d9ee72f | 2011-10-05 22:26:05 -0700 | [diff] [blame] | 405 | * <li>{@link #getScrollX()} - The offset of the source left edge in pixels |
| 406 | * (without descendants of AdapterView).</li> |
| 407 | * <li>{@link #getScrollY()} - The offset of the source top edge in pixels |
| 408 | * (without descendants of AdapterView).</li> |
| 409 | * <li>{@link #getFromIndex()} - The zero based index of the first visible item of the source, |
| 410 | * inclusive (for descendants of AdapterView).</li> |
| 411 | * <li>{@link #getToIndex()} - The zero based index of the last visible item of the source, |
| 412 | * inclusive (for descendants of AdapterView).</li> |
| 413 | * <li>{@link #getItemCount()} - The total items of the source |
| 414 | * (for descendants of AdapterView).</li> |
Svetoslav Ganov | 82e236d | 2011-09-29 19:31:06 -0700 | [diff] [blame] | 415 | * </ul> |
| 416 | * </p> |
| 417 | * <b>View hover exit</b> - represents the event of stopping to hover |
| 418 | * over a {@link android.view.View}. The hover may be generated via |
| 419 | * exploring the screen by touch or via a pointing device.</br> |
| 420 | * <em>Type:</em> {@link #TYPE_VIEW_HOVER_EXIT}</br> |
| 421 | * <em>Properties:</em></br> |
| 422 | * <ul> |
| 423 | * <li>{@link #getEventType()} - The type of the event.</li> |
| 424 | * <li>{@link #getSource()} - The source info (for registered clients).</li> |
| 425 | * <li>{@link #getClassName()} - The class name of the source.</li> |
| 426 | * <li>{@link #getPackageName()} - The package name of the source.</li> |
| 427 | * <li>{@link #getEventTime()} - The event time.</li> |
| 428 | * <li>{@link #getText()} - The text of the source's sub-tree.</li> |
| 429 | * <li>{@link #isEnabled()} - Whether the source is enabled.</li> |
| 430 | * <li>{@link #getContentDescription()} - The content description of the source.</li> |
Svetoslav Ganov | d9ee72f | 2011-10-05 22:26:05 -0700 | [diff] [blame] | 431 | * <li>{@link #getScrollX()} - The offset of the source left edge in pixels |
| 432 | * (without descendants of AdapterView).</li> |
| 433 | * <li>{@link #getScrollY()} - The offset of the source top edge in pixels |
| 434 | * (without descendants of AdapterView).</li> |
| 435 | * <li>{@link #getFromIndex()} - The zero based index of the first visible item of the source, |
| 436 | * inclusive (for descendants of AdapterView).</li> |
| 437 | * <li>{@link #getToIndex()} - The zero based index of the last visible item of the source, |
| 438 | * inclusive (for descendants of AdapterView).</li> |
| 439 | * <li>{@link #getItemCount()} - The total items of the source |
| 440 | * (for descendants of AdapterView).</li> |
Svetoslav Ganov | 82e236d | 2011-09-29 19:31:06 -0700 | [diff] [blame] | 441 | * </ul> |
| 442 | * </p> |
| 443 | * <p> |
Svetoslav Ganov | 77276b6 | 2012-09-14 10:23:00 -0700 | [diff] [blame] | 444 | * <b>Touch interaction start</b> - represents the event of starting a touch |
| 445 | * interaction, which is the user starts touching the screen.</br> |
| 446 | * <em>Type:</em> {@link #TYPE_TOUCH_INTERACTION_START}</br> |
| 447 | * <em>Properties:</em></br> |
| 448 | * <ul> |
| 449 | * <li>{@link #getEventType()} - The type of the event.</li> |
| 450 | * </ul> |
| 451 | * <em>Note:</em> This event is fired only by the system and is not passed to the |
| 452 | * view tree to be populated.</br> |
| 453 | * </p> |
| 454 | * <p> |
| 455 | * <b>Touch interaction end</b> - represents the event of ending a touch |
| 456 | * interaction, which is the user stops touching the screen.</br> |
| 457 | * <em>Type:</em> {@link #TYPE_TOUCH_INTERACTION_END}</br> |
| 458 | * <em>Properties:</em></br> |
| 459 | * <ul> |
| 460 | * <li>{@link #getEventType()} - The type of the event.</li> |
| 461 | * </ul> |
| 462 | * <em>Note:</em> This event is fired only by the system and is not passed to the |
| 463 | * view tree to be populated.</br> |
| 464 | * </p> |
| 465 | * <p> |
Svetoslav Ganov | 82e236d | 2011-09-29 19:31:06 -0700 | [diff] [blame] | 466 | * <b>Touch exploration gesture start</b> - represents the event of starting a touch |
| 467 | * exploring gesture.</br> |
| 468 | * <em>Type:</em> {@link #TYPE_TOUCH_EXPLORATION_GESTURE_START}</br> |
| 469 | * <em>Properties:</em></br> |
| 470 | * <ul> |
| 471 | * <li>{@link #getEventType()} - The type of the event.</li> |
| 472 | * </ul> |
Svetoslav Ganov | 77276b6 | 2012-09-14 10:23:00 -0700 | [diff] [blame] | 473 | * <em>Note:</em> This event is fired only by the system and is not passed to the |
| 474 | * view tree to be populated.</br> |
Svetoslav Ganov | 82e236d | 2011-09-29 19:31:06 -0700 | [diff] [blame] | 475 | * </p> |
| 476 | * <p> |
| 477 | * <b>Touch exploration gesture end</b> - represents the event of ending a touch |
| 478 | * exploring gesture.</br> |
| 479 | * <em>Type:</em> {@link #TYPE_TOUCH_EXPLORATION_GESTURE_END}</br> |
| 480 | * <em>Properties:</em></br> |
| 481 | * <ul> |
| 482 | * <li>{@link #getEventType()} - The type of the event.</li> |
| 483 | * </ul> |
Svetoslav Ganov | 77276b6 | 2012-09-14 10:23:00 -0700 | [diff] [blame] | 484 | * <em>Note:</em> This event is fired only by the system and is not passed to the |
| 485 | * view tree to be populated.</br> |
| 486 | * </p> |
| 487 | * <p> |
| 488 | * <b>Touch gesture detection start</b> - represents the event of starting a user |
| 489 | * gesture detection.</br> |
| 490 | * <em>Type:</em> {@link #TYPE_GESTURE_DETECTION_START}</br> |
| 491 | * <em>Properties:</em></br> |
| 492 | * <ul> |
| 493 | * <li>{@link #getEventType()} - The type of the event.</li> |
| 494 | * </ul> |
| 495 | * <em>Note:</em> This event is fired only by the system and is not passed to the |
| 496 | * view tree to be populated.</br> |
| 497 | * </p> |
| 498 | * <p> |
| 499 | * <b>Touch gesture detection end</b> - represents the event of ending a user |
| 500 | * gesture detection.</br> |
| 501 | * <em>Type:</em> {@link #TYPE_GESTURE_DETECTION_END}</br> |
| 502 | * <em>Properties:</em></br> |
| 503 | * <ul> |
| 504 | * <li>{@link #getEventType()} - The type of the event.</li> |
| 505 | * </ul> |
| 506 | * <em>Note:</em> This event is fired only by the system and is not passed to the |
| 507 | * view tree to be populated.</br> |
Svetoslav Ganov | 38e8b4e | 2011-06-29 20:00:53 -0700 | [diff] [blame] | 508 | * </p> |
svetoslavganov | 75986cf | 2009-05-14 22:28:01 -0700 | [diff] [blame] | 509 | * <p> |
Svetoslav Ganov | 51ab90c | 2012-03-09 10:54:49 -0800 | [diff] [blame] | 510 | * <b>MISCELLANEOUS TYPES</b></br> |
| 511 | * </p> |
| 512 | * <p> |
| 513 | * <b>Announcement</b> - represents the event of an application making an |
| 514 | * announcement. Usually this announcement is related to some sort of a context |
| 515 | * change for which none of the events representing UI transitions is a good fit. |
| 516 | * For example, announcing a new page in a book.</br> |
| 517 | * <em>Type:</em> {@link #TYPE_ANNOUNCEMENT}</br> |
| 518 | * <em>Properties:</em></br> |
| 519 | * <ul> |
| 520 | * <li>{@link #getEventType()} - The type of the event.</li> |
| 521 | * <li>{@link #getSource()} - The source info (for registered clients).</li> |
| 522 | * <li>{@link #getClassName()} - The class name of the source.</li> |
| 523 | * <li>{@link #getPackageName()} - The package name of the source.</li> |
| 524 | * <li>{@link #getEventTime()} - The event time.</li> |
| 525 | * <li>{@link #getText()} - The text of the announcement.</li> |
| 526 | * <li>{@link #isEnabled()} - Whether the source is enabled.</li> |
| 527 | * </ul> |
| 528 | * </p> |
svetoslavganov | 75986cf | 2009-05-14 22:28:01 -0700 | [diff] [blame] | 529 | * |
| 530 | * @see android.view.accessibility.AccessibilityManager |
| 531 | * @see android.accessibilityservice.AccessibilityService |
Svetoslav Ganov | 38e8b4e | 2011-06-29 20:00:53 -0700 | [diff] [blame] | 532 | * @see AccessibilityNodeInfo |
svetoslavganov | 75986cf | 2009-05-14 22:28:01 -0700 | [diff] [blame] | 533 | */ |
Svetoslav Ganov | 736c275 | 2011-04-22 18:30:36 -0700 | [diff] [blame] | 534 | public final class AccessibilityEvent extends AccessibilityRecord implements Parcelable { |
Svetoslav Ganov | 8643aa0 | 2011-04-20 12:12:33 -0700 | [diff] [blame] | 535 | private static final boolean DEBUG = false; |
svetoslavganov | 75986cf | 2009-05-14 22:28:01 -0700 | [diff] [blame] | 536 | |
| 537 | /** |
| 538 | * Invalid selection/focus position. |
| 539 | * |
| 540 | * @see #getCurrentItemIndex() |
| 541 | */ |
| 542 | public static final int INVALID_POSITION = -1; |
| 543 | |
| 544 | /** |
| 545 | * Maximum length of the text fields. |
| 546 | * |
| 547 | * @see #getBeforeText() |
| 548 | * @see #getText() |
Svetoslav Ganov | c0a8cd1 | 2011-03-18 17:05:56 -0700 | [diff] [blame] | 549 | * </br> |
| 550 | * Note: This constant is no longer needed since there |
| 551 | * is no limit on the length of text that is contained |
| 552 | * in an accessibility event anymore. |
svetoslavganov | 75986cf | 2009-05-14 22:28:01 -0700 | [diff] [blame] | 553 | */ |
Svetoslav Ganov | c0a8cd1 | 2011-03-18 17:05:56 -0700 | [diff] [blame] | 554 | @Deprecated |
svetoslavganov | 75986cf | 2009-05-14 22:28:01 -0700 | [diff] [blame] | 555 | public static final int MAX_TEXT_LENGTH = 500; |
| 556 | |
| 557 | /** |
| 558 | * Represents the event of clicking on a {@link android.view.View} like |
| 559 | * {@link android.widget.Button}, {@link android.widget.CompoundButton}, etc. |
| 560 | */ |
| 561 | public static final int TYPE_VIEW_CLICKED = 0x00000001; |
| 562 | |
| 563 | /** |
| 564 | * Represents the event of long clicking on a {@link android.view.View} like |
| 565 | * {@link android.widget.Button}, {@link android.widget.CompoundButton}, etc. |
| 566 | */ |
| 567 | public static final int TYPE_VIEW_LONG_CLICKED = 0x00000002; |
| 568 | |
| 569 | /** |
| 570 | * Represents the event of selecting an item usually in the context of an |
| 571 | * {@link android.widget.AdapterView}. |
| 572 | */ |
| 573 | public static final int TYPE_VIEW_SELECTED = 0x00000004; |
| 574 | |
| 575 | /** |
Svetoslav Ganov | 4213804 | 2012-03-20 11:51:39 -0700 | [diff] [blame] | 576 | * Represents the event of setting input focus of a {@link android.view.View}. |
svetoslavganov | 75986cf | 2009-05-14 22:28:01 -0700 | [diff] [blame] | 577 | */ |
| 578 | public static final int TYPE_VIEW_FOCUSED = 0x00000008; |
| 579 | |
| 580 | /** |
| 581 | * Represents the event of changing the text of an {@link android.widget.EditText}. |
| 582 | */ |
| 583 | public static final int TYPE_VIEW_TEXT_CHANGED = 0x00000010; |
| 584 | |
| 585 | /** |
Svetoslav Ganov | 38e8b4e | 2011-06-29 20:00:53 -0700 | [diff] [blame] | 586 | * Represents the event of opening a {@link android.widget.PopupWindow}, |
svetoslavganov | 75986cf | 2009-05-14 22:28:01 -0700 | [diff] [blame] | 587 | * {@link android.view.Menu}, {@link android.app.Dialog}, etc. |
| 588 | */ |
| 589 | public static final int TYPE_WINDOW_STATE_CHANGED = 0x00000020; |
| 590 | |
| 591 | /** |
Svetoslav Ganov | 38e8b4e | 2011-06-29 20:00:53 -0700 | [diff] [blame] | 592 | * Represents the event showing a {@link android.app.Notification}. |
svetoslavganov | 75986cf | 2009-05-14 22:28:01 -0700 | [diff] [blame] | 593 | */ |
| 594 | public static final int TYPE_NOTIFICATION_STATE_CHANGED = 0x00000040; |
| 595 | |
| 596 | /** |
Svetoslav Ganov | 736c275 | 2011-04-22 18:30:36 -0700 | [diff] [blame] | 597 | * Represents the event of a hover enter over a {@link android.view.View}. |
| 598 | */ |
| 599 | public static final int TYPE_VIEW_HOVER_ENTER = 0x00000080; |
| 600 | |
| 601 | /** |
| 602 | * Represents the event of a hover exit over a {@link android.view.View}. |
| 603 | */ |
| 604 | public static final int TYPE_VIEW_HOVER_EXIT = 0x00000100; |
| 605 | |
| 606 | /** |
| 607 | * Represents the event of starting a touch exploration gesture. |
| 608 | */ |
| 609 | public static final int TYPE_TOUCH_EXPLORATION_GESTURE_START = 0x00000200; |
| 610 | |
| 611 | /** |
| 612 | * Represents the event of ending a touch exploration gesture. |
| 613 | */ |
| 614 | public static final int TYPE_TOUCH_EXPLORATION_GESTURE_END = 0x00000400; |
| 615 | |
| 616 | /** |
Svetoslav Ganov | 4213804 | 2012-03-20 11:51:39 -0700 | [diff] [blame] | 617 | * Represents the event of changing the content of a window and more |
| 618 | * specifically the sub-tree rooted at the event's source. |
Svetoslav Ganov | eeee4d2 | 2011-06-10 20:51:30 -0700 | [diff] [blame] | 619 | */ |
| 620 | public static final int TYPE_WINDOW_CONTENT_CHANGED = 0x00000800; |
| 621 | |
| 622 | /** |
Phil Weaver | 2b94bbe | 2017-06-06 10:48:47 -0700 | [diff] [blame] | 623 | * Represents the event of scrolling a view. This event type is generally not sent directly. |
| 624 | * @see View#onScrollChanged(int, int, int, int) |
Svetoslav Ganov | a015617 | 2011-06-26 17:55:44 -0700 | [diff] [blame] | 625 | */ |
| 626 | public static final int TYPE_VIEW_SCROLLED = 0x00001000; |
| 627 | |
| 628 | /** |
| 629 | * Represents the event of changing the selection in an {@link android.widget.EditText}. |
| 630 | */ |
| 631 | public static final int TYPE_VIEW_TEXT_SELECTION_CHANGED = 0x00002000; |
| 632 | |
| 633 | /** |
Svetoslav Ganov | 51ab90c | 2012-03-09 10:54:49 -0800 | [diff] [blame] | 634 | * Represents the event of an application making an announcement. |
| 635 | */ |
| 636 | public static final int TYPE_ANNOUNCEMENT = 0x00004000; |
| 637 | |
| 638 | /** |
Svetoslav Ganov | 4213804 | 2012-03-20 11:51:39 -0700 | [diff] [blame] | 639 | * Represents the event of gaining accessibility focus. |
| 640 | */ |
| 641 | public static final int TYPE_VIEW_ACCESSIBILITY_FOCUSED = 0x00008000; |
| 642 | |
| 643 | /** |
| 644 | * Represents the event of clearing accessibility focus. |
| 645 | */ |
| 646 | public static final int TYPE_VIEW_ACCESSIBILITY_FOCUS_CLEARED = 0x00010000; |
| 647 | |
| 648 | /** |
Svetoslav Ganov | 2b435aa | 2012-05-04 17:16:37 -0700 | [diff] [blame] | 649 | * Represents the event of traversing the text of a view at a given movement granularity. |
Svetoslav Ganov | b7ff325 | 2012-04-24 18:40:07 -0700 | [diff] [blame] | 650 | */ |
Svetoslav Ganov | 2b435aa | 2012-05-04 17:16:37 -0700 | [diff] [blame] | 651 | public static final int TYPE_VIEW_TEXT_TRAVERSED_AT_MOVEMENT_GRANULARITY = 0x00020000; |
Svetoslav Ganov | b7ff325 | 2012-04-24 18:40:07 -0700 | [diff] [blame] | 652 | |
| 653 | /** |
Svetoslav Ganov | 77276b6 | 2012-09-14 10:23:00 -0700 | [diff] [blame] | 654 | * Represents the event of beginning gesture detection. |
| 655 | */ |
| 656 | public static final int TYPE_GESTURE_DETECTION_START = 0x00040000; |
| 657 | |
| 658 | /** |
| 659 | * Represents the event of ending gesture detection. |
| 660 | */ |
| 661 | public static final int TYPE_GESTURE_DETECTION_END = 0x00080000; |
| 662 | |
| 663 | /** |
| 664 | * Represents the event of the user starting to touch the screen. |
| 665 | */ |
| 666 | public static final int TYPE_TOUCH_INTERACTION_START = 0x00100000; |
| 667 | |
| 668 | /** |
| 669 | * Represents the event of the user ending to touch the screen. |
| 670 | */ |
| 671 | public static final int TYPE_TOUCH_INTERACTION_END = 0x00200000; |
| 672 | |
| 673 | /** |
Svetoslav | 8e3feb1 | 2014-02-24 13:46:47 -0800 | [diff] [blame] | 674 | * Represents the event change in the windows shown on the screen. |
| 675 | */ |
| 676 | public static final int TYPE_WINDOWS_CHANGED = 0x00400000; |
| 677 | |
| 678 | /** |
Mady Mellor | e860891 | 2015-06-05 09:02:55 -0700 | [diff] [blame] | 679 | * Represents the event of a context click on a {@link android.view.View}. |
Mady Mellor | e82067b | 2015-04-30 09:58:35 -0700 | [diff] [blame] | 680 | */ |
Mady Mellor | e860891 | 2015-06-05 09:02:55 -0700 | [diff] [blame] | 681 | public static final int TYPE_VIEW_CONTEXT_CLICKED = 0x00800000; |
Mady Mellor | e82067b | 2015-04-30 09:58:35 -0700 | [diff] [blame] | 682 | |
| 683 | /** |
Jorim Jaggi | e85da2ba | 2015-06-25 17:26:10 -0700 | [diff] [blame] | 684 | * Represents the event of the assistant currently reading the users screen context. |
| 685 | */ |
| 686 | public static final int TYPE_ASSIST_READING_CONTEXT = 0x01000000; |
| 687 | |
| 688 | /** |
Svetoslav | 6254f48 | 2013-06-04 17:22:14 -0700 | [diff] [blame] | 689 | * Change type for {@link #TYPE_WINDOW_CONTENT_CHANGED} event: |
Alan Viverette | 77e9a28 | 2013-09-12 17:16:09 -0700 | [diff] [blame] | 690 | * The type of change is not defined. |
Svetoslav | 6254f48 | 2013-06-04 17:22:14 -0700 | [diff] [blame] | 691 | */ |
Alan Viverette | 77e9a28 | 2013-09-12 17:16:09 -0700 | [diff] [blame] | 692 | public static final int CONTENT_CHANGE_TYPE_UNDEFINED = 0x00000000; |
Svetoslav | 6254f48 | 2013-06-04 17:22:14 -0700 | [diff] [blame] | 693 | |
| 694 | /** |
| 695 | * Change type for {@link #TYPE_WINDOW_CONTENT_CHANGED} event: |
Alan Viverette | 77e9a28 | 2013-09-12 17:16:09 -0700 | [diff] [blame] | 696 | * A node in the subtree rooted at the source node was added or removed. |
Svetoslav | 6254f48 | 2013-06-04 17:22:14 -0700 | [diff] [blame] | 697 | */ |
Alan Viverette | 77e9a28 | 2013-09-12 17:16:09 -0700 | [diff] [blame] | 698 | public static final int CONTENT_CHANGE_TYPE_SUBTREE = 0x00000001; |
| 699 | |
| 700 | /** |
| 701 | * Change type for {@link #TYPE_WINDOW_CONTENT_CHANGED} event: |
| 702 | * The node's text changed. |
| 703 | */ |
| 704 | public static final int CONTENT_CHANGE_TYPE_TEXT = 0x00000002; |
| 705 | |
| 706 | /** |
| 707 | * Change type for {@link #TYPE_WINDOW_CONTENT_CHANGED} event: |
| 708 | * The node's content description changed. |
| 709 | */ |
| 710 | public static final int CONTENT_CHANGE_TYPE_CONTENT_DESCRIPTION = 0x00000004; |
Svetoslav | 6254f48 | 2013-06-04 17:22:14 -0700 | [diff] [blame] | 711 | |
| 712 | /** |
svetoslavganov | 75986cf | 2009-05-14 22:28:01 -0700 | [diff] [blame] | 713 | * Mask for {@link AccessibilityEvent} all types. |
| 714 | * |
| 715 | * @see #TYPE_VIEW_CLICKED |
| 716 | * @see #TYPE_VIEW_LONG_CLICKED |
| 717 | * @see #TYPE_VIEW_SELECTED |
| 718 | * @see #TYPE_VIEW_FOCUSED |
| 719 | * @see #TYPE_VIEW_TEXT_CHANGED |
| 720 | * @see #TYPE_WINDOW_STATE_CHANGED |
| 721 | * @see #TYPE_NOTIFICATION_STATE_CHANGED |
Svetoslav Ganov | 38e8b4e | 2011-06-29 20:00:53 -0700 | [diff] [blame] | 722 | * @see #TYPE_VIEW_HOVER_ENTER |
| 723 | * @see #TYPE_VIEW_HOVER_EXIT |
| 724 | * @see #TYPE_TOUCH_EXPLORATION_GESTURE_START |
| 725 | * @see #TYPE_TOUCH_EXPLORATION_GESTURE_END |
| 726 | * @see #TYPE_WINDOW_CONTENT_CHANGED |
| 727 | * @see #TYPE_VIEW_SCROLLED |
| 728 | * @see #TYPE_VIEW_TEXT_SELECTION_CHANGED |
Svetoslav Ganov | 51ab90c | 2012-03-09 10:54:49 -0800 | [diff] [blame] | 729 | * @see #TYPE_ANNOUNCEMENT |
Svetoslav Ganov | 2b435aa | 2012-05-04 17:16:37 -0700 | [diff] [blame] | 730 | * @see #TYPE_VIEW_TEXT_TRAVERSED_AT_MOVEMENT_GRANULARITY |
Svetoslav Ganov | 77276b6 | 2012-09-14 10:23:00 -0700 | [diff] [blame] | 731 | * @see #TYPE_GESTURE_DETECTION_START |
| 732 | * @see #TYPE_GESTURE_DETECTION_END |
| 733 | * @see #TYPE_TOUCH_INTERACTION_START |
| 734 | * @see #TYPE_TOUCH_INTERACTION_END |
Svetoslav | 8e3feb1 | 2014-02-24 13:46:47 -0800 | [diff] [blame] | 735 | * @see #TYPE_WINDOWS_CHANGED |
Mady Mellor | e860891 | 2015-06-05 09:02:55 -0700 | [diff] [blame] | 736 | * @see #TYPE_VIEW_CONTEXT_CLICKED |
svetoslavganov | 75986cf | 2009-05-14 22:28:01 -0700 | [diff] [blame] | 737 | */ |
| 738 | public static final int TYPES_ALL_MASK = 0xFFFFFFFF; |
| 739 | |
Svetoslav Ganov | 736c275 | 2011-04-22 18:30:36 -0700 | [diff] [blame] | 740 | private static final int MAX_POOL_SIZE = 10; |
Svetoslav Ganov | f4782ec | 2012-11-28 09:11:41 -0800 | [diff] [blame] | 741 | private static final SynchronizedPool<AccessibilityEvent> sPool = |
| 742 | new SynchronizedPool<AccessibilityEvent>(MAX_POOL_SIZE); |
svetoslavganov | 75986cf | 2009-05-14 22:28:01 -0700 | [diff] [blame] | 743 | |
| 744 | private int mEventType; |
Svetoslav Ganov | 736c275 | 2011-04-22 18:30:36 -0700 | [diff] [blame] | 745 | private CharSequence mPackageName; |
svetoslavganov | 75986cf | 2009-05-14 22:28:01 -0700 | [diff] [blame] | 746 | private long mEventTime; |
Svetoslav Ganov | 2b435aa | 2012-05-04 17:16:37 -0700 | [diff] [blame] | 747 | int mMovementGranularity; |
Svetoslav Ganov | 6d17a93 | 2012-04-27 19:30:38 -0700 | [diff] [blame] | 748 | int mAction; |
Alan Viverette | 77e9a28 | 2013-09-12 17:16:09 -0700 | [diff] [blame] | 749 | int mContentChangeTypes; |
svetoslavganov | 75986cf | 2009-05-14 22:28:01 -0700 | [diff] [blame] | 750 | |
Alan Viverette | 502cb33 | 2013-10-15 18:29:53 -0700 | [diff] [blame] | 751 | private ArrayList<AccessibilityRecord> mRecords; |
svetoslavganov | 75986cf | 2009-05-14 22:28:01 -0700 | [diff] [blame] | 752 | |
| 753 | /* |
| 754 | * Hide constructor from clients. |
| 755 | */ |
| 756 | private AccessibilityEvent() { |
Svetoslav Ganov | 8643aa0 | 2011-04-20 12:12:33 -0700 | [diff] [blame] | 757 | } |
Svetoslav Ganov | 736c275 | 2011-04-22 18:30:36 -0700 | [diff] [blame] | 758 | |
Svetoslav Ganov | 8643aa0 | 2011-04-20 12:12:33 -0700 | [diff] [blame] | 759 | /** |
| 760 | * Initialize an event from another one. |
| 761 | * |
| 762 | * @param event The event to initialize from. |
| 763 | */ |
| 764 | void init(AccessibilityEvent event) { |
| 765 | super.init(event); |
| 766 | mEventType = event.mEventType; |
Svetoslav Ganov | 2b435aa | 2012-05-04 17:16:37 -0700 | [diff] [blame] | 767 | mMovementGranularity = event.mMovementGranularity; |
Svetoslav Ganov | 6d17a93 | 2012-04-27 19:30:38 -0700 | [diff] [blame] | 768 | mAction = event.mAction; |
Alan Viverette | 77e9a28 | 2013-09-12 17:16:09 -0700 | [diff] [blame] | 769 | mContentChangeTypes = event.mContentChangeTypes; |
Svetoslav Ganov | 8643aa0 | 2011-04-20 12:12:33 -0700 | [diff] [blame] | 770 | mEventTime = event.mEventTime; |
Svetoslav Ganov | 8643aa0 | 2011-04-20 12:12:33 -0700 | [diff] [blame] | 771 | mPackageName = event.mPackageName; |
Svetoslav Ganov | eeee4d2 | 2011-06-10 20:51:30 -0700 | [diff] [blame] | 772 | } |
| 773 | |
| 774 | /** |
Svetoslav Ganov | eeee4d2 | 2011-06-10 20:51:30 -0700 | [diff] [blame] | 775 | * Sets if this instance is sealed. |
| 776 | * |
| 777 | * @param sealed Whether is sealed. |
| 778 | * |
| 779 | * @hide |
| 780 | */ |
| 781 | @Override |
| 782 | public void setSealed(boolean sealed) { |
| 783 | super.setSealed(sealed); |
Alan Viverette | 502cb33 | 2013-10-15 18:29:53 -0700 | [diff] [blame] | 784 | final List<AccessibilityRecord> records = mRecords; |
| 785 | if (records != null) { |
| 786 | final int recordCount = records.size(); |
| 787 | for (int i = 0; i < recordCount; i++) { |
| 788 | AccessibilityRecord record = records.get(i); |
| 789 | record.setSealed(sealed); |
| 790 | } |
Svetoslav Ganov | eeee4d2 | 2011-06-10 20:51:30 -0700 | [diff] [blame] | 791 | } |
svetoslavganov | 75986cf | 2009-05-14 22:28:01 -0700 | [diff] [blame] | 792 | } |
| 793 | |
| 794 | /** |
Svetoslav Ganov | 736c275 | 2011-04-22 18:30:36 -0700 | [diff] [blame] | 795 | * Gets the number of records contained in the event. |
svetoslavganov | 75986cf | 2009-05-14 22:28:01 -0700 | [diff] [blame] | 796 | * |
Svetoslav Ganov | 736c275 | 2011-04-22 18:30:36 -0700 | [diff] [blame] | 797 | * @return The number of records. |
svetoslavganov | 75986cf | 2009-05-14 22:28:01 -0700 | [diff] [blame] | 798 | */ |
Svetoslav Ganov | 736c275 | 2011-04-22 18:30:36 -0700 | [diff] [blame] | 799 | public int getRecordCount() { |
Alan Viverette | 502cb33 | 2013-10-15 18:29:53 -0700 | [diff] [blame] | 800 | return mRecords == null ? 0 : mRecords.size(); |
svetoslavganov | 75986cf | 2009-05-14 22:28:01 -0700 | [diff] [blame] | 801 | } |
| 802 | |
| 803 | /** |
Svetoslav Ganov | 736c275 | 2011-04-22 18:30:36 -0700 | [diff] [blame] | 804 | * Appends an {@link AccessibilityRecord} to the end of event records. |
svetoslavganov | 75986cf | 2009-05-14 22:28:01 -0700 | [diff] [blame] | 805 | * |
Svetoslav Ganov | 736c275 | 2011-04-22 18:30:36 -0700 | [diff] [blame] | 806 | * @param record The record to append. |
Svetoslav Ganov | 8643aa0 | 2011-04-20 12:12:33 -0700 | [diff] [blame] | 807 | * |
| 808 | * @throws IllegalStateException If called from an AccessibilityService. |
svetoslavganov | 75986cf | 2009-05-14 22:28:01 -0700 | [diff] [blame] | 809 | */ |
Svetoslav Ganov | 736c275 | 2011-04-22 18:30:36 -0700 | [diff] [blame] | 810 | public void appendRecord(AccessibilityRecord record) { |
Svetoslav Ganov | 8643aa0 | 2011-04-20 12:12:33 -0700 | [diff] [blame] | 811 | enforceNotSealed(); |
Alan Viverette | 502cb33 | 2013-10-15 18:29:53 -0700 | [diff] [blame] | 812 | if (mRecords == null) { |
| 813 | mRecords = new ArrayList<AccessibilityRecord>(); |
| 814 | } |
Svetoslav Ganov | 736c275 | 2011-04-22 18:30:36 -0700 | [diff] [blame] | 815 | mRecords.add(record); |
svetoslavganov | 75986cf | 2009-05-14 22:28:01 -0700 | [diff] [blame] | 816 | } |
| 817 | |
| 818 | /** |
Svetoslav Ganov | 38e8b4e | 2011-06-29 20:00:53 -0700 | [diff] [blame] | 819 | * Gets the record at a given index. |
svetoslavganov | 75986cf | 2009-05-14 22:28:01 -0700 | [diff] [blame] | 820 | * |
Svetoslav Ganov | 736c275 | 2011-04-22 18:30:36 -0700 | [diff] [blame] | 821 | * @param index The index. |
Svetoslav Ganov | 38e8b4e | 2011-06-29 20:00:53 -0700 | [diff] [blame] | 822 | * @return The record at the specified index. |
svetoslavganov | 75986cf | 2009-05-14 22:28:01 -0700 | [diff] [blame] | 823 | */ |
Svetoslav Ganov | 736c275 | 2011-04-22 18:30:36 -0700 | [diff] [blame] | 824 | public AccessibilityRecord getRecord(int index) { |
Alan Viverette | 502cb33 | 2013-10-15 18:29:53 -0700 | [diff] [blame] | 825 | if (mRecords == null) { |
| 826 | throw new IndexOutOfBoundsException("Invalid index " + index + ", size is 0"); |
| 827 | } |
Svetoslav Ganov | 736c275 | 2011-04-22 18:30:36 -0700 | [diff] [blame] | 828 | return mRecords.get(index); |
svetoslavganov | 75986cf | 2009-05-14 22:28:01 -0700 | [diff] [blame] | 829 | } |
| 830 | |
| 831 | /** |
| 832 | * Gets the event type. |
| 833 | * |
| 834 | * @return The event type. |
| 835 | */ |
| 836 | public int getEventType() { |
| 837 | return mEventType; |
| 838 | } |
| 839 | |
| 840 | /** |
Alan Viverette | 77e9a28 | 2013-09-12 17:16:09 -0700 | [diff] [blame] | 841 | * Gets the bit mask of change types signaled by an |
| 842 | * {@link #TYPE_WINDOW_CONTENT_CHANGED} event. A single event may represent |
| 843 | * multiple change types. |
Svetoslav | 6254f48 | 2013-06-04 17:22:14 -0700 | [diff] [blame] | 844 | * |
Alan Viverette | 77e9a28 | 2013-09-12 17:16:09 -0700 | [diff] [blame] | 845 | * @return The bit mask of change types. One or more of: |
| 846 | * <ul> |
| 847 | * <li>{@link AccessibilityEvent#CONTENT_CHANGE_TYPE_CONTENT_DESCRIPTION} |
| 848 | * <li>{@link AccessibilityEvent#CONTENT_CHANGE_TYPE_SUBTREE} |
| 849 | * <li>{@link AccessibilityEvent#CONTENT_CHANGE_TYPE_TEXT} |
| 850 | * <li>{@link AccessibilityEvent#CONTENT_CHANGE_TYPE_UNDEFINED} |
| 851 | * </ul> |
Svetoslav | 6254f48 | 2013-06-04 17:22:14 -0700 | [diff] [blame] | 852 | */ |
Alan Viverette | 77e9a28 | 2013-09-12 17:16:09 -0700 | [diff] [blame] | 853 | public int getContentChangeTypes() { |
| 854 | return mContentChangeTypes; |
Svetoslav | 6254f48 | 2013-06-04 17:22:14 -0700 | [diff] [blame] | 855 | } |
| 856 | |
Eugene Susla | 4a34f9c | 2017-05-16 14:16:38 -0700 | [diff] [blame] | 857 | private static String contentChangeTypesToString(int types) { |
| 858 | return BitUtils.flagsToString(types, AccessibilityEvent::singleContentChangeTypeToString); |
| 859 | } |
| 860 | |
| 861 | private static String singleContentChangeTypeToString(int type) { |
| 862 | switch (type) { |
| 863 | case CONTENT_CHANGE_TYPE_CONTENT_DESCRIPTION: { |
| 864 | return "CONTENT_CHANGE_TYPE_CONTENT_DESCRIPTION"; |
| 865 | } |
| 866 | case CONTENT_CHANGE_TYPE_SUBTREE: return "CONTENT_CHANGE_TYPE_SUBTREE"; |
| 867 | case CONTENT_CHANGE_TYPE_TEXT: return "CONTENT_CHANGE_TYPE_TEXT"; |
| 868 | case CONTENT_CHANGE_TYPE_UNDEFINED: return "CONTENT_CHANGE_TYPE_UNDEFINED"; |
| 869 | default: return Integer.toHexString(type); |
| 870 | } |
| 871 | } |
| 872 | |
Svetoslav | 6254f48 | 2013-06-04 17:22:14 -0700 | [diff] [blame] | 873 | /** |
Alan Viverette | 77e9a28 | 2013-09-12 17:16:09 -0700 | [diff] [blame] | 874 | * Sets the bit mask of node tree changes signaled by an |
Svetoslav | 6254f48 | 2013-06-04 17:22:14 -0700 | [diff] [blame] | 875 | * {@link #TYPE_WINDOW_CONTENT_CHANGED} event. |
| 876 | * |
Alan Viverette | 77e9a28 | 2013-09-12 17:16:09 -0700 | [diff] [blame] | 877 | * @param changeTypes The bit mask of change types. |
| 878 | * @throws IllegalStateException If called from an AccessibilityService. |
| 879 | * @see #getContentChangeTypes() |
Svetoslav | 6254f48 | 2013-06-04 17:22:14 -0700 | [diff] [blame] | 880 | */ |
Alan Viverette | 77e9a28 | 2013-09-12 17:16:09 -0700 | [diff] [blame] | 881 | public void setContentChangeTypes(int changeTypes) { |
Svetoslav | 6254f48 | 2013-06-04 17:22:14 -0700 | [diff] [blame] | 882 | enforceNotSealed(); |
Alan Viverette | 77e9a28 | 2013-09-12 17:16:09 -0700 | [diff] [blame] | 883 | mContentChangeTypes = changeTypes; |
Svetoslav | 6254f48 | 2013-06-04 17:22:14 -0700 | [diff] [blame] | 884 | } |
| 885 | |
| 886 | /** |
svetoslavganov | 75986cf | 2009-05-14 22:28:01 -0700 | [diff] [blame] | 887 | * Sets the event type. |
| 888 | * |
| 889 | * @param eventType The event type. |
Svetoslav Ganov | 8643aa0 | 2011-04-20 12:12:33 -0700 | [diff] [blame] | 890 | * |
| 891 | * @throws IllegalStateException If called from an AccessibilityService. |
svetoslavganov | 75986cf | 2009-05-14 22:28:01 -0700 | [diff] [blame] | 892 | */ |
| 893 | public void setEventType(int eventType) { |
Svetoslav Ganov | 8643aa0 | 2011-04-20 12:12:33 -0700 | [diff] [blame] | 894 | enforceNotSealed(); |
svetoslavganov | 75986cf | 2009-05-14 22:28:01 -0700 | [diff] [blame] | 895 | mEventType = eventType; |
| 896 | } |
| 897 | |
| 898 | /** |
svetoslavganov | 75986cf | 2009-05-14 22:28:01 -0700 | [diff] [blame] | 899 | * Gets the time in which this event was sent. |
| 900 | * |
| 901 | * @return The event time. |
| 902 | */ |
| 903 | public long getEventTime() { |
| 904 | return mEventTime; |
| 905 | } |
| 906 | |
| 907 | /** |
| 908 | * Sets the time in which this event was sent. |
| 909 | * |
| 910 | * @param eventTime The event time. |
Svetoslav Ganov | 8643aa0 | 2011-04-20 12:12:33 -0700 | [diff] [blame] | 911 | * |
| 912 | * @throws IllegalStateException If called from an AccessibilityService. |
svetoslavganov | 75986cf | 2009-05-14 22:28:01 -0700 | [diff] [blame] | 913 | */ |
| 914 | public void setEventTime(long eventTime) { |
Svetoslav Ganov | 8643aa0 | 2011-04-20 12:12:33 -0700 | [diff] [blame] | 915 | enforceNotSealed(); |
svetoslavganov | 75986cf | 2009-05-14 22:28:01 -0700 | [diff] [blame] | 916 | mEventTime = eventTime; |
| 917 | } |
| 918 | |
| 919 | /** |
svetoslavganov | 75986cf | 2009-05-14 22:28:01 -0700 | [diff] [blame] | 920 | * Gets the package name of the source. |
| 921 | * |
| 922 | * @return The package name. |
| 923 | */ |
| 924 | public CharSequence getPackageName() { |
| 925 | return mPackageName; |
| 926 | } |
| 927 | |
| 928 | /** |
| 929 | * Sets the package name of the source. |
| 930 | * |
| 931 | * @param packageName The package name. |
Svetoslav Ganov | 8643aa0 | 2011-04-20 12:12:33 -0700 | [diff] [blame] | 932 | * |
| 933 | * @throws IllegalStateException If called from an AccessibilityService. |
svetoslavganov | 75986cf | 2009-05-14 22:28:01 -0700 | [diff] [blame] | 934 | */ |
| 935 | public void setPackageName(CharSequence packageName) { |
Svetoslav Ganov | 8643aa0 | 2011-04-20 12:12:33 -0700 | [diff] [blame] | 936 | enforceNotSealed(); |
svetoslavganov | 75986cf | 2009-05-14 22:28:01 -0700 | [diff] [blame] | 937 | mPackageName = packageName; |
| 938 | } |
| 939 | |
| 940 | /** |
Svetoslav Ganov | 2b435aa | 2012-05-04 17:16:37 -0700 | [diff] [blame] | 941 | * Sets the movement granularity that was traversed. |
Svetoslav Ganov | b7ff325 | 2012-04-24 18:40:07 -0700 | [diff] [blame] | 942 | * |
| 943 | * @param granularity The granularity. |
| 944 | * |
| 945 | * @throws IllegalStateException If called from an AccessibilityService. |
| 946 | */ |
Svetoslav Ganov | 2b435aa | 2012-05-04 17:16:37 -0700 | [diff] [blame] | 947 | public void setMovementGranularity(int granularity) { |
Svetoslav Ganov | b7ff325 | 2012-04-24 18:40:07 -0700 | [diff] [blame] | 948 | enforceNotSealed(); |
Svetoslav Ganov | 2b435aa | 2012-05-04 17:16:37 -0700 | [diff] [blame] | 949 | mMovementGranularity = granularity; |
Svetoslav Ganov | b7ff325 | 2012-04-24 18:40:07 -0700 | [diff] [blame] | 950 | } |
| 951 | |
| 952 | /** |
Svetoslav Ganov | 2b435aa | 2012-05-04 17:16:37 -0700 | [diff] [blame] | 953 | * Gets the movement granularity that was traversed. |
Svetoslav Ganov | b7ff325 | 2012-04-24 18:40:07 -0700 | [diff] [blame] | 954 | * |
| 955 | * @return The granularity. |
| 956 | */ |
Svetoslav Ganov | 2b435aa | 2012-05-04 17:16:37 -0700 | [diff] [blame] | 957 | public int getMovementGranularity() { |
| 958 | return mMovementGranularity; |
Svetoslav Ganov | b7ff325 | 2012-04-24 18:40:07 -0700 | [diff] [blame] | 959 | } |
| 960 | |
| 961 | /** |
Svetoslav Ganov | 6d17a93 | 2012-04-27 19:30:38 -0700 | [diff] [blame] | 962 | * Sets the performed action that triggered this event. |
Alan Viverette | af43110 | 2013-10-04 13:16:51 -0700 | [diff] [blame] | 963 | * <p> |
| 964 | * Valid actions are defined in {@link AccessibilityNodeInfo}: |
| 965 | * <ul> |
| 966 | * <li>{@link AccessibilityNodeInfo#ACTION_ACCESSIBILITY_FOCUS} |
| 967 | * <li>{@link AccessibilityNodeInfo#ACTION_CLEAR_ACCESSIBILITY_FOCUS} |
| 968 | * <li>{@link AccessibilityNodeInfo#ACTION_CLEAR_FOCUS} |
| 969 | * <li>{@link AccessibilityNodeInfo#ACTION_CLEAR_SELECTION} |
| 970 | * <li>{@link AccessibilityNodeInfo#ACTION_CLICK} |
| 971 | * <li>etc. |
| 972 | * </ul> |
Svetoslav Ganov | 6d17a93 | 2012-04-27 19:30:38 -0700 | [diff] [blame] | 973 | * |
| 974 | * @param action The action. |
Svetoslav Ganov | 6d17a93 | 2012-04-27 19:30:38 -0700 | [diff] [blame] | 975 | * @throws IllegalStateException If called from an AccessibilityService. |
Alan Viverette | af43110 | 2013-10-04 13:16:51 -0700 | [diff] [blame] | 976 | * @see AccessibilityNodeInfo#performAction(int) |
Svetoslav Ganov | 6d17a93 | 2012-04-27 19:30:38 -0700 | [diff] [blame] | 977 | */ |
| 978 | public void setAction(int action) { |
| 979 | enforceNotSealed(); |
| 980 | mAction = action; |
| 981 | } |
| 982 | |
| 983 | /** |
| 984 | * Gets the performed action that triggered this event. |
| 985 | * |
| 986 | * @return The action. |
| 987 | */ |
| 988 | public int getAction() { |
| 989 | return mAction; |
| 990 | } |
| 991 | |
| 992 | /** |
svetoslavganov | 75986cf | 2009-05-14 22:28:01 -0700 | [diff] [blame] | 993 | * Returns a cached instance if such is available or a new one is |
Svetoslav Ganov | 38e8b4e | 2011-06-29 20:00:53 -0700 | [diff] [blame] | 994 | * instantiated with its type property set. |
svetoslavganov | 75986cf | 2009-05-14 22:28:01 -0700 | [diff] [blame] | 995 | * |
| 996 | * @param eventType The event type. |
| 997 | * @return An instance. |
| 998 | */ |
| 999 | public static AccessibilityEvent obtain(int eventType) { |
| 1000 | AccessibilityEvent event = AccessibilityEvent.obtain(); |
| 1001 | event.setEventType(eventType); |
| 1002 | return event; |
| 1003 | } |
| 1004 | |
| 1005 | /** |
| 1006 | * Returns a cached instance if such is available or a new one is |
Svetoslav Ganov | 35bfede | 2011-07-14 17:57:06 -0700 | [diff] [blame] | 1007 | * created. The returned instance is initialized from the given |
| 1008 | * <code>event</code>. |
Svetoslav Ganov | 8643aa0 | 2011-04-20 12:12:33 -0700 | [diff] [blame] | 1009 | * |
| 1010 | * @param event The other event. |
| 1011 | * @return An instance. |
| 1012 | */ |
| 1013 | public static AccessibilityEvent obtain(AccessibilityEvent event) { |
| 1014 | AccessibilityEvent eventClone = AccessibilityEvent.obtain(); |
| 1015 | eventClone.init(event); |
| 1016 | |
Alan Viverette | 502cb33 | 2013-10-15 18:29:53 -0700 | [diff] [blame] | 1017 | if (event.mRecords != null) { |
| 1018 | final int recordCount = event.mRecords.size(); |
| 1019 | eventClone.mRecords = new ArrayList<AccessibilityRecord>(recordCount); |
| 1020 | for (int i = 0; i < recordCount; i++) { |
| 1021 | final AccessibilityRecord record = event.mRecords.get(i); |
| 1022 | final AccessibilityRecord recordClone = AccessibilityRecord.obtain(record); |
| 1023 | eventClone.mRecords.add(recordClone); |
| 1024 | } |
Svetoslav Ganov | 8643aa0 | 2011-04-20 12:12:33 -0700 | [diff] [blame] | 1025 | } |
| 1026 | |
| 1027 | return eventClone; |
| 1028 | } |
| 1029 | |
| 1030 | /** |
| 1031 | * Returns a cached instance if such is available or a new one is |
svetoslavganov | 75986cf | 2009-05-14 22:28:01 -0700 | [diff] [blame] | 1032 | * instantiated. |
| 1033 | * |
| 1034 | * @return An instance. |
| 1035 | */ |
| 1036 | public static AccessibilityEvent obtain() { |
Svetoslav Ganov | f4782ec | 2012-11-28 09:11:41 -0800 | [diff] [blame] | 1037 | AccessibilityEvent event = sPool.acquire(); |
| 1038 | return (event != null) ? event : new AccessibilityEvent(); |
svetoslavganov | 75986cf | 2009-05-14 22:28:01 -0700 | [diff] [blame] | 1039 | } |
| 1040 | |
| 1041 | /** |
Svetoslav Ganov | 38e8b4e | 2011-06-29 20:00:53 -0700 | [diff] [blame] | 1042 | * Recycles an instance back to be reused. |
svetoslavganov | 75986cf | 2009-05-14 22:28:01 -0700 | [diff] [blame] | 1043 | * <p> |
Svetoslav Ganov | 38e8b4e | 2011-06-29 20:00:53 -0700 | [diff] [blame] | 1044 | * <b>Note: You must not touch the object after calling this function.</b> |
| 1045 | * </p> |
Svetoslav Ganov | 887e1a1 | 2011-04-29 15:09:28 -0700 | [diff] [blame] | 1046 | * |
| 1047 | * @throws IllegalStateException If the event is already recycled. |
svetoslavganov | 75986cf | 2009-05-14 22:28:01 -0700 | [diff] [blame] | 1048 | */ |
Svetoslav Ganov | 736c275 | 2011-04-22 18:30:36 -0700 | [diff] [blame] | 1049 | @Override |
svetoslavganov | 75986cf | 2009-05-14 22:28:01 -0700 | [diff] [blame] | 1050 | public void recycle() { |
svetoslavganov | 75986cf | 2009-05-14 22:28:01 -0700 | [diff] [blame] | 1051 | clear(); |
Svetoslav Ganov | f4782ec | 2012-11-28 09:11:41 -0800 | [diff] [blame] | 1052 | sPool.release(this); |
svetoslavganov | 75986cf | 2009-05-14 22:28:01 -0700 | [diff] [blame] | 1053 | } |
| 1054 | |
| 1055 | /** |
| 1056 | * Clears the state of this instance. |
Svetoslav Ganov | 8643aa0 | 2011-04-20 12:12:33 -0700 | [diff] [blame] | 1057 | * |
| 1058 | * @hide |
svetoslavganov | 75986cf | 2009-05-14 22:28:01 -0700 | [diff] [blame] | 1059 | */ |
Svetoslav Ganov | 736c275 | 2011-04-22 18:30:36 -0700 | [diff] [blame] | 1060 | @Override |
| 1061 | protected void clear() { |
| 1062 | super.clear(); |
svetoslavganov | 75986cf | 2009-05-14 22:28:01 -0700 | [diff] [blame] | 1063 | mEventType = 0; |
Svetoslav Ganov | 2b435aa | 2012-05-04 17:16:37 -0700 | [diff] [blame] | 1064 | mMovementGranularity = 0; |
Svetoslav Ganov | 6d17a93 | 2012-04-27 19:30:38 -0700 | [diff] [blame] | 1065 | mAction = 0; |
Alan Viverette | 77e9a28 | 2013-09-12 17:16:09 -0700 | [diff] [blame] | 1066 | mContentChangeTypes = 0; |
Adam Powell | 3fb3d7c | 2011-04-22 17:08:55 -0700 | [diff] [blame] | 1067 | mPackageName = null; |
Svetoslav Ganov | 736c275 | 2011-04-22 18:30:36 -0700 | [diff] [blame] | 1068 | mEventTime = 0; |
Alan Viverette | 502cb33 | 2013-10-15 18:29:53 -0700 | [diff] [blame] | 1069 | if (mRecords != null) { |
| 1070 | while (!mRecords.isEmpty()) { |
| 1071 | AccessibilityRecord record = mRecords.remove(0); |
| 1072 | record.recycle(); |
| 1073 | } |
svetoslavganov | 75986cf | 2009-05-14 22:28:01 -0700 | [diff] [blame] | 1074 | } |
| 1075 | } |
| 1076 | |
| 1077 | /** |
| 1078 | * Creates a new instance from a {@link Parcel}. |
| 1079 | * |
| 1080 | * @param parcel A parcel containing the state of a {@link AccessibilityEvent}. |
| 1081 | */ |
| 1082 | public void initFromParcel(Parcel parcel) { |
Svetoslav Ganov | d116d7c | 2011-11-21 18:41:59 -0800 | [diff] [blame] | 1083 | mSealed = (parcel.readInt() == 1); |
svetoslavganov | 75986cf | 2009-05-14 22:28:01 -0700 | [diff] [blame] | 1084 | mEventType = parcel.readInt(); |
Svetoslav Ganov | 2b435aa | 2012-05-04 17:16:37 -0700 | [diff] [blame] | 1085 | mMovementGranularity = parcel.readInt(); |
Svetoslav Ganov | 6d17a93 | 2012-04-27 19:30:38 -0700 | [diff] [blame] | 1086 | mAction = parcel.readInt(); |
Alan Viverette | 77e9a28 | 2013-09-12 17:16:09 -0700 | [diff] [blame] | 1087 | mContentChangeTypes = parcel.readInt(); |
Adam Powell | 3fb3d7c | 2011-04-22 17:08:55 -0700 | [diff] [blame] | 1088 | mPackageName = TextUtils.CHAR_SEQUENCE_CREATOR.createFromParcel(parcel); |
Svetoslav Ganov | 736c275 | 2011-04-22 18:30:36 -0700 | [diff] [blame] | 1089 | mEventTime = parcel.readLong(); |
Svetoslav Ganov | d116d7c | 2011-11-21 18:41:59 -0800 | [diff] [blame] | 1090 | mConnectionId = parcel.readInt(); |
Svetoslav Ganov | 736c275 | 2011-04-22 18:30:36 -0700 | [diff] [blame] | 1091 | readAccessibilityRecordFromParcel(this, parcel); |
| 1092 | |
| 1093 | // Read the records. |
| 1094 | final int recordCount = parcel.readInt(); |
Alan Viverette | 502cb33 | 2013-10-15 18:29:53 -0700 | [diff] [blame] | 1095 | if (recordCount > 0) { |
| 1096 | mRecords = new ArrayList<AccessibilityRecord>(recordCount); |
| 1097 | for (int i = 0; i < recordCount; i++) { |
| 1098 | AccessibilityRecord record = AccessibilityRecord.obtain(); |
| 1099 | readAccessibilityRecordFromParcel(record, parcel); |
| 1100 | record.mConnectionId = mConnectionId; |
| 1101 | mRecords.add(record); |
| 1102 | } |
Svetoslav Ganov | 736c275 | 2011-04-22 18:30:36 -0700 | [diff] [blame] | 1103 | } |
svetoslavganov | 75986cf | 2009-05-14 22:28:01 -0700 | [diff] [blame] | 1104 | } |
| 1105 | |
Svetoslav Ganov | 736c275 | 2011-04-22 18:30:36 -0700 | [diff] [blame] | 1106 | /** |
| 1107 | * Reads an {@link AccessibilityRecord} from a parcel. |
| 1108 | * |
| 1109 | * @param record The record to initialize. |
| 1110 | * @param parcel The parcel to read from. |
| 1111 | */ |
| 1112 | private void readAccessibilityRecordFromParcel(AccessibilityRecord record, |
| 1113 | Parcel parcel) { |
| 1114 | record.mBooleanProperties = parcel.readInt(); |
| 1115 | record.mCurrentItemIndex = parcel.readInt(); |
| 1116 | record.mItemCount = parcel.readInt(); |
| 1117 | record.mFromIndex = parcel.readInt(); |
Svetoslav Ganov | a015617 | 2011-06-26 17:55:44 -0700 | [diff] [blame] | 1118 | record.mToIndex = parcel.readInt(); |
| 1119 | record.mScrollX = parcel.readInt(); |
| 1120 | record.mScrollY = parcel.readInt(); |
Svetoslav Ganov | d9ee72f | 2011-10-05 22:26:05 -0700 | [diff] [blame] | 1121 | record.mMaxScrollX = parcel.readInt(); |
| 1122 | record.mMaxScrollY = parcel.readInt(); |
Svetoslav Ganov | 736c275 | 2011-04-22 18:30:36 -0700 | [diff] [blame] | 1123 | record.mAddedCount = parcel.readInt(); |
| 1124 | record.mRemovedCount = parcel.readInt(); |
| 1125 | record.mClassName = TextUtils.CHAR_SEQUENCE_CREATOR.createFromParcel(parcel); |
| 1126 | record.mContentDescription = TextUtils.CHAR_SEQUENCE_CREATOR.createFromParcel(parcel); |
| 1127 | record.mBeforeText = TextUtils.CHAR_SEQUENCE_CREATOR.createFromParcel(parcel); |
| 1128 | record.mParcelableData = parcel.readParcelable(null); |
| 1129 | parcel.readList(record.mText, null); |
Svetoslav Ganov | eeee4d2 | 2011-06-10 20:51:30 -0700 | [diff] [blame] | 1130 | record.mSourceWindowId = parcel.readInt(); |
Phil Weaver | 651fe9f | 2017-05-24 16:43:46 -0700 | [diff] [blame] | 1131 | record.mSourceNodeId = parcel.readLong(); |
Svetoslav Ganov | eeee4d2 | 2011-06-10 20:51:30 -0700 | [diff] [blame] | 1132 | record.mSealed = (parcel.readInt() == 1); |
Svetoslav Ganov | 736c275 | 2011-04-22 18:30:36 -0700 | [diff] [blame] | 1133 | } |
| 1134 | |
| 1135 | /** |
| 1136 | * {@inheritDoc} |
| 1137 | */ |
svetoslavganov | 75986cf | 2009-05-14 22:28:01 -0700 | [diff] [blame] | 1138 | public void writeToParcel(Parcel parcel, int flags) { |
Svetoslav Ganov | 8643aa0 | 2011-04-20 12:12:33 -0700 | [diff] [blame] | 1139 | parcel.writeInt(isSealed() ? 1 : 0); |
svetoslavganov | 75986cf | 2009-05-14 22:28:01 -0700 | [diff] [blame] | 1140 | parcel.writeInt(mEventType); |
Svetoslav Ganov | 2b435aa | 2012-05-04 17:16:37 -0700 | [diff] [blame] | 1141 | parcel.writeInt(mMovementGranularity); |
Svetoslav Ganov | 6d17a93 | 2012-04-27 19:30:38 -0700 | [diff] [blame] | 1142 | parcel.writeInt(mAction); |
Alan Viverette | 77e9a28 | 2013-09-12 17:16:09 -0700 | [diff] [blame] | 1143 | parcel.writeInt(mContentChangeTypes); |
Adam Powell | 3fb3d7c | 2011-04-22 17:08:55 -0700 | [diff] [blame] | 1144 | TextUtils.writeToParcel(mPackageName, parcel, 0); |
Svetoslav Ganov | 736c275 | 2011-04-22 18:30:36 -0700 | [diff] [blame] | 1145 | parcel.writeLong(mEventTime); |
Svetoslav Ganov | d116d7c | 2011-11-21 18:41:59 -0800 | [diff] [blame] | 1146 | parcel.writeInt(mConnectionId); |
Svetoslav Ganov | 736c275 | 2011-04-22 18:30:36 -0700 | [diff] [blame] | 1147 | writeAccessibilityRecordToParcel(this, parcel, flags); |
| 1148 | |
| 1149 | // Write the records. |
| 1150 | final int recordCount = getRecordCount(); |
| 1151 | parcel.writeInt(recordCount); |
| 1152 | for (int i = 0; i < recordCount; i++) { |
| 1153 | AccessibilityRecord record = mRecords.get(i); |
| 1154 | writeAccessibilityRecordToParcel(record, parcel, flags); |
| 1155 | } |
svetoslavganov | 75986cf | 2009-05-14 22:28:01 -0700 | [diff] [blame] | 1156 | } |
| 1157 | |
Svetoslav Ganov | 736c275 | 2011-04-22 18:30:36 -0700 | [diff] [blame] | 1158 | /** |
| 1159 | * Writes an {@link AccessibilityRecord} to a parcel. |
| 1160 | * |
| 1161 | * @param record The record to write. |
| 1162 | * @param parcel The parcel to which to write. |
| 1163 | */ |
| 1164 | private void writeAccessibilityRecordToParcel(AccessibilityRecord record, Parcel parcel, |
| 1165 | int flags) { |
| 1166 | parcel.writeInt(record.mBooleanProperties); |
| 1167 | parcel.writeInt(record.mCurrentItemIndex); |
| 1168 | parcel.writeInt(record.mItemCount); |
| 1169 | parcel.writeInt(record.mFromIndex); |
Svetoslav Ganov | a015617 | 2011-06-26 17:55:44 -0700 | [diff] [blame] | 1170 | parcel.writeInt(record.mToIndex); |
| 1171 | parcel.writeInt(record.mScrollX); |
| 1172 | parcel.writeInt(record.mScrollY); |
Svetoslav Ganov | d9ee72f | 2011-10-05 22:26:05 -0700 | [diff] [blame] | 1173 | parcel.writeInt(record.mMaxScrollX); |
| 1174 | parcel.writeInt(record.mMaxScrollY); |
Svetoslav Ganov | 736c275 | 2011-04-22 18:30:36 -0700 | [diff] [blame] | 1175 | parcel.writeInt(record.mAddedCount); |
| 1176 | parcel.writeInt(record.mRemovedCount); |
| 1177 | TextUtils.writeToParcel(record.mClassName, parcel, flags); |
| 1178 | TextUtils.writeToParcel(record.mContentDescription, parcel, flags); |
| 1179 | TextUtils.writeToParcel(record.mBeforeText, parcel, flags); |
| 1180 | parcel.writeParcelable(record.mParcelableData, flags); |
| 1181 | parcel.writeList(record.mText); |
Svetoslav Ganov | eeee4d2 | 2011-06-10 20:51:30 -0700 | [diff] [blame] | 1182 | parcel.writeInt(record.mSourceWindowId); |
Phil Weaver | 651fe9f | 2017-05-24 16:43:46 -0700 | [diff] [blame] | 1183 | parcel.writeLong(record.mSourceNodeId); |
Svetoslav Ganov | eeee4d2 | 2011-06-10 20:51:30 -0700 | [diff] [blame] | 1184 | parcel.writeInt(record.mSealed ? 1 : 0); |
Svetoslav Ganov | 736c275 | 2011-04-22 18:30:36 -0700 | [diff] [blame] | 1185 | } |
| 1186 | |
| 1187 | /** |
| 1188 | * {@inheritDoc} |
| 1189 | */ |
svetoslavganov | 75986cf | 2009-05-14 22:28:01 -0700 | [diff] [blame] | 1190 | public int describeContents() { |
| 1191 | return 0; |
| 1192 | } |
| 1193 | |
| 1194 | @Override |
| 1195 | public String toString() { |
| 1196 | StringBuilder builder = new StringBuilder(); |
Svetoslav Ganov | 38e8b4e | 2011-06-29 20:00:53 -0700 | [diff] [blame] | 1197 | builder.append("EventType: ").append(eventTypeToString(mEventType)); |
Svetoslav Ganov | cc4053e | 2011-05-23 13:37:44 -0700 | [diff] [blame] | 1198 | builder.append("; EventTime: ").append(mEventTime); |
| 1199 | builder.append("; PackageName: ").append(mPackageName); |
Svetoslav Ganov | 2b435aa | 2012-05-04 17:16:37 -0700 | [diff] [blame] | 1200 | builder.append("; MovementGranularity: ").append(mMovementGranularity); |
Svetoslav Ganov | 6d17a93 | 2012-04-27 19:30:38 -0700 | [diff] [blame] | 1201 | builder.append("; Action: ").append(mAction); |
Svetoslav Ganov | 736c275 | 2011-04-22 18:30:36 -0700 | [diff] [blame] | 1202 | builder.append(super.toString()); |
Svetoslav Ganov | 8643aa0 | 2011-04-20 12:12:33 -0700 | [diff] [blame] | 1203 | if (DEBUG) { |
Svetoslav Ganov | 736c275 | 2011-04-22 18:30:36 -0700 | [diff] [blame] | 1204 | builder.append("\n"); |
Eugene Susla | 4a34f9c | 2017-05-16 14:16:38 -0700 | [diff] [blame] | 1205 | builder.append("; ContentChangeTypes: ").append( |
| 1206 | contentChangeTypesToString(mContentChangeTypes)); |
Svetoslav Ganov | eeee4d2 | 2011-06-10 20:51:30 -0700 | [diff] [blame] | 1207 | builder.append("; sourceWindowId: ").append(mSourceWindowId); |
Phil Weaver | 651fe9f | 2017-05-24 16:43:46 -0700 | [diff] [blame] | 1208 | builder.append("; mSourceNodeId: ").append(mSourceNodeId); |
Alan Viverette | 502cb33 | 2013-10-15 18:29:53 -0700 | [diff] [blame] | 1209 | for (int i = 0; i < getRecordCount(); i++) { |
| 1210 | final AccessibilityRecord record = getRecord(i); |
Svetoslav Ganov | 8643aa0 | 2011-04-20 12:12:33 -0700 | [diff] [blame] | 1211 | builder.append(" Record "); |
| 1212 | builder.append(i); |
| 1213 | builder.append(":"); |
| 1214 | builder.append(" [ ClassName: " + record.mClassName); |
| 1215 | builder.append("; Text: " + record.mText); |
| 1216 | builder.append("; ContentDescription: " + record.mContentDescription); |
| 1217 | builder.append("; ItemCount: " + record.mItemCount); |
| 1218 | builder.append("; CurrentItemIndex: " + record.mCurrentItemIndex); |
| 1219 | builder.append("; IsEnabled: " + record.isEnabled()); |
| 1220 | builder.append("; IsPassword: " + record.isPassword()); |
| 1221 | builder.append("; IsChecked: " + record.isChecked()); |
| 1222 | builder.append("; IsFullScreen: " + record.isFullScreen()); |
Svetoslav Ganov | a015617 | 2011-06-26 17:55:44 -0700 | [diff] [blame] | 1223 | builder.append("; Scrollable: " + record.isScrollable()); |
Svetoslav Ganov | 8643aa0 | 2011-04-20 12:12:33 -0700 | [diff] [blame] | 1224 | builder.append("; BeforeText: " + record.mBeforeText); |
| 1225 | builder.append("; FromIndex: " + record.mFromIndex); |
Svetoslav Ganov | a015617 | 2011-06-26 17:55:44 -0700 | [diff] [blame] | 1226 | builder.append("; ToIndex: " + record.mToIndex); |
| 1227 | builder.append("; ScrollX: " + record.mScrollX); |
| 1228 | builder.append("; ScrollY: " + record.mScrollY); |
Svetoslav Ganov | 8643aa0 | 2011-04-20 12:12:33 -0700 | [diff] [blame] | 1229 | builder.append("; AddedCount: " + record.mAddedCount); |
| 1230 | builder.append("; RemovedCount: " + record.mRemovedCount); |
| 1231 | builder.append("; ParcelableData: " + record.mParcelableData); |
| 1232 | builder.append(" ]"); |
| 1233 | builder.append("\n"); |
| 1234 | } |
| 1235 | } else { |
Svetoslav Ganov | e4aa13b | 2011-07-31 20:43:45 -0700 | [diff] [blame] | 1236 | builder.append("; recordCount: ").append(getRecordCount()); |
Svetoslav Ganov | 736c275 | 2011-04-22 18:30:36 -0700 | [diff] [blame] | 1237 | } |
svetoslavganov | 75986cf | 2009-05-14 22:28:01 -0700 | [diff] [blame] | 1238 | return builder.toString(); |
| 1239 | } |
| 1240 | |
| 1241 | /** |
Svetoslav Ganov | cc4053e | 2011-05-23 13:37:44 -0700 | [diff] [blame] | 1242 | * Returns the string representation of an event type. For example, |
| 1243 | * {@link #TYPE_VIEW_CLICKED} is represented by the string TYPE_VIEW_CLICKED. |
| 1244 | * |
Svetoslav Ganov | 38e8b4e | 2011-06-29 20:00:53 -0700 | [diff] [blame] | 1245 | * @param eventType The event type |
Svetoslav Ganov | cc4053e | 2011-05-23 13:37:44 -0700 | [diff] [blame] | 1246 | * @return The string representation. |
| 1247 | */ |
Svetoslav Ganov | 38e8b4e | 2011-06-29 20:00:53 -0700 | [diff] [blame] | 1248 | public static String eventTypeToString(int eventType) { |
Svetoslav Ganov | 6ce77cd | 2012-11-21 16:35:57 -0800 | [diff] [blame] | 1249 | if (eventType == TYPES_ALL_MASK) { |
| 1250 | return "TYPES_ALL_MASK"; |
Svetoslav Ganov | cc4053e | 2011-05-23 13:37:44 -0700 | [diff] [blame] | 1251 | } |
Svetoslav Ganov | 6ce77cd | 2012-11-21 16:35:57 -0800 | [diff] [blame] | 1252 | StringBuilder builder = new StringBuilder(); |
| 1253 | int eventTypeCount = 0; |
| 1254 | while (eventType != 0) { |
| 1255 | final int eventTypeFlag = 1 << Integer.numberOfTrailingZeros(eventType); |
| 1256 | eventType &= ~eventTypeFlag; |
Eugene Susla | 3b86707 | 2017-05-16 13:40:31 -0700 | [diff] [blame] | 1257 | |
| 1258 | if (eventTypeCount > 0) { |
| 1259 | builder.append(", "); |
Svetoslav Ganov | 6ce77cd | 2012-11-21 16:35:57 -0800 | [diff] [blame] | 1260 | } |
Eugene Susla | 3b86707 | 2017-05-16 13:40:31 -0700 | [diff] [blame] | 1261 | builder.append(singleEventTypeToString(eventTypeFlag)); |
| 1262 | |
| 1263 | eventTypeCount++; |
Svetoslav Ganov | 6ce77cd | 2012-11-21 16:35:57 -0800 | [diff] [blame] | 1264 | } |
| 1265 | if (eventTypeCount > 1) { |
| 1266 | builder.insert(0, '['); |
| 1267 | builder.append(']'); |
| 1268 | } |
| 1269 | return builder.toString(); |
Svetoslav Ganov | cc4053e | 2011-05-23 13:37:44 -0700 | [diff] [blame] | 1270 | } |
| 1271 | |
Eugene Susla | 3b86707 | 2017-05-16 13:40:31 -0700 | [diff] [blame] | 1272 | private static String singleEventTypeToString(int eventType) { |
| 1273 | switch (eventType) { |
| 1274 | case TYPE_VIEW_CLICKED: return "TYPE_VIEW_CLICKED"; |
| 1275 | case TYPE_VIEW_LONG_CLICKED: return "TYPE_VIEW_LONG_CLICKED"; |
| 1276 | case TYPE_VIEW_SELECTED: return "TYPE_VIEW_SELECTED"; |
| 1277 | case TYPE_VIEW_FOCUSED: return "TYPE_VIEW_FOCUSED"; |
| 1278 | case TYPE_VIEW_TEXT_CHANGED: return "TYPE_VIEW_TEXT_CHANGED"; |
| 1279 | case TYPE_WINDOW_STATE_CHANGED: return "TYPE_WINDOW_STATE_CHANGED"; |
| 1280 | case TYPE_VIEW_HOVER_ENTER: return "TYPE_VIEW_HOVER_ENTER"; |
| 1281 | case TYPE_VIEW_HOVER_EXIT: return "TYPE_VIEW_HOVER_EXIT"; |
| 1282 | case TYPE_NOTIFICATION_STATE_CHANGED: return "TYPE_NOTIFICATION_STATE_CHANGED"; |
| 1283 | case TYPE_TOUCH_EXPLORATION_GESTURE_START: { |
| 1284 | return "TYPE_TOUCH_EXPLORATION_GESTURE_START"; |
| 1285 | } |
| 1286 | case TYPE_TOUCH_EXPLORATION_GESTURE_END: return "TYPE_TOUCH_EXPLORATION_GESTURE_END"; |
| 1287 | case TYPE_WINDOW_CONTENT_CHANGED: return "TYPE_WINDOW_CONTENT_CHANGED"; |
| 1288 | case TYPE_VIEW_TEXT_SELECTION_CHANGED: return "TYPE_VIEW_TEXT_SELECTION_CHANGED"; |
| 1289 | case TYPE_VIEW_SCROLLED: return "TYPE_VIEW_SCROLLED"; |
| 1290 | case TYPE_ANNOUNCEMENT: return "TYPE_ANNOUNCEMENT"; |
| 1291 | case TYPE_VIEW_ACCESSIBILITY_FOCUSED: return "TYPE_VIEW_ACCESSIBILITY_FOCUSED"; |
| 1292 | case TYPE_VIEW_ACCESSIBILITY_FOCUS_CLEARED: { |
| 1293 | return "TYPE_VIEW_ACCESSIBILITY_FOCUS_CLEARED"; |
| 1294 | } |
| 1295 | case TYPE_VIEW_TEXT_TRAVERSED_AT_MOVEMENT_GRANULARITY: { |
| 1296 | return "TYPE_VIEW_TEXT_TRAVERSED_AT_MOVEMENT_GRANULARITY"; |
| 1297 | } |
| 1298 | case TYPE_GESTURE_DETECTION_START: return "TYPE_GESTURE_DETECTION_START"; |
| 1299 | case TYPE_GESTURE_DETECTION_END: return "TYPE_GESTURE_DETECTION_END"; |
| 1300 | case TYPE_TOUCH_INTERACTION_START: return "TYPE_TOUCH_INTERACTION_START"; |
| 1301 | case TYPE_TOUCH_INTERACTION_END: return "TYPE_TOUCH_INTERACTION_END"; |
| 1302 | case TYPE_WINDOWS_CHANGED: return "TYPE_WINDOWS_CHANGED"; |
| 1303 | case TYPE_VIEW_CONTEXT_CLICKED: return "TYPE_VIEW_CONTEXT_CLICKED"; |
| 1304 | case TYPE_ASSIST_READING_CONTEXT: return "TYPE_ASSIST_READING_CONTEXT"; |
| 1305 | default: return Integer.toHexString(eventType); |
| 1306 | } |
| 1307 | } |
| 1308 | |
Svetoslav Ganov | cc4053e | 2011-05-23 13:37:44 -0700 | [diff] [blame] | 1309 | /** |
svetoslavganov | 75986cf | 2009-05-14 22:28:01 -0700 | [diff] [blame] | 1310 | * @see Parcelable.Creator |
| 1311 | */ |
| 1312 | public static final Parcelable.Creator<AccessibilityEvent> CREATOR = |
| 1313 | new Parcelable.Creator<AccessibilityEvent>() { |
| 1314 | public AccessibilityEvent createFromParcel(Parcel parcel) { |
| 1315 | AccessibilityEvent event = AccessibilityEvent.obtain(); |
| 1316 | event.initFromParcel(parcel); |
| 1317 | return event; |
| 1318 | } |
| 1319 | |
| 1320 | public AccessibilityEvent[] newArray(int size) { |
| 1321 | return new AccessibilityEvent[size]; |
| 1322 | } |
| 1323 | }; |
| 1324 | } |