public class AccessibilityNodeInfo extends Object implements Parcelable
AccessibilityService
a window content is
presented as tree of accessibility node info which may or may not map one-to-one
to the view hierarchy. In other words, a custom view is free to report itself as
a tree of accessibility node info.
Once an accessibility node info is delivered to an accessibility service it is made immutable and calling a state mutation method generates an error.
Please refer to AccessibilityService
for
details about how to obtain a handle to window content as a tree of accessibility
node info as well as familiarizing with the security model.
For more information about making applications accessible, read the Accessibility developer guide.
Parcelable.ClassLoaderCreator<T>, Parcelable.Creator<T>
Modifier and Type | Field and Description |
---|---|
static int |
ACTION_ACCESSIBILITY_FOCUS
Action that gives accessibility focus to the node.
|
static String |
ACTION_ARGUMENT_HTML_ELEMENT_STRING
Argument for which HTML element to get moving to the next/previous HTML element.
|
static String |
ACTION_ARGUMENT_MOVEMENT_GRANULARITY_INT
Argument for which movement granularity to be used when traversing the node text.
|
static int |
ACTION_CLEAR_ACCESSIBILITY_FOCUS
Action that clears accessibility focus of the node.
|
static int |
ACTION_CLEAR_FOCUS
Action that clears input focus of the node.
|
static int |
ACTION_CLEAR_SELECTION
Action that unselects the node.
|
static int |
ACTION_CLICK
Action that clicks on the node info.
|
static int |
ACTION_FOCUS
Action that gives input focus to the node.
|
static int |
ACTION_LONG_CLICK
Action that long clicks on the node.
|
static int |
ACTION_NEXT_AT_MOVEMENT_GRANULARITY
Action that requests to go to the next entity in this node's text
at a given movement granularity.
|
static int |
ACTION_NEXT_HTML_ELEMENT
Action to move to the next HTML element of a given type.
|
static int |
ACTION_PREVIOUS_AT_MOVEMENT_GRANULARITY
Action that requests to go to the previous entity in this node's text
at a given movement granularity.
|
static int |
ACTION_PREVIOUS_HTML_ELEMENT
Action to move to the previous HTML element of a given type.
|
static int |
ACTION_SCROLL_BACKWARD
Action to scroll the node content backward.
|
static int |
ACTION_SCROLL_FORWARD
Action to scroll the node content forward.
|
static int |
ACTION_SELECT
Action that selects the node.
|
static int |
ACTIVE_WINDOW_ID |
static Parcelable.Creator<AccessibilityNodeInfo> |
CREATOR |
static int |
FLAG_PREFETCH_DESCENDANTS |
static int |
FLAG_PREFETCH_PREDECESSORS |
static int |
FLAG_PREFETCH_SIBLINGS |
static int |
FOCUS_ACCESSIBILITY
The accessibility focus.
|
static int |
FOCUS_INPUT
The input focus.
|
static int |
INCLUDE_NOT_IMPORTANT_VIEWS |
static int |
MOVEMENT_GRANULARITY_CHARACTER
Movement granularity bit for traversing the text of a node by character.
|
static int |
MOVEMENT_GRANULARITY_LINE
Movement granularity bit for traversing the text of a node by line.
|
static int |
MOVEMENT_GRANULARITY_PAGE
Movement granularity bit for traversing the text of a node by page.
|
static int |
MOVEMENT_GRANULARITY_PARAGRAPH
Movement granularity bit for traversing the text of a node by paragraph.
|
static int |
MOVEMENT_GRANULARITY_WORD
Movement granularity bit for traversing the text of a node by word.
|
static long |
ROOT_NODE_ID |
static int |
UNDEFINED |
CONTENTS_FILE_DESCRIPTOR, PARCELABLE_WRITE_RETURN_VALUE
Modifier and Type | Method and Description |
---|---|
void |
addAction(int action)
Adds an action that can be performed on the node.
|
void |
addChild(View child)
Adds a child.
|
void |
addChild(View root,
int virtualDescendantId)
Adds a virtual child which is a descendant of the given
root . |
int |
describeContents()
Describe the kinds of special objects contained in this Parcelable's
marshalled representation.
|
protected void |
enforceNotSealed()
Enforces that this instance is not sealed.
|
protected void |
enforceSealed()
Enforces that this instance is sealed.
|
boolean |
equals(Object object)
Compares this instance with the specified object and indicates if they
are equal.
|
List<AccessibilityNodeInfo> |
findAccessibilityNodeInfosByText(String text)
Finds
AccessibilityNodeInfo s by text. |
AccessibilityNodeInfo |
findFocus(int focus)
Find the view that has the specified focus type.
|
AccessibilityNodeInfo |
focusSearch(int direction)
Searches for the nearest view in the specified direction that can take
the input focus.
|
static int |
getAccessibilityViewId(long accessibilityNodeId)
Gets the accessibility view id which identifies a View in the view three.
|
int |
getActions()
Gets the actions that can be performed on the node.
|
void |
getBoundsInParent(Rect outBounds)
Gets the node bounds in parent coordinates.
|
void |
getBoundsInScreen(Rect outBounds)
Gets the node bounds in screen coordinates.
|
AccessibilityNodeInfo |
getChild(int index)
Get the child at given index.
|
int |
getChildCount()
Gets the number of children.
|
SparseLongArray |
getChildNodeIds() |
CharSequence |
getClassName()
Gets the class this node comes from.
|
CharSequence |
getContentDescription()
Gets the content description of this node.
|
AccessibilityNodeInfo |
getLabeledBy()
Gets the node info which serves as the label of the view represented by
this info for accessibility purposes.
|
AccessibilityNodeInfo |
getLabelFor()
Gets the node info for which the view represented by this info serves as
a label for accessibility purposes.
|
int |
getMovementGranularities()
Gets the movement granularities for traversing the text of this node.
|
CharSequence |
getPackageName()
Gets the package this node comes from.
|
AccessibilityNodeInfo |
getParent()
Gets the parent.
|
long |
getParentNodeId() |
long |
getSourceNodeId()
Gets the id of the source node.
|
CharSequence |
getText()
Gets the text of this node.
|
static int |
getVirtualDescendantId(long accessibilityNodeId)
Gets the virtual descendant id which identifies an imaginary view in a
containing View.
|
int |
getWindowId()
Gets the id of the window from which the info comes from.
|
int |
hashCode()
Returns an integer hash code for this object.
|
boolean |
isAccessibilityFocused()
Gets whether this node is accessibility focused.
|
boolean |
isCheckable()
Gets whether this node is checkable.
|
boolean |
isChecked()
Gets whether this node is checked.
|
boolean |
isClickable()
Gets whether this node is clickable.
|
boolean |
isEnabled()
Gets whether this node is enabled.
|
boolean |
isFocusable()
Gets whether this node is focusable.
|
boolean |
isFocused()
Gets whether this node is focused.
|
boolean |
isLongClickable()
Gets whether this node is long clickable.
|
boolean |
isPassword()
Gets whether this node is a password.
|
boolean |
isScrollable()
Gets if the node is scrollable.
|
boolean |
isSealed()
Gets if this instance is sealed.
|
boolean |
isSelected()
Gets whether this node is selected.
|
boolean |
isVisibleToUser()
Sets whether this node is visible to the user.
|
static long |
makeNodeId(int accessibilityViewId,
int virtualDescendantId)
Makes a node id by shifting the
virtualDescendantId
by VIRTUAL_DESCENDANT_ID_SHIFT and taking
the bitwise or with the accessibilityViewId . |
static AccessibilityNodeInfo |
obtain()
Returns a cached instance if such is available otherwise a new one.
|
static AccessibilityNodeInfo |
obtain(AccessibilityNodeInfo info)
Returns a cached instance if such is available or a new one is
create.
|
static AccessibilityNodeInfo |
obtain(View source)
Returns a cached instance if such is available otherwise a new one
and sets the source.
|
static AccessibilityNodeInfo |
obtain(View root,
int virtualDescendantId)
Returns a cached instance if such is available otherwise a new one
and sets the source.
|
boolean |
performAction(int action)
Performs an action on the node.
|
boolean |
performAction(int action,
Bundle arguments)
Performs an action on the node.
|
void |
recycle()
Return an instance back to be reused.
|
void |
setAccessibilityFocused(boolean focused)
Sets whether this node is accessibility focused.
|
void |
setBoundsInParent(Rect bounds)
Sets the node bounds in parent coordinates.
|
void |
setBoundsInScreen(Rect bounds)
Sets the node bounds in screen coordinates.
|
void |
setCheckable(boolean checkable)
Sets whether this node is checkable.
|
void |
setChecked(boolean checked)
Sets whether this node is checked.
|
void |
setClassName(CharSequence className)
Sets the class this node comes from.
|
void |
setClickable(boolean clickable)
Sets whether this node is clickable.
|
void |
setConnectionId(int connectionId)
Sets the unique id of the IAccessibilityServiceConnection over which
this instance can send requests to the system.
|
void |
setContentDescription(CharSequence contentDescription)
Sets the content description of this node.
|
void |
setEnabled(boolean enabled)
Sets whether this node is enabled.
|
void |
setFocusable(boolean focusable)
Sets whether this node is focusable.
|
void |
setFocused(boolean focused)
Sets whether this node is focused.
|
void |
setLabeledBy(View label)
Sets the view which serves as the label of the view represented by
this info for accessibility purposes.
|
void |
setLabeledBy(View root,
int virtualDescendantId)
Sets the view which serves as the label of the view represented by
this info for accessibility purposes.
|
void |
setLabelFor(View labeled)
Sets the view for which the view represented by this info serves as a
label for accessibility purposes.
|
void |
setLabelFor(View root,
int virtualDescendantId)
Sets the view for which the view represented by this info serves as a
label for accessibility purposes.
|
void |
setLongClickable(boolean longClickable)
Sets whether this node is long clickable.
|
void |
setMovementGranularities(int granularities)
Sets the movement granularities for traversing the text of this node.
|
void |
setPackageName(CharSequence packageName)
Sets the package this node comes from.
|
void |
setParent(View parent)
Sets the parent.
|
void |
setParent(View root,
int virtualDescendantId)
Sets the parent to be a virtual descendant of the given
root . |
void |
setPassword(boolean password)
Sets whether this node is a password.
|
void |
setScrollable(boolean scrollable)
Sets if the node is scrollable.
|
void |
setSealed(boolean sealed)
Sets if this instance is sealed.
|
void |
setSelected(boolean selected)
Sets whether this node is selected.
|
void |
setSource(View source)
Sets the source.
|
void |
setSource(View root,
int virtualDescendantId)
Sets the source to be a virtual descendant of the given
root . |
void |
setText(CharSequence text)
Sets the text of this node.
|
void |
setVisibleToUser(boolean visibleToUser)
Sets whether this node is visible to the user.
|
String |
toString()
Returns a string containing a concise, human-readable description of this
object.
|
void |
writeToParcel(Parcel parcel,
int flags)
Flatten this object in to a Parcel.
|
public static final int UNDEFINED
public static final long ROOT_NODE_ID
public static final int ACTIVE_WINDOW_ID
public static final int FLAG_PREFETCH_PREDECESSORS
public static final int FLAG_PREFETCH_SIBLINGS
public static final int FLAG_PREFETCH_DESCENDANTS
public static final int INCLUDE_NOT_IMPORTANT_VIEWS
public static final int ACTION_FOCUS
public static final int ACTION_CLEAR_FOCUS
public static final int ACTION_SELECT
public static final int ACTION_CLEAR_SELECTION
public static final int ACTION_CLICK
public static final int ACTION_LONG_CLICK
public static final int ACTION_ACCESSIBILITY_FOCUS
public static final int ACTION_CLEAR_ACCESSIBILITY_FOCUS
public static final int ACTION_NEXT_AT_MOVEMENT_GRANULARITY
Arguments:
Bundle arguments = new Bundle();
arguments.putInt(AccessibilityNodeInfo.ACTION_ARGUMENT_MOVEMENT_GRANULARITY_INT,
AccessibilityNodeInfo.MOVEMENT_GRANULARITY_CHARACTER);
info.performAction(AccessibilityNodeInfo.ACTION_NEXT_AT_MOVEMENT_GRANULARITY, arguments);
ACTION_ARGUMENT_MOVEMENT_GRANULARITY_INT
Example:
public static final int ACTION_PREVIOUS_AT_MOVEMENT_GRANULARITY
Arguments:
Bundle arguments = new Bundle();
arguments.putInt(AccessibilityNodeInfo.ACTION_ARGUMENT_MOVEMENT_GRANULARITY_INT,
AccessibilityNodeInfo.MOVEMENT_GRANULARITY_CHARACTER);
info.performAction(AccessibilityNodeInfo.ACTION_PREVIOUS_AT_MOVEMENT_GRANULARITY,
arguments);
ACTION_ARGUMENT_MOVEMENT_GRANULARITY_INT
Example:
public static final int ACTION_NEXT_HTML_ELEMENT
Arguments:
Bundle arguments = new Bundle();
arguments.putString(AccessibilityNodeInfo.ACTION_ARGUMENT_HTML_ELEMENT_STRING, "BUTTON");
info.performAction(AccessibilityNodeInfo.ACTION_NEXT_HTML_ELEMENT, arguments);
ACTION_ARGUMENT_HTML_ELEMENT_STRING
Example:
public static final int ACTION_PREVIOUS_HTML_ELEMENT
Arguments:
Bundle arguments = new Bundle();
arguments.putString(AccessibilityNodeInfo.ACTION_ARGUMENT_HTML_ELEMENT_STRING, "BUTTON");
info.performAction(AccessibilityNodeInfo.ACTION_PREVIOUS_HTML_ELEMENT, arguments);
ACTION_ARGUMENT_HTML_ELEMENT_STRING
Example:
public static final int ACTION_SCROLL_FORWARD
public static final int ACTION_SCROLL_BACKWARD
public static final String ACTION_ARGUMENT_MOVEMENT_GRANULARITY_INT
Type: int
Actions: ACTION_NEXT_AT_MOVEMENT_GRANULARITY
,
ACTION_PREVIOUS_AT_MOVEMENT_GRANULARITY
public static final String ACTION_ARGUMENT_HTML_ELEMENT_STRING
Type: String
Actions: ACTION_NEXT_HTML_ELEMENT
,
ACTION_PREVIOUS_HTML_ELEMENT
public static final int FOCUS_INPUT
public static final int FOCUS_ACCESSIBILITY
public static final int MOVEMENT_GRANULARITY_CHARACTER
public static final int MOVEMENT_GRANULARITY_WORD
public static final int MOVEMENT_GRANULARITY_LINE
public static final int MOVEMENT_GRANULARITY_PARAGRAPH
public static final int MOVEMENT_GRANULARITY_PAGE
public static final Parcelable.Creator<AccessibilityNodeInfo> CREATOR
Parcelable.Creator
public static int getAccessibilityViewId(long accessibilityNodeId)
accessibilityNodeId
- The id of an AccessibilityNodeInfo
.public static int getVirtualDescendantId(long accessibilityNodeId)
accessibilityNodeId
- The id of an AccessibilityNodeInfo
.public static long makeNodeId(int accessibilityViewId, int virtualDescendantId)
virtualDescendantId
by VIRTUAL_DESCENDANT_ID_SHIFT
and taking
the bitwise or with the accessibilityViewId
.accessibilityViewId
- A View accessibility id.virtualDescendantId
- A virtual descendant id.public void setSource(View source)
Note: Cannot be called from an
AccessibilityService
.
This class is made immutable before being delivered to an AccessibilityService.
source
- The info source.public void setSource(View root, int virtualDescendantId)
root
.
If virtualDescendantId
is 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
AccessibilityService
.
This class is made immutable before being delivered to an AccessibilityService.
root
- The root of the virtual subtree.virtualDescendantId
- The id of the virtual descendant.public AccessibilityNodeInfo findFocus(int focus)
focus
- The focus to find. One of FOCUS_INPUT
or
FOCUS_ACCESSIBILITY
.FOCUS_INPUT
,
FOCUS_ACCESSIBILITY
public AccessibilityNodeInfo focusSearch(int direction)
direction
- The direction. Can be one of:
View.FOCUS_DOWN
,
View.FOCUS_UP
,
View.FOCUS_LEFT
,
View.FOCUS_RIGHT
,
View.FOCUS_FORWARD
,
View.FOCUS_BACKWARD
.public int getWindowId()
public SparseLongArray getChildNodeIds()
public int getChildCount()
public AccessibilityNodeInfo getChild(int index)
Note: It is a client responsibility to recycle the
received info by calling recycle()
to avoid creating of multiple instances.
index
- The child index.IllegalStateException
- If called outside of an AccessibilityService.public void addChild(View child)
Note: Cannot be called from an
AccessibilityService
.
This class is made immutable before being delivered to an AccessibilityService.
child
- The child.IllegalStateException
- If called from an AccessibilityService.public void addChild(View root, int virtualDescendantId)
root
.
If virtualDescendantId
is 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.
root
- The root of the virtual subtree.virtualDescendantId
- The id of the virtual child.public int getActions()
ACTION_FOCUS
,
ACTION_CLEAR_FOCUS
,
ACTION_SELECT
,
ACTION_CLEAR_SELECTION
,
ACTION_ACCESSIBILITY_FOCUS
,
ACTION_CLEAR_ACCESSIBILITY_FOCUS
,
ACTION_CLICK
,
ACTION_LONG_CLICK
,
ACTION_NEXT_AT_MOVEMENT_GRANULARITY
,
ACTION_PREVIOUS_AT_MOVEMENT_GRANULARITY
,
ACTION_NEXT_HTML_ELEMENT
,
ACTION_PREVIOUS_HTML_ELEMENT
,
ACTION_SCROLL_FORWARD
,
ACTION_SCROLL_BACKWARD
public void addAction(int action)
Note: Cannot be called from an
AccessibilityService
.
This class is made immutable before being delivered to an AccessibilityService.
action
- The action.IllegalStateException
- If called from an AccessibilityService.public void setMovementGranularities(int granularities)
Note: Cannot be called from an
AccessibilityService
.
This class is made immutable before being delivered to an AccessibilityService.
granularities
- The bit mask with granularities.IllegalStateException
- If called from an AccessibilityService.public int getMovementGranularities()
public boolean performAction(int action)
Note: An action can be performed only if the request is made
from an AccessibilityService
.
action
- The action to perform.IllegalStateException
- If called outside of an AccessibilityService.public boolean performAction(int action, Bundle arguments)
Note: An action can be performed only if the request is made
from an AccessibilityService
.
action
- The action to perform.arguments
- A bundle with additional arguments.IllegalStateException
- If called outside of an AccessibilityService.public List<AccessibilityNodeInfo> findAccessibilityNodeInfosByText(String text)
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 recycle()
to avoid creating of multiple instances.
text
- The searched text.public AccessibilityNodeInfo getParent()
Note: It is a client responsibility to recycle the
received info by calling recycle()
to avoid creating of multiple instances.
public long getParentNodeId()
public void setParent(View parent)
Note: Cannot be called from an
AccessibilityService
.
This class is made immutable before being delivered to an AccessibilityService.
parent
- The parent.IllegalStateException
- If called from an AccessibilityService.public void setParent(View root, int virtualDescendantId)
root
.
If virtualDescendantId
equals to 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
AccessibilityService
.
This class is made immutable before being delivered to an AccessibilityService.
root
- The root of the virtual subtree.virtualDescendantId
- The id of the virtual descendant.public void getBoundsInParent(Rect outBounds)
outBounds
- The output node bounds.public void setBoundsInParent(Rect bounds)
Note: Cannot be called from an
AccessibilityService
.
This class is made immutable before being delivered to an AccessibilityService.
bounds
- The node bounds.IllegalStateException
- If called from an AccessibilityService.public void getBoundsInScreen(Rect outBounds)
outBounds
- The output node bounds.public void setBoundsInScreen(Rect bounds)
Note: Cannot be called from an
AccessibilityService
.
This class is made immutable before being delivered to an AccessibilityService.
bounds
- The node bounds.IllegalStateException
- If called from an AccessibilityService.public boolean isCheckable()
public void setCheckable(boolean checkable)
Note: Cannot be called from an
AccessibilityService
.
This class is made immutable before being delivered to an AccessibilityService.
checkable
- True if the node is checkable.IllegalStateException
- If called from an AccessibilityService.public boolean isChecked()
public void setChecked(boolean checked)
Note: Cannot be called from an
AccessibilityService
.
This class is made immutable before being delivered to an AccessibilityService.
checked
- True if the node is checked.IllegalStateException
- If called from an AccessibilityService.public boolean isFocusable()
public void setFocusable(boolean focusable)
Note: Cannot be called from an
AccessibilityService
.
This class is made immutable before being delivered to an AccessibilityService.
focusable
- True if the node is focusable.IllegalStateException
- If called from an AccessibilityService.public boolean isFocused()
public void setFocused(boolean focused)
Note: Cannot be called from an
AccessibilityService
.
This class is made immutable before being delivered to an AccessibilityService.
focused
- True if the node is focused.IllegalStateException
- If called from an AccessibilityService.public boolean isVisibleToUser()
public void setVisibleToUser(boolean visibleToUser)
Note: Cannot be called from an
AccessibilityService
.
This class is made immutable before being delivered to an AccessibilityService.
visibleToUser
- Whether the node is visible to the user.IllegalStateException
- If called from an AccessibilityService.public boolean isAccessibilityFocused()
public void setAccessibilityFocused(boolean focused)
Note: Cannot be called from an
AccessibilityService
.
This class is made immutable before being delivered to an AccessibilityService.
focused
- True if the node is accessibility focused.IllegalStateException
- If called from an AccessibilityService.public boolean isSelected()
public void setSelected(boolean selected)
Note: Cannot be called from an
AccessibilityService
.
This class is made immutable before being delivered to an AccessibilityService.
selected
- True if the node is selected.IllegalStateException
- If called from an AccessibilityService.public boolean isClickable()
public void setClickable(boolean clickable)
Note: Cannot be called from an
AccessibilityService
.
This class is made immutable before being delivered to an AccessibilityService.
clickable
- True if the node is clickable.IllegalStateException
- If called from an AccessibilityService.public boolean isLongClickable()
public void setLongClickable(boolean longClickable)
Note: Cannot be called from an
AccessibilityService
.
This class is made immutable before being delivered to an AccessibilityService.
longClickable
- True if the node is long clickable.IllegalStateException
- If called from an AccessibilityService.public boolean isEnabled()
public void setEnabled(boolean enabled)
Note: Cannot be called from an
AccessibilityService
.
This class is made immutable before being delivered to an AccessibilityService.
enabled
- True if the node is enabled.IllegalStateException
- If called from an AccessibilityService.public boolean isPassword()
public void setPassword(boolean password)
Note: Cannot be called from an
AccessibilityService
.
This class is made immutable before being delivered to an AccessibilityService.
password
- True if the node is a password.IllegalStateException
- If called from an AccessibilityService.public boolean isScrollable()
public void setScrollable(boolean scrollable)
Note: Cannot be called from an
AccessibilityService
.
This class is made immutable before being delivered to an AccessibilityService.
scrollable
- True if the node is scrollable, false otherwise.IllegalStateException
- If called from an AccessibilityService.public CharSequence getPackageName()
public void setPackageName(CharSequence packageName)
Note: Cannot be called from an
AccessibilityService
.
This class is made immutable before being delivered to an AccessibilityService.
packageName
- The package name.IllegalStateException
- If called from an AccessibilityService.public CharSequence getClassName()
public void setClassName(CharSequence className)
Note: Cannot be called from an
AccessibilityService
.
This class is made immutable before being delivered to an AccessibilityService.
className
- The class name.IllegalStateException
- If called from an AccessibilityService.public CharSequence getText()
public void setText(CharSequence text)
Note: Cannot be called from an
AccessibilityService
.
This class is made immutable before being delivered to an AccessibilityService.
text
- The text.IllegalStateException
- If called from an AccessibilityService.public CharSequence getContentDescription()
public void setContentDescription(CharSequence contentDescription)
Note: Cannot be called from an
AccessibilityService
.
This class is made immutable before being delivered to an AccessibilityService.
contentDescription
- The content description.IllegalStateException
- If called from an AccessibilityService.public void setLabelFor(View labeled)
labeled
- The view for which this info serves as a label.public void setLabelFor(View root, int virtualDescendantId)
virtualDescendantId
is View.NO_ID
the root is set as the labeled.
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
AccessibilityService
.
This class is made immutable before being delivered to an AccessibilityService.
root
- The root whose virtual descendant serves as a label.virtualDescendantId
- The id of the virtual descendant.public AccessibilityNodeInfo getLabelFor()
Note: It is a client responsibility to recycle the
received info by calling recycle()
to avoid creating of multiple instances.
public void setLabeledBy(View label)
label
- The view that labels this node's source.public void setLabeledBy(View root, int virtualDescendantId)
virtualDescendantId
is View.NO_ID
the root is set as the label.
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
AccessibilityService
.
This class is made immutable before being delivered to an AccessibilityService.
root
- The root whose virtual descendant labels this node's source.virtualDescendantId
- The id of the virtual descendant.public AccessibilityNodeInfo getLabeledBy()
Note: It is a client responsibility to recycle the
received info by calling recycle()
to avoid creating of multiple instances.
public void setConnectionId(int connectionId)
connectionId
- The connection id.public int describeContents()
describeContents
in interface Parcelable
public long getSourceNodeId()
public void setSealed(boolean sealed)
sealed
- Whether is sealed.public boolean isSealed()
protected void enforceSealed()
IllegalStateException
- If this instance is not sealed.protected void enforceNotSealed()
IllegalStateException
- If this instance is sealed.public static AccessibilityNodeInfo obtain(View source)
source
- The source view.setSource(View)
public static AccessibilityNodeInfo obtain(View root, int virtualDescendantId)
root
- The root of the virtual subtree.virtualDescendantId
- The id of the virtual descendant.setSource(View, int)
public static AccessibilityNodeInfo obtain()
public static AccessibilityNodeInfo obtain(AccessibilityNodeInfo info)
info
.info
- The other info.public void recycle()
Note: You must not touch the object after calling this function.
IllegalStateException
- If the info is already recycled.public void writeToParcel(Parcel parcel, int flags)
Note: After the instance is written to a parcel it is recycled. You must not touch the object after calling this function.
writeToParcel
in interface Parcelable
parcel
- The Parcel in which the object should be written.flags
- Additional flags about how the object should be written.
May be 0 or Parcelable.PARCELABLE_WRITE_RETURN_VALUE
.public boolean equals(Object object)
Object
o
must represent the same object
as this instance using a class-specific comparison. The general contract
is that this comparison should be reflexive, symmetric, and transitive.
Also, no object reference other than null is equal to null.
The default implementation returns true
only if this ==
o
. See Writing a correct
equals
method
if you intend implementing your own equals
method.
The general contract for the equals
and Object.hashCode()
methods is that if equals
returns true
for
any two objects, then hashCode()
must return the same value for
these objects. This means that subclasses of Object
usually
override either both methods or neither of them.
equals
in class Object
object
- the object to compare this instance with.true
if the specified object is equal to this Object
; false
otherwise.Object.hashCode()
public int hashCode()
Object
Object.equals(java.lang.Object)
returns true
must return
the same hash code value. This means that subclasses of Object
usually override both methods or neither method.
Note that hash values must not change over time unless information used in equals comparisons also changes.
See Writing a correct
hashCode
method
if you intend implementing your own hashCode
method.
hashCode
in class Object
Object.equals(java.lang.Object)
public String toString()
Object
getClass().getName() + '@' + Integer.toHexString(hashCode())
See Writing a useful
toString
method
if you intend implementing your own toString
method.