• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1/*
2 * Copyright (c) 2021-2022 Huawei Device Co., Ltd.
3 * Licensed under the Apache License, Version 2.0 (the "License"),
4 * you may not use this file except in compliance with the License.
5 * You may obtain a copy of the License at
6 *
7 *     http://www.apache.org/licenses/LICENSE-2.0
8 *
9 * Unless required by applicable law or agreed to in writing, software
10 * distributed under the License is distributed on an "AS IS" BASIS,
11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 * See the License for the specific language governing permissions and
13 * limitations under the License.
14 */
15
16import type { AsyncCallback } from '../basic';
17import type { Callback } from './@ohos.base';
18import ExtensionContext from './ExtensionContext';
19import type accessibility from '../@ohos.accessibility';
20import type { GesturePath } from '../@ohos.accessibility.GesturePath';
21import type Want from '../@ohos.app.ability.Want';
22
23/**
24 * The accessibility extension context. Used to configure, query information, and inject gestures.
25 *
26 * @extends ExtensionContext
27 * @syscap SystemCapability.BarrierFree.Accessibility.Core
28 * @since 9
29 */
30export default class AccessibilityExtensionContext extends ExtensionContext {
31  /**
32   * Set the bundle names that is interested in sending the event.
33   *
34   * @param { Array<string> } targetNames The bundle names that are interested in sending the event.
35   * @param { AsyncCallback<void> } callback Indicates the listener.
36   * @throws { BusinessError } 401 - Parameter error. Possible causes:
37   *                           1. Mandatory parameters are left unspecified;
38   *                           2. Incorrect parameter types;
39   *                           3. Parameter verification failed.
40   * @syscap SystemCapability.BarrierFree.Accessibility.Core
41   * @since 9
42   */
43  setTargetBundleName(targetNames: Array<string>, callback: AsyncCallback<void>): void;
44
45  /**
46   * Set the bundle names that is interested in sending the event.
47   *
48   * @param { Array<string> } targetNames The bundle names that are interested in sending the event.
49   * @returns { Promise<void> }
50   * @throws { BusinessError } 401 - Parameter error. Possible causes:
51   *                           1. Mandatory parameters are left unspecified;
52   *                           2. Incorrect parameter types;
53   *                           3. Parameter verification failed.
54   * @syscap SystemCapability.BarrierFree.Accessibility.Core
55   * @since 9
56   */
57  setTargetBundleName(targetNames: Array<string>): Promise<void>;
58
59  /**
60   * Get focus element.
61   *
62   * @param { boolean } isAccessibilityFocus Indicates whether the acquired element has an accessibility focus.
63   * @param { AsyncCallback<AccessibilityElement> } callback Indicates the listener.
64   * @throws { BusinessError } 401 - Parameter error. Possible causes:
65   *                           1. Mandatory parameters are left unspecified;
66   *                           2. Incorrect parameter types;
67   *                           3. Parameter verification failed.
68   * @throws { BusinessError } 9300003 -  No accessibility permission to perform the operation.
69   * @syscap SystemCapability.BarrierFree.Accessibility.Core
70   * @since 9
71   */
72  getFocusElement(isAccessibilityFocus: boolean, callback: AsyncCallback<AccessibilityElement>): void;
73
74  /**
75   * Get focus element.
76   *
77   * @param { boolean } isAccessibilityFocus Indicates whether the acquired element has an accessibility focus.
78   * @returns { Promise<AccessibilityElement> }
79   * @throws { BusinessError } 401 - Parameter error. Possible causes:
80   *                           1. Mandatory parameters are left unspecified;
81   *                           2. Incorrect parameter types;
82   *                           3. Parameter verification failed.
83   * @throws { BusinessError } 9300003 -  No accessibility permission to perform the operation.
84   * @syscap SystemCapability.BarrierFree.Accessibility.Core
85   * @since 9
86   */
87  getFocusElement(isAccessibilityFocus?: boolean): Promise<AccessibilityElement>;
88
89  /**
90   * Get focus element.
91   * @param { AsyncCallback<AccessibilityElement> } callback Indicates the listener.
92   * @throws { BusinessError } 401 - Parameter error. Possible causes:
93   *                           1. Mandatory parameters are left unspecified;
94   *                           2. Incorrect parameter types;
95   *                           3. Parameter verification failed.
96   * @throws { BusinessError } 9300003 -  No accessibility permission to perform the operation.
97   * @syscap SystemCapability.BarrierFree.Accessibility.Core
98   * @since 9
99   */
100  getFocusElement(callback: AsyncCallback<AccessibilityElement>): void;
101
102  /**
103   * Get window root element.
104   *
105   * @param { number } windowId Indicates the window ID.
106   * @param { AsyncCallback<AccessibilityElement> } callback Indicates the listener.
107   * @throws { BusinessError } 401 - Parameter error. Possible causes:
108   *                           1. Mandatory parameters are left unspecified;
109   *                           2. Incorrect parameter types;
110   *                           3. Parameter verification failed.
111   * @throws { BusinessError } 9300003 -  No accessibility permission to perform the operation.
112   * @syscap SystemCapability.BarrierFree.Accessibility.Core
113   * @since 9
114   */
115  getWindowRootElement(windowId: number, callback: AsyncCallback<AccessibilityElement>): void;
116
117  /**
118   * Get window root element.
119   *
120   * @param { number } windowId Indicates the window ID.
121   * @returns { Promise<AccessibilityElement> }
122   * @throws { BusinessError } 401 - Parameter error. Possible causes:
123   *                           1. Mandatory parameters are left unspecified;
124   *                           2. Incorrect parameter types;
125   *                           3. Parameter verification failed.
126   * @throws { BusinessError } 9300003 -  No accessibility permission to perform the operation.
127   * @syscap SystemCapability.BarrierFree.Accessibility.Core
128   * @since 9
129   */
130  getWindowRootElement(windowId?: number): Promise<AccessibilityElement>;
131
132  /**
133   * Get window root element.
134   * @param { AsyncCallback<AccessibilityElement> } callback Indicates the listener.
135   * @throws { BusinessError } 401 - Parameter error. Possible causes:
136   *                           1. Mandatory parameters are left unspecified;
137   *                           2. Incorrect parameter types;
138   *                           3. Parameter verification failed.
139   * @throws { BusinessError } 9300003 -  No accessibility permission to perform the operation.
140   * @syscap SystemCapability.BarrierFree.Accessibility.Core
141   * @since 9
142   */
143  getWindowRootElement(callback: AsyncCallback<AccessibilityElement>): void;
144
145  /**
146   * Get window list.
147   *
148   * @param { number } displayId Indicates the display ID.
149   * @param { AsyncCallback<Array<AccessibilityElement>> } callback Indicates the listener.
150   * @throws { BusinessError } 401 - Parameter error. Possible causes:
151   *                           1. Mandatory parameters are left unspecified;
152   *                           2. Incorrect parameter types;
153   *                           3. Parameter verification failed.
154   * @throws { BusinessError } 9300003 -  No accessibility permission to perform the operation.
155   * @syscap SystemCapability.BarrierFree.Accessibility.Core
156   * @since 9
157   */
158  getWindows(displayId: number, callback: AsyncCallback<Array<AccessibilityElement>>): void;
159
160  /**
161   * Get window list.
162   *
163   * @param { number } displayId Indicates the display ID.
164   * @returns { Promise<Array<AccessibilityElement>> }
165   * @throws { BusinessError } 401 - Parameter error. Possible causes:
166   *                           1. Mandatory parameters are left unspecified;
167   *                           2. Incorrect parameter types;
168   *                           3. Parameter verification failed.
169   * @throws { BusinessError } 9300003 -  No accessibility permission to perform the operation.
170   * @syscap SystemCapability.BarrierFree.Accessibility.Core
171   * @since 9
172   */
173  getWindows(displayId?: number): Promise<Array<AccessibilityElement>>;
174
175  /**
176   * Get window list.
177   * @param { AsyncCallback<Array<AccessibilityElement>> } callback Indicates the listener.
178   * @throws { BusinessError } 401 - Parameter error. Possible causes:
179   *                           1. Mandatory parameters are left unspecified;
180   *                           2. Incorrect parameter types;
181   *                           3. Parameter verification failed.
182   * @throws { BusinessError } 9300003 -  No accessibility permission to perform the operation.
183   * @syscap SystemCapability.BarrierFree.Accessibility.Core
184   * @since 9
185   */
186  getWindows(callback: AsyncCallback<Array<AccessibilityElement>>): void;
187
188  /**
189   * Inject gesture path events.
190   *
191   * @param { GesturePath } gesturePath Indicates the gesture path.
192   * @param { AsyncCallback<void> } callback Indicates the listener.
193   * @throws { BusinessError } 401 - Parameter error. Possible causes:
194   *                           1. Mandatory parameters are left unspecified;
195   *                           2. Incorrect parameter types;
196   *                           3. Parameter verification failed.
197   * @throws { BusinessError } 9300003 -  No accessibility permission to perform the operation.
198   * @syscap SystemCapability.BarrierFree.Accessibility.Core
199   * @since 9
200   * @deprecated since 10
201   * @useinstead AccessibilityExtensionContext/AccessibilityExtensionContext#injectGestureSync
202   */
203  injectGesture(gesturePath: GesturePath, callback: AsyncCallback<void>): void;
204
205  /**
206   * Inject gesture path events.
207   *
208   * @param { GesturePath } gesturePath Indicates the gesture path.
209   * @returns { Promise<void> }
210   * @throws { BusinessError } 401 - Parameter error. Possible causes:
211   *                           1. Mandatory parameters are left unspecified;
212   *                           2. Incorrect parameter types;
213   *                           3. Parameter verification failed.
214   * @throws { BusinessError } 9300003 -  No accessibility permission to perform the operation.
215   * @syscap SystemCapability.BarrierFree.Accessibility.Core
216   * @since 9
217   * @deprecated since 10
218   * @useinstead AccessibilityExtensionContext/AccessibilityExtensionContext#injectGestureSync
219   */
220  injectGesture(gesturePath: GesturePath): Promise<void>;
221
222  /**
223   * Inject gesture path events.
224   *
225   * @param { GesturePath } gesturePath Indicates the gesture path.
226   * @throws { BusinessError } 401 - Parameter error. Possible causes:
227   *                           1. Mandatory parameters are left unspecified;
228   *                           2. Incorrect parameter types;
229   *                           3. Parameter verification failed.
230   * @throws { BusinessError } 9300003 -  No accessibility permission to perform the operation.
231   * @syscap SystemCapability.BarrierFree.Accessibility.Core
232   * @since 10
233   */
234  injectGestureSync(gesturePath: GesturePath): void;
235
236  /**
237   * Starts a new ability. If the caller application is in foreground, you can use this method to start ability;
238   * If the caller application is in the background, you need to apply for permission:ohos.permission.START_ABILITIES_FROM_BACKGROUND.
239   * If the target ability is visible, you can start the target ability; If the target ability is invisible,
240   * you need to apply for permission:ohos.permission.START_INVISIBLE_ABILITY to start target invisible ability.
241   * If the target ability is in cross-device, you need to apply for permission:ohos.permission.DISTRIBUTED_DATASYNC.
242   *
243   * @param { Want } want - Indicates the ability to start.
244   * @param { AsyncCallback<void> } callback - The callback of startAbility.
245   * @throws { BusinessError } 201 - The application does not have permission to call the interface.
246   * @throws { BusinessError } 401 - Params error. Possible causes: 1.Mandatory parameters are left unspecified. 2.Incorrect parameter types.
247   * @throws { BusinessError } 16000001 - The specified ability does not exist.
248   * @throws { BusinessError } 16000002 - Incorrect ability type.
249   * @throws { BusinessError } 16000004 - Can not start invisible component.
250   * @throws { BusinessError } 16000005 - The specified process does not have the permission.
251   * @throws { BusinessError } 16000006 - Cross-user operations are not allowed.
252   * @throws { BusinessError } 16000008 - The crowdtesting application expires.
253   * @throws { BusinessError } 16000009 - An ability cannot be started or stopped in Wukong mode.
254   * @throws { BusinessError } 16000010 - The call with the continuation flag is forbidden.
255   * @throws { BusinessError } 16000011 - The context does not exist.
256   * @throws { BusinessError } 16000012 - The application is controlled.
257   * @throws { BusinessError } 16000013 - The application is controlled by EDM.
258   * @throws { BusinessError } 16000018 - The application is not allow jumping to other applications.
259   * @throws { BusinessError } 16000019 - Can not match any component.
260   * @throws { BusinessError } 16000050 - Internal error.
261   * @throws { BusinessError } 16000053 - The ability is not on the top of the UI.
262   * @throws { BusinessError } 16000055 - Installation-free timed out.
263   * @throws { BusinessError } 16200001 - The caller has been released.
264   * @throws { BusinessError } 16000073 - The target app clone with the specified index does not exist.
265   * @syscap SystemCapability.Ability.AbilityRuntime.Core
266   * @stagemodelonly
267   * @crossplatform
268   * @atomicservice
269   * @since 12
270   */
271  startAbility(want: Want, callback: AsyncCallback<void>): void;
272
273   /**
274   * Starts a new ability. If the caller application is in foreground, you can use this method to start ability;
275   * If the caller application is in the background, you need to apply for permission:ohos.permission.START_ABILITIES_FROM_BACKGROUND.
276   * If the target ability is visible, you can start the target ability; If the target ability is invisible,
277   * you need to apply for permission:ohos.permission.START_INVISIBLE_ABILITY to start target invisible ability.
278   * If the target ability is in cross-device, you need to apply for permission:ohos.permission.DISTRIBUTED_DATASYNC.
279   *
280   * @param { Want } want - Indicates the ability to start.
281   * @param { StartOptions } [options] - Indicates the start options.
282   * @returns { Promise<void> } The promise returned by the function.
283   * @throws { BusinessError } 201 - The application does not have permission to call the interface.
284   * @throws { BusinessError } 401 - Params error. Possible causes: 1.Mandatory parameters are left unspecified. 2.Incorrect parameter types.
285   * @throws { BusinessError } 801 - Capability not support.
286   * @throws { BusinessError } 16000001 - The specified ability does not exist.
287   * @throws { BusinessError } 16000002 - Incorrect ability type.
288   * @throws { BusinessError } 16000004 - Can not start invisible component.
289   * @throws { BusinessError } 16000005 - The specified process does not have the permission.
290   * @throws { BusinessError } 16000006 - Cross-user operations are not allowed.
291   * @throws { BusinessError } 16000008 - The crowdtesting application expires.
292   * @throws { BusinessError } 16000009 - An ability cannot be started or stopped in Wukong mode.
293   * @throws { BusinessError } 16000010 - The call with the continuation flag is forbidden.
294   * @throws { BusinessError } 16000011 - The context does not exist.
295   * @throws { BusinessError } 16000012 - The application is controlled.
296   * @throws { BusinessError } 16000013 - The application is controlled by EDM.
297   * @throws { BusinessError } 16000018 - The application is not allow jumping to other applications.
298   * @throws { BusinessError } 16000019 - Can not match any component.
299   * @throws { BusinessError } 16000050 - Internal error.
300   * @throws { BusinessError } 16000053 - The ability is not on the top of the UI.
301   * @throws { BusinessError } 16000055 - Installation-free timed out.
302   * @throws { BusinessError } 16000067 - Start options check failed.
303   * @throws { BusinessError } 16000068 - Ability already running.
304   * @throws { BusinessError } 16200001 - The caller has been released.
305   * @throws { BusinessError } 16300003 - The target application is not self application.
306   * @throws { BusinessError } 16000073 - The target app clone with the specified index does not exist.
307   * @syscap SystemCapability.Ability.AbilityRuntime.Core
308   * @stagemodelonly
309   * @atomicservice
310   * @since 12
311   */
312   startAbility(want: Want): Promise<void>;
313
314  /**
315   * Set the screen curtain enable or disable.
316   *
317   * @param { boolean } isEnable Indicates whether the screen curtain is enabled.
318   * @throws { BusinessError } 401 - Parameter error. Possible causes:
319   *                           1. Mandatory parameters are left unspecified;
320   *                           2. Incorrect parameter types;
321   *                           3. Parameter verification failed.
322   * @throws { BusinessError } 9300003 -  No accessibility permission to perform the operation.
323   * @syscap SystemCapability.BarrierFree.Accessibility.Core
324   * @systemapi
325   * @since 12
326   */
327  enableScreenCurtain(isEnable: boolean): void;
328
329  /**
330   * Get all subElements in window
331   *
332   * @param { number } windowId Indicates the window ID.
333   * @param { number } elementId Indicates the elementId.
334   * @returns { Promise<Array<AccessibilityElement>> }
335   * @throws { BusinessError } 401 - Input parameter error.
336   * @throws { BusinessError } 9300003 -  No accessibility permission to perform the operation.
337   * @syscap SystemCapability.BarrierFree.Accessibility.Core
338   * @since 16
339   */
340  getElements(windowId: number, elementId?: number): Promise<Array<AccessibilityElement>>;
341
342  /**
343   * Hold running lock to prevent screen turning off automatically.
344   *
345   * @throws { BusinessError } 202 - Permission verification failed. A non-system application calls a system API.
346   * @syscap SystemCapability.BarrierFree.Accessibility.Core
347   * @systemapi
348   * @since 20
349   */
350  holdRunningLockSync(): void;
351
352  /**
353   * Unhold running lock.
354   *
355   * @throws { BusinessError } 202 - Permission verification failed. A non-system application calls a system API.
356   * @syscap SystemCapability.BarrierFree.Accessibility.Core
357   * @systemapi
358   * @since 20
359   */
360  unholdRunningLockSync(): void;
361
362  /**
363   * Register accessibilityExtensionAbility disconnect callback.
364   *
365   * @param { 'preDisconnect' } type Indicates the accessibilityExtensionAbility pre disconnect.
366   * @param { Callback<void> } callback Indicates the callback function.
367   * @throws { BusinessError } 202 - Permission verification failed. A non-system application calls a system API.
368   * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 2. Incorrect parameter types. 3.Parameter verification failed.
369   * @syscap SystemCapability.BarrierFree.Accessibility.Core
370   * @systemapi
371   * @since 20
372   */
373  on(type: 'preDisconnect', callback: Callback<void>): void;
374
375  /**
376   * Unregister accessibilityExtensionAbility disconnect callback.
377   *
378   * @param { 'preDisconnect' } type Indicates the accessibilityExtensionAbility pre disconnect.
379   * @param { Callback<void> } callback Indicates the callback function.
380   * @throws { BusinessError } 202 - Permission verification failed. A non-system application calls a system API.
381   * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 2. Incorrect parameter types. 3.Parameter verification failed.
382   * @syscap SystemCapability.BarrierFree.Accessibility.Core
383   * @systemapi
384   * @since 20
385   */
386  off(type: 'preDisconnect', callback?: Callback<void>): void;
387
388  /**
389   * Notify accessibility when accessibilityExtensionAbility is ready to disconnect.
390   *
391   * @throws { BusinessError } 202 - Permission verification failed. A non-system application calls a system API.
392   * @syscap SystemCapability.BarrierFree.Accessibility.Core
393   * @systemapi
394   * @since 20
395   */
396  notifyDisconnect(): void;
397}
398
399/**
400 * Indicates an accessibility element.
401 * Supports querying element attributes, requesting execution actions, and finding child elements by condition.
402 *
403 * @typedef AccessibilityElement
404 * @syscap SystemCapability.BarrierFree.Accessibility.Core
405 * @since 9
406 */
407declare interface AccessibilityElement {
408  /**
409   * Get a list of attribute names.
410   *
411   * @param { AsyncCallback<Array<T>> } callback Indicates the listener.
412   * @syscap SystemCapability.BarrierFree.Accessibility.Core
413   * @since 9
414   */
415  attributeNames<T extends keyof ElementAttributeValues>(callback: AsyncCallback<Array<T>>): void;
416
417  /**
418   * Get a list of attribute names.
419   * @returns { Promise<Array<T>> }
420   * @syscap SystemCapability.BarrierFree.Accessibility.Core
421   * @since 9
422   */
423  attributeNames<T extends keyof ElementAttributeValues>(): Promise<Array<T>>;
424
425  /**
426   * Get the value of an attribute.
427   *
428   * @param { T } attributeName Indicates the attribute name.
429   * @param { AsyncCallback<ElementAttributeValues[T]> } callback Indicates the listener.
430   * @throws { BusinessError } 401 - Parameter error. Possible causes:
431   *                           1. Mandatory parameters are left unspecified;
432   *                           2. Incorrect parameter types;
433   *                           3. Parameter verification failed.
434   * @throws { BusinessError } 9300004 - This property does not exist.
435   * @syscap SystemCapability.BarrierFree.Accessibility.Core
436   * @since 9
437   */
438  attributeValue<T extends keyof ElementAttributeValues>(
439    attributeName: T,
440    callback: AsyncCallback<ElementAttributeValues[T]>
441  ): void;
442
443  /**
444   * Get the value of an attribute.
445   *
446   * @param { T } attributeName Indicates the attribute name.
447   * @returns { Promise<ElementAttributeValues[T]> }
448   * @throws { BusinessError } 401 - Parameter error. Possible causes:
449   *                           1. Mandatory parameters are left unspecified;
450   *                           2. Incorrect parameter types;
451   *                           3. Parameter verification failed.
452   * @throws { BusinessError } 9300004 - This property does not exist.
453   * @syscap SystemCapability.BarrierFree.Accessibility.Core
454   * @since 9
455   */
456  attributeValue<T extends keyof ElementAttributeValues>(attributeName: T): Promise<ElementAttributeValues[T]>;
457
458  /**
459   * Get a list of supported actions.
460   *
461   * @param { AsyncCallback<Array<string>> } callback Indicates the listener.
462   * @syscap SystemCapability.BarrierFree.Accessibility.Core
463   * @since 9
464   */
465  actionNames(callback: AsyncCallback<Array<string>>): void;
466
467  /**
468   * Get a list of supported actions.
469   *
470   * @returns { Promise<Array<string>> }
471   * @syscap SystemCapability.BarrierFree.Accessibility.Core
472   * @since 9
473   */
474  actionNames(): Promise<Array<string>>;
475
476  /**
477   * Perform the specified action.
478   *
479   * @param { string } actionName Indicates the action name.
480   * @param { object } parameters Indicates the parameters needed to execute the action.
481   * @param { AsyncCallback<void> } callback Indicates the listener.
482   * @throws { BusinessError } 401 - Parameter error. Possible causes:
483   *                           1. Mandatory parameters are left unspecified;
484   *                           2. Incorrect parameter types;
485   *                           3. Parameter verification failed.
486   * @throws { BusinessError } 9300005 - This action is not supported.
487   * @syscap SystemCapability.BarrierFree.Accessibility.Core
488   * @since 9
489   */
490  performAction(actionName: string, parameters: object, callback: AsyncCallback<void>): void;
491
492  /**
493   * Perform the specified action.
494   *
495   * @param { string } actionName Indicates the action name.
496   * @param { object } parameters Indicates the parameters needed to execute the action.
497   * @returns { Promise<void> }
498   * @throws { BusinessError } 401 - Parameter error. Possible causes:
499   *                           1. Mandatory parameters are left unspecified;
500   *                           2. Incorrect parameter types;
501   *                           3. Parameter verification failed.
502   * @throws { BusinessError } 9300005 - This action is not supported.
503   * @syscap SystemCapability.BarrierFree.Accessibility.Core
504   * @since 9
505   */
506  performAction(actionName: string, parameters?: object): Promise<void>;
507
508  /**
509   * Perform the specified action.
510   *
511   * @param { string } actionName Indicates the action name.
512   * @param { AsyncCallback<void> } callback Indicates the listener.
513   * @throws { BusinessError } 401 - Parameter error. Possible causes:
514   *                           1. Mandatory parameters are left unspecified;
515   *                           2. Incorrect parameter types;
516   *                           3. Parameter verification failed.
517   * @throws { BusinessError } 9300005 - This action is not supported.
518   * @syscap SystemCapability.BarrierFree.Accessibility.Core
519   * @since 9
520   */
521  performAction(actionName: string, callback: AsyncCallback<void>): void;
522
523  /**
524   * Get the position of cursor in TextInput.
525   *
526   * @param { AsyncCallback<void> } callback Indicates the listener.
527   * @syscap SystemCapability.BarrierFree.Accessibility.Core
528   * @since 12
529   */
530  getCursorPosition(callback: AsyncCallback<number>): void;
531
532  /**
533   * Get the position of cursor in TextInput.
534   *
535   * @returns { Promise<number> }
536   * @syscap SystemCapability.BarrierFree.Accessibility.Core
537   * @since 12
538   */
539  getCursorPosition(): Promise<number>;
540
541  /**
542   * Set the screen curtain enable or disable.
543   *
544   * @param { boolean } isEnable Indicates whether the screen curtain is enabled.
545   * @throws { BusinessError } 401 - Parameter error. Possible causes:
546   *                           1. Mandatory parameters are left unspecified;
547   *                           2. Incorrect parameter types;
548   *                           3. Parameter verification failed.
549   * @throws { BusinessError } 9300003 -  No accessibility permission to perform the operation.
550   * @syscap SystemCapability.BarrierFree.Accessibility.Core
551   * @systemapi
552   * @since 12
553   */
554  enableScreenCurtain(isEnable: boolean): void;
555
556   /**
557   * Get the position of cursor in TextInput.
558   *
559   * @param { AsyncCallback<number> } callback Indicates the listener.
560   * @syscap SystemCapability.BarrierFree.Accessibility.Core
561   * @since 12
562   */
563   getCursorPosition(callback: AsyncCallback<number>): void;
564
565   /**
566    * Get the position of cursor in TextInput.
567    *
568    * @returns { Promise<number> }
569    * @syscap SystemCapability.BarrierFree.Accessibility.Core
570    * @since 12
571    */
572   getCursorPosition(): Promise<number>;
573
574  /**
575   * Find elements that match the condition.
576   *
577   * @param { 'content' } type The type of query condition is content.
578   * @param { string } condition Indicates the specific content to be queried.
579   * @param { AsyncCallback<Array<AccessibilityElement>> } callback Indicates the listener.
580   * @throws { BusinessError } 401 - Parameter error. Possible causes:
581   *                           1. Mandatory parameters are left unspecified;
582   *                           2. Incorrect parameter types;
583   *                           3. Parameter verification failed.
584   * @syscap SystemCapability.BarrierFree.Accessibility.Core
585   * @since 9
586   */
587  findElement(type: 'content', condition: string, callback: AsyncCallback<Array<AccessibilityElement>>): void;
588
589  /**
590   * Find elements that match the condition.
591   *
592   * @param { 'content' } type The type of query condition is content.
593   * @param { string } condition Indicates the specific content to be queried.
594   * @returns { Promise<Array<AccessibilityElement>> }
595   * @throws { BusinessError } 401 - Parameter error. Possible causes:
596   *                           1. Mandatory parameters are left unspecified;
597   *                           2. Incorrect parameter types;
598   *                           3. Parameter verification failed.
599   * @syscap SystemCapability.BarrierFree.Accessibility.Core
600   * @since 9
601   */
602  findElement(type: 'content', condition: string): Promise<Array<AccessibilityElement>>;
603
604  /**
605   * Find elements that match the condition.
606   *
607   * @param { 'focusType' } type The type of query condition is focus type.
608   * @param { FocusType } condition Indicates the type of focus to query.
609   * @param { AsyncCallback<AccessibilityElement> } callback Indicates the listener.
610   * @throws { BusinessError } 401 - Parameter error. Possible causes:
611   *                           1. Mandatory parameters are left unspecified;
612   *                           2. Incorrect parameter types;
613   *                           3. Parameter verification failed.
614   * @syscap SystemCapability.BarrierFree.Accessibility.Core
615   * @since 9
616   */
617  findElement(type: 'focusType', condition: FocusType, callback: AsyncCallback<AccessibilityElement>): void;
618
619  /**
620   * Find elements that match the condition.
621   *
622   * @param { 'focusType' } type The type of query condition is focus type.
623   * @param { FocusType } condition Indicates the type of focus to query.
624   * @returns { Promise<AccessibilityElement> }
625   * @throws { BusinessError } 401 - Parameter error. Possible causes:
626   *                           1. Mandatory parameters are left unspecified;
627   *                           2. Incorrect parameter types;
628   *                           3. Parameter verification failed.
629   * @syscap SystemCapability.BarrierFree.Accessibility.Core
630   * @since 9
631   */
632  findElement(type: 'focusType', condition: FocusType): Promise<AccessibilityElement>;
633
634  /**
635   * Find elements that match the condition.
636   *
637   * @param { 'focusDirection' } type The type of query condition is focus direction.
638   * @param { FocusDirection } condition Indicates the direction of search focus to query.
639   * @param { AsyncCallback<AccessibilityElement> } callback Indicates the listener.
640   * @throws { BusinessError } 401 - Parameter error. Possible causes:
641   *                           1. Mandatory parameters are left unspecified;
642   *                           2. Incorrect parameter types;
643   *                           3. Parameter verification failed.
644   * @syscap SystemCapability.BarrierFree.Accessibility.Core
645   * @since 9
646   */
647  findElement(type: 'focusDirection', condition: FocusDirection, callback: AsyncCallback<AccessibilityElement>): void;
648
649  /**
650   * Find elements that match the condition.
651   *
652   * @param { 'focusDirection' } type The type of query condition is focus direction.
653   * @param { FocusDirection } condition Indicates the direction of search focus to query.
654   * @returns { Promise<AccessibilityElement> }
655   * @throws { BusinessError } 401 - Parameter error. Possible causes:
656   *                           1. Mandatory parameters are left unspecified;
657   *                           2. Incorrect parameter types;
658   *                           3. Parameter verification failed.
659   * @syscap SystemCapability.BarrierFree.Accessibility.Core
660   * @since 9
661   */
662  findElement(type: 'focusDirection', condition: FocusDirection): Promise<AccessibilityElement>;
663}
664
665/**
666 * Indicates the possible attributes of the element and the type of the attribute value.
667 *
668 * @syscap SystemCapability.BarrierFree.Accessibility.Core
669 * @since 9
670 */
671type ElementAttributeValues = {
672  /**
673   * Indicates accessibility focus state.
674   *
675   * @syscap SystemCapability.BarrierFree.Accessibility.Core
676   * @since 9
677   */
678  'accessibilityFocused': boolean;
679  /**
680   * Indicates the bundle name to which it belongs.
681   *
682   * @syscap SystemCapability.BarrierFree.Accessibility.Core
683   * @since 9
684   */
685  'bundleName': string;
686  /**
687   * Indicates whether the element is checkable.
688   *
689   * @syscap SystemCapability.BarrierFree.Accessibility.Core
690   * @since 9
691   */
692  'checkable': boolean;
693  /**
694   * Indicates whether the element is checked.
695   *
696   * @syscap SystemCapability.BarrierFree.Accessibility.Core
697   * @since 9
698   */
699  'checked': boolean;
700  /**
701   * Indicates all child elements.
702   *
703   * @syscap SystemCapability.BarrierFree.Accessibility.Core
704   * @since 9
705   */
706  'children': Array<AccessibilityElement>;
707  /**
708   * Indicates whether the element is clickable.
709   *
710   * @syscap SystemCapability.BarrierFree.Accessibility.Core
711   * @since 9
712   */
713  'clickable': boolean;
714  /**
715   * Indicates the component ID to which the element belongs.
716   *
717   * @syscap SystemCapability.BarrierFree.Accessibility.Core
718   * @since 9
719   */
720  'componentId': number;
721  /**
722   * Indicates the component type to which the element belongs.
723   *
724   * @syscap SystemCapability.BarrierFree.Accessibility.Core
725   * @since 9
726   */
727  'componentType': string;
728  /**
729   * Indicates the content.
730   *
731   * @syscap SystemCapability.BarrierFree.Accessibility.Core
732   * @since 9
733   */
734  'contents': Array<string>;
735  /**
736   * Indicates the index of the current item.
737   *
738   * @syscap SystemCapability.BarrierFree.Accessibility.Core
739   * @since 9
740   */
741  'currentIndex': number;
742  /**
743   * Indicates the description of the element.
744   *
745   * @syscap SystemCapability.BarrierFree.Accessibility.Core
746   * @since 9
747   */
748  'description': string;
749  /**
750   * Indicates whether the element is editable.
751   *
752   * @syscap SystemCapability.BarrierFree.Accessibility.Core
753   * @since 9
754   */
755  'editable': boolean;
756  /**
757   * Indicates the list index of the last item displayed on the screen.
758   *
759   * @syscap SystemCapability.BarrierFree.Accessibility.Core
760   * @since 9
761   */
762  'endIndex': number;
763  /**
764   * Indicates the string of error state.
765   *
766   * @syscap SystemCapability.BarrierFree.Accessibility.Core
767   * @since 9
768   */
769  'error': string;
770  /**
771   * Indicates whether the element is focusable.
772   *
773   * @syscap SystemCapability.BarrierFree.Accessibility.Core
774   * @since 9
775   */
776  'focusable': boolean;
777  /**
778   * Indicates the hint text.
779   *
780   * @syscap SystemCapability.BarrierFree.Accessibility.Core
781   * @since 9
782   */
783  'hintText': string;
784  /**
785   * Indicates the type of input text.
786   *
787   * @syscap SystemCapability.BarrierFree.Accessibility.Core
788   * @since 9
789   */
790  'inputType': number;
791  /**
792   * Indicates the inspector key.
793   *
794   * @syscap SystemCapability.BarrierFree.Accessibility.Core
795   * @since 9
796   */
797  'inspectorKey': string;
798  /**
799   * Indicates whether the element is active or not.
800   *
801   * @syscap SystemCapability.BarrierFree.Accessibility.Core
802   * @since 9
803   */
804  'isActive': boolean;
805  /**
806   * Indicates whether the element is enable or not.
807   *
808   * @syscap SystemCapability.BarrierFree.Accessibility.Core
809   * @since 9
810   */
811  'isEnable': boolean;
812  /**
813   * Indicates whether the element is hint state or not.
814   *
815   * @syscap SystemCapability.BarrierFree.Accessibility.Core
816   * @since 9
817   */
818  'isHint': boolean;
819  /**
820   * Indicates whether the element is focused or not.
821   *
822   * @syscap SystemCapability.BarrierFree.Accessibility.Core
823   * @since 9
824   */
825  'isFocused': boolean;
826  /**
827   * Indicates whether the element is password or not.
828   *
829   * @syscap SystemCapability.BarrierFree.Accessibility.Core
830   * @since 9
831   */
832  'isPassword': boolean;
833  /**
834   * Indicates whether the element is visible or not.
835   *
836   * @syscap SystemCapability.BarrierFree.Accessibility.Core
837   * @since 9
838   */
839  'isVisible': boolean;
840  /**
841   * Indicates the total count of the items.
842   *
843   * @syscap SystemCapability.BarrierFree.Accessibility.Core
844   * @since 9
845   */
846  'itemCount': number;
847  /**
848   * Indicates the last content.
849   *
850   * @syscap SystemCapability.BarrierFree.Accessibility.Core
851   * @since 9
852   */
853  'lastContent': string;
854  /**
855   * Indicates the display layer of the element.
856   *
857   * @syscap SystemCapability.BarrierFree.Accessibility.Core
858   * @since 9
859   */
860  'layer': number;
861  /**
862   * Indicates whether the element is long clickable.
863   *
864   * @syscap SystemCapability.BarrierFree.Accessibility.Core
865   * @since 9
866   */
867  'longClickable': boolean;
868  /**
869   * Indicates the page id.
870   *
871   * @syscap SystemCapability.BarrierFree.Accessibility.Core
872   * @since 9
873   */
874  'pageId': number;
875  /**
876   * Indicates the parent of the element.
877   *
878   * @syscap SystemCapability.BarrierFree.Accessibility.Core
879   * @since 9
880   */
881  'parent': AccessibilityElement;
882  /**
883   * Indicates whether the element supports multiple lines of text.
884   *
885   * @syscap SystemCapability.BarrierFree.Accessibility.Core
886   * @since 9
887   */
888  'pluralLineSupported': boolean;
889  /**
890   * Indicates the area of the element.
891   *
892   * @syscap SystemCapability.BarrierFree.Accessibility.Core
893   * @since 9
894   */
895  'rect': Rect;
896    /**
897   * Indicates the span of the element.
898   *
899   * @syscap SystemCapability.BarrierFree.Accessibility.Core
900   * @since 12
901   */
902  'span': Span;
903  /**
904   * Indicates the resource name of the element.
905   *
906   * @syscap SystemCapability.BarrierFree.Accessibility.Core
907   * @since 9
908   */
909  'resourceName': string;
910  /**
911   * Indicates the root element of the window element.
912   *
913   * @syscap SystemCapability.BarrierFree.Accessibility.Core
914   * @since 9
915   */
916  'rootElement': AccessibilityElement;
917  /**
918   * Indicates the display area of the element.
919   *
920   * @syscap SystemCapability.BarrierFree.Accessibility.Core
921   * @since 9
922   */
923  'screenRect': Rect;
924  /**
925   * Indicates whether the element is scrollable.
926   *
927   * @syscap SystemCapability.BarrierFree.Accessibility.Core
928   * @since 9
929   */
930  'scrollable': boolean;
931  /**
932   * Indicates whether the element is selected.
933   *
934   * @syscap SystemCapability.BarrierFree.Accessibility.Core
935   * @since 9
936   */
937  'selected': boolean;
938  /**
939   * Indicates the list index of the first item displayed on the screen.
940   *
941   * @syscap SystemCapability.BarrierFree.Accessibility.Core
942   * @since 9
943   */
944  'startIndex': number;
945  /**
946   * Indicates the text of the element.
947   *
948   * @syscap SystemCapability.BarrierFree.Accessibility.Core
949   * @since 9
950   */
951  'text': string;
952  /**
953   * Indicates the maximum length limit of the element text.
954   *
955   * @syscap SystemCapability.BarrierFree.Accessibility.Core
956   * @since 9
957   */
958  'textLengthLimit': number;
959  /**
960   * Indicates the unit of movement of the element text as it is read.
961   *
962   * @syscap SystemCapability.BarrierFree.Accessibility.Core
963   * @since 9
964   */
965  'textMoveUnit': accessibility.TextMoveUnit;
966  /**
967   * Indicates the action that triggered the element event.
968   *
969   * @syscap SystemCapability.BarrierFree.Accessibility.Core
970   * @since 9
971   */
972  'triggerAction': accessibility.Action;
973  /**
974   * Indicates the window type of the element.
975   *
976   * @syscap SystemCapability.BarrierFree.Accessibility.Core
977   * @since 9
978   */
979  'type': WindowType;
980  /**
981   * Indicates the maximum value.
982   *
983   * @syscap SystemCapability.BarrierFree.Accessibility.Core
984   * @since 9
985   */
986  'valueMax': number;
987  /**
988   * Indicates the minimum value.
989   *
990   * @syscap SystemCapability.BarrierFree.Accessibility.Core
991   * @since 9
992   */
993  'valueMin': number;
994  /**
995   * Indicates the current value.
996   *
997   * @syscap SystemCapability.BarrierFree.Accessibility.Core
998   * @since 9
999   */
1000  'valueNow': number;
1001  /**
1002   * Indicates the window id.
1003   *
1004   * @syscap SystemCapability.BarrierFree.Accessibility.Core
1005   * @since 9
1006   */
1007  'windowId': number;
1008  /**
1009   * Indicates the accessibility text.
1010   *
1011   * @syscap SystemCapability.BarrierFree.Accessibility.Core
1012   * @since 12
1013   */
1014  'accessibilityText': string;
1015};
1016
1017/**
1018 * Indicates the direction of the search focus.
1019 *
1020 * @syscap SystemCapability.BarrierFree.Accessibility.Core
1021 * @since 9
1022 */
1023type FocusDirection = 'up' | 'down' | 'left' | 'right' | 'forward' | 'backward';
1024
1025/**
1026 * Indicates the type of the focus.
1027 *
1028 * @syscap SystemCapability.BarrierFree.Accessibility.Core
1029 * @since 9
1030 */
1031type FocusType = 'accessibility' | 'normal';
1032
1033/**
1034 * Indicates the type of the window.
1035 *
1036 * @syscap SystemCapability.BarrierFree.Accessibility.Core
1037 * @since 9
1038 */
1039type WindowType = 'application' | 'system';
1040
1041/**
1042 * Indicates rectangle.
1043 *
1044 * @typedef Rect
1045 * @syscap SystemCapability.BarrierFree.Accessibility.Core
1046 * @since 9
1047 */
1048interface Rect {
1049  left: number;
1050  top: number;
1051  width: number;
1052  height: number;
1053}
1054
1055/**
1056 * Indicates span info.
1057 *
1058 * @typedef Span
1059 * @syscap SystemCapability.BarrierFree.Accessibility.Core
1060 */
1061interface Span {
1062  spanId: number;
1063  spanText: string;
1064  accessibilityText: string;
1065  accessibilityDescription: string;
1066  accessibilityLevel: string;
1067}
1068