public class AccessibilitySystemAbilityClient extends Object
The client provides functions such as sending accessibility events specified by AccessibilityEventInfo to
the accessibility ability, querying the accessibility status, and sending accessibility status change notifications.
For example, when a view control gains the focus, this class will send an
AccessibilityEventInfo#TYPE_VIEW_FOCUSED_EVENT event to notify the accessibility ability.
AccessibilityEventInfo,
AccessibilityStateObserver,
AccessibilityAbilityInfoSystemCapability.Accessibility#ABILITY| 限定符和类型 | 字段 | 说明 |
|---|---|---|
static int |
CONTENT_CONTROLS |
Indicates that the control content is a control.
|
static int |
CONTENT_ICONS |
Indicates that the control content is an icon.
|
static int |
CONTENT_TEXT |
Indicates that the control content is text.
|
| 限定符和类型 | 方法 | 说明 |
|---|---|---|
List<AccessibilityAbilityInfo> |
getAbilityList(int accessibilityAbilityTypes,
int stateType) |
Queries the list of accessibility abilities.
|
CaptionProperties |
getAccessibilityCaptionProperties() |
Obtains the properties of the accessibility caption function.
|
static AccessibilitySystemAbilityClient |
getInstance(Context abilityContext) |
Obtains the
AccessibilitySystemAbilityClient instance. |
int |
getSuggestedInterval(int timeout,
int contentType) |
Obtains the suggested interval for switching the UI.
|
boolean |
isAccessibilityCaptionEnabled() |
Checks whether the accessibility caption function is enabled.
|
boolean |
isEnabled() |
Checks whether accessibility ability is enabled.
|
boolean |
sendEvent(int eventType,
int viewId) |
Sends an accessibility event.
|
boolean |
sendEvent(AccessibilityEventInfo eventInfo) |
Sends information about an accessibility event.
|
boolean |
subscribeStateObserver(AccessibilityStateObserver observer,
int eventType) |
Subscribes to the specified type of accessibility status change events.
|
boolean |
unsubscribeStateObserver(AccessibilityStateObserver observer) |
Unsubscribe the accessibility status change events from the observer.
|
boolean |
unSubscribeStateObserver(AccessibilityStateObserver observer,
int eventType) |
Unsubscribe the specified type of accessibility status change events.
|
public static final int CONTENT_CONTROLS
public static final int CONTENT_ICONS
public static final int CONTENT_TEXT
public static AccessibilitySystemAbilityClient getInstance(Context abilityContext)
AccessibilitySystemAbilityClient instance.abilityContext - Indicates the context of the associated ability.public boolean sendEvent(int eventType,
int viewId)
This method is used to send an accessibility event to the accessibility ability.
For example, when a view control gains the focus, this method will send an
AccessibilityEventInfo#TYPE_VIEW_FOCUSED_EVENT event to notify the accessibility ability.
eventType - Identifies the accessibility event specified by AccessibilityEventInfo.viewId - Indicates the ID of the view to be associated with the event.True if the event is successfully sent; returns False otherwise, for example, the
event ID is invalid or the accessibility ability is disabled.public boolean sendEvent(AccessibilityEventInfo eventInfo)
This method is used to send information about an accessibility event to the accessibility ability.
For example, when a view control gains the focus, your app can use this method to send information about an
AccessibilityEventInfo#TYPE_VIEW_FOCUSED_EVENT event to notify the accessibility ability, such as the
action triggering this event, package name of the target application, associated view ID, and event record list.
eventInfo - Indicates the accessibility event information specified by AccessibilityEventInfo.True if the event information is successfully sent; returns False if the event
information fails to be sent for reasons such as the event ID is invalid or the accessibility ability is
disabled.public List<AccessibilityAbilityInfo> getAbilityList(int accessibilityAbilityTypes, int stateType)
This method is used to query information about specified accessibility abilities with the given search criteria. For example, you can use this method to check whether an ability is enabled and send a notification to the application if no match is found.
accessibilityAbilityTypes - Indicates the accessibility type specified by
AccessibilityAbilityInfo#ACCESSIBILITY_ABILITY_TYPE_SPOKEN.stateType - Indicates the accessibility ability status. 1 indicates that the ability is enabled;
2 indicates that the ability is disabled; 3 indicates that the ability has been installed.AccessibilityAbilityInfopublic boolean isEnabled()
True if accessibility ability is enabled; returns False otherwise.public boolean subscribeStateObserver(AccessibilityStateObserver observer, int eventType)
This method will receive a notification when the accessibility status has changed, for example, the accessibility ability is unavailable.
observer - Indicates the observer for listening to status events, which is specified by
AccessibilityStateObserver.eventType - Indicates the status type, which is specified by
AccessibilityStateEvent#EVENT_ACCESSIBILITY_STATE_CHANGED and
AccessibilityStateEvent#EVENT_TOUCH_BROWSE_STATE_CHANGED.True if the subscription is successful; returns False if an invalid parameter
exists or the accessibility ability is disabled.AccessibilityStateObserverpublic boolean unSubscribeStateObserver(AccessibilityStateObserver observer, int eventType)
observer - Indicates the registered accessibility status event observer.eventType - Indicates the status type, which is specified by
AccessibilityStateEvent#EVENT_ACCESSIBILITY_STATE_CHANGED and
AccessibilityStateEvent#EVENT_TOUCH_BROWSE_STATE_CHANGED.True if the unsubscription is successful; returns False if an invalid parameter
exists or the accessibility ability is disabled.AccessibilityStateObserverpublic boolean unsubscribeStateObserver(AccessibilityStateObserver observer)
observer - Indicates the registered accessibility status event observer.True if the unsubscription is successful; returns False if an invalid parameter
exists or the accessibility ability is disabled.AccessibilityStateObserverpublic boolean isAccessibilityCaptionEnabled()
True if the caption function is enabled; returns False otherwise.public CaptionProperties getAccessibilityCaptionProperties()
public int getSuggestedInterval(int timeout,
int contentType)
timeout - Indicates the interval at which the UI is changed.contentType - Indicates the type of the UI control.