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