The **GesturePath** module provides APIs for creating gesture path information required for an accessibility application to inject gestures.
> **NOTE**
>
> The initial APIs of this module are supported since API version 9. Newly added APIs will be marked with a superscript to indicate their earliest API version.
The **GesturePoint** module provides APIs for creating gesture touch point information required for an accessibility application to inject gestures.
> **NOTE**
>
> The initial APIs of this module are supported since API version 9. Newly added APIs will be marked with a superscript to indicate their earliest API version.
The **config** module allows you to configure system accessibility features, including accessibility extension, high-contrast text, mouse buttons, and captions.
The System Accessibility Configuration module allows you to configure system accessibility features, including accessibility extension, high-contrast text, mouse buttons, and captions.
> **NOTE**
>
> The initial APIs of this module are supported since API version 9. Newly added APIs will be marked with a superscript to indicate their earliest API version.
>
> The APIs provided by this module are system APIs.
> - The initial APIs of this module are supported since API version 9. Newly added APIs will be marked with a superscript to indicate their earliest API version.
> - The APIs provided by this module are system APIs.
## Modules to Import
```typescript
importconfigfrom"@ohos.accessibility.config";
```ts
importconfigfrom'@ohos.accessibility.config';
```
## Attributes
...
...
@@ -22,20 +21,20 @@ import config from "@ohos.accessibility.config";
| daltonizationColorFilter | [Config](#config)<[DaltonizationColorFilter](#daltonizationcolorfilter)>| Yes| Yes| Configuration of the daltonization filter.|
| contentTimeout | [Config](#config)\<number>| Yes| Yes| Recommended duration for content display. The value ranges from 0 to 5000, in milliseconds.|
| animationOff | [Config](#config)\<boolean>| Yes| Yes| Whether to enable animation.|
| animationOff | [Config](#config)\<boolean>| Yes| Yes| Whether to disable animation.|
| brightnessDiscount | [Config](#config)\<number>| Yes| Yes| Brightness discount. The value ranges from 0 to 1.0.|
| mouseKey | [Config](#config)\<boolean>| Yes| Yes| Whether to enable the mouse button feature.|
| mouseAutoClick | [Config](#config)\<number>| Yes| Yes| Interval for the automatic mouse clicks. The value ranges from 0 to 5000, in milliseconds.|
| mouseAutoClick | [Config](#config)\<number>| Yes| Yes| Interval for automatic mouse clicks. The value ranges from 0 to 5000, in milliseconds.|
| shortkey | [Config](#config)\<boolean>| Yes| Yes| Whether to enable the accessibility extension shortcut key.|
| shortkeyTarget | [Config](#config)\<string>| Yes| Yes| Target application for the accessibility extension shortcut key. The value format is bundleName/abilityName.|
| shortkeyTarget | [Config](#config)\<string>| Yes| Yes| Target application for the accessibility extension shortcut key. The value format is 'bundleName/abilityName'.|
| captions | [Config](#config)\<boolean>| Yes| Yes| Whether to enable captions.|
@@ -163,22 +218,27 @@ Adds a listener for changes in the list of enabled accessibility extension abili
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| type | string | Yes| Listening type. The value is fixed at **'enableAbilityListsStateChanged'**, indicating the changes in the list of enabled accessibility extension abilities. |
| type | string | Yes| Listening type. The value is fixed at **'enabledAccessibilityExtensionListChange'**, indicating listening for changes in the list of enabled accessibility extension abilities.|
| callback | Callback<void> | Yes| Callback invoked when the list of enabled accessibility extension abilities changes.|
**Example**
```typescript
config.on('enableAbilityListsStateChanged',()=>{
console.info('ax extension ability enable list changed');
Cancels the listener for changes in the list of enabled accessibility extension abilities.
Cancels the listener for changes in the list of enabled accessibility extension abilities. This API uses an asynchronous callback to return the result.
@@ -186,14 +246,21 @@ Cancels the listener for changes in the list of enabled accessibility extension
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| type | string | No| Listening type. The value is fixed at **'enableAbilityListsStateChanged'**, indicating the changes in the list of enabled accessibility extension abilities. |
| type | string | Yes| Listening type. The value is fixed at **'enabledAccessibilityExtensionListChange'**, indicating listening for changes in the list of enabled accessibility extension abilities.|
| callback | Callback<void> | No| Callback invoked when the list of enabled accessibility extension abilities changes.|
The **Accessibility** module implements the accessibility functions, including obtaining the accessibility application list, accessibility application enabled status, and captions configuration.
...
...
@@ -8,7 +8,7 @@ The **Accessibility** module implements the accessibility functions, including o
## Modules to Import
```typescript
```ts
importaccessibilityfrom'@ohos.accessibility';
```
...
...
@@ -49,7 +49,7 @@ Provides information about an accessibility application.
@@ -145,7 +145,7 @@ Describes the style of captions.
## CaptionsManager<sup>8+</sup>
Implements configuration management for captions.
Implements configuration management for captions. Before calling any API of **CaptionsManager**, you must use the [accessibility.getCaptionsManager()](#accessibilitygetcaptionsmanager8) API to obtain a **CaptionsManager** instance.
| style | [CaptionsStyle](#captionsstyle8) | Yes| No| Style of captions.|
In the following API examples, you must first use the [accessibility.getCaptionsManager()](#accessibilitygetcaptionsmanager8) API to obtain a **captionsManager** instance, and then call the methods using the obtained instance.
| callback | AsyncCallback<Array<[AccessibilityAbilityInfo](#accessibilityabilityinfo)>> | Yes| Callback used to return the accessibility application list.|
| callback | AsyncCallback<Array<[AccessibilityAbilityInfo](#accessibilityabilityinfo)>> | Yes| Callback used to return the accessibility application list.|
| callback | AsyncCallback<Array<[AccessibilityAbilityInfo](#accessibilityabilityinfo)>> | Yes| Callback used to return the accessibility application list.|
Enables listening for the enabled status changes of the accessibility application or touch guide mode.
Enables listening for the enabled status changes of the accessibility application. This API uses an asynchronous callback to return the result.
-**Parameters**
**Parameters**
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| type | string | Yes| Type of the event to listen for.<br>- **'accessibilityStateChange'** means to listen for the enabled status changes of the accessibility application.<br>**System capability**: SystemCapability.BarrierFree.Accessibility.Core<br>- **'touchGuideStateChange'** means to listen for the enabled status changes of the touch guide mode.<br>**System capability**: SystemCapability.BarrierFree.Accessibility.Vision|
| callback | Callback\<boolean> | Yes| Callback invoked when the enabled status of captions configuration changes.|
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| type | string | Yes| Type of the event to listen for, which is set to **'accessibilityStateChange'** in this API.|
| callback | Callback<boolean> | Yes| Callback used to return the result.|
Disables listening for the enabled status changes of the accessibility application or touch guide mode.
Enables listening for the enabled status changes of the touch guide mode. This API uses an asynchronous callback to return the result.
-**Parameters**
**Parameters**
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| type | string | No| Type of the event to listen for.<br>- **'accessibilityStateChange'** means to listen for the enabled status changes of the accessibility application.<br>**System capability**: SystemCapability.BarrierFree.Accessibility.Core<br>- **'touchGuideStateChange'** means to listen for the enabled status changes of the touch guide mode.<br>**System capability**: SystemCapability.BarrierFree.Accessibility.Vision|
| callback | Callback<boolean> | No| Callback invoked when the enabled status changes.|
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| type | string | Yes| Type of the event to listen for, which is set to **'touchGuideStateChange'** in this API.|
| callback | Callback<boolean> | Yes| Callback used to return the result.|
| callback | AsyncCallback<boolean> | Yes| Callback used to return the result. Returns **true** if accessibility is enabled; returns **false** otherwise.|
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| callback | AsyncCallback<boolean> | Yes| Callback used to return the result. Returns **true** if accessibility is enabled; returns **false** otherwise.|
-**Example**
**Example**
```typescript
accessibility.isOpenAccessibility((err,data)=>{
if(err){
console.error('failed to isOpenAccessibility because '+JSON.stringify(err));
| callback | AsyncCallback<boolean> | Yes| Callback used to return the result. Returns **true** if touch guide mode is enabled; returns **false** otherwise.|
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| callback | AsyncCallback<boolean> | Yes| Callback used to return the result. Returns **true** if touch guide mode is enabled; returns **false** otherwise.|
-**Example**
**Example**
```typescript
accessibility.isOpenTouchGuide((err,data)=>{
if(err){
console.error('failed to isOpenTouchGuide because '+JSON.stringify(err));
| callback | AsyncCallback<void> | Yes| Callback used to return the result. Returns data if the accessibility event is sent successfully; returns an error otherwise.|
The **AccessibilityExtensionAbility** module is based on the ExtensionAbility framework and provides the **AccessibilityExtensionAbility**.
The **AccessibilityExtensionAbility** module provides accessibility extension capabilities based on the ExtensionAbility framework.
>**NOTE**
>**NOTE**
>
>The initial APIs of this module are supported since API version 9. Newly added APIs will be marked with a superscript to indicate their earliest API version.
>
>The APIs of this module can be used only in the stage model.
> The initial APIs of this module are supported since API version 9. Newly added APIs will be marked with a superscript to indicate their earliest API version.
## Modules to Import
...
...
@@ -18,9 +16,9 @@ import AccessibilityExtensionAbility from '@ohos.application.AccessibilityExtens
@@ -106,27 +78,25 @@ Enumerates the touch guide event types.
| Name | Description |
| ---------- | ------------ |
| touchBegin | A touch starts in touch guide mode.|
| touchEnd | A touch ends in touch guide mode.|
| touchBegin | Start of touch in touch guide mode. |
| touchEnd | End of touch in touch guide mode. |
## AccessibilityExtensionAbility.onConnect
onConnect(): void;
Called when the **AccessibilityExtensionAbility** is enabled and connected to the system service. In this API, you can initialize service logic. This API can be overridden as required.
Called when the **AccessibilityExtensionAbility** is enabled and connected to the system service. In this API, you can have the service logic initialized. This API can be overridden as required.
The **AccessibilityExtensionContext** module, inherited from **ExtensionContext**, provides context for **Accessibility Extension** abilities.
You can use the APIs of this module to configure the concerned information, obtain root information, and inject gestures.
> **NOTE**
>
> The initial APIs of this module are supported since API version 9. Newly added APIs will be marked with a superscript to indicate their earliest API version.
>
> The APIs of this module can be used only in the stage model.
## Usage
Before using the **AccessibilityExtensionContext** module, you must define a child class that inherits from **AccessibilityExtensionAbility**.
| windowId | number | No | Window for which you want to obtain the root element. If this parameter is not specified, it indicates the current active window.|
| windowId | number | Yes | Window for which you want to obtain the root element. If this parameter is not specified, it indicates the current active window.|
| callback | AsyncCallback<AccessibilityElement> | Yes | Callback used to return the root element.|
**Error codes**
For details about the error codes, see [Accessibility Error Codes](../errorcodes/errorcode-accessibility.md).
| ID| Error Message|
| ------- | -------------------------------- |
| 9300003 | Do not have accessibility right for this operation. |
| displayId | number | No | ID of the display from which the window information is obtained. If this parameter is not specified, it indicates the default main display.|
| displayId | number | Yes | ID of the display from which the window information is obtained. If this parameter is not specified, it indicates the default main display.|
| callback | AsyncCallback<Array<AccessibilityElement>> | Yes | Callback used to return the window list.|
**Error codes**
For details about the error codes, see [Accessibility Error Codes](../errorcodes/errorcode-accessibility.md).
| ID| Error Message|
| ------- | -------------------------------- |
| 9300003 | Do not have accessibility right for this operation. |
**Example**
```ts
letwindows;
letdisplayId=10;
try{
axContext.getWindows(displayId,(err,data)=>{
if(err){
console.error('failed to get windows, because '+JSON.stringify(err));
return;
}
windows=data;
console.info('get windows success');
});
}catch(exception){
console.error('failed to get windows, because '+JSON.stringify(exception));
console.error('failed to inject gesture, because '+JSON.stringify(err));
return;
}
console.info('inject gesture success');
});
}catch(exception){
console.error('failed to inject gesture, because '+JSON.stringify(exception));
}
```
## AccessibilityElement<sup>9+</sup>
Defines the accessibilityelement. Before calling APIs of **AccessibilityElement**, you must call [AccessibilityExtensionContext.getFocusElement()](#accessibilityextensioncontextgetfocuselement) or [AccessibilityExtensionContext.getWindowRootElement()](#accessibilityextensioncontextgetwindowrootelement) to obtain an **AccessibilityElement** instance.