/* * Copyright (C) 2011 The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package android.support.v4.view.accessibility; import android.graphics.Rect; import android.os.Build; import android.os.Bundle; import android.support.v4.accessibilityservice.AccessibilityServiceInfoCompat; import android.support.v4.view.ViewCompat; import android.view.View; import android.view.accessibility.AccessibilityEvent; import java.util.ArrayList; import java.util.Collections; import java.util.List; /** * Helper for accessing {@link android.view.accessibility.AccessibilityNodeInfo} * introduced after API level 4 in a backwards compatible fashion. */ public class AccessibilityNodeInfoCompat { static interface AccessibilityNodeInfoImpl { public Object obtain(); public Object obtain(View source); public Object obtain(Object info); public Object obtain(View root, int virtualDescendantId); public void setSource(Object info, View source); public void setSource(Object info, View root, int virtualDescendantId); public Object findFocus(Object info, int focus); public Object focusSearch(Object info, int direction); public int getWindowId(Object info); public int getChildCount(Object info); public Object getChild(Object info, int index); public void addChild(Object info, View child); public void addChild(Object info, View child, int virtualDescendantId); public int getActions(Object info); public void addAction(Object info, int action); public boolean performAction(Object info, int action); public boolean performAction(Object info, int action, Bundle arguments); public void setMovementGranularities(Object info, int granularities); public int getMovementGranularities(Object info); public List
* * @see #ACTION_ARGUMENT_MOVEMENT_GRANULARITY_INT * @see #ACTION_ARGUMENT_EXTEND_SELECTION_BOOLEAN * * @see #setMovementGranularities(int) * @see #getMovementGranularities() * * @see #MOVEMENT_GRANULARITY_CHARACTER * @see #MOVEMENT_GRANULARITY_WORD * @see #MOVEMENT_GRANULARITY_LINE * @see #MOVEMENT_GRANULARITY_PARAGRAPH * @see #MOVEMENT_GRANULARITY_PAGE */ public static final int ACTION_NEXT_AT_MOVEMENT_GRANULARITY = 0x00000100; /** * Action that requests to go to the previous entity in this node's text * at a given movement granularity. For example, move to the next character, * word, etc. *
* Arguments: {@link #ACTION_ARGUMENT_MOVEMENT_GRANULARITY_INT}<,
* {@link #ACTION_ARGUMENT_EXTEND_SELECTION_BOOLEAN}
* Bundle arguments = new Bundle();
* arguments.putInt(AccessibilityNodeInfo.ACTION_ARGUMENT_MOVEMENT_GRANULARITY_INT,
* AccessibilityNodeInfo.MOVEMENT_GRANULARITY_CHARACTER);
* arguments.putBoolean(AccessibilityNodeInfo.ACTION_ARGUMENT_EXTEND_SELECTION_BOOLEAN,
* false);
* info.performAction(AccessibilityNodeInfo.ACTION_PREVIOUS_AT_MOVEMENT_GRANULARITY,
* arguments);
*
* Example: Move to the next character and do not extend selection.
*
* Arguments: {@link #ACTION_ARGUMENT_HTML_ELEMENT_STRING}
* Bundle arguments = new Bundle();
* arguments.putString(AccessibilityNodeInfo.ACTION_ARGUMENT_HTML_ELEMENT_STRING, "BUTTON");
* info.performAction(AccessibilityNodeInfo.ACTION_NEXT_HTML_ELEMENT, arguments);
*
* Example:
*
* Arguments: {@link #ACTION_ARGUMENT_HTML_ELEMENT_STRING}
* Bundle arguments = new Bundle();
* arguments.putString(AccessibilityNodeInfo.ACTION_ARGUMENT_HTML_ELEMENT_STRING, "BUTTON");
* info.performAction(AccessibilityNodeInfo.ACTION_PREVIOUS_HTML_ELEMENT, arguments);
*
* Example:
*
* Arguments: {@link #ACTION_ARGUMENT_SELECTION_START_INT},
* {@link #ACTION_ARGUMENT_SELECTION_END_INT}
* Bundle arguments = new Bundle();
* arguments.putInt(AccessibilityNodeInfo.ACTION_ARGUMENT_SELECTION_START_INT, 1);
* arguments.putInt(AccessibilityNodeInfo.ACTION_ARGUMENT_SELECTION_END_INT, 2);
* info.performAction(AccessibilityNodeInfo.ACTION_SET_SELECTION, arguments);
*
* Example:
*
* Type: int
* Actions: {@link #ACTION_NEXT_AT_MOVEMENT_GRANULARITY},
* {@link #ACTION_PREVIOUS_AT_MOVEMENT_GRANULARITY}
*
* Type: String
* Actions: {@link #ACTION_NEXT_HTML_ELEMENT},
* {@link #ACTION_PREVIOUS_HTML_ELEMENT}
*
* Type: boolean
* Actions: {@link #ACTION_NEXT_AT_MOVEMENT_GRANULARITY},
* {@link #ACTION_PREVIOUS_AT_MOVEMENT_GRANULARITY}
*
* Type: int
* Actions: {@link #ACTION_SET_SELECTION}
*
* Type: int
* Actions: {@link #ACTION_SET_SELECTION}
*
info
.
*
* @param info The other info.
* @return An instance.
*/
public static AccessibilityNodeInfoCompat obtain(AccessibilityNodeInfoCompat info) {
return AccessibilityNodeInfoCompat.wrapNonNullInstance(IMPL.obtain(info.mInfo));
}
/**
* Sets the source.
*
* @param source The info source.
*/
public void setSource(View source) {
IMPL.setSource(mInfo, source);
}
/**
* Sets the source to be a virtual descendant of the given root
.
* If virtualDescendantId
is {@link View#NO_ID} the root
* is set as the source.
* * A virtual descendant is an imaginary View that is reported as a part of the view * hierarchy for accessibility purposes. This enables custom views that draw complex * content to report themselves as a tree of virtual views, thus conveying their * logical structure. *
** Note: Cannot be called from an * {@link android.accessibilityservice.AccessibilityService}. * This class is made immutable before being delivered to an AccessibilityService. *
* * @param root The root of the virtual subtree. * @param virtualDescendantId The id of the virtual descendant. */ public void setSource(View root, int virtualDescendantId) { IMPL.setSource(mInfo, root, virtualDescendantId); } /** * Find the view that has the specified focus type. The search starts from * the view represented by this node info. * * @param focus The focus to find. One of {@link #FOCUS_INPUT} or * {@link #FOCUS_ACCESSIBILITY}. * @return The node info of the focused view or null. * * @see #FOCUS_INPUT * @see #FOCUS_ACCESSIBILITY */ public AccessibilityNodeInfoCompat findFocus(int focus) { return AccessibilityNodeInfoCompat.wrapNonNullInstance(IMPL.findFocus(mInfo, focus)); } /** * Searches for the nearest view in the specified direction that can take * input focus. * * @param direction The direction. Can be one of: * {@link View#FOCUS_DOWN}, * {@link View#FOCUS_UP}, * {@link View#FOCUS_LEFT}, * {@link View#FOCUS_RIGHT}, * {@link View#FOCUS_FORWARD}, * {@link View#FOCUS_BACKWARD}. * * @return The node info for the view that can take accessibility focus. */ public AccessibilityNodeInfoCompat focusSearch(int direction) { return AccessibilityNodeInfoCompat.wrapNonNullInstance(IMPL.focusSearch(mInfo, direction)); } /** * Gets the id of the window from which the info comes from. * * @return The window id. */ public int getWindowId() { return IMPL.getWindowId(mInfo); } /** * Gets the number of children. * * @return The child count. */ public int getChildCount() { return IMPL.getChildCount(mInfo); } /** * Get the child at given index. ** Note: It is a client responsibility to recycle the * received info by calling {@link AccessibilityNodeInfoCompat#recycle()} to * avoid creating of multiple instances. *
* * @param index The child index. * @return The child node. * @throws IllegalStateException If called outside of an * AccessibilityService. */ public AccessibilityNodeInfoCompat getChild(int index) { return AccessibilityNodeInfoCompat.wrapNonNullInstance(IMPL.getChild(mInfo, index)); } /** * Adds a child. ** Note: Cannot be called from an * {@link android.accessibilityservice.AccessibilityService}. This class is * made immutable before being delivered to an AccessibilityService. *
* * @param child The child. * @throws IllegalStateException If called from an AccessibilityService. */ public void addChild(View child) { IMPL.addChild(mInfo, child); } /** * Adds a virtual child which is a descendant of the givenroot
.
* If virtualDescendantId
is {@link View#NO_ID} the root
* is added as a child.
* * A virtual descendant is an imaginary View that is reported as a part of the view * hierarchy for accessibility purposes. This enables custom views that draw complex * content to report them selves as a tree of virtual views, thus conveying their * logical structure. *
* * @param root The root of the virtual subtree. * @param virtualDescendantId The id of the virtual child. */ public void addChild(View root, int virtualDescendantId) { IMPL.addChild(mInfo, root, virtualDescendantId); } /** * Gets the actions that can be performed on the node. * * @return The bit mask of with actions. * @see android.view.accessibility.AccessibilityNodeInfo#ACTION_FOCUS * @see android.view.accessibility.AccessibilityNodeInfo#ACTION_CLEAR_FOCUS * @see android.view.accessibility.AccessibilityNodeInfo#ACTION_SELECT * @see android.view.accessibility.AccessibilityNodeInfo#ACTION_CLEAR_SELECTION */ public int getActions() { return IMPL.getActions(mInfo); } /** * Adds an action that can be performed on the node. ** Note: Cannot be called from an * {@link android.accessibilityservice.AccessibilityService}. This class is * made immutable before being delivered to an AccessibilityService. *
* * @param action The action. * @throws IllegalStateException If called from an AccessibilityService. */ public void addAction(int action) { IMPL.addAction(mInfo, action); } /** * Performs an action on the node. ** Note: An action can be performed only if the request is * made from an {@link android.accessibilityservice.AccessibilityService}. *
* * @param action The action to perform. * @return True if the action was performed. * @throws IllegalStateException If called outside of an * AccessibilityService. */ public boolean performAction(int action) { return IMPL.performAction(mInfo, action); } /** * Performs an action on the node. ** Note: An action can be performed only if the request is made * from an {@link android.accessibilityservice.AccessibilityService}. *
* * @param action The action to perform. * @param arguments A bundle with additional arguments. * @return True if the action was performed. * * @throws IllegalStateException If called outside of an AccessibilityService. */ public boolean performAction(int action, Bundle arguments) { return IMPL.performAction(mInfo, action, arguments); } /** * Sets the movement granularities for traversing the text of this node. ** Note: Cannot be called from an * {@link android.accessibilityservice.AccessibilityService}. * This class is made immutable before being delivered to an AccessibilityService. *
* * @param granularities The bit mask with granularities. * * @throws IllegalStateException If called from an AccessibilityService. */ public void setMovementGranularities(int granularities) { IMPL.setMovementGranularities(mInfo, granularities); } /** * Gets the movement granularities for traversing the text of this node. * * @return The bit mask with granularities. */ public int getMovementGranularities() { return IMPL.getMovementGranularities(mInfo); } /** * Finds {@link android.view.accessibility.AccessibilityNodeInfo}s by text. The match * is case insensitive containment. The search is relative to this info i.e. this * info is the root of the traversed tree. ** Note: It is a client responsibility to recycle the * received info by calling {@link android.view.accessibility.AccessibilityNodeInfo#recycle()} * to avoid creating of multiple instances. *
* * @param text The searched text. * @return A list of node info. */ public List* Note: It is a client responsibility to recycle the * received info by calling {@link android.view.accessibility.AccessibilityNodeInfo#recycle()} * to avoid creating of multiple instances. *
* * @return The parent. */ public AccessibilityNodeInfoCompat getParent() { return AccessibilityNodeInfoCompat.wrapNonNullInstance(IMPL.getParent(mInfo)); } /** * Sets the parent. ** Note: Cannot be called from an * {@link android.accessibilityservice.AccessibilityService}. This class is * made immutable before being delivered to an AccessibilityService. *
* * @param parent The parent. * @throws IllegalStateException If called from an AccessibilityService. */ public void setParent(View parent) { IMPL.setParent(mInfo, parent); } /** * Sets the parent to be a virtual descendant of the givenroot
.
* If virtualDescendantId
equals to {@link View#NO_ID} the root
* is set as the parent.
* * A virtual descendant is an imaginary View that is reported as a part of the view * hierarchy for accessibility purposes. This enables custom views that draw complex * content to report them selves as a tree of virtual views, thus conveying their * logical structure. *
** Note: Cannot be called from an * {@link android.accessibilityservice.AccessibilityService}. * This class is made immutable before being delivered to an AccessibilityService. *
* * @param root The root of the virtual subtree. * @param virtualDescendantId The id of the virtual descendant. */ public void setParent(View root, int virtualDescendantId) { IMPL.setParent(mInfo, root, virtualDescendantId); } /** * Gets the node bounds in parent coordinates. * * @param outBounds The output node bounds. */ public void getBoundsInParent(Rect outBounds) { IMPL.getBoundsInParent(mInfo, outBounds); } /** * Sets the node bounds in parent coordinates. ** Note: Cannot be called from an * {@link android.accessibilityservice.AccessibilityService}. This class is * made immutable before being delivered to an AccessibilityService. *
* * @param bounds The node bounds. *@throws IllegalStateException If called from an AccessibilityService. */ public void setBoundsInParent(Rect bounds) { IMPL.setBoundsInParent(mInfo, bounds); } /** * Gets the node bounds in screen coordinates. * * @param outBounds The output node bounds. */ public void getBoundsInScreen(Rect outBounds) { IMPL.getBoundsInScreen(mInfo, outBounds); } /** * Sets the node bounds in screen coordinates. ** Note: Cannot be called from an * {@link android.accessibilityservice.AccessibilityService}. This class is * made immutable before being delivered to an AccessibilityService. *
* * @param bounds The node bounds. * @throws IllegalStateException If called from an AccessibilityService. */ public void setBoundsInScreen(Rect bounds) { IMPL.setBoundsInScreen(mInfo, bounds); } /** * Gets whether this node is checkable. * * @return True if the node is checkable. */ public boolean isCheckable() { return IMPL.isCheckable(mInfo); } /** * Sets whether this node is checkable. ** Note: Cannot be called from an * {@link android.accessibilityservice.AccessibilityService}. This class is * made immutable before being delivered to an AccessibilityService. *
* * @param checkable True if the node is checkable. * @throws IllegalStateException If called from an AccessibilityService. */ public void setCheckable(boolean checkable) { IMPL.setCheckable(mInfo, checkable); } /** * Gets whether this node is checked. * * @return True if the node is checked. */ public boolean isChecked() { return IMPL.isChecked(mInfo); } /** * Sets whether this node is checked. ** Note: Cannot be called from an * {@link android.accessibilityservice.AccessibilityService}. This class is * made immutable before being delivered to an AccessibilityService. *
* * @param checked True if the node is checked. * @throws IllegalStateException If called from an AccessibilityService. */ public void setChecked(boolean checked) { IMPL.setChecked(mInfo, checked); } /** * Gets whether this node is focusable. * * @return True if the node is focusable. */ public boolean isFocusable() { return IMPL.isFocusable(mInfo); } /** * Sets whether this node is focusable. ** Note: Cannot be called from an * {@link android.accessibilityservice.AccessibilityService}. This class is * made immutable before being delivered to an AccessibilityService. *
* * @param focusable True if the node is focusable. * @throws IllegalStateException If called from an AccessibilityService. */ public void setFocusable(boolean focusable) { IMPL.setFocusable(mInfo, focusable); } /** * Gets whether this node is focused. * * @return True if the node is focused. */ public boolean isFocused() { return IMPL.isFocused(mInfo); } /** * Sets whether this node is focused. ** Note: Cannot be called from an * {@link android.accessibilityservice.AccessibilityService}. This class is * made immutable before being delivered to an AccessibilityService. *
* * @param focused True if the node is focused. * @throws IllegalStateException If called from an AccessibilityService. */ public void setFocused(boolean focused) { IMPL.setFocused(mInfo, focused); } /** * Sets whether this node is visible to the user. * * @return Whether the node is visible to the user. */ public boolean isVisibleToUser() { return IMPL.isVisibleToUser(mInfo); } /** * Sets whether this node is visible to the user. ** Note: Cannot be called from an * {@link android.accessibilityservice.AccessibilityService}. * This class is made immutable before being delivered to an AccessibilityService. *
* * @param visibleToUser Whether the node is visible to the user. * * @throws IllegalStateException If called from an AccessibilityService. */ public void setVisibleToUser(boolean visibleToUser) { IMPL.setVisibleToUser(mInfo, visibleToUser); } /** * Gets whether this node is accessibility focused. * * @return True if the node is accessibility focused. */ public boolean isAccessibilityFocused() { return IMPL.isAccessibilityFocused(mInfo); } /** * Sets whether this node is accessibility focused. ** Note: Cannot be called from an * {@link android.accessibilityservice.AccessibilityService}. * This class is made immutable before being delivered to an AccessibilityService. *
* * @param focused True if the node is accessibility focused. * * @throws IllegalStateException If called from an AccessibilityService. */ public void setAccessibilityFocused(boolean focused) { IMPL.setAccessibilityFocused(mInfo, focused); } /** * Gets whether this node is selected. * * @return True if the node is selected. */ public boolean isSelected() { return IMPL.isSelected(mInfo); } /** * Sets whether this node is selected. ** Note: Cannot be called from an * {@link android.accessibilityservice.AccessibilityService}. This class is * made immutable before being delivered to an AccessibilityService. *
* * @param selected True if the node is selected. * @throws IllegalStateException If called from an AccessibilityService. */ public void setSelected(boolean selected) { IMPL.setSelected(mInfo, selected); } /** * Gets whether this node is clickable. * * @return True if the node is clickable. */ public boolean isClickable() { return IMPL.isClickable(mInfo); } /** * Sets whether this node is clickable. ** Note: Cannot be called from an * {@link android.accessibilityservice.AccessibilityService}. This class is * made immutable before being delivered to an AccessibilityService. *
* * @param clickable True if the node is clickable. * @throws IllegalStateException If called from an AccessibilityService. */ public void setClickable(boolean clickable) { IMPL.setClickable(mInfo, clickable); } /** * Gets whether this node is long clickable. * * @return True if the node is long clickable. */ public boolean isLongClickable() { return IMPL.isLongClickable(mInfo); } /** * Sets whether this node is long clickable. ** Note: Cannot be called from an * {@link android.accessibilityservice.AccessibilityService}. This class is * made immutable before being delivered to an AccessibilityService. *
* * @param longClickable True if the node is long clickable. * @throws IllegalStateException If called from an AccessibilityService. */ public void setLongClickable(boolean longClickable) { IMPL.setLongClickable(mInfo, longClickable); } /** * Gets whether this node is enabled. * * @return True if the node is enabled. */ public boolean isEnabled() { return IMPL.isEnabled(mInfo); } /** * Sets whether this node is enabled. ** Note: Cannot be called from an * {@link android.accessibilityservice.AccessibilityService}. This class is * made immutable before being delivered to an AccessibilityService. *
* * @param enabled True if the node is enabled. * @throws IllegalStateException If called from an AccessibilityService. */ public void setEnabled(boolean enabled) { IMPL.setEnabled(mInfo, enabled); } /** * Gets whether this node is a password. * * @return True if the node is a password. */ public boolean isPassword() { return IMPL.isPassword(mInfo); } /** * Sets whether this node is a password. ** Note: Cannot be called from an * {@link android.accessibilityservice.AccessibilityService}. This class is * made immutable before being delivered to an AccessibilityService. *
* * @param password True if the node is a password. * @throws IllegalStateException If called from an AccessibilityService. */ public void setPassword(boolean password) { IMPL.setPassword(mInfo, password); } /** * Gets if the node is scrollable. * * @return True if the node is scrollable, false otherwise. */ public boolean isScrollable() { return IMPL.isScrollable(mInfo); } /** * Sets if the node is scrollable. ** Note: Cannot be called from an * {@link android.accessibilityservice.AccessibilityService}. This class is * made immutable before being delivered to an AccessibilityService. *
* * @param scrollable True if the node is scrollable, false otherwise. * @throws IllegalStateException If called from an AccessibilityService. */ public void setScrollable(boolean scrollable) { IMPL.setScrollable(mInfo, scrollable); } /** * Gets the package this node comes from. * * @return The package name. */ public CharSequence getPackageName() { return IMPL.getPackageName(mInfo); } /** * Sets the package this node comes from. ** Note: Cannot be called from an * {@link android.accessibilityservice.AccessibilityService}. This class is * made immutable before being delivered to an AccessibilityService. *
* * @param packageName The package name. * @throws IllegalStateException If called from an AccessibilityService. */ public void setPackageName(CharSequence packageName) { IMPL.setPackageName(mInfo, packageName); } /** * Gets the class this node comes from. * * @return The class name. */ public CharSequence getClassName() { return IMPL.getClassName(mInfo); } /** * Sets the class this node comes from. ** Note: Cannot be called from an * {@link android.accessibilityservice.AccessibilityService}. This class is * made immutable before being delivered to an AccessibilityService. *
* * @param className The class name. * @throws IllegalStateException If called from an AccessibilityService. */ public void setClassName(CharSequence className) { IMPL.setClassName(mInfo, className); } /** * Gets the text of this node. * * @return The text. */ public CharSequence getText() { return IMPL.getText(mInfo); } /** * Sets the text of this node. ** Note: Cannot be called from an * {@link android.accessibilityservice.AccessibilityService}. This class is * made immutable before being delivered to an AccessibilityService. *
* * @param text The text. * @throws IllegalStateException If called from an AccessibilityService. */ public void setText(CharSequence text) { IMPL.setText(mInfo, text); } /** * Gets the content description of this node. * * @return The content description. */ public CharSequence getContentDescription() { return IMPL.getContentDescription(mInfo); } /** * Sets the content description of this node. ** Note: Cannot be called from an * {@link android.accessibilityservice.AccessibilityService}. This class is * made immutable before being delivered to an AccessibilityService. *
* * @param contentDescription The content description. * @throws IllegalStateException If called from an AccessibilityService. */ public void setContentDescription(CharSequence contentDescription) { IMPL.setContentDescription(mInfo, contentDescription); } /** * Return an instance back to be reused. ** Note: You must not touch the object after calling this function. * * @throws IllegalStateException If the info is already recycled. */ public void recycle() { IMPL.recycle(mInfo); } /** * Sets the fully qualified resource name of the source view's id. * *
* Note: Cannot be called from an * {@link android.accessibilityservice.AccessibilityService}. * This class is made immutable before being delivered to an AccessibilityService. *
* * @param viewId The id resource name. */ public void setViewIdResourceName(String viewId) { IMPL.setViewIdResourceName(mInfo, viewId); } /** * Gets the fully qualified resource name of the source view's id. * ** Note: The primary usage of this API is for UI test automation * and in order to report the source view id of an {@link AccessibilityNodeInfoCompat} * the client has to set the {@link AccessibilityServiceInfoCompat#FLAG_REPORT_VIEW_IDS} * flag when configuring his {@link android.accessibilityservice.AccessibilityService}. *
* * @return The id resource name. */ public String getViewIdResourceName() { return IMPL.getViewIdResourceName(mInfo); } /** * Gets the node's live region mode. ** A live region is a node that contains information that is important for * the user and when it changes the user should be notified. For example, * in a login screen with a TextView that displays an "incorrect password" * notification, that view should be marked as a live region with mode * {@link ViewCompat#ACCESSIBILITY_LIVE_REGION_POLITE}. *
* It is the responsibility of the accessibility service to monitor * {@link AccessibilityEventCompat#TYPE_WINDOW_CONTENT_CHANGED} events * indicating changes to live region nodes and their children. * * @return The live region mode, or * {@link ViewCompat#ACCESSIBILITY_LIVE_REGION_NONE} if the view is * not a live region. * @see ViewCompat#getAccessibilityLiveRegion(View) */ public int getLiveRegion() { return IMPL.getLiveRegion(mInfo); } /** * Sets the node's live region mode. *
* Note: Cannot be called from an * {@link android.accessibilityservice.AccessibilityService}. This class is * made immutable before being delivered to an AccessibilityService. * * @param mode The live region mode, or * {@link ViewCompat#ACCESSIBILITY_LIVE_REGION_NONE} if the view is * not a live region. * @see ViewCompat#setAccessibilityLiveRegion(View, int) */ public void setLiveRegion(int mode) { IMPL.setLiveRegion(mInfo, mode); } @Override public int hashCode() { return (mInfo == null) ? 0 : mInfo.hashCode(); } @Override public boolean equals(Object obj) { if (this == obj) { return true; } if (obj == null) { return false; } if (getClass() != obj.getClass()) { return false; } AccessibilityNodeInfoCompat other = (AccessibilityNodeInfoCompat) obj; if (mInfo == null) { if (other.mInfo != null) { return false; } } else if (!mInfo.equals(other.mInfo)) { return false; } return true; } @Override public String toString() { StringBuilder builder = new StringBuilder(); builder.append(super.toString()); Rect bounds = new Rect(); getBoundsInParent(bounds); builder.append("; boundsInParent: " + bounds); getBoundsInScreen(bounds); builder.append("; boundsInScreen: " + bounds); builder.append("; packageName: ").append(getPackageName()); builder.append("; className: ").append(getClassName()); builder.append("; text: ").append(getText()); builder.append("; contentDescription: ").append(getContentDescription()); builder.append("; viewId: ").append(getViewIdResourceName()); builder.append("; checkable: ").append(isCheckable()); builder.append("; checked: ").append(isChecked()); builder.append("; focusable: ").append(isFocusable()); builder.append("; focused: ").append(isFocused()); builder.append("; selected: ").append(isSelected()); builder.append("; clickable: ").append(isClickable()); builder.append("; longClickable: ").append(isLongClickable()); builder.append("; enabled: ").append(isEnabled()); builder.append("; password: ").append(isPassword()); builder.append("; scrollable: " + isScrollable()); builder.append("; ["); for (int actionBits = getActions(); actionBits != 0;) { final int action = 1 << Integer.numberOfTrailingZeros(actionBits); actionBits &= ~action; builder.append(getActionSymbolicName(action)); if (actionBits != 0) { builder.append(", "); } } builder.append("]"); return builder.toString(); } private static String getActionSymbolicName(int action) { switch (action) { case ACTION_FOCUS: return "ACTION_FOCUS"; case ACTION_CLEAR_FOCUS: return "ACTION_CLEAR_FOCUS"; case ACTION_SELECT: return "ACTION_SELECT"; case ACTION_CLEAR_SELECTION: return "ACTION_CLEAR_SELECTION"; case ACTION_CLICK: return "ACTION_CLICK"; case ACTION_LONG_CLICK: return "ACTION_LONG_CLICK"; case ACTION_ACCESSIBILITY_FOCUS: return "ACTION_ACCESSIBILITY_FOCUS"; case ACTION_CLEAR_ACCESSIBILITY_FOCUS: return "ACTION_CLEAR_ACCESSIBILITY_FOCUS"; case ACTION_NEXT_AT_MOVEMENT_GRANULARITY: return "ACTION_NEXT_AT_MOVEMENT_GRANULARITY"; case ACTION_PREVIOUS_AT_MOVEMENT_GRANULARITY: return "ACTION_PREVIOUS_AT_MOVEMENT_GRANULARITY"; case ACTION_NEXT_HTML_ELEMENT: return "ACTION_NEXT_HTML_ELEMENT"; case ACTION_PREVIOUS_HTML_ELEMENT: return "ACTION_PREVIOUS_HTML_ELEMENT"; case ACTION_SCROLL_FORWARD: return "ACTION_SCROLL_FORWARD"; case ACTION_SCROLL_BACKWARD: return "ACTION_SCROLL_BACKWARD"; case ACTION_CUT: return "ACTION_CUT"; case ACTION_COPY: return "ACTION_COPY"; case ACTION_PASTE: return "ACTION_PASTE"; case ACTION_SET_SELECTION: return "ACTION_SET_SELECTION"; default: return"ACTION_UNKNOWN"; } } }