js-apis-accessibility.md 21.1 KB
Newer Older
L
laiguizhong 已提交
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
# 辅助功能

> ![icon-note.gif](public_sys-resources/icon-note.gif) **说明:**
> 本模块首批接口从 API version 7 开始支持。后续版本的新增接口,采用上角标单独标记接口的起始版本。

## 导入模块

```typescript
import accessibility from '@ohos.accessibility';
```

## AbilityState

辅助应用状态类型。

L
laiguizhong 已提交
16
**系统能力**:以下各项对应的系统能力均为 SystemCapability.Barrierfree.Accessibility.Core
L
laiguizhong 已提交
17

L
laiguizhong 已提交
18 19
| 名称 | 描述 |
| -------- | -------- |
L
laiguizhong 已提交
20 21 22
| enable | 辅助应用已启用。 |
| disable | 辅助应用已禁用。 |
| install | 辅助应用已安装。 |
L
laiguizhong 已提交
23 24 25 26 27

## AbilityType

无障碍辅助应用类型。

L
laiguizhong 已提交
28
**系统能力**:以下各项对应的系统能力均为 SystemCapability.Barrierfree.Accessibility.Core
L
laiguizhong 已提交
29

L
laiguizhong 已提交
30 31 32 33 34 35 36 37 38 39 40 41
| 名称 | 描述 |
| -------- | -------- |
| audible | 表示具有听觉反馈。 |
| generic | 表示具有通用反馈。 |
| haptic | 表示具有触觉反馈。 |
| spoken  | 表示具有语音反馈。 |
| visual | 表示具有视觉反馈。 |

## AccessibilityAbilityInfo

辅助应用信息。

L
laiguizhong 已提交
42
**系统能力**:以下各项对应的系统能力均为 SystemCapability.Barrierfree.Accessibility.Core
L
laiguizhong 已提交
43

L
laiguizhong 已提交
44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59
### 属性

