1# @ohos.accessibility 2 3The **Accessibility** module implements the accessibility functions, including obtaining the accessibility application list, accessibility application enabled status, and captions configuration. 4 5> **NOTE** 6> 7> 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. 8 9## Modules to Import 10 11```ts 12import accessibility from '@ohos.accessibility'; 13``` 14 15## AbilityState 16 17Enumerates the states of an accessibility application. 18 19**System capability**: SystemCapability.BarrierFree.Accessibility.Core 20 21| Name| Description| 22| -------- | -------- | 23| enable | The accessibility application is enabled.| 24| disable | The accessibility application is disabled.| 25| install | The accessibility application has been installed.| 26 27## AbilityType 28 29Enumerates the types of accessibility applications. 30 31**System capability**: SystemCapability.BarrierFree.Accessibility.Core 32 33| Name| Description| 34| -------- | -------- | 35| audible | The accessibility application provides audible feedback.| 36| generic | The accessibility application provides generic feedback.| 37| haptic | The accessibility application provides haptic feedback.| 38| spoken | The accessibility application provides spoken feedback.| 39| visual | The accessibility application provides visual feedback.| 40| all<sup>9+</sup> | All the preceding types.| 41 42## AccessibilityAbilityInfo 43 44Provides information about an accessibility application. 45 46**System capability**: SystemCapability.BarrierFree.Accessibility.Core 47 48### Attributes 49 50| Name| Type| Readable| Writable| Description| 51| -------- | -------- | -------- | -------- | -------- | 52| id | string | Yes| No| Ability ID.| 53| name | string | Yes| No| Ability name.| 54| bundleName | string | Yes| No| Bundle name.| 55| targetBundleNames<sup>9+</sup> | Array<string> | Yes| No| Name of the target bundle.| 56| abilityTypes | Array<[AbilityType](#abilitytype)> | Yes| No| Accessibility application type.| 57| capabilities | Array<[Capability](#capability)> | Yes| No| Capabilities list of the accessibility application.| 58| description | string | Yes| No| Description of the accessibility application.| 59| eventTypes | Array<[EventType](#eventtype)> | Yes| No| List of events that the accessibility application focuses on.| 60 61## Action 62 63Describes the target action supported by an accessibility application. 64 65**System capability**: SystemCapability.BarrierFree.Accessibility.Core 66 67| Name| Description| 68| -------- | -------- | 69| click | Clicking.| 70| longClick | Long pressing.| 71| scrollForward | Scrolling forward.| 72| scrollBackward | Scrolling backward.| 73| focus | Obtaining focus.| 74| clearFocus | Clearing focus.| 75| clearSelection | Clearing selection.| 76| accessibilityFocus | Obtaining the accessibility focus.| 77| clearAccessibilityFocus | Clearing the accessibility focus.| 78| cut | Cut.| 79| copy | Copy.| 80| paste | Paste.| 81| select | Select.| 82| setText | Setting the text.| 83| delete | Delete.| 84| setSelection | Setting the selection.| 85 86## Capability 87 88Enumerates the capabilities of an accessibility application. 89 90**System capability**: SystemCapability.BarrierFree.Accessibility.Core 91 92| Name| Description| 93| -------- | -------- | 94| retrieve | Capability to retrieve the window content.| 95| touchGuide | Capability of touch guide mode.| 96| keyEventObserver | Capability to filter key events.| 97| zoom | Capability to control the display zoom level.| 98| gesture | Capability to perform gesture actions.| 99 100## CaptionsFontEdgeType<sup>8+</sup> 101 102Enumerates the font edge types of captions. 103 104**System capability**: SystemCapability.BarrierFree.Accessibility.Hearing 105 106| Name| Description| 107| -------- | -------- | 108| none | No effect.| 109| raised | Raised effect.| 110| depressed | Depressed effect.| 111| uniform | Uniform effect.| 112| dropShadow | Drop shadow effect.| 113 114## CaptionsFontFamily<sup>8+</sup> 115 116Enumerates the font families of captions. 117 118**System capability**: SystemCapability.BarrierFree.Accessibility.Hearing 119 120| Name| Description| 121| -------- | -------- | 122| default | Default font family.| 123| monospacedSerif | Monospaced Serif fonts, which use the same width for each character.| 124| serif | Serif fonts.| 125| monospacedSansSerif | Monospaced Sans Serif fonts, which use the same width for each character.| 126| sansSerif | Sans Serif fonts.| 127| casual | Casual fonts.| 128| cursive | Cursive fonts.| 129| smallCapitals | Small caps fonts.| 130 131## CaptionsStyle<sup>8+</sup> 132 133Describes the style of captions. 134 135**System capability**: SystemCapability.BarrierFree.Accessibility.Hearing 136 137| Name| Type| Readable| Writable| Description| 138| -------- | -------- | -------- | -------- | -------- | 139| fontFamily | [CaptionsFontFamily](#captionsfontfamily8) | Yes| No| Font family of captions.| 140| fontScale | number | Yes| No| Font scale of captions.| 141| fontColor | number \| string | Yes| No| Font color of captions.| 142| fontEdgeType | [CaptionsFontEdgeType](#captionsfontedgetype8) | Yes| No| Font edge type of captions.| 143| backgroundColor | number \| string | Yes| No| Background color of captions.| 144| windowColor | number \| string | Yes| No| Window color of captions.| 145 146## CaptionsManager<sup>8+</sup> 147 148Implements configuration management for captions. Before calling any API of **CaptionsManager**, you must use the [accessibility.getCaptionsManager()](#accessibilitygetcaptionsmanager8) API to obtain a **CaptionsManager** instance. 149 150**System capability**: SystemCapability.BarrierFree.Accessibility.Hearing 151 152### Attributes 153 154| Name| Type| Readable| Writable| Description| 155| -------- | -------- | -------- | -------- | -------- | 156| enabled | boolean | Yes| No| Whether to enable captions configuration.| 157| style | [CaptionsStyle](#captionsstyle8) | Yes| No| Style of captions.| 158 159### on('enableChange') 160 161on(type: 'enableChange', callback: Callback<boolean>): void; 162 163Enables listening for the enabled status changes of captions configuration. This API uses an asynchronous callback to return the result. 164 165**Parameters** 166 167| Name| Type| Mandatory| Description| 168| -------- | -------- | -------- | -------- | 169| type | string | Yes| Type of the event to listen for, which is set to **'enableChange'** in this API.| 170| callback | Callback<boolean> | Yes| Callback invoked when the enabled status of captions configuration changes.| 171 172**Example** 173 174```ts 175let captionsManager = accessibility.getCaptionsManager(); 176try { 177 captionsManager.on('enableChange', (data) => { 178 console.info('subscribe caption manager enable state change, result: ' + JSON.stringify(data)); 179 }); 180} catch (exception) { 181 console.error('failed to subscribe caption manager enable state change, because ' + JSON.stringify(exception)); 182} 183``` 184 185### on('styleChange') 186 187on(type: 'styleChange', callback: Callback<CaptionsStyle>): void; 188 189Enables listening for captions style changes. This API uses an asynchronous callback to return the result. 190 191**Parameters** 192 193| Name| Type| Mandatory| Description| 194| -------- | -------- | -------- | -------- | 195| type | string | Yes| Type of the event to listen for, which is set to **'styleChange'** in this API.| 196| callback | Callback<[CaptionsStyle](#captionsstyle8)> | Yes| Callback invoked when the style of captions changes.| 197 198**Example** 199 200```ts 201let captionStyle; 202let captionsManager = accessibility.getCaptionsManager(); 203try { 204 captionsManager.on('styleChange', (data) => { 205 captionStyle = data; 206 console.info('subscribe caption manager style state change, result: ' + JSON.stringify(data)); 207 }); 208} catch (exception) { 209 console.error('failed to subscribe caption manager style state change, because ' + JSON.stringify(exception)); 210} 211``` 212 213### off('enableChange') 214 215off(type: 'enableChange', callback?: Callback<boolean>): void; 216 217Disables listening for the enabled status changes of captions configuration. This API uses an asynchronous callback to return the result. 218 219**Parameters** 220 221| Name| Type| Mandatory| Description| 222| -------- | -------- | -------- | -------- | 223| type | string | Yes| Type of the event to listen for, which is set to **'enableChange'** in this API.| 224| callback | Callback<boolean> | No| Callback invoked when the enabled status of captions configuration changes.| 225 226**Example** 227 228```ts 229let captionsManager = accessibility.getCaptionsManager(); 230try { 231 captionsManager.off('enableChange', (data) => { 232 console.info('Unsubscribe caption manager enable state change, result: ' + JSON.stringify(data)); 233 }); 234} catch (exception) { 235 console.error('failed to Unsubscribe caption manager enable state change, because ' + JSON.stringify(exception)); 236} 237``` 238 239### off('styleChange') 240 241off(type: 'styleChange', callback?: Callback<CaptionsStyle>): void; 242 243Disables listening for captions style changes. This API uses an asynchronous callback to return the result. 244 245**Parameters** 246 247| Name| Type| Mandatory| Description| 248| -------- | -------- | -------- | -------- | 249| type | string | Yes| Type of the event to listen for, which is set to **'styleChange'** in this API.| 250| callback | Callback<[CaptionsStyle](#captionsstyle8)> | No| Callback invoked when the style of captions changes.| 251 252**Example** 253 254```ts 255let captionStyle; 256let captionsManager = accessibility.getCaptionsManager(); 257try { 258 captionsManager.off('styleChange', (data) => { 259 captionStyle = data; 260 console.info('Unsubscribe caption manager style state change, result: ' + JSON.stringify(data)); 261 }); 262} catch (exception) { 263 console.error('failed to Unsubscribe caption manager style state change, because ' + JSON.stringify(exception)); 264} 265``` 266 267## EventInfo 268 269Describes a GUI change event. 270 271**System capability**: SystemCapability.BarrierFree.Accessibility.Core 272 273### Attributes 274 275| Name| Type| Readable| Writable| Description| 276| -------- | -------- | -------- | -------- | -------- | 277| type | [EventType](#eventtype) | Yes| Yes| Accessibility event type.| 278| windowUpdateType | [WindowUpdateType](#windowupdatetype) | Yes| Yes| Window update type.| 279| bundleName | string | Yes| Yes| Target application name.| 280| componentType | string | Yes| Yes| Type of the event source component, for example, button or chart.| 281| pageId | number | Yes| Yes| Page ID of the event source.| 282| description | string | Yes| Yes| Event description.| 283| triggerAction | [Action](#action) | Yes| Yes| Action that triggers the event.| 284| textMoveUnit | [TextMoveUnit](#textmoveunit) | Yes| Yes| Text movement unit.| 285| contents | Array<string> | Yes| Yes| Array of contents.| 286| lastContent | string | Yes| Yes| Latest content.| 287| beginIndex | number | Yes| Yes| Sequence number of the first item displayed on the page.| 288| currentIndex | number | Yes| Yes| Sequence number of the current item.| 289| endIndex | number | Yes| Yes| Sequence number of the last item displayed on the page.| 290| itemCount | number | Yes| Yes| Total number of items.| 291 292### constructor 293 294constructor(jsonObject) 295 296Implements a constructor. 297 298**System capability**: SystemCapability.BarrierFree.Accessibility.Core 299 300**Parameters** 301 302| Name| Type| Mandatory| Description| 303| -------- | -------- | -------- | -------- | 304| jsonObject | string | Yes| JSON string required for creating an object.| 305 306**Example** 307 308 ```ts 309 let eventInfo = new accessibility.EventInfo({ 310 'type':'click', 311 'bundleName':'com.example.MyApplication', 312 'triggerAction':'click' 313 }); 314 ``` 315 316## EventType 317 318Enumerates accessibility event types. 319 320**System capability**: SystemCapability.BarrierFree.Accessibility.Core 321 322| Name| Description| 323| -------- | -------- | 324| click | Event of clicking a component.| 325| longClick | Event of long-pressing a component.| 326| select | Event of selecting a component.| 327| focus | Event indicating that the component obtains the focus.| 328| textUpdate | Event indicating that the component text has been updated.| 329| hoverEnter | Event indicating that the hover enters a component.| 330| hoverExit | Event indicating that the hover exits a component.| 331| scroll | Event of the scroll view.| 332| textSelectionUpdate | Event indicating that the selected text has been updated.| 333| accessibilityFocus | Event indicating that the accessibility focus has been obtained.| 334| accessibilityFocusClear | Event indicating that the accessibility focus has been cleared.| 335 336## TextMoveUnit 337 338Enumerates the movement units for traversing the node text. 339 340**System capability**: SystemCapability.BarrierFree.Accessibility.Core 341 342| Name| Description| 343| -------- | -------- | 344| char | The movement unit for traversing the node text is by character.| 345| word | The movement unit for traversing the node text is by word.| 346| line | The movement unit for traversing the node text is by line.| 347| page | The movement unit for traversing the node text is by page.| 348| paragraph | The movement unit for traversing the node text is by paragraph.| 349 350## WindowUpdateType 351 352Enumerates window update types. 353 354**System capability**: SystemCapability.BarrierFree.Accessibility.Core 355 356| Name| Description| 357| -------- | -------- | 358| add | Window adding.| 359| remove | Window deletion.| 360| bounds | Window boundary change.| 361| active | Window activity change.| 362| focus | Window focus change.| 363 364## accessibility.getAbilityLists<sup>(deprecated)</sup> 365 366getAbilityLists(abilityType: AbilityType, stateType: AbilityState): Promise<Array<AccessibilityAbilityInfo>> 367 368Obtains the accessibility application list. This API uses a promise to return the result. 369 370> **NOTE** 371> 372> This API is supported since API version 7 and deprecated since API version 9. 373> You are advised to use[getAccessibilityExtensionList()](#accessibilitygetaccessibilityextensionlist9). 374 375**System capability**: SystemCapability.BarrierFree.Accessibility.Core 376 377**Parameters** 378 379| Name| Type| Mandatory| Description| 380| -------- | -------- | -------- | -------- | 381| abilityType | [AbilityType](#abilitytype) | Yes| Accessibility application type.| 382| stateType | [AbilityState](#abilitystate) | Yes| Accessibility application status.| 383 384**Return value** 385 386| Type| Description| 387| -------- | -------- | 388| Promise<Array<[AccessibilityAbilityInfo](#accessibilityabilityinfo)>> | Promise used to return the accessibility application list.| 389 390**Example** 391 392```ts 393let abilityType = 'spoken'; 394let abilityState = 'enable'; 395let abilityList: accessibility.AccessibilityInfo[]; 396try { 397 accessibility.getAbilityLists(abilityType, abilityState).then((data) => { 398 for (let item of data) { 399 console.info(item.id); 400 console.info(item.name); 401 console.info(item.description); 402 console.info(item.bundleName); 403 extensionList.push(item); 404 } 405 console.info('get accessibility extension list success'); 406 }).catch((err) => { 407 console.error('failed to get accessibility extension list because ' + JSON.stringify(err)); 408 }); 409} catch (exception) { 410 console.error('failed to get accessibility extension list because ' + JSON.stringify(exception)); 411} 412``` 413 414## accessibility.getAbilityLists<sup>(deprecated)</sup> 415 416getAbilityLists(abilityType: AbilityType, stateType: AbilityState,callback: AsyncCallback<Array<AccessibilityAbilityInfo>>): void 417 418Obtains the accessibility application list. This API uses an asynchronous callback to return the result. 419 420> **NOTE** 421> 422> This API is supported since API version 7 and deprecated since API version 9. 423> You are advised to use [getAccessibilityExtensionList()](#accessibilitygetaccessibilityextensionlist9-1). 424 425**System capability**: SystemCapability.BarrierFree.Accessibility.Core 426 427**Parameters** 428 429| Name| Type| Mandatory| Description| 430| -------- | -------- | -------- | -------- | 431| abilityType | [AbilityType](#abilitytype) | Yes| Accessibility application type.| 432| stateType | [AbilityState](#abilitystate) | Yes| Accessibility application status.| 433| callback | AsyncCallback<Array<[AccessibilityAbilityInfo](#accessibilityabilityinfo)>> | Yes| Callback used to return the accessibility application list.| 434 435**Example** 436 437```ts 438let abilityType = 'spoken'; 439let abilityState = 'enable'; 440let abilityList: accessibility.AccessibilityInfo[]; 441try { 442 accessibility.getAbilityLists(abilityType, abilityState, (err, data) => { 443 if (err) { 444 console.error('failed to get accessibility extension list because ' + JSON.stringify(err)); 445 return; 446 } 447 for (let item of data) { 448 console.info(item.id); 449 console.info(item.name); 450 console.info(item.description); 451 console.info(item.bundleName); 452 abilityList.push(item); 453 } 454 console.info('get accessibility extension list success'); 455 }).catch((err) => { 456 console.error('failed to get accessibility extension list because ' + JSON.stringify(err)); 457 }); 458} catch (exception) { 459 console.error('failed to get accessibility extension list because ' + JSON.stringify(exception)); 460} 461``` 462 463## accessibility.getAccessibilityExtensionList<sup>9+</sup> 464 465getAccessibilityExtensionList(abilityType: AbilityType, stateType: AbilityState): Promise<Array<AccessibilityAbilityInfo>> 466 467Obtains the accessibility application list. This API uses a promise to return the result. 468 469**System capability**: SystemCapability.BarrierFree.Accessibility.Core 470 471**Parameters** 472 473| Name| Type| Mandatory| Description| 474| -------- | -------- | -------- | -------- | 475| abilityType | [AbilityType](#abilitytype) | Yes| Accessibility application type.| 476| stateType | [AbilityState](#abilitystate) | Yes| Accessibility application status.| 477 478**Return value** 479 480| Type| Description| 481| -------- | -------- | 482| Promise<Array<[AccessibilityAbilityInfo](#accessibilityabilityinfo)>> | Promise used to return the accessibility application list.| 483 484**Example** 485 486```ts 487let abilityType : accessibility.AbilityType = 'spoken'; 488let abilityState : accessibility.AbilityState = 'enable'; 489let extensionList: accessibility.AccessibilityAbilityInfo[] = []; 490try { 491 accessibility.getAccessibilityExtensionList(abilityType, abilityState).then((data) => { 492 for (let item of data) { 493 console.info(item.id); 494 console.info(item.name); 495 console.info(item.description); 496 console.info(item.bundleName); 497 extensionList.push(item); 498 } 499 console.info('get accessibility extension list success'); 500 }).catch((err) => { 501 console.error('failed to get accessibility extension list because ' + JSON.stringify(err)); 502 }); 503} catch (exception) { 504 console.error('failed to get accessibility extension list because ' + JSON.stringify(exception)); 505} 506``` 507 508## accessibility.getAccessibilityExtensionList<sup>9+</sup> 509 510getAccessibilityExtensionList(abilityType: AbilityType, stateType: AbilityState, callback: AsyncCallback<Array<AccessibilityAbilityInfo>>): void 511 512Obtains the accessibility application list. This API uses an asynchronous callback to return the result. 513 514**System capability**: SystemCapability.BarrierFree.Accessibility.Core 515 516**Parameters** 517 518| Name| Type| Mandatory| Description| 519| -------- | -------- | -------- | -------- | 520| abilityType | [AbilityType](#abilitytype) | Yes| Accessibility application type.| 521| stateType | [AbilityState](#abilitystate) | Yes| Accessibility application status.| 522| callback | AsyncCallback<Array<[AccessibilityAbilityInfo](#accessibilityabilityinfo)>> | Yes| Callback used to return the accessibility application list.| 523 524**Example** 525 526```ts 527let abilityType : accessibility.AbilityType = 'spoken'; 528let abilityState : accessibility.AbilityState = 'enable'; 529let extensionList: accessibility.AccessibilityAbilityInfo[] = []; 530try { 531 accessibility.getAccessibilityExtensionList(abilityType, abilityState, (err, data) => { 532 if (err) { 533 console.error('failed to get accessibility extension list because ' + JSON.stringify(err)); 534 return; 535 } 536 for (let item of data) { 537 console.info(item.id); 538 console.info(item.name); 539 console.info(item.description); 540 console.info(item.bundleName); 541 extensionList.push(item); 542 } 543 console.info('get accessibility extension list success'); 544 }); 545} catch (exception) { 546 console.error('failed to get accessibility extension list because ' + JSON.stringify(exception)); 547} 548``` 549 550## accessibility.getCaptionsManager<sup>8+</sup> 551 552getCaptionsManager(): CaptionsManager 553 554Obtains a **CaptionsManager** instance. 555 556**System capability**: SystemCapability.BarrierFree.Accessibility.Hearing 557 558**Return value** 559 560| Type| Description| 561| -------- | -------- | 562| [CaptionsManager](#captionsmanager8) | Captions configuration.| 563 564**Example** 565 566```ts 567let captionsManager = accessibility.getCaptionsManager(); 568``` 569 570## accessibility.on('accessibilityStateChange') 571 572on(type: 'accessibilityStateChange', callback: Callback<boolean>): void 573 574Enables listening for the enabled status changes of the accessibility application. This API uses an asynchronous callback to return the result. 575 576 577 578**Parameters** 579 580| Name| Type| Mandatory| Description| 581| -------- | -------- | -------- | -------- | 582| type | string | Yes| Type of the event to listen for, which is set to **'accessibilityStateChange'** in this API.| 583| callback | Callback<boolean> | Yes| Callback used to return the result.| 584 585**Example** 586 587```ts 588try { 589 accessibility.on('accessibilityStateChange', (data) => { 590 console.info('subscribe accessibility state change, result: ' + JSON.stringify(data)); 591 }); 592} catch (exception) { 593 console.error('failed to subscribe accessibility state change, because ' + JSON.stringify(exception)); 594} 595``` 596 597## accessibility.on('touchGuideStateChange') 598 599on(type: 'touchGuideStateChange', callback: Callback<boolean>): void 600 601Enables listening for the enabled status changes of the touch guide mode. This API uses an asynchronous callback to return the result. 602 603 604 605**Parameters** 606 607| Name| Type| Mandatory| Description| 608| -------- | -------- | -------- | -------- | 609| type | string | Yes| Type of the event to listen for, which is set to **'touchGuideStateChange'** in this API.| 610| callback | Callback<boolean> | Yes| Callback used to return the result.| 611 612**Example** 613 614```ts 615try { 616 accessibility.on('touchGuideStateChange', (data) => { 617 console.info('subscribe touch guide state change, result: ' + JSON.stringify(data)); 618 }); 619} catch (exception) { 620 console.error('failed to subscribe touch guide state change, because ' + JSON.stringify(exception)); 621} 622``` 623 624## accessibility.off('accessibilityStateChange') 625 626off(type: 'accessibilityStateChange', callback?: Callback<boolean>): void 627 628Disables listening for the enabled status changes of the accessibility application. This API uses an asynchronous callback to return the result. 629 630 631 632**Parameters** 633 634| Name| Type| Mandatory| Description| 635| -------- | -------- | -------- | -------- | 636| type | string | No| Type of the event to listen for, which is set to **'accessibilityStateChange'** in this API.| 637| callback | Callback<boolean> | No| Callback used to return the result.| 638 639**Example** 640 641```ts 642try { 643 accessibility.off('accessibilityStateChange', (data) => { 644 console.info('Unsubscribe accessibility state change, result: ' + JSON.stringify(data)); 645 }); 646} catch (exception) { 647 console.error('failed to Unsubscribe accessibility state change, because ' + JSON.stringify(exception)); 648} 649``` 650 651## accessibility.off('touchGuideStateChange') 652 653off(type: 'touchGuideStateChange', callback?: Callback<boolean>): void 654 655Disables listening for the enabled status changes of the touch guide mode. This API uses an asynchronous callback to return the result. 656 657 658 659**Parameters** 660 661| Name| Type| Mandatory| Description| 662| -------- | -------- | -------- | -------- | 663| type | string | No| Type of the event to listen for, which is set to **'touchGuideStateChange'** in this API.| 664| callback | Callback<boolean> | No| Callback used to return the result.| 665 666**Example** 667 668```ts 669try { 670 accessibility.off('touchGuideStateChange', (data) => { 671 console.info('Unsubscribe touch guide state change, result: ' + JSON.stringify(data)); 672 }); 673} catch (exception) { 674 console.error('failed to Unsubscribe touch guide state change, because ' + JSON.stringify(exception)); 675} 676``` 677 678## accessibility.isOpenAccessibility 679 680isOpenAccessibility(): Promise<boolean> 681 682Checks whether accessibility is enabled. This API uses a promise to return the result. 683 684**System capability**: SystemCapability.BarrierFree.Accessibility.Core 685 686**Return value** 687 688| Type| Description| 689| -------- | -------- | 690| Promise<boolean> | Promise used to return the result. Returns **true** if accessibility is enabled; returns **false** otherwise.| 691 692**Example** 693 694```ts 695accessibility.isOpenAccessibility().then((data) => { 696 console.info('success data:isOpenAccessibility : ' + JSON.stringify(data)) 697}).catch((err) => { 698 console.error('failed to isOpenAccessibility because ' + JSON.stringify(err)); 699}); 700``` 701 702## accessibility.isOpenAccessibility 703 704isOpenAccessibility(callback: AsyncCallback<boolean>): void 705 706Checks whether accessibility is enabled. This API uses an asynchronous callback to return the result. 707 708**System capability**: SystemCapability.BarrierFree.Accessibility.Core 709 710**Parameters** 711 712| Name| Type| Mandatory| Description| 713| -------- | -------- | -------- | -------- | 714| callback | AsyncCallback<boolean> | Yes| Callback used to return the result. Returns **true** if accessibility is enabled; returns **false** otherwise.| 715 716**Example** 717 718```ts 719accessibility.isOpenAccessibility((err, data) => { 720 if (err) { 721 console.error('failed to isOpenAccessibility because ' + JSON.stringify(err)); 722 return; 723 } 724 console.info('success data:isOpenAccessibility : ' + JSON.stringify(data)) 725}); 726``` 727 728## accessibility.isOpenTouchGuide 729 730isOpenTouchGuide(): Promise<boolean> 731 732Checks whether touch guide mode is enabled. This API uses a promise to return the result. 733 734**System capability**: SystemCapability.BarrierFree.Accessibility.Vision 735 736**Return value** 737 738| Type| Description| 739| -------- | -------- | 740| Promise<boolean> | Promise used to return the result. Returns **true** if touch guide mode is enabled; returns **false** otherwise.| 741 742**Example** 743 744```ts 745accessibility.isOpenTouchGuide().then((data) => { 746 console.info('success data:isOpenTouchGuide : ' + JSON.stringify(data)) 747}).catch((err) => { 748 console.error('failed to isOpenTouchGuide because ' + JSON.stringify(err)); 749}); 750``` 751 752## accessibility.isOpenTouchGuide 753 754isOpenTouchGuide(callback: AsyncCallback<boolean>): void 755 756Checks whether touch guide mode is enabled. This API uses an asynchronous callback to return the result. 757 758**System capability**: SystemCapability.BarrierFree.Accessibility.Vision 759 760**Parameters** 761 762| Name| Type| Mandatory| Description| 763| -------- | -------- | -------- | -------- | 764| callback | AsyncCallback<boolean> | Yes| Callback used to return the result. Returns **true** if touch guide mode is enabled; returns **false** otherwise.| 765 766**Example** 767 768```ts 769accessibility.isOpenTouchGuide((err, data) => { 770 if (err) { 771 console.error('failed to isOpenTouchGuide because ' + JSON.stringify(err)); 772 return; 773 } 774 console.info('success data:isOpenTouchGuide : ' + JSON.stringify(data)) 775}); 776``` 777 778## accessibility.sendEvent<sup>(deprecated)</sup> 779 780sendEvent(event: EventInfo): Promise<void> 781 782Sends an accessibility event. This API uses a promise to return the result. 783 784> **NOTE** 785> 786> This API is supported since API version 7 and deprecated since API version 9. 787> You are advised to use **[sendAccessibilityEvent()](#accessibilitysendaccessibilityevent9)**. 788 789**System capability**: SystemCapability.BarrierFree.Accessibility.Core 790 791**Parameters** 792 793| Name| Type| Mandatory| Description| 794| -------- | -------- | -------- | -------- | 795| event | [EventInfo](#eventinfo) | Yes| Accessibility event.| 796 797**Return value** 798 799| Type| Description| 800| -------- | -------- | 801| Promise<void> | Promise that returns no value.| 802 803**Example** 804 805```ts 806let eventInfo = new accessibility.EventInfo({ 807 'type':'click', 808 'bundleName':'com.example.MyApplication', 809 'triggerAction':'click' 810}); 811accessibility.sendEvent(eventInfo).then(() => { 812 console.info('send event success'); 813}).catch((err) => { 814 console.error('failed to sendEvent because ' + JSON.stringify(err)); 815}); 816``` 817 818## accessibility.sendEvent<sup>(deprecated)</sup> 819 820sendEvent(event: EventInfo, callback: AsyncCallback<void>): void 821 822Sends an accessibility event. This API uses an asynchronous callback to return the result. 823 824> **NOTE** 825> 826> This API is supported since API version 7 and deprecated since API version 9. 827> You are advised to use **[sendAccessibilityEvent()](#accessibilitysendaccessibilityevent9-1)**. 828 829**System capability**: SystemCapability.BarrierFree.Accessibility.Core 830 831**Parameters** 832 833| Name| Type| Mandatory| Description| 834| -------- | -------- | -------- | -------- | 835| event | [EventInfo](#eventinfo) | Yes| Accessibility event.| 836| callback | AsyncCallback<void> | Yes| Callback used to return the result. If the operation fails, **error** that contains data is returned. | 837 838**Example** 839 840```ts 841let eventInfo = new accessibility.EventInfo({ 842 'type':'click', 843 'bundleName':'com.example.MyApplication', 844 'triggerAction':'click' 845}); 846accessibility.sendEvent(eventInfo, (err, data) => { 847 if (err) { 848 console.error('failed to sendEvent because ' + JSON.stringify(err)); 849 return; 850 } 851 console.info('sendEvent success'); 852}); 853``` 854 855## accessibility.sendAccessibilityEvent<sup>9+</sup> 856 857sendAccessibilityEvent(event: EventInfo): Promise<void> 858 859Sends an accessibility event. This API uses a promise to return the result. 860 861**System capability**: SystemCapability.BarrierFree.Accessibility.Core 862 863**Parameters** 864 865| Name| Type| Mandatory| Description| 866| -------- | -------- | -------- | -------- | 867| event | [EventInfo](#eventinfo) | Yes| Accessibility event.| 868 869**Return value** 870 871| Type| Description| 872| -------- | -------- | 873| Promise<void> | Promise that returns no value.| 874 875**Example** 876 877```ts 878let eventInfo = new accessibility.EventInfo({ 879 'type':'click', 880 'bundleName':'com.example.MyApplication', 881 'triggerAction':'click' 882}); 883try { 884 accessibility.sendAccessibilityEvent(eventInfo).then(() => { 885 console.info('send event success'); 886 }).catch((err) => { 887 console.error('failed to send event because ' + JSON.stringify(err)); 888 }); 889} catch (exception) { 890 console.error('failed to send event because ' + JSON.stringify(exception)); 891} 892``` 893 894## accessibility.sendAccessibilityEvent<sup>9+</sup> 895 896sendAccessibilityEvent(event: EventInfo, callback: AsyncCallback<void>): void 897 898Sends an accessibility event. This API uses an asynchronous callback to return the result. 899 900**System capability**: SystemCapability.BarrierFree.Accessibility.Core 901 902**Parameters** 903 904| Name| Type| Mandatory| Description| 905| -------- | -------- | -------- | -------- | 906| event | [EventInfo](#eventinfo) | Yes| Accessibility event.| 907| callback | AsyncCallback<void> | Yes| Callback used to return the result. If the operation fails, **error** that contains data is returned. | 908 909**Example** 910 911```ts 912let eventInfo = new accessibility.EventInfo({ 913 'type':'click', 914 'bundleName':'com.example.MyApplication', 915 'triggerAction':'click' 916}); 917try { 918 accessibility.sendEvent(eventInfo, (err, data) => { 919 if (err) { 920 console.error('failed to send event because ' + JSON.stringify(err)); 921 return; 922 } 923 console.info('send event success'); 924 }); 925} catch (exception) { 926 console.error('failed to send event because ' + JSON.stringify(exception)); 927} 928``` 929