js-apis-accessibility.md 31.1 KB
Newer Older
E
ester.zhou 已提交
1
# @ohos.accessibility (Accessibility)
E
esterzhou 已提交
2

E
ester.zhou 已提交
3 4 5 6
The **Accessibility** module implements the accessibility functions, including obtaining the accessibility application list, accessibility application enabled status, and captions configuration.

> **NOTE**
>
E
esterzhou 已提交
7 8 9 10
> The initial APIs of this module are supported since API version 7. Newly added APIs will be marked with a superscript to indicate their earliest API version.

## Modules to Import

E
esterzhou 已提交
11
```ts
E
esterzhou 已提交
12 13 14 15 16 17 18
import accessibility from '@ohos.accessibility';
```

## AbilityState

Enumerates the states of an accessibility application.

E
ester.zhou 已提交
19
**System capability**: SystemCapability.BarrierFree.Accessibility.Core
E
esterzhou 已提交
20

E
ester.zhou 已提交
21 22 23 24 25
| Name| Description|
| -------- | -------- |
| enable | The accessibility application is enabled.|
| disable | The accessibility application is disabled.|
| install | The accessibility application has been installed.|
E
esterzhou 已提交
26 27 28 29 30

## AbilityType

Enumerates the types of accessibility applications.

E
ester.zhou 已提交
31
**System capability**: SystemCapability.BarrierFree.Accessibility.Core
E
esterzhou 已提交
32

E
ester.zhou 已提交
33 34 35 36 37 38 39 40
| Name| Description|
| -------- | -------- |
| audible | The accessibility application provides audible feedback.|
| generic | The accessibility application provides generic feedback.|
| haptic | The accessibility application provides haptic feedback.|
| spoken  | The accessibility application provides spoken feedback.|
| visual | The accessibility application provides visual feedback.|
| all<sup>9+</sup> | All the preceding types.|
E
esterzhou 已提交
41 42 43 44 45

## AccessibilityAbilityInfo

Provides information about an accessibility application.

E
ester.zhou 已提交
46
**System capability**: SystemCapability.BarrierFree.Accessibility.Core
E
esterzhou 已提交
47 48 49

### Attributes

