public class AccessibilityServiceInfo extends Object implements Parcelable
AccessibilityService
. The system notifies an
AccessibilityService
for AccessibilityEvent
s
according to the information encapsulated in this class.
For more information about creating AccessibilityServices, read the Accessibility developer guide.
Modifier and Type | Class and Description |
---|---|
static class |
AccessibilityServiceInfo.CapabilityInfo |
Parcelable.ClassLoaderCreator<T>, Parcelable.Creator<T>
Modifier and Type | Field and Description |
---|---|
static int |
CAPABILITY_CAN_CONTROL_MAGNIFICATION
Capability: This accessibility service can control display magnification.
|
static int |
CAPABILITY_CAN_PERFORM_GESTURES
Capability: This accessibility service can perform gestures.
|
static int |
CAPABILITY_CAN_REQUEST_ENHANCED_WEB_ACCESSIBILITY
Capability: This accessibility service can request enhanced web accessibility
enhancements.
|
static int |
CAPABILITY_CAN_REQUEST_FILTER_KEY_EVENTS
Capability: This accessibility service can request to filter the key event stream.
|
static int |
CAPABILITY_CAN_REQUEST_TOUCH_EXPLORATION
Capability: This accessibility service can request touch exploration mode in which
touched items are spoken aloud and the UI can be explored via gestures.
|
static int |
CAPABILITY_CAN_RETRIEVE_WINDOW_CONTENT
Capability: This accessibility service can retrieve the active window content.
|
static Parcelable.Creator<AccessibilityServiceInfo> |
CREATOR |
static int |
DEFAULT
If an
AccessibilityService is the default for a given type. |
int |
eventTypes
The event types an
AccessibilityService is interested in. |
static int |
FEEDBACK_ALL_MASK
Mask for all feedback types.
|
static int |
FEEDBACK_AUDIBLE
Denotes audible (not spoken) feedback.
|
static int |
FEEDBACK_BRAILLE
Denotes braille feedback.
|
static int |
FEEDBACK_GENERIC
Denotes generic feedback.
|
static int |
FEEDBACK_HAPTIC
Denotes haptic feedback.
|
static int |
FEEDBACK_SPOKEN
Denotes spoken feedback.
|
static int |
FEEDBACK_VISUAL
Denotes visual feedback.
|
int |
feedbackType
The feedback type an
AccessibilityService provides. |
static int |
FLAG_FORCE_DIRECT_BOOT_AWARE |
static int |
FLAG_INCLUDE_NOT_IMPORTANT_VIEWS
If this flag is set the system will regard views that are not important
for accessibility in addition to the ones that are important for accessibility.
|
static int |
FLAG_REPORT_VIEW_IDS
This flag requests that the
AccessibilityNodeInfo s obtained
by an AccessibilityService contain the id of the source view. |
static int |
FLAG_REQUEST_ENHANCED_WEB_ACCESSIBILITY
This flag requests from the system to enable web accessibility enhancing
extensions.
|
static int |
FLAG_REQUEST_FILTER_KEY_EVENTS
This flag requests from the system to filter key events.
|
static int |
FLAG_REQUEST_TOUCH_EXPLORATION_MODE
This flag requests that the system gets into touch exploration mode.
|
static int |
FLAG_RETRIEVE_INTERACTIVE_WINDOWS
This flag indicates to the system that the accessibility service wants
to access content of all interactive windows.
|
int |
flags
This field represents a set of flags used for configuring an
AccessibilityService . |
long |
notificationTimeout
The timeout after the most recent event of a given type before an
AccessibilityService is notified. |
String[] |
packageNames
The package names an
AccessibilityService is interested in. |
CONTENTS_FILE_DESCRIPTOR, PARCELABLE_ELIDE_DUPLICATES, PARCELABLE_WRITE_RETURN_VALUE
Constructor and Description |
---|
AccessibilityServiceInfo()
Creates a new instance.
|
AccessibilityServiceInfo(ResolveInfo resolveInfo,
Context context)
Creates a new instance.
|
Modifier and Type | Method and Description |
---|---|
static String |
capabilityToString(int capability)
Returns the string representation of a capability.
|
int |
describeContents()
Describe the kinds of special objects contained in this Parcelable
instance's marshaled representation.
|
boolean |
equals(Object obj)
Indicates whether some other object is "equal to" this one.
|
static String |
feedbackTypeToString(int feedbackType)
Returns the string representation of a feedback type.
|
static String |
flagToString(int flag)
Returns the string representation of a flag.
|
boolean |
getCanRetrieveWindowContent()
Deprecated.
Use
getCapabilities() . |
int |
getCapabilities()
Returns the bit mask of capabilities this accessibility service has such as
being able to retrieve the active window content, etc.
|
List<AccessibilityServiceInfo.CapabilityInfo> |
getCapabilityInfos() |
String |
getDescription()
Deprecated.
|
String |
getId()
The accessibility service id.
|
ResolveInfo |
getResolveInfo()
The service
ResolveInfo . |
String |
getSettingsActivityName()
The settings activity name.
|
int |
hashCode()
Returns a hash code value for the object.
|
boolean |
isDirectBootAware() |
String |
loadDescription(PackageManager packageManager)
The localized description of the accessibility service.
|
void |
setCapabilities(int capabilities)
Sets the bit mask of capabilities this accessibility service has such as
being able to retrieve the active window content, etc.
|
void |
setComponentName(ComponentName component) |
String |
toString()
Returns a string representation of the object.
|
void |
updateDynamicallyConfigurableProperties(AccessibilityServiceInfo other)
Updates the properties that an AccessibilitySerivice can change dynamically.
|
void |
writeToParcel(Parcel parcel,
int flagz)
Flatten this object in to a Parcel.
|
public static final int CAPABILITY_CAN_RETRIEVE_WINDOW_CONTENT
android.R.styleable#AccessibilityService_canRetrieveWindowContent
,
Constant Field Valuespublic static final int CAPABILITY_CAN_REQUEST_TOUCH_EXPLORATION
android.R.styleable#AccessibilityService_canRequestTouchExplorationMode
,
Constant Field Valuespublic static final int CAPABILITY_CAN_REQUEST_ENHANCED_WEB_ACCESSIBILITY
android.R.styleable#AccessibilityService_canRequestEnhancedWebAccessibility
,
Constant Field Valuespublic static final int CAPABILITY_CAN_REQUEST_FILTER_KEY_EVENTS
android.R.styleable#AccessibilityService_canRequestFilterKeyEvents
,
Constant Field Valuespublic static final int CAPABILITY_CAN_CONTROL_MAGNIFICATION
android.R.styleable#AccessibilityService_canControlMagnification
,
Constant Field Valuespublic static final int CAPABILITY_CAN_PERFORM_GESTURES
android.R.styleable#AccessibilityService_canPerformGestures
,
Constant Field Valuespublic static final int FEEDBACK_SPOKEN
public static final int FEEDBACK_HAPTIC
public static final int FEEDBACK_AUDIBLE
public static final int FEEDBACK_VISUAL
public static final int FEEDBACK_GENERIC
public static final int FEEDBACK_BRAILLE
public static final int FEEDBACK_ALL_MASK
public static final int DEFAULT
AccessibilityService
is the default for a given type.
Default service is invoked only if no package specific one exists. In case of
more than one package specific service only the earlier registered is notified.public static final int FLAG_INCLUDE_NOT_IMPORTANT_VIEWS
View.IMPORTANT_FOR_ACCESSIBILITY_NO
or
View.IMPORTANT_FOR_ACCESSIBILITY_NO_HIDE_DESCENDANTS
and views that are
marked as potentially important for accessibility via
View.IMPORTANT_FOR_ACCESSIBILITY_AUTO
for which the system has determined
that are not important for accessibility, are reported while querying the window
content and also the accessibility service will receive accessibility events from
them.
Note: For accessibility services targeting API version
Build.VERSION_CODES#JELLY_BEAN
or higher this flag has to be explicitly
set for the system to regard views that are not important for accessibility. For
accessibility services targeting API version lower than
Build.VERSION_CODES#JELLY_BEAN
this flag is ignored and all views are
regarded for accessibility purposes.
Usually views not important for accessibility are layout managers that do not react to user actions, do not draw any content, and do not have any special semantics in the context of the screen content. For example, a three by three grid can be implemented as three horizontal linear layouts and one vertical, or three vertical linear layouts and one horizontal, or one grid layout, etc. In this context the actual layout mangers used to achieve the grid configuration are not important, rather it is important that there are nine evenly distributed elements.
public static final int FLAG_REQUEST_TOUCH_EXPLORATION_MODE
For accessibility services targeting API version higher than
Build.VERSION_CODES#JELLY_BEAN_MR1
that want to set
this flag have to declare this capability in their meta-data by setting
the attribute canRequestTouchExplorationMode
to true, otherwise this flag will
be ignored. For how to declare the meta-data of a service refer to
.
Services targeting API version equal to or lower than
Build.VERSION_CODES#JELLY_BEAN_MR1
will work normally, i.e.
the first time they are run, if this flag is specified, a dialog is
shown to the user to confirm enabling explore by touch.
android.R.styleable#AccessibilityService_canRequestTouchExplorationMode
,
Constant Field Valuespublic static final int FLAG_REQUEST_ENHANCED_WEB_ACCESSIBILITY
WebView
. An example of such
an extension is injecting JavaScript from a secure source. The system will enable
enhanced web accessibility if there is at least one accessibility service
that has this flag set. Hence, clearing this flag does not guarantee that the
device will not have enhanced web accessibility enabled since there may be
another enabled service that requested it.
Services that want to set this flag have to declare this capability
in their meta-data by setting the attribute #canRequestEnhancedWebAccessibility canRequestEnhancedWebAccessibility
to
true, otherwise this flag will be ignored. For how to declare the meta-data
of a service refer to .
android.R.styleable#AccessibilityService_canRequestEnhancedWebAccessibility
,
Constant Field Valuespublic static final int FLAG_REPORT_VIEW_IDS
AccessibilityNodeInfo
s obtained
by an AccessibilityService
contain the id of the source view.
The source view id will be a fully qualified resource name of the
form "package:id/name", for example "foo.bar:id/my_list", and it is
useful for UI test automation. This flag is not set by default.public static final int FLAG_REQUEST_FILTER_KEY_EVENTS
Services that want to set this flag have to declare this capability
in their meta-data by setting the attribute #canRequestFilterKeyEvents canRequestFilterKeyEvents
to true,
otherwise this flag will be ignored. For how to declare the meta-data
of a service refer to .
android.R.styleable#AccessibilityService_canRequestFilterKeyEvents
,
Constant Field Valuespublic static final int FLAG_RETRIEVE_INTERACTIVE_WINDOWS
AccessibilityEvent.TYPE_WINDOWS_CHANGED
events, calling AccessibilityServiceAccessibilityService.getWindows()
will return an empty list, and AccessibilityNodeInfo.getWindow()
will
return null.
Services that want to set this flag have to declare the capability
to retrieve window content in their meta-data by setting the attribute
canRetrieveWindowContent
to
true, otherwise this flag will be ignored. For how to declare the meta-data
of a service refer to .
android.R.styleable#AccessibilityService_canRetrieveWindowContent
,
Constant Field Valuespublic static final int FLAG_FORCE_DIRECT_BOOT_AWARE
public int eventTypes
AccessibilityService
is interested in.
Can be dynamically set at runtime.
AccessibilityEvent.TYPE_VIEW_CLICKED
,
AccessibilityEvent.TYPE_VIEW_LONG_CLICKED
,
AccessibilityEvent.TYPE_VIEW_FOCUSED
,
AccessibilityEvent.TYPE_VIEW_SELECTED
,
AccessibilityEvent.TYPE_VIEW_TEXT_CHANGED
,
AccessibilityEvent.TYPE_WINDOW_STATE_CHANGED
,
AccessibilityEvent.TYPE_NOTIFICATION_STATE_CHANGED
,
AccessibilityEvent.TYPE_TOUCH_EXPLORATION_GESTURE_START
,
AccessibilityEvent.TYPE_TOUCH_EXPLORATION_GESTURE_END
,
AccessibilityEvent.TYPE_VIEW_HOVER_ENTER
,
AccessibilityEvent.TYPE_VIEW_HOVER_EXIT
,
AccessibilityEvent.TYPE_VIEW_SCROLLED
,
AccessibilityEvent.TYPE_VIEW_TEXT_SELECTION_CHANGED
,
AccessibilityEvent.TYPE_WINDOW_CONTENT_CHANGED
,
AccessibilityEvent.TYPE_TOUCH_INTERACTION_START
,
AccessibilityEvent.TYPE_TOUCH_INTERACTION_END
,
AccessibilityEvent.TYPE_ANNOUNCEMENT
,
AccessibilityEvent.TYPE_GESTURE_DETECTION_START
,
AccessibilityEvent.TYPE_GESTURE_DETECTION_END
,
AccessibilityEvent.TYPE_VIEW_ACCESSIBILITY_FOCUSED
,
AccessibilityEvent.TYPE_VIEW_ACCESSIBILITY_FOCUS_CLEARED
,
AccessibilityEvent.TYPE_VIEW_TEXT_TRAVERSED_AT_MOVEMENT_GRANULARITY
,
AccessibilityEvent.TYPE_WINDOWS_CHANGED
public String[] packageNames
AccessibilityService
is interested in. Setting
to null
is equivalent to all packages.
Can be dynamically set at runtime.
public int feedbackType
AccessibilityService
provides.
Can be dynamically set at runtime.
public long notificationTimeout
AccessibilityService
is notified.
Can be dynamically set at runtime..
Note: The event notification timeout is useful to avoid propagating events to the client too frequently since this is accomplished via an expensive interprocess call. One can think of the timeout as a criteria to determine when event generation has settled down.
public int flags
AccessibilityService
.
Can be dynamically set at runtime.
public static final Parcelable.Creator<AccessibilityServiceInfo> CREATOR
Parcelable.Creator
public AccessibilityServiceInfo()
public AccessibilityServiceInfo(ResolveInfo resolveInfo, Context context) throws XmlPullParserException, IOException
resolveInfo
- The service resolve info.context
- Context for accessing resources.XmlPullParserException
- If a XML parsing error occurs.IOException
- If a XML parsing error occurs.public void updateDynamicallyConfigurableProperties(AccessibilityServiceInfo other)
other
- The info from which to update the properties.public void setComponentName(ComponentName component)
public String getId()
Generated by the system.
public ResolveInfo getResolveInfo()
ResolveInfo
.
Generated by the system.
public String getSettingsActivityName()
Statically set from
meta-data
.
public boolean getCanRetrieveWindowContent()
getCapabilities()
.
Statically set from
meta-data
.
public int getCapabilities()
CAPABILITY_CAN_RETRIEVE_WINDOW_CONTENT
,
CAPABILITY_CAN_REQUEST_TOUCH_EXPLORATION
,
CAPABILITY_CAN_REQUEST_ENHANCED_WEB_ACCESSIBILITY
,
#CAPABILITY_FILTER_KEY_EVENTS
,
CAPABILITY_CAN_CONTROL_MAGNIFICATION
,
CAPABILITY_CAN_PERFORM_GESTURES
public void setCapabilities(int capabilities)
capabilities
- The capability bit mask.CAPABILITY_CAN_RETRIEVE_WINDOW_CONTENT
,
CAPABILITY_CAN_REQUEST_TOUCH_EXPLORATION
,
CAPABILITY_CAN_REQUEST_ENHANCED_WEB_ACCESSIBILITY
,
#CAPABILITY_FILTER_KEY_EVENTS
,
CAPABILITY_CAN_CONTROL_MAGNIFICATION
,
CAPABILITY_CAN_PERFORM_GESTURES
public String getDescription()
loadDescription(PackageManager)
.
Statically set from
meta-data
.
public String loadDescription(PackageManager packageManager)
Statically set from
meta-data
.
public boolean isDirectBootAware()
public int describeContents()
Parcelable.writeToParcel(Parcel, int)
,
the return value of this method must include the
Parcelable.CONTENTS_FILE_DESCRIPTOR
bit.describeContents
in interface Parcelable
Parcelable.CONTENTS_FILE_DESCRIPTOR
public void writeToParcel(Parcel parcel, int flagz)
Parcelable
writeToParcel
in interface Parcelable
parcel
- The Parcel in which the object should be written.flagz
- Additional flags about how the object should be written.
May be 0 or Parcelable.PARCELABLE_WRITE_RETURN_VALUE
.public int hashCode()
Object
HashMap
.
The general contract of hashCode
is:
hashCode
method
must consistently return the same integer, provided no information
used in equals
comparisons on the object is modified.
This integer need not remain consistent from one execution of an
application to another execution of the same application.
equals(Object)
method, then calling the hashCode
method on each of
the two objects must produce the same integer result.
Object.equals(java.lang.Object)
method, then calling the hashCode
method on each of the
two objects must produce distinct integer results. However, the
programmer should be aware that producing distinct integer results
for unequal objects may improve the performance of hash tables.
As much as is reasonably practical, the hashCode method defined by
class Object
does return distinct integers for distinct
objects. (This is typically implemented by converting the internal
address of the object into an integer, but this implementation
technique is not required by the
JavaTM programming language.)
hashCode
in class Object
Object.equals(java.lang.Object)
,
System.identityHashCode(java.lang.Object)
public boolean equals(Object obj)
Object
The equals
method implements an equivalence relation
on non-null object references:
x
, x.equals(x)
should return
true
.
x
and y
, x.equals(y)
should return true
if and only if
y.equals(x)
returns true
.
x
, y
, and z
, if
x.equals(y)
returns true
and
y.equals(z)
returns true
, then
x.equals(z)
should return true
.
x
and y
, multiple invocations of
x.equals(y)
consistently return true
or consistently return false
, provided no
information used in equals
comparisons on the
objects is modified.
x
,
x.equals(null)
should return false
.
The equals
method for class Object
implements
the most discriminating possible equivalence relation on objects;
that is, for any non-null reference values x
and
y
, this method returns true
if and only
if x
and y
refer to the same object
(x == y
has the value true
).
Note that it is generally necessary to override the hashCode
method whenever this method is overridden, so as to maintain the
general contract for the hashCode
method, which states
that equal objects must have equal hash codes.
equals
in class Object
obj
- the reference object with which to compare.true
if this object is the same as the obj
argument; false
otherwise.Object.hashCode()
,
HashMap
public String toString()
Object
toString
method returns a string that
"textually represents" this object. The result should
be a concise but informative representation that is easy for a
person to read.
It is recommended that all subclasses override this method.
The toString
method for class Object
returns a string consisting of the name of the class of which the
object is an instance, the at-sign character `@
', and
the unsigned hexadecimal representation of the hash code of the
object. In other words, this method returns a string equal to the
value of:
getClass().getName() + '@' + Integer.toHexString(hashCode())
public static String feedbackTypeToString(int feedbackType)
FEEDBACK_SPOKEN
is represented by the string FEEDBACK_SPOKEN.feedbackType
- The feedback type.public static String flagToString(int flag)
DEFAULT
is represented by the string DEFAULT.flag
- The flag.public static String capabilityToString(int capability)
CAPABILITY_CAN_RETRIEVE_WINDOW_CONTENT
is represented
by the string CAPABILITY_CAN_RETRIEVE_WINDOW_CONTENT.capability
- The capability.public List<AccessibilityServiceInfo.CapabilityInfo> getCapabilityInfos()
AccessibilityServiceInfo.CapabilityInfo
objects.