| 名称 | 参数类型 | 可读 | 可写 | 说明 |
| -------- | -------- | -------- | -------- | -------- |
| id | number | 是 | 否 | ability id。 |
| name | string | 是 | 否 | ability 名。 |
| bundleName | string | 是 | 否 | 包名。 |
| abilityTypes | Array<[AbilityType](#abilitytype)> | 是 | 否 | 辅助应用类型。 |
| capabilities | Array<[Capability](#capability)> | 是 | 否 | 辅助应用能力列表。 |
| description | string | 是 | 否 | 辅助应用描述。 |
| eventTypes | Array<[EventType](#eventtype)> | 是 | 否 | 辅助应用关注的无障碍事件列表。 |

## Action

应用所支持的目标动作。

L
laiguizhong 已提交
60
**系统能力**:以下各项对应的系统能力均为 SystemCapability.Barrierfree.Accessibility.Core
L
laiguizhong 已提交
61

L
laiguizhong 已提交
62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84
| 名称 | 描述 |
| -------- | -------- |
| click | 表示点击操作。 |
| longClick | 表示长按操作。 |
| scrollForward | 表示向前滚动操作。 |
| scrollBackward | 表示向后滚动操作。 |
| focus | 表示获得焦点操作。 |
| clearFocus | 表示清除焦点操作。 |
| clearSelection | 表示清除选择操作。 |
| accessibilityFocus | 表示获得无障碍焦点操作。 |
| clearAccessibilityFocus | 表示清除无障碍焦点操作。 |
| cut | 表示剪切操作。 |
| copy | 表示复制操作。 |
| paste | 表示粘贴操作。 |
| select | 表示选择操作。 |
| setText | 表示设置文本操作。 |
| delete | 表示删除操作。 |
| setSelection | 表示选择操作。 |

## Capability

辅助应用能力类型。

L
laiguizhong 已提交
85
**系统能力**:以下各项对应的系统能力均为 SystemCapability.Barrierfree.Accessibility.Core
L
laiguizhong 已提交
86

L
laiguizhong 已提交
87 88 89 90 91 92 93 94 95 96 97 98
| 名称 | 描述 |
| -------- | -------- |
| retrieve | 具有检索窗口内容的能力。 |
| touchGuide | 具有触摸探索模式的能力。 |
| keyEventObserver | 具有过滤按键事件的能力。 |
| zoom | 具有控制显示放大的能力。 |
| gesture | 具有执行手势动作的能力。 |

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

字幕字体边缘类型。

L
laiguizhong 已提交
99
**系统能力**:以下各项对应的系统能力均为 SystemCapability.Barrierfree.Accessibility.Hearing
L
laiguizhong 已提交
100

L
laiguizhong 已提交
101 102 103 104 105 106 107 108 109 110 111 112
| 名称 | 描述 |
| -------- | -------- |
| none | 无效果。 |
| raised | 凸起效果。 |
| depressed | 凹陷效果。 |
| uniform | 轮廓效果。 |
| dropShadow | 阴影效果。 |

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

字幕字体。

L
laiguizhong 已提交
113
**系统能力**:以下各项对应的系统能力均为 SystemCapability.Barrierfree.Accessibility.Hearing
L
laiguizhong 已提交
114

L
laiguizhong 已提交
115 116 117 118 119 120 121 122 123 124 125 126 127 128 129
| 名称 | 描述 |
| -------- | -------- |
| default | 默认字体。 |
| monospacedSerif | 等宽 Serif 字体。 |
| serif | Serif 字体。 |
| monospacedSansSerif | 等宽 Sans Serif 字体。 |
| sansSerif | Sans Serif 字体。 |
| casual | 非正式字体。 |
| cursive | 手写字体。 |
| smallCapitals | 小型大写字母字体。 |

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

字幕风格。

L
laiguizhong 已提交
130
**系统能力**:以下各项对应的系统能力均为 SystemCapability.Barrierfree.Accessibility.Hearing
L
laiguizhong 已提交
131

L
laiguizhong 已提交
132 133
| 名称 | 参数类型 | 可读 | 可写 | 说明 |
| -------- | -------- | -------- | -------- | -------- |
L
laiguizhong 已提交
134
| fontFamily | [CaptionsFontFamily](#captionsfontfamily8) | 是 | 否 | 描述字幕字体。 |
L
laiguizhong 已提交
135 136
| fontScale | number | 是 | 否 | 描述字幕字体缩放系数。 |
| fontColor | number \| string | 是 | 否 | 描述字幕字体颜色。 |
L
laiguizhong 已提交
137
| fontEdgeType | [CaptionsFontEdgeType](#captionsfontedgetype8) | 是 | 否 | 描述字幕字体边缘。 |
L
laiguizhong 已提交
138 139 140 141 142 143 144 145 146 147 148
| backgroundColor | number \| string | 是 | 否 | 描述字幕背景颜色。 |
| windowColor | number \| string | 是 | 否 | 描述字幕窗口颜色。 |

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

字幕配置。

### 属性

| 名称 | 参数类型 | 可读 | 可写 | 说明 |
| -------- | -------- | -------- | -------- | -------- |
L
laiguizhong 已提交
149
| enabled | boolean | 是 | 否 | 表示是否启用字幕配置。 |
L
laiguizhong 已提交
150
| style | [CaptionsStyle](#captionsstyle8) | 是 | 否 | 表示字幕风格。 |
L
laiguizhong 已提交
151 152

### 方法
L
laiguizhong 已提交
153

L
laiguizhong 已提交
154
下列 API 示例中都需要使用 [accessibility.getCaptionsManager()](#accessibilitygetcaptionsmanager8) 获取 captionsManager 实例,再通过此实例调用对应的方法。
L
laiguizhong 已提交
155

L
laiguizhong 已提交
156
#### on('enableChange')
L
laiguizhong 已提交
157 158 159 160 161

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

注册字幕配置启用的监听函数。

L
laiguizhong 已提交
162 163
**系统能力**:SystemCapability.Barrierfree.Accessibility.Hearing

L
laiguizhong 已提交
164 165 166 167
- 参数:

  | 参数名 | 参数类型 | 必填 | 说明 |
  | -------- | -------- | -------- | -------- |
L
laiguizhong 已提交
168
  | type | string | 是 | 监听字幕配置启用状态。 |
L
laiguizhong 已提交
169 170 171 172 173
  | callback | Callback&lt;boolean&gt; | 是 | 回调函数,在启用状态变化时将状态通过此函数进行通知。 |

- 示例

  ```typescript
L
laiguizhong 已提交
174
  captionsManager.on('enableChange',(data) => {
L
laiguizhong 已提交
175 176 177 178
      console.info('success data:subscribeStateObserver : ' + JSON.stringify(data))
  })
  ```

L
laiguizhong 已提交
179
#### on('styleChange')
L
laiguizhong 已提交
180 181 182 183 184

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

注册字幕风格变化的监听函数。

L
laiguizhong 已提交
185 186
**系统能力**:SystemCapability.Barrierfree.Accessibility.Hearing

L
laiguizhong 已提交
187 188 189 190
- 参数:

  | 参数名 | 参数类型 | 必填 | 说明 |
  | -------- | -------- | -------- | -------- |
L
laiguizhong 已提交
191
  | type | string | 是 | 监听字幕风格变化。 |
L
laiguizhong 已提交
192
  | callback | Callback&lt;[CaptionsStyle](#captionsstyle8)&gt; | 是 | 回调函数,在字幕风格变化时通过此函数进行通知。 |
L
laiguizhong 已提交
193 194 195 196

- 示例

  ```typescript
L
laiguizhong 已提交
197
  captionsManager.on('styleChange',(data) => {
L
laiguizhong 已提交
198 199 200 201
      console.info('success data:subscribeStateObserver : ' + JSON.stringify(data))
  })
  ```
  
L
laiguizhong 已提交
202
#### off('enableChange')
L
laiguizhong 已提交
203

L
laiguizhong 已提交
204
off(type: 'enableChange', callback?: Callback&lt;boolean&gt;): void;
L
laiguizhong 已提交
205 206 207

移除字幕配置启用的监听函数。

L
laiguizhong 已提交
208 209
**系统能力**:SystemCapability.Barrierfree.Accessibility.Hearing

L
laiguizhong 已提交
210 211 212 213
- 参数:

  | 参数名 | 参数类型 | 必填 | 说明 |
  | -------- | -------- | -------- | -------- |
L
laiguizhong 已提交
214
  | type | string | 是 | 监听字幕配置启用状态。 |
L
laiguizhong 已提交
215 216 217 218 219
  | callback | Callback&lt;boolean&gt; | 否 | 回调函数,在启用状态变化时将状态通过此函数进行通知。 |

- 示例

  ```typescript
L
laiguizhong 已提交
220
  captionsManager.off('enableChange')
L
laiguizhong 已提交
221 222
  ```

L
laiguizhong 已提交
223
#### off('styleChange')
L
laiguizhong 已提交
224 225 226 227 228

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

移除字幕风格变化的监听函数。

L
laiguizhong 已提交
229 230
**系统能力**:SystemCapability.Barrierfree.Accessibility.Hearing

L
laiguizhong 已提交
231 232 233 234
- 参数:

  | 参数名 | 参数类型 | 必填 | 说明 |
  | -------- | -------- | -------- | -------- |
L
laiguizhong 已提交
235
  | type | string | 是 | 字幕风格变化。 |
L
laiguizhong 已提交
236
  | callback | Callback&lt;[CaptionsStyle](#captionsstyle8)&gt; | 否 | 回调函数,在字幕风格变化时通过此函数进行通知。 |
L
laiguizhong 已提交
237 238 239 240

- 示例

  ```typescript
L
laiguizhong 已提交
241
  captionsManager.off('styleChange')
L
laiguizhong 已提交
242 243 244 245 246 247
  ```

## EventInfo

界面变更事件。

L
laiguizhong 已提交
248
**系统能力**:以下各项对应的系统能力均为 SystemCapability.Barrierfree.Accessibility.Core
L
laiguizhong 已提交
249

L
laiguizhong 已提交
250 251 252 253 254 255 256 257 258 259
### 属性

| 名称 | 参数类型 | 可读 | 可写 | 说明 |
| -------- | -------- | -------- | -------- | -------- |
| type | [EventType](#eventtype) | 是 | 是 | 无障碍事件类型。 |
| windowUpdateType | [WindowUpdateType](#windowupdatetype) | 是 | 是 | 窗口变化类型。 |
| bundleName | string | 是 | 是 | 目标应用名。 |
| componentType | string | 是 | 是 | 事件源组件类型,如按钮、图表。 |
| pageId | number | 是 | 是 | 事件源的页面 ID。 |
| description | string | 是 | 是 | 事件描述。 |
L
laiguizhong 已提交
260
| triggerAction | [Action](#action) | 是 | 是 | 触发事件的 Action。 |
L
laiguizhong 已提交
261 262 263 264 265 266 267 268
| textMoveUnit | [TextMoveUnit](#textmoveunit) | 是 | 是 | 文本移动粒度。 |
| contents | Array&lt;string&gt; | 是 | 是 | 内容列表。 |
| lastContent | string | 是 | 是 | 最新内容。 |
| beginIndex | number | 是 | 是 | 画面显示条目的开始序号。 |
| currentIndex | number | 是 | 是 | 当前条目序号。 |
| endIndex | number | 是 | 是 | 画面显示条目的结束序号。 |
| itemCount | number | 是 | 是 | 条目总数。 |

269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288
### 方法

#### constructor

constructor(jsonObject)

构造函数。

- 参数:

  | 参数名 | 参数类型 | 必填 | 说明 |
  | -------- | -------- | -------- | -------- |
  | jsonObject | string | 是 | 创建对象所需要的 JSON 格式字符串。 |

- 示例

  ```typescript
  let eventInfo = new accessibility.EventInfo({"type":"click","bundleName":"com.example.MyApplication","triggerAction":"click"})
  ```

L
laiguizhong 已提交
289 290 291 292
## EventType

无障碍事件类型。

L
laiguizhong 已提交
293
**系统能力**:以下各项对应的系统能力均为 SystemCapability.Barrierfree.Accessibility.Core
L
laiguizhong 已提交
294

L
laiguizhong 已提交
295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312
| 名称 | 描述 |
| -------- | -------- |
| click | 描述点击组件的事件。 |
| longClick | 描述长按组件的事件。 |
| select | 描述选择组件的事件。 |
| focus | 描述组件获得焦点的事件。 |
| textUpdate | 描述组件文本已更改的事件。 |
| hoverEnter | 描述悬停进入组件的事件。 |
| hoverExit | 描述悬停离开组件的事件。 |
| scroll | 描述滚动视图的事件。 |
| textSelectionUpdate | 描述选定文本已更改的事件。 |
| accessibilityFocus | 描述获得无障碍焦点的事件。 |
| accessibilityFocusClear | 描述清除无障碍焦点的事件。 |

## TextMoveUnit

文本无障碍导航移动粒度。

L
laiguizhong 已提交
313
**系统能力**:以下各项对应的系统能力均为 SystemCapability.Barrierfree.Accessibility.Core
L
laiguizhong 已提交
314

L
laiguizhong 已提交
315 316 317 318 319 320 321 322 323 324 325 326
| 名称 | 描述 |
| -------- | -------- |
| char | 以字符为移动粒度遍历节点文本。 |
| word | 以词为移动粒度遍历节点文本。 |
| line | 以行为移动粒度遍历节点文本。 |
| page | 以页为移动粒度遍历节点文本。 |
| paragraph | 以段落为移动粒度遍历节点文本。 |

## WindowUpdateType

窗口变化类型。

L
laiguizhong 已提交
327
**系统能力**:以下各项对应的系统能力均为 SystemCapability.Barrierfree.Accessibility.Core
L
laiguizhong 已提交
328

L
laiguizhong 已提交
329 330 331 332 333 334 335 336 337 338 339 340 341 342
| 名称 | 描述 |
| -------- | -------- |
| add | 添加窗口的窗口变化事件。 |
| remove | 一个窗口被删除的窗口变化事件。 |
| bounds | 窗口边界已更改的窗口变化事件。 |
| active | 窗口变为活动或不活动的窗口变化事件。 |
| focus | 窗口焦点发生变化的窗口变化事件。 |

## accessibility.getAbilityLists

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

查询辅助应用列表。

L
laiguizhong 已提交
343 344
**系统能力**:SystemCapability.Barrierfree.Accessibility.Core

L
laiguizhong 已提交
345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363
- 参数:

  | 参数名 | 参数类型 | 必填 | 说明 |
  | -------- | -------- | -------- | -------- |
  | abilityType | [AbilityType](#abilitytype) | 是 | 辅助应用的类型。 |
  | stateType | [AbilityState](#abilitystate) | 是 | 辅助应用的状态。 |

- 返回值:

  | 类型 | 说明 |
  | -------- | -------- |
  | Promise&lt;Array&lt;[AccessibilityAbilityInfo](#accessibilityabilityinfo)&gt;&gt; | 返回辅助应用信息列表。 |

- 示例

  ```typescript
  accessibility.getAbilityLists("spoken", "enable")
      .then((data) => {
          console.info('success data:getAbilityList1 : ' + JSON.stringify(data));
L
laiguizhong 已提交
364 365 366 367 368 369 370 371 372 373 374 375 376 377
          for (let item of data) {
              console.info(item.id);
              console.info(item.name);
              console.info(item.description);
              console.info(item.abilityTypes);
              console.info(item.eventTypes);
              console.info(item.capabilities);
              console.info(item.packageName);
              console.info(item.filterBundleNames);
              console.info(item.bundleName);
          }
      }).catch((error) => {
          console.error('failed to  getAbilityList1 because ' + JSON.stringify(error));
      })
L
laiguizhong 已提交
378 379 380 381 382 383 384 385
  ```

## accessibility.getAbilityLists

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

查询辅助应用列表。

L
laiguizhong 已提交
386 387
**系统能力**:SystemCapability.Barrierfree.Accessibility.Core

L
laiguizhong 已提交
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 415 416 417 418
- 参数:

  | 参数名 | 参数类型 | 必填 | 说明 |
  | -------- | -------- | -------- | -------- |
  | abilityType | [AbilityType](#abilitytype) | 是 | 辅助应用的类型。 |
  | stateType | [AbilityState](#abilitystate) | 是 | 辅助应用的状态。 |
  | callback | AsyncCallback&lt;Array&lt;[AccessibilityAbilityInfo](#accessibilityabilityinfo)&gt;&gt; | 是 | 回调函数,返回辅助应用信息列表。 |

- 示例

  ```typescript
  accessibility.getAbilityLists("visual", "enable", (err, data) => {
      if (err) {
          console.error('failed to getAbilityList2 because ' + JSON.stringify(err));
          return;
      }
      console.info('success data:getAbilityList2 : ' + JSON.stringify(data));
      for (let item of data) {
          console.info(item.id);
          console.info(item.name);
          console.info(item.description);
          console.info(item.abilityTypes);
          console.info(item.eventTypes);
          console.info(item.capabilities);
          console.info(item.packageName);
          console.info(item.filterBundleNames);
          console.info(item.bundleName);
      }
  })
  ```

L
laiguizhong 已提交
419
## accessibility.getCaptionsManager<sup>8+</sup>
L
laiguizhong 已提交
420 421 422 423 424

getCaptionsManager(): CaptionsManager

获取无障碍字幕配置。

L
laiguizhong 已提交
425 426
**系统能力**:SystemCapability.Barrierfree.Accessibility.Hearing

L
laiguizhong 已提交
427 428 429 430
- 返回值:

  | 类型 | 说明 |
  | -------- | -------- |
L
laiguizhong 已提交
431
  | [CaptionsManager](#captionsmanager8) | 无障碍字幕配置管理。 |
L
laiguizhong 已提交
432 433 434 435 436 437 438

- 示例

  ```typescript
  captionsManager = accessibility.getCaptionsManager()
  ```

L
laiguizhong 已提交
439
## accessibility.on('accessibilityStateChange' | 'touchGuideStateChange')
L
laiguizhong 已提交
440 441 442

on(type: 'accessibilityStateChange' | 'touchGuideStateChange', callback: Callback&lt;boolean&gt;): void

L
laiguizhong 已提交
443 444 445
启用辅助应用和触摸浏览功能的状态变化监听。

**系统能力**:以下各项对应的系统能力有所不同,详见下表。
L
laiguizhong 已提交
446 447 448 449 450

- 参数:

  | 参数名 | 参数类型 | 必填 | 说明 |
  | -------- | -------- | -------- | -------- |
L
laiguizhong 已提交
451
  | type | string | 是 | 监听的事件类型。<br/>-&nbsp;type 为'accessibilityStateChange'时表示监听类型为辅助功能启用状态变化监听;<br/>**系统能力**:SystemCapability.Barrierfree.Accessibility.Core<br/>-&nbsp;type 为'touchGuideStateChange'时表示监听类型为触摸浏览启用状态变化监听。<br/>**系统能力**:SystemCapability.Barrierfree.Accessibility.Vision |
L
laiguizhong 已提交
452 453 454 455 456 457 458 459 460 461
  | callback | Callback&lt;boolean&gt; | 是 | 回调函数,在启用状态变化时将状态通过此函数进行通知。 |

- 示例

  ```typescript
  accessibility.on('accessibilityStateChange',(data) => { 
      console.info('success data:subscribeStateObserver : ' + JSON.stringify(data))
  })
  ```

L
laiguizhong 已提交
462
## accessibility.off('accessibilityStateChange' | 'touchGuideStateChange')
L
laiguizhong 已提交
463 464 465

off(type: ‘accessibilityStateChange ’ | ‘touchGuideStateChange’, callback?: Callback&lt;boolean&gt;): void

L
laiguizhong 已提交
466
关闭辅助应用和触摸浏览功能的状态变化监听。
L
laiguizhong 已提交
467

L
laiguizhong 已提交
468
**系统能力**:以下各项对应的系统能力有所不同,详见下表。
L
laiguizhong 已提交
469

L
laiguizhong 已提交
470 471 472 473
- 参数:

  | 参数名 | 参数类型 | 必填 | 说明 |
  | -------- | -------- | -------- | -------- |
L
laiguizhong 已提交
474
  | type |  string | 否 | 监听的事件类型。<br/>-&nbsp;type 为'accessibilityStateChange'时表示监听类型为辅助功能启用状态变化监听;<br/>**系统能力**:SystemCapability.Barrierfree.Accessibility.Core<br/>-&nbsp;type 为'touchGuideStateChange'时表示监听类型为触摸浏览启用状态变化监听。<br/>**系统能力**:SystemCapability.Barrierfree.Accessibility.Vision |
L
laiguizhong 已提交
475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490
  | callback | Callback&lt;boolean&gt; | 否 | 要取消的监听回调函数。 |

- 示例

  ```typescript
  accessibility.off('accessibilityStateChange',(data) => {
      console.info('success data:unSubscribeStateObserver : ' + JSON.stringify(data))
  })
  ```

## accessibility.isOpenAccessibility

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

判断是否启用了辅助功能。

L
laiguizhong 已提交
491 492
**系统能力**:SystemCapability.Barrierfree.Accessibility.Core

L
laiguizhong 已提交
493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515
- 返回值:

  | 类型 | 说明 |
  | -------- | -------- |
  | Promise&lt;boolean&gt; | 如果辅助功能已启用,则返回 true;否则返回 false。 |

- 示例

  ```typescript
  accessibility.isOpenAccessibility()
      .then((data) => {
          console.info('success data:isOpenAccessibility : ' + JSON.stringify(data))
      }).catch((error) => {
          console.error('failed to  isOpenAccessibility because ' + JSON.stringify(error));
      })
  ```

## accessibility.isOpenAccessibility

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

判断是否启用了辅助功能。

L
laiguizhong 已提交
516 517
**系统能力**:SystemCapability.Barrierfree.Accessibility.Core

L
laiguizhong 已提交
518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541
- 参数

  | 参数名 | 参数类型 | 必填 | 说明 |
  | -------- | -------- | -------- | -------- |
  | callback | AsyncCallback&lt;boolean&gt; | 是 | 回调函数,如果辅助功能已启用,则返回 true;否则返回 false。 |

- 示例

  ```typescript
  accessibility.isOpenAccessibility((err, data) => {
      if (err) {
          console.error('failed to isOpenAccessibility because ' + JSON.stringify(err));
          return;
      }
      console.info('success data:isOpenAccessibility : ' + JSON.stringify(data))
  })
  ```

## accessibility.isOpenTouchGuide

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

判断触摸浏览模式是否开启。

L
laiguizhong 已提交
542 543
**系统能力**:SystemCapability.Barrierfree.Accessibility.Core

L
laiguizhong 已提交
544 545 546 547 548 549 550 551 552 553 554
- 返回值:

  | 类型 | 说明 |
  | -------- | -------- |
  | Promise&lt;boolean&gt; | 如果触摸浏览模式已开启,则返回 true;否则返回 false。 |

- 示例

  ```typescript
  accessibility.isOpenTouchGuide()
      .then((data) => {
L
laiguizhong 已提交
555 556 557 558
          console.info('success data:isOpenTouchGuide : ' + JSON.stringify(data))
      }).catch((error) => {
          console.error('failed to  isOpenTouchGuide because ' + JSON.stringify(error));
      })
L
laiguizhong 已提交
559 560 561 562 563 564 565 566
  ```

## accessibility.isOpenTouchGuide

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

判断触摸浏览模式是否开启。

L
laiguizhong 已提交
567 568
**系统能力**:SystemCapability.Barrierfree.Accessibility.Core

L
laiguizhong 已提交
569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592
- 参数

  | 参数名 | 参数类型 | 必填 | 说明 |
  | -------- | -------- | -------- | -------- |
  | callback | AsyncCallback&lt;boolean&gt; | 是 | 回调函数,如果触摸浏览模式已开启,则返回 true;否则返回 false。 |

- 示例

  ```typescript
  accessibility.isOpenTouchGuide((err, data) => {
      if (err) {
          console.error('failed to isOpenTouchGuide because ' + JSON.stringify(err));
          return;
      }
      console.info('success data:isOpenTouchGuide : ' + JSON.stringify(data))
  })
  ```

## accessibility.sendEvent

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

发送无障碍事件。

L
laiguizhong 已提交
593 594
**系统能力**:SystemCapability.Barrierfree.Accessibility.Core

L
laiguizhong 已提交
595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611
- 参数:

  | 参数名 | 参数类型 | 必填 | 说明 |
  | -------- | -------- | -------- | -------- |
  | event | [EventInfo](#eventinfo) | 是 | 无障碍事件对象。 |

- 返回值:

  | 类型 | 说明 |
  | -------- | -------- |
  | Promise&lt;void&gt; | 以 Promise 形式返回结果,如果发送无障碍事件成功,则 data 有数据返回;如果发送无障碍事件失败,则 err 有数据返回。 |

- 示例

  ```typescript
  accessibility.sendEvent(this.eventInfo)
      .then((data) => {
L
laiguizhong 已提交
612 613 614 615
          console.info('success data:sendEvent : ' + JSON.stringify(data))
      }).catch((error) => {
          console.error('failed to  sendEvent because ' + JSON.stringify(error));
      })
L
laiguizhong 已提交
616 617 618 619 620 621 622 623
  ```

## accessibility.sendEvent

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

发送无障碍事件。

L
laiguizhong 已提交
624 625
**系统能力**:SystemCapability.Barrierfree.Accessibility.Core

L
laiguizhong 已提交
626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643
- 参数:

  | 参数名 | 参数类型 | 必填 | 说明 |
  | -------- | -------- | -------- | -------- |
  | event | [EventInfo](#eventinfo) | 是 | 辅助事件对象。 |
  | callback | AsyncCallback&lt;void&gt; | 是 | 回调函数,如果发送无障碍事件成功,则 AsyncCallback 中 data 有数据返回;如果发送无障碍事件失败,则 AsyncCallback 中 err 有数据返回。 |

- 示例

  ```typescript
  accessibility.sendEvent(this.eventInfo,(err, data) => {
      if (err) {
          console.error('failed to sendEvent because ' + JSON.stringify(err));
          return;
      }   
      console.info('success data:sendEvent : ' + JSON.stringify(data))
  })
  ```