E
ester.zhou 已提交
50 51
| Name| Type| Readable| Writable| Description|
| -------- | -------- | -------- | -------- | -------- |
E
esterzhou 已提交
52
| id | string | Yes| No| Ability ID.|
E
ester.zhou 已提交
53 54 55 56 57 58 59
| name | string | Yes| No| Ability name.|
| bundleName | string | Yes| No| Bundle name.|
| targetBundleNames<sup>9+</sup> | Array&lt;string&gt; | Yes| No| Name of the target bundle.|
| abilityTypes | Array&lt;[AbilityType](#abilitytype)&gt; | Yes| No| Accessibility application type.|
| capabilities | Array&lt;[Capability](#capability)&gt; | Yes| No| Capabilities list of the accessibility application.|
| description | string | Yes| No| Description of the accessibility application.|
| eventTypes | Array&lt;[EventType](#eventtype)&gt; | Yes| No| List of events that the accessibility application focuses on.|
E
esterzhou 已提交
60 61 62 63 64

## Action

Describes the target action supported by an accessibility application.

E
ester.zhou 已提交
65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84
**System capability**: SystemCapability.BarrierFree.Accessibility.Core

| Name| Description|
| -------- | -------- |
| click | Clicking.|
| longClick | Long pressing.|
| scrollForward | Scrolling forward.|
| scrollBackward | Scrolling backward.|
| focus | Obtaining focus.|
| clearFocus | Clearing focus.|
| clearSelection | Clearing selection.|
| accessibilityFocus | Obtaining the accessibility focus.|
| clearAccessibilityFocus | Clearing the accessibility focus.|
| cut | Cut.|
| copy | Copy.|
| paste | Paste.|
| select | Select.|
| setText | Setting the text.|
| delete | Delete.|
| setSelection | Setting the selection.|
E
esterzhou 已提交
85 86 87

## Capability

E
esterzhou 已提交
88
Enumerates the capabilities of an accessibility application.
E
esterzhou 已提交
89

E
ester.zhou 已提交
90
**System capability**: SystemCapability.BarrierFree.Accessibility.Core
E
esterzhou 已提交
91

E
ester.zhou 已提交
92 93 94 95 96 97 98
| Name| Description|
| -------- | -------- |
| retrieve | Capability to retrieve the window content.|
| touchGuide | Capability of touch guide mode.|
| keyEventObserver | Capability to filter key events.|
| zoom | Capability to control the display zoom level.|
| gesture | Capability to perform gesture actions.|
E
esterzhou 已提交
99 100 101

## CaptionsFontEdgeType<sup>8+</sup>

E
ester.zhou 已提交
102
Enumerates the font edge types of captions.
E
esterzhou 已提交
103

E
ester.zhou 已提交
104
**System capability**: SystemCapability.BarrierFree.Accessibility.Hearing
E
esterzhou 已提交
105

E
ester.zhou 已提交
106 107 108 109 110 111 112
| Name| Description|
| -------- | -------- |
| none | No effect.|
| raised | Raised effect.|
| depressed | Depressed effect.|
| uniform | Uniform effect.|
| dropShadow | Drop shadow effect.|
E
esterzhou 已提交
113 114 115

## CaptionsFontFamily<sup>8+</sup>

E
ester.zhou 已提交
116
Enumerates the font families of captions.
E
esterzhou 已提交
117

E
ester.zhou 已提交
118
**System capability**: SystemCapability.BarrierFree.Accessibility.Hearing
E
esterzhou 已提交
119

E
ester.zhou 已提交
120 121 122 123 124 125 126 127 128 129
| Name| Description|
| -------- | -------- |
| default | Default font family.|
| monospacedSerif | Monospaced Serif fonts, which use the same width for each character.|
| serif | Serif fonts.|
| monospacedSansSerif | Monospaced Sans Serif fonts, which use the same width for each character.|
| sansSerif | Sans Serif fonts.|
| casual | Casual fonts.|
| cursive | Cursive fonts.|
| smallCapitals | Small caps fonts.|
E
esterzhou 已提交
130 131 132

## CaptionsStyle<sup>8+</sup>

E
ester.zhou 已提交
133
Describes the style of captions.
E
esterzhou 已提交
134

E
ester.zhou 已提交
135
**System capability**: SystemCapability.BarrierFree.Accessibility.Hearing
E
esterzhou 已提交
136

E
ester.zhou 已提交
137 138 139 140 141 142 143 144
| Name| Type| Readable| Writable| Description|
| -------- | -------- | -------- | -------- | -------- |
| fontFamily | [CaptionsFontFamily](#captionsfontfamily8) | Yes| No| Font family of captions.|
| fontScale | number | Yes| No| Font scale of captions.|
| fontColor | number \| string | Yes| No| Font color of captions.|
| fontEdgeType | [CaptionsFontEdgeType](#captionsfontedgetype8) | Yes| No| Font edge type of captions.|
| backgroundColor | number \| string | Yes| No| Background color of captions.|
| windowColor | number \| string | Yes| No| Window color of captions.|
E
esterzhou 已提交
145 146 147

## CaptionsManager<sup>8+</sup>

E
esterzhou 已提交
148
Implements configuration management for captions. Before calling any API of **CaptionsManager**, you must use the [accessibility.getCaptionsManager()](#accessibilitygetcaptionsmanager8) API to obtain a **CaptionsManager** instance.
E
esterzhou 已提交
149

E
ester.zhou 已提交
150
**System capability**: SystemCapability.BarrierFree.Accessibility.Hearing
E
esterzhou 已提交
151

E
ester.zhou 已提交
152
### Attributes
E
esterzhou 已提交
153

E
ester.zhou 已提交
154 155 156 157
| Name| Type| Readable| Writable| Description|
| -------- | -------- | -------- | -------- | -------- |
| enabled | boolean | Yes| No| Whether to enable captions configuration.|
| style | [CaptionsStyle](#captionsstyle8) | Yes| No| Style of captions.|
E
esterzhou 已提交
158

E
ester.zhou 已提交
159
### on('enableChange')
E
esterzhou 已提交
160 161 162

on(type: 'enableChange', callback: Callback&lt;boolean&gt;): void;

E
esterzhou 已提交
163
Enables listening for the enabled status changes of captions configuration. This API uses an asynchronous callback to return the result.
E
esterzhou 已提交
164

E
esterzhou 已提交
165
**Parameters**
E
esterzhou 已提交
166

E
esterzhou 已提交
167 168 169 170
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| type | string | Yes| Type of the event to listen for, which is set to **'enableChange'** in this API.|
| callback | Callback&lt;boolean&gt; | Yes| Callback invoked when the enabled status of captions configuration changes.|
E
esterzhou 已提交
171

E
esterzhou 已提交
172
**Example**
E
esterzhou 已提交
173

E
esterzhou 已提交
174 175 176 177 178 179 180 181 182 183
```ts
let captionsManager = accessibility.getCaptionsManager();
try {
    captionsManager.on('enableChange', (data) => {
        console.info('subscribe caption manager enable state change, result: ' + JSON.stringify(data));
    });
} catch (exception) {
    console.error('failed to subscribe caption manager enable state change, because ' + JSON.stringify(exception));
}
```
E
esterzhou 已提交
184

E
ester.zhou 已提交
185
### on('styleChange')
E
esterzhou 已提交
186 187 188

on(type: 'styleChange', callback: Callback&lt;CaptionsStyle&gt;): void;

E
esterzhou 已提交
189
Enables listening for captions style changes. This API uses an asynchronous callback to return the result.
E
esterzhou 已提交
190

E
esterzhou 已提交
191
**Parameters**
E
esterzhou 已提交
192

E
esterzhou 已提交
193 194 195 196
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| type | string | Yes| Type of the event to listen for, which is set to **'styleChange'** in this API.|
| callback | Callback&lt;[CaptionsStyle](#captionsstyle8)&gt; | Yes| Callback invoked when the style of captions changes.|
E
esterzhou 已提交
197

E
esterzhou 已提交
198 199 200 201 202 203 204 205 206 207 208 209 210 211
**Example**

```ts
let captionStyle;
let captionsManager = accessibility.getCaptionsManager();
try {
    captionsManager.on('styleChange', (data) => {
        captionStyle = data;
        console.info('subscribe caption manager style state change, result: ' + JSON.stringify(data));
    });
} catch (exception) {
    console.error('failed to subscribe caption manager style state change, because ' + JSON.stringify(exception));
}
```
E
esterzhou 已提交
212

E
ester.zhou 已提交
213
### off('enableChange')
E
esterzhou 已提交
214 215 216

off(type: 'enableChange', callback?: Callback&lt;boolean&gt;): void;

E
esterzhou 已提交
217
Disables listening for the enabled status changes of captions configuration. This API uses an asynchronous callback to return the result.
E
esterzhou 已提交
218

E
esterzhou 已提交
219
**Parameters**
E
esterzhou 已提交
220

E
esterzhou 已提交
221 222 223 224
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| type | string | Yes| Type of the event to listen for, which is set to **'enableChange'** in this API.|
| callback | Callback&lt;boolean&gt; | No| Callback invoked when the enabled status of captions configuration changes.|
E
esterzhou 已提交
225

E
esterzhou 已提交
226
**Example**
E
esterzhou 已提交
227

E
esterzhou 已提交
228 229 230 231 232 233 234 235 236 237
```ts
let captionsManager = accessibility.getCaptionsManager();
try {
    captionsManager.off('enableChange', (data) => {
        console.info('Unsubscribe caption manager enable state change, result: ' + JSON.stringify(data));
    });
} catch (exception) {
    console.error('failed to Unsubscribe caption manager enable state change, because ' + JSON.stringify(exception));
}
```
E
esterzhou 已提交
238

E
ester.zhou 已提交
239
### off('styleChange')
E
esterzhou 已提交
240 241 242

off(type: 'styleChange', callback?: Callback&lt;CaptionsStyle&gt;): void;

E
esterzhou 已提交
243
Disables listening for captions style changes. This API uses an asynchronous callback to return the result.
E
esterzhou 已提交
244

E
esterzhou 已提交
245
**Parameters**
E
esterzhou 已提交
246

E
esterzhou 已提交
247 248 249 250
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| type | string | Yes| Type of the event to listen for, which is set to **'styleChange'** in this API.|
| callback | Callback&lt;[CaptionsStyle](#captionsstyle8)&gt; | No| Callback invoked when the style of captions changes.|
E
esterzhou 已提交
251

E
esterzhou 已提交
252
**Example**
E
esterzhou 已提交
253

E
esterzhou 已提交
254 255 256 257 258 259 260 261 262 263 264 265
```ts
let captionStyle;
let captionsManager = accessibility.getCaptionsManager();
try {
    captionsManager.off('styleChange', (data) => {
        captionStyle = data;
        console.info('Unsubscribe caption manager style state change, result: ' + JSON.stringify(data));
    });
} catch (exception) {
    console.error('failed to Unsubscribe caption manager style state change, because ' + JSON.stringify(exception));
}
```
E
esterzhou 已提交
266 267 268 269 270

## EventInfo

Describes a GUI change event.

E
ester.zhou 已提交
271
**System capability**: SystemCapability.BarrierFree.Accessibility.Core
E
esterzhou 已提交
272 273 274

### Attributes

E
ester.zhou 已提交
275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297
| Name| Type| Readable| Writable| Description|
| -------- | -------- | -------- | -------- | -------- |
| type | [EventType](#eventtype) | Yes| Yes| Accessibility event type.|
| windowUpdateType | [WindowUpdateType](#windowupdatetype) | Yes| Yes| Window update type.|
| bundleName | string | Yes| Yes| Target application name.|
| componentType | string | Yes| Yes| Type of the event source component, for example, button or chart.|
| pageId | number | Yes| Yes| Page ID of the event source.|
| description | string | Yes| Yes| Event description.|
| triggerAction | [Action](#action) | Yes| Yes| Action that triggers the event.|
| textMoveUnit | [TextMoveUnit](#textmoveunit) | Yes| Yes| Text movement unit.|
| contents | Array&lt;string&gt; | Yes| Yes| Array of contents.|
| lastContent | string | Yes| Yes| Latest content.|
| beginIndex | number | Yes| Yes| Sequence number of the first item displayed on the page.|
| currentIndex | number | Yes| Yes| Sequence number of the current item.|
| endIndex | number | Yes| Yes| Sequence number of the last item displayed on the page.|
| itemCount | number | Yes| Yes| Total number of items.|

### constructor

constructor(jsonObject)

Implements a constructor.

E
ester.zhou 已提交
298 299
**System capability**: SystemCapability.BarrierFree.Accessibility.Core

E
esterzhou 已提交
300
**Parameters**
E
ester.zhou 已提交
301

E
esterzhou 已提交
302 303 304
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| jsonObject | string | Yes| JSON string required for creating an object.|
E
ester.zhou 已提交
305

E
esterzhou 已提交
306
**Example**
E
ester.zhou 已提交
307

E
esterzhou 已提交
308 309 310 311 312 313
  ```ts
  let eventInfo = new accessibility.EventInfo({
    'type':'click',
    'bundleName':'com.example.MyApplication',
    'triggerAction':'click'
  });
E
ester.zhou 已提交
314
  ```
E
esterzhou 已提交
315 316 317 318 319

## EventType

Enumerates accessibility event types.

E
ester.zhou 已提交
320 321 322 323 324 325 326 327 328 329 330 331 332 333 334
**System capability**: SystemCapability.BarrierFree.Accessibility.Core

| Name| Description|
| -------- | -------- |
| click | Event of clicking a component.|
| longClick | Event of long-pressing a component.|
| select | Event of selecting a component.|
| focus | Event indicating that the component obtains the focus.|
| textUpdate | Event indicating that the component text has been updated.|
| hoverEnter | Event indicating that the hover enters a component.|
| hoverExit | Event indicating that the hover exits a component.|
| scroll | Event of the scroll view.|
| textSelectionUpdate | Event indicating that the selected text has been updated.|
| accessibilityFocus | Event indicating that the accessibility focus has been obtained.|
| accessibilityFocusClear | Event indicating that the accessibility focus has been cleared.|
E
esterzhou 已提交
335 336 337 338 339

## TextMoveUnit

Enumerates the movement units for traversing the node text.

E
ester.zhou 已提交
340
**System capability**: SystemCapability.BarrierFree.Accessibility.Core
E
esterzhou 已提交
341

E
ester.zhou 已提交
342 343 344 345 346 347 348
| Name| Description|
| -------- | -------- |
| char | The movement unit for traversing the node text is by character.|
| word | The movement unit for traversing the node text is by word.|
| line | The movement unit for traversing the node text is by line.|
| page | The movement unit for traversing the node text is by page.|
| paragraph | The movement unit for traversing the node text is by paragraph.|
E
esterzhou 已提交
349 350 351 352 353

## WindowUpdateType

Enumerates window update types.

E
ester.zhou 已提交
354 355 356 357 358 359 360 361 362
**System capability**: SystemCapability.BarrierFree.Accessibility.Core

| Name| Description|
| -------- | -------- |
| add | Window adding.|
| remove | Window deletion.|
| bounds | Window boundary change.|
| active | Window activity change.|
| focus | Window focus change.|
E
esterzhou 已提交
363

E
esterzhou 已提交
364
## accessibility.getAbilityLists<sup>(deprecated)</sup>
E
esterzhou 已提交
365 366 367 368 369

getAbilityLists(abilityType: AbilityType, stateType: AbilityState): Promise&lt;Array&lt;AccessibilityAbilityInfo&gt;&gt;

Obtains the accessibility application list. This API uses a promise to return the result.

E
esterzhou 已提交
370 371 372 373 374
> **NOTE**
>
> This API is supported since API version 7 and deprecated since API version 9.
> You are advised to use[getAccessibilityExtensionList()](#accessibilitygetaccessibilityextensionlist9).

E
ester.zhou 已提交
375
**System capability**: SystemCapability.BarrierFree.Accessibility.Core
E
esterzhou 已提交
376

E
esterzhou 已提交
377
**Parameters**
E
esterzhou 已提交
378

E
esterzhou 已提交
379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| abilityType | [AbilityType](#abilitytype) | Yes| Accessibility application type.|
| stateType | [AbilityState](#abilitystate) | Yes| Accessibility application status.|

**Return value**

| Type| Description|
| -------- | -------- |
| Promise&lt;Array&lt;[AccessibilityAbilityInfo](#accessibilityabilityinfo)&gt;&gt; | Promise used to return the accessibility application list.|

**Example**

```ts
let abilityType = 'spoken';
let abilityState = 'enable';
let abilityList: accessibility.AccessibilityInfo[];
try {
    accessibility.getAbilityLists(abilityType, abilityState).then((data) => {
        for (let item of data) {
            console.info(item.id);
            console.info(item.name);
            console.info(item.description);
            console.info(item.bundleName);
            extensionList.push(item);
        }
        console.info('get accessibility extension list success');
    }).catch((err) => {
        console.error('failed to get accessibility extension list because ' + JSON.stringify(err));
    });
} catch (exception) {
    console.error('failed to get accessibility extension list because ' + JSON.stringify(exception));
}
```

## accessibility.getAbilityLists<sup>(deprecated)</sup>
E
esterzhou 已提交
415 416 417 418 419

getAbilityLists(abilityType: AbilityType, stateType: AbilityState,callback: AsyncCallback&lt;Array&lt;AccessibilityAbilityInfo&gt;&gt;): void

Obtains the accessibility application list. This API uses an asynchronous callback to return the result.

E
esterzhou 已提交
420 421 422 423 424
> **NOTE**
>
> This API is supported since API version 7 and deprecated since API version 9.
> You are advised to use [getAccessibilityExtensionList()](#accessibilitygetaccessibilityextensionlist9-1).

E
ester.zhou 已提交
425
**System capability**: SystemCapability.BarrierFree.Accessibility.Core
E
esterzhou 已提交
426

E
esterzhou 已提交
427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548
**Parameters**

| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| abilityType | [AbilityType](#abilitytype) | Yes| Accessibility application type.|
| stateType | [AbilityState](#abilitystate) | Yes| Accessibility application status.|
| callback | AsyncCallback&lt;Array&lt;[AccessibilityAbilityInfo](#accessibilityabilityinfo)&gt;&gt; | Yes| Callback used to return the accessibility application list.|

**Example**

```ts
let abilityType = 'spoken';
let abilityState = 'enable';
let abilityList: accessibility.AccessibilityInfo[];
try {
    accessibility.getAbilityLists(abilityType, abilityState, (err, data) => {
        if (err) {
            console.error('failed to get accessibility extension list because ' + JSON.stringify(err));
            return;
        }
        for (let item of data) {
            console.info(item.id);
            console.info(item.name);
            console.info(item.description);
            console.info(item.bundleName);
            abilityList.push(item);
        }
        console.info('get accessibility extension list success');
    }).catch((err) => {
        console.error('failed to get accessibility extension list because ' + JSON.stringify(err));
    });
} catch (exception) {
    console.error('failed to get accessibility extension list because ' + JSON.stringify(exception));
}
```

## accessibility.getAccessibilityExtensionList<sup>9+</sup>

getAccessibilityExtensionList(abilityType: AbilityType, stateType: AbilityState): Promise&lt;Array&lt;AccessibilityAbilityInfo&gt;&gt;

Obtains the accessibility application list. This API uses a promise to return the result.

**System capability**: SystemCapability.BarrierFree.Accessibility.Core

**Parameters**

| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| abilityType | [AbilityType](#abilitytype) | Yes| Accessibility application type.|
| stateType | [AbilityState](#abilitystate) | Yes| Accessibility application status.|

**Return value**

| Type| Description|
| -------- | -------- |
| Promise&lt;Array&lt;[AccessibilityAbilityInfo](#accessibilityabilityinfo)&gt;&gt; | Promise used to return the accessibility application list.|

**Example**

```ts
let abilityType : accessibility.AbilityType = 'spoken';
let abilityState : accessibility.AbilityState = 'enable';
let extensionList: accessibility.AccessibilityAbilityInfo[] = [];
try {
    accessibility.getAccessibilityExtensionList(abilityType, abilityState).then((data) => {
        for (let item of data) {
            console.info(item.id);
            console.info(item.name);
            console.info(item.description);
            console.info(item.bundleName);
            extensionList.push(item);
        }
        console.info('get accessibility extension list success');
    }).catch((err) => {
        console.error('failed to get accessibility extension list because ' + JSON.stringify(err));
    });
} catch (exception) {
    console.error('failed to get accessibility extension list because ' + JSON.stringify(exception));
}
```

## accessibility.getAccessibilityExtensionList<sup>9+</sup>

getAccessibilityExtensionList(abilityType: AbilityType, stateType: AbilityState, callback: AsyncCallback&lt;Array&lt;AccessibilityAbilityInfo&gt;&gt;): void

Obtains the accessibility application list. This API uses an asynchronous callback to return the result.

**System capability**: SystemCapability.BarrierFree.Accessibility.Core

**Parameters**

| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| abilityType | [AbilityType](#abilitytype) | Yes| Accessibility application type.|
| stateType | [AbilityState](#abilitystate) | Yes| Accessibility application status.|
| callback | AsyncCallback&lt;Array&lt;[AccessibilityAbilityInfo](#accessibilityabilityinfo)&gt;&gt; | Yes| Callback used to return the accessibility application list.|

**Example**

```ts
let abilityType : accessibility.AbilityType = 'spoken';
let abilityState : accessibility.AbilityState = 'enable';
let extensionList: accessibility.AccessibilityAbilityInfo[] = [];
try {
    accessibility.getAccessibilityExtensionList(abilityType, abilityState, (err, data) => {
        if (err) {
            console.error('failed to get accessibility extension list because ' + JSON.stringify(err));
            return;
        }
        for (let item of data) {
            console.info(item.id);
            console.info(item.name);
            console.info(item.description);
            console.info(item.bundleName);
            extensionList.push(item);
        }
        console.info('get accessibility extension list success');
    });
} catch (exception) {
    console.error('failed to get accessibility extension list because ' + JSON.stringify(exception));
}
```
E
esterzhou 已提交
549 550 551 552 553

## accessibility.getCaptionsManager<sup>8+</sup>

getCaptionsManager(): CaptionsManager

E
esterzhou 已提交
554
Obtains a **CaptionsManager** instance.
E
esterzhou 已提交
555

E
ester.zhou 已提交
556
**System capability**: SystemCapability.BarrierFree.Accessibility.Hearing
E
esterzhou 已提交
557

E
esterzhou 已提交
558
**Return value**
E
esterzhou 已提交
559

E
esterzhou 已提交
560 561 562
| Type| Description|
| -------- | -------- |
| [CaptionsManager](#captionsmanager8) | Captions configuration.|
E
esterzhou 已提交
563

E
esterzhou 已提交
564
**Example**
E
esterzhou 已提交
565

E
esterzhou 已提交
566 567 568
```ts
let captionsManager = accessibility.getCaptionsManager();
```
E
esterzhou 已提交
569

E
esterzhou 已提交
570
## accessibility.on('accessibilityStateChange')
E
esterzhou 已提交
571

E
esterzhou 已提交
572
on(type: 'accessibilityStateChange', callback: Callback&lt;boolean&gt;): void
E
esterzhou 已提交
573

E
esterzhou 已提交
574
Enables listening for the enabled status changes of the accessibility application. This API uses an asynchronous callback to return the result.
E
ester.zhou 已提交
575 576

 
E
esterzhou 已提交
577

E
esterzhou 已提交
578
**Parameters**
E
esterzhou 已提交
579

E
esterzhou 已提交
580 581 582 583
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| type | string | Yes| Type of the event to listen for, which is set to **'accessibilityStateChange'** in this API.|
| callback | Callback&lt;boolean&gt; | Yes| Callback used to return the result.|
E
esterzhou 已提交
584

E
esterzhou 已提交
585
**Example**
E
esterzhou 已提交
586

E
esterzhou 已提交
587 588 589 590 591 592 593 594 595
```ts
try {
    accessibility.on('accessibilityStateChange', (data) => {
        console.info('subscribe accessibility state change, result: ' + JSON.stringify(data));
    });
} catch (exception) {
    console.error('failed to subscribe accessibility state change, because ' + JSON.stringify(exception));
}
```
E
esterzhou 已提交
596

E
esterzhou 已提交
597
## accessibility.on('touchGuideStateChange')
E
esterzhou 已提交
598

E
esterzhou 已提交
599
on(type: 'touchGuideStateChange', callback: Callback&lt;boolean&gt;): void
E
esterzhou 已提交
600

E
esterzhou 已提交
601
Enables listening for the enabled status changes of the touch guide mode. This API uses an asynchronous callback to return the result.
E
ester.zhou 已提交
602 603

 
E
esterzhou 已提交
604

E
esterzhou 已提交
605
**Parameters**
E
esterzhou 已提交
606

E
esterzhou 已提交
607 608 609 610
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| type | string | Yes| Type of the event to listen for, which is set to **'touchGuideStateChange'** in this API.|
| callback | Callback&lt;boolean&gt; | Yes| Callback used to return the result.|
E
esterzhou 已提交
611

E
esterzhou 已提交
612
**Example**
E
esterzhou 已提交
613

E
esterzhou 已提交
614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676
```ts
try {
    accessibility.on('touchGuideStateChange', (data) => {
        console.info('subscribe touch guide state change, result: ' + JSON.stringify(data));
    });
} catch (exception) {
    console.error('failed to subscribe touch guide state change, because ' + JSON.stringify(exception));
}
```

## accessibility.off('accessibilityStateChange')

off(type: 'accessibilityStateChange', callback?: Callback&lt;boolean&gt;): void

Disables listening for the enabled status changes of the accessibility application. This API uses an asynchronous callback to return the result.

 

**Parameters**

| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| type |  string | No| Type of the event to listen for, which is set to **'accessibilityStateChange'** in this API.|
| callback | Callback&lt;boolean&gt; | No| Callback used to return the result.|

**Example**

```ts
try {
    accessibility.off('accessibilityStateChange', (data) => {
        console.info('Unsubscribe accessibility state change, result: ' + JSON.stringify(data));
    });
} catch (exception) {
    console.error('failed to Unsubscribe accessibility state change, because ' + JSON.stringify(exception));
}
```

## accessibility.off('touchGuideStateChange')

off(type: 'touchGuideStateChange', callback?: Callback&lt;boolean&gt;): void

Disables listening for the enabled status changes of the touch guide mode. This API uses an asynchronous callback to return the result.

 

**Parameters**

| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| type |  string | No| Type of the event to listen for, which is set to **'touchGuideStateChange'** in this API.|
| callback | Callback&lt;boolean&gt; | No| Callback used to return the result.|

**Example**

```ts
try {
    accessibility.off('touchGuideStateChange', (data) => {
        console.info('Unsubscribe touch guide state change, result: ' + JSON.stringify(data));
    });
} catch (exception) {
    console.error('failed to Unsubscribe touch guide state change, because ' + JSON.stringify(exception));
}
```
E
esterzhou 已提交
677 678 679 680 681 682 683

## accessibility.isOpenAccessibility

isOpenAccessibility(): Promise&lt;boolean&gt;

Checks whether accessibility is enabled. This API uses a promise to return the result.

E
ester.zhou 已提交
684
**System capability**: SystemCapability.BarrierFree.Accessibility.Core
E
esterzhou 已提交
685

E
esterzhou 已提交
686
**Return value**
E
esterzhou 已提交
687

E
esterzhou 已提交
688 689 690
| Type| Description|
| -------- | -------- |
| Promise&lt;boolean&gt; | Promise used to return the result. Returns **true** if accessibility is enabled; returns **false** otherwise.|
E
esterzhou 已提交
691

E
esterzhou 已提交
692
**Example**
E
esterzhou 已提交
693

E
esterzhou 已提交
694 695 696 697 698 699 700
```ts
accessibility.isOpenAccessibility().then((data) => {
    console.info('success data:isOpenAccessibility : ' + JSON.stringify(data))
}).catch((err) => {
    console.error('failed to  isOpenAccessibility because ' + JSON.stringify(err));
});
```
E
esterzhou 已提交
701 702 703 704 705 706 707

## accessibility.isOpenAccessibility

isOpenAccessibility(callback: AsyncCallback&lt;boolean&gt;): void

Checks whether accessibility is enabled. This API uses an asynchronous callback to return the result.

E
ester.zhou 已提交
708
**System capability**: SystemCapability.BarrierFree.Accessibility.Core
E
esterzhou 已提交
709

E
esterzhou 已提交
710
**Parameters**
E
esterzhou 已提交
711

E
esterzhou 已提交
712 713 714
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| callback | AsyncCallback&lt;boolean&gt; | Yes| Callback used to return the result. Returns **true** if accessibility is enabled; returns **false** otherwise.|
E
esterzhou 已提交
715

E
esterzhou 已提交
716
**Example**
E
esterzhou 已提交
717

E
esterzhou 已提交
718 719 720 721 722 723 724 725 726
```ts
accessibility.isOpenAccessibility((err, data) => {
    if (err) {
        console.error('failed to isOpenAccessibility because ' + JSON.stringify(err));
        return;
    }
    console.info('success data:isOpenAccessibility : ' + JSON.stringify(data))
});
```
E
esterzhou 已提交
727 728 729 730 731 732 733

## accessibility.isOpenTouchGuide

isOpenTouchGuide(): Promise&lt;boolean&gt;

Checks whether touch guide mode is enabled. This API uses a promise to return the result.

E
ester.zhou 已提交
734
**System capability**: SystemCapability.BarrierFree.Accessibility.Vision
E
esterzhou 已提交
735

E
esterzhou 已提交
736
**Return value**
E
esterzhou 已提交
737

E
esterzhou 已提交
738 739 740
| Type| Description|
| -------- | -------- |
| Promise&lt;boolean&gt; | Promise used to return the result. Returns **true** if touch guide mode is enabled; returns **false** otherwise.|
E
esterzhou 已提交
741

E
esterzhou 已提交
742
**Example**
E
esterzhou 已提交
743

E
esterzhou 已提交
744 745 746 747 748 749 750
```ts
accessibility.isOpenTouchGuide().then((data) => {
    console.info('success data:isOpenTouchGuide : ' + JSON.stringify(data))
}).catch((err) => {
    console.error('failed to  isOpenTouchGuide because ' + JSON.stringify(err));
});
```
E
esterzhou 已提交
751 752 753 754 755 756 757

## accessibility.isOpenTouchGuide

isOpenTouchGuide(callback: AsyncCallback&lt;boolean&gt;): void

Checks whether touch guide mode is enabled. This API uses an asynchronous callback to return the result.

E
ester.zhou 已提交
758
**System capability**: SystemCapability.BarrierFree.Accessibility.Vision
E
esterzhou 已提交
759

E
esterzhou 已提交
760
**Parameters**
E
esterzhou 已提交
761

E
esterzhou 已提交
762 763 764
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| callback | AsyncCallback&lt;boolean&gt; | Yes| Callback used to return the result. Returns **true** if touch guide mode is enabled; returns **false** otherwise.|
E
esterzhou 已提交
765

E
esterzhou 已提交
766
**Example**
E
esterzhou 已提交
767

E
esterzhou 已提交
768 769 770 771 772 773 774 775 776
```ts
accessibility.isOpenTouchGuide((err, data) => {
    if (err) {
        console.error('failed to isOpenTouchGuide because ' + JSON.stringify(err));
        return;
    }
    console.info('success data:isOpenTouchGuide : ' + JSON.stringify(data))
});
```
E
esterzhou 已提交
777

E
esterzhou 已提交
778
## accessibility.sendEvent<sup>(deprecated)</sup>
E
esterzhou 已提交
779 780 781 782 783

sendEvent(event: EventInfo): Promise&lt;void&gt;

Sends an accessibility event. This API uses a promise to return the result.

E
esterzhou 已提交
784 785 786 787
> **NOTE**
>
> This API is supported since API version 7 and deprecated since API version 9.
> You are advised to use **[sendAccessibilityEvent()](#accessibilitysendaccessibilityevent9)**.
E
esterzhou 已提交
788

E
esterzhou 已提交
789
**System capability**: SystemCapability.BarrierFree.Accessibility.Core
E
esterzhou 已提交
790

E
esterzhou 已提交
791
**Parameters**
E
esterzhou 已提交
792

E
esterzhou 已提交
793 794 795
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| event | [EventInfo](#eventinfo) | Yes| Accessibility event.|
E
esterzhou 已提交
796

E
esterzhou 已提交
797
**Return value**
E
esterzhou 已提交
798

E
esterzhou 已提交
799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816
| Type| Description|
| -------- | -------- |
| Promise&lt;void&gt; | Promise that returns no value.|

**Example**

```ts
let eventInfo = new accessibility.EventInfo({
  'type':'click',
  'bundleName':'com.example.MyApplication',
  'triggerAction':'click'
});
accessibility.sendEvent(eventInfo).then(() => {
    console.info('send event success');
}).catch((err) => {
    console.error('failed to sendEvent because ' + JSON.stringify(err));
});
```
E
esterzhou 已提交
817

E
esterzhou 已提交
818
## accessibility.sendEvent<sup>(deprecated)</sup>
E
esterzhou 已提交
819 820 821 822 823

sendEvent(event: EventInfo, callback: AsyncCallback&lt;void&gt;): void

Sends an accessibility event. This API uses an asynchronous callback to return the result.

E
esterzhou 已提交
824 825 826 827 828
> **NOTE**
>
> This API is supported since API version 7 and deprecated since API version 9.
> You are advised to use **[sendAccessibilityEvent()](#accessibilitysendaccessibilityevent9-1)**.

E
ester.zhou 已提交
829
**System capability**: SystemCapability.BarrierFree.Accessibility.Core
E
esterzhou 已提交
830

E
esterzhou 已提交
831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853
**Parameters**

| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| event | [EventInfo](#eventinfo) | Yes| Accessibility event.|
| callback | AsyncCallback&lt;void&gt; | Yes| Callback used to return the result. If the operation fails, **error** that contains data is returned. |

**Example**

```ts
let eventInfo = new accessibility.EventInfo({
  'type':'click',
  'bundleName':'com.example.MyApplication',
  'triggerAction':'click'
});
accessibility.sendEvent(eventInfo, (err, data) => {
    if (err) {
        console.error('failed to sendEvent because ' + JSON.stringify(err));
        return;
    }
    console.info('sendEvent success');
});
```
E
esterzhou 已提交
854

E
esterzhou 已提交
855
## accessibility.sendAccessibilityEvent<sup>9+</sup>
E
esterzhou 已提交
856

E
esterzhou 已提交
857
sendAccessibilityEvent(event: EventInfo): Promise&lt;void&gt;
E
esterzhou 已提交
858

E
esterzhou 已提交
859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928
Sends an accessibility event. This API uses a promise to return the result.

**System capability**: SystemCapability.BarrierFree.Accessibility.Core

**Parameters**

| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| event | [EventInfo](#eventinfo) | Yes| Accessibility event.|

**Return value**

| Type| Description|
| -------- | -------- |
| Promise&lt;void&gt; | Promise that returns no value.|

**Example**

```ts
let eventInfo = new accessibility.EventInfo({
    'type':'click',
    'bundleName':'com.example.MyApplication',
    'triggerAction':'click'
});
try {
    accessibility.sendAccessibilityEvent(eventInfo).then(() => {
        console.info('send event success');
    }).catch((err) => {
        console.error('failed to send event because ' + JSON.stringify(err));
    });
} catch (exception) {
    console.error('failed to send event because ' + JSON.stringify(exception));
}
```

## accessibility.sendAccessibilityEvent<sup>9+</sup>

sendAccessibilityEvent(event: EventInfo, callback: AsyncCallback&lt;void&gt;): void

Sends an accessibility event. This API uses an asynchronous callback to return the result.

**System capability**: SystemCapability.BarrierFree.Accessibility.Core

**Parameters**

| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| event | [EventInfo](#eventinfo) | Yes| Accessibility event.|
| callback | AsyncCallback&lt;void&gt; | Yes| Callback used to return the result. If the operation fails, **error** that contains data is returned. |

**Example**

```ts
let eventInfo = new accessibility.EventInfo({
    'type':'click',
    'bundleName':'com.example.MyApplication',
    'triggerAction':'click'
});
try {
    accessibility.sendEvent(eventInfo, (err, data) => {
        if (err) {
            console.error('failed to send event because ' + JSON.stringify(err));
            return;
        }
        console.info('send event success');
    });
} catch (exception) {
    console.error('failed to send event because ' + JSON.stringify(exception));
}
```