• 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 '../@ohos.base';
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/**
315 * Indicates an accessibility element.
316 * Supports querying element attributes, requesting execution actions, and finding child elements by condition.
317 *
318 * @typedef AccessibilityElement
319 * @syscap SystemCapability.BarrierFree.Accessibility.Core
320 * @since 9
321 */
322declare interface AccessibilityElement {
323  /**
324   * Get a list of attribute names.
325   *
326   * @param { AsyncCallback<Array<T>> } callback Indicates the listener.
327   * @syscap SystemCapability.BarrierFree.Accessibility.Core
328   * @since 9
329   */
330  attributeNames<T extends keyof ElementAttributeValues>(callback: AsyncCallback<Array<T>>): void;
331
332  /**
333   * Get a list of attribute names.
334   * @returns { Promise<Array<T>> }
335   * @syscap SystemCapability.BarrierFree.Accessibility.Core
336   * @since 9
337   */
338  attributeNames<T extends keyof ElementAttributeValues>(): Promise<Array<T>>;
339
340  /**
341   * Get the value of an attribute.
342   *
343   * @param { T } attributeName Indicates the attribute name.
344   * @param { AsyncCallback<ElementAttributeValues[T]> } callback Indicates the listener.
345   * @throws { BusinessError } 401 - Parameter error. Possible causes:
346   *                           1. Mandatory parameters are left unspecified;
347   *                           2. Incorrect parameter types;
348   *                           3. Parameter verification failed.
349   * @throws { BusinessError } 9300004 - This property does not exist.
350   * @syscap SystemCapability.BarrierFree.Accessibility.Core
351   * @since 9
352   */
353  attributeValue<T extends keyof ElementAttributeValues>(
354    attributeName: T,
355    callback: AsyncCallback<ElementAttributeValues[T]>
356  ): void;
357
358  /**
359   * Get the value of an attribute.
360   *
361   * @param { T } attributeName Indicates the attribute name.
362   * @returns { Promise<ElementAttributeValues[T]> }
363   * @throws { BusinessError } 401 - Parameter error. Possible causes:
364   *                           1. Mandatory parameters are left unspecified;
365   *                           2. Incorrect parameter types;
366   *                           3. Parameter verification failed.
367   * @throws { BusinessError } 9300004 - This property does not exist.
368   * @syscap SystemCapability.BarrierFree.Accessibility.Core
369   * @since 9
370   */
371  attributeValue<T extends keyof ElementAttributeValues>(attributeName: T): Promise<ElementAttributeValues[T]>;
372
373  /**
374   * Get a list of supported actions.
375   *
376   * @param { AsyncCallback<Array<string>> } callback Indicates the listener.
377   * @syscap SystemCapability.BarrierFree.Accessibility.Core
378   * @since 9
379   */
380  actionNames(callback: AsyncCallback<Array<string>>): void;
381
382  /**
383   * Get a list of supported actions.
384   *
385   * @returns { Promise<Array<string>> }
386   * @syscap SystemCapability.BarrierFree.Accessibility.Core
387   * @since 9
388   */
389  actionNames(): Promise<Array<string>>;
390
391  /**
392   * Perform the specified action.
393   *
394   * @param { string } actionName Indicates the action name.
395   * @param { object } parameters Indicates the parameters needed to execute the action.
396   * @param { AsyncCallback<void> } callback Indicates the listener.
397   * @throws { BusinessError } 401 - Parameter error. Possible causes:
398   *                           1. Mandatory parameters are left unspecified;
399   *                           2. Incorrect parameter types;
400   *                           3. Parameter verification failed.
401   * @throws { BusinessError } 9300005 - This action is not supported.
402   * @syscap SystemCapability.BarrierFree.Accessibility.Core
403   * @since 9
404   */
405  performAction(actionName: string, parameters: object, callback: AsyncCallback<void>): void;
406
407  /**
408   * Perform the specified action.
409   *
410   * @param { string } actionName Indicates the action name.
411   * @param { object } parameters Indicates the parameters needed to execute the action.
412   * @returns { Promise<void> }
413   * @throws { BusinessError } 401 - Parameter error. Possible causes:
414   *                           1. Mandatory parameters are left unspecified;
415   *                           2. Incorrect parameter types;
416   *                           3. Parameter verification failed.
417   * @throws { BusinessError } 9300005 - This action is not supported.
418   * @syscap SystemCapability.BarrierFree.Accessibility.Core
419   * @since 9
420   */
421  performAction(actionName: string, parameters?: object): Promise<void>;
422
423  /**
424   * Perform the specified action.
425   *
426   * @param { string } actionName Indicates the action name.
427   * @param { AsyncCallback<void> } callback Indicates the listener.
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, callback: AsyncCallback<void>): void;
437
438  /**
439   * Set the screen curtain enable or disable.
440   *
441   * @param { boolean } isEnable Indicates whether the screen curtain is enabled.
442   * @throws { BusinessError } 401 - Parameter error. Possible causes:
443   *                           1. Mandatory parameters are left unspecified;
444   *                           2. Incorrect parameter types;
445   *                           3. Parameter verification failed.
446   * @throws { BusinessError } 9300003 -  No accessibility permission to perform the operation.
447   * @syscap SystemCapability.BarrierFree.Accessibility.Core
448   * @systemapi
449   * @since 12
450   */
451  enableScreenCurtain(isEnable: boolean): 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   * Find elements that match the condition.
473   *
474   * @param { 'content' } type The type of query condition is content.
475   * @param { string } condition Indicates the specific content to be queried.
476   * @param { AsyncCallback<Array<AccessibilityElement>> } callback Indicates the listener.
477   * @throws { BusinessError } 401 - Parameter error. Possible causes:
478   *                           1. Mandatory parameters are left unspecified;
479   *                           2. Incorrect parameter types;
480   *                           3. Parameter verification failed.
481   * @syscap SystemCapability.BarrierFree.Accessibility.Core
482   * @since 9
483   */
484  findElement(type: 'content', condition: string, callback: AsyncCallback<Array<AccessibilityElement>>): void;
485
486  /**
487   * Find elements that match the condition.
488   *
489   * @param { 'content' } type The type of query condition is content.
490   * @param { string } condition Indicates the specific content to be queried.
491   * @returns { Promise<Array<AccessibilityElement>> }
492   * @throws { BusinessError } 401 - Parameter error. Possible causes:
493   *                           1. Mandatory parameters are left unspecified;
494   *                           2. Incorrect parameter types;
495   *                           3. Parameter verification failed.
496   * @syscap SystemCapability.BarrierFree.Accessibility.Core
497   * @since 9
498   */
499  findElement(type: 'content', condition: string): Promise<Array<AccessibilityElement>>;
500
501  /**
502   * Find elements that match the condition.
503   *
504   * @param { 'focusType' } type The type of query condition is focus type.
505   * @param { FocusType } condition Indicates the type of focus to query.
506   * @param { AsyncCallback<AccessibilityElement> } callback Indicates the listener.
507   * @throws { BusinessError } 401 - Parameter error. Possible causes:
508   *                           1. Mandatory parameters are left unspecified;
509   *                           2. Incorrect parameter types;
510   *                           3. Parameter verification failed.
511   * @syscap SystemCapability.BarrierFree.Accessibility.Core
512   * @since 9
513   */
514  findElement(type: 'focusType', condition: FocusType, callback: AsyncCallback<AccessibilityElement>): void;
515
516  /**
517   * Find elements that match the condition.
518   *
519   * @param { 'focusType' } type The type of query condition is focus type.
520   * @param { FocusType } condition Indicates the type of focus to query.
521   * @returns { Promise<AccessibilityElement> }
522   * @throws { BusinessError } 401 - Parameter error. Possible causes:
523   *                           1. Mandatory parameters are left unspecified;
524   *                           2. Incorrect parameter types;
525   *                           3. Parameter verification failed.
526   * @syscap SystemCapability.BarrierFree.Accessibility.Core
527   * @since 9
528   */
529  findElement(type: 'focusType', condition: FocusType): Promise<AccessibilityElement>;
530
531  /**
532   * Find elements that match the condition.
533   *
534   * @param { 'focusDirection' } type The type of query condition is focus direction.
535   * @param { FocusDirection } condition Indicates the direction of search focus to query.
536   * @param { AsyncCallback<AccessibilityElement> } callback Indicates the listener.
537   * @throws { BusinessError } 401 - Parameter error. Possible causes:
538   *                           1. Mandatory parameters are left unspecified;
539   *                           2. Incorrect parameter types;
540   *                           3. Parameter verification failed.
541   * @syscap SystemCapability.BarrierFree.Accessibility.Core
542   * @since 9
543   */
544  findElement(type: 'focusDirection', condition: FocusDirection, callback: AsyncCallback<AccessibilityElement>): void;
545
546  /**
547   * Find elements that match the condition.
548   *
549   * @param { 'focusDirection' } type The type of query condition is focus direction.
550   * @param { FocusDirection } condition Indicates the direction of search focus to query.
551   * @returns { Promise<AccessibilityElement> }
552   * @throws { BusinessError } 401 - Parameter error. Possible causes:
553   *                           1. Mandatory parameters are left unspecified;
554   *                           2. Incorrect parameter types;
555   *                           3. Parameter verification failed.
556   * @syscap SystemCapability.BarrierFree.Accessibility.Core
557   * @since 9
558   */
559  findElement(type: 'focusDirection', condition: FocusDirection): Promise<AccessibilityElement>;
560}
561
562/**
563 * Indicates the possible attributes of the element and the type of the attribute value.
564 *
565 * @syscap SystemCapability.BarrierFree.Accessibility.Core
566 * @since 9
567 */
568type ElementAttributeValues = {
569  /**
570   * Indicates accessibility focus state.
571   *
572   * @syscap SystemCapability.BarrierFree.Accessibility.Core
573   * @since 9
574   */
575  'accessibilityFocused': boolean;
576  /**
577   * Indicates the bundle name to which it belongs.
578   *
579   * @syscap SystemCapability.BarrierFree.Accessibility.Core
580   * @since 9
581   */
582  'bundleName': string;
583  /**
584   * Indicates whether the element is checkable.
585   *
586   * @syscap SystemCapability.BarrierFree.Accessibility.Core
587   * @since 9
588   */
589  'checkable': boolean;
590  /**
591   * Indicates whether the element is checked.
592   *
593   * @syscap SystemCapability.BarrierFree.Accessibility.Core
594   * @since 9
595   */
596  'checked': boolean;
597  /**
598   * Indicates all child elements.
599   *
600   * @syscap SystemCapability.BarrierFree.Accessibility.Core
601   * @since 9
602   */
603  'children': Array<AccessibilityElement>;
604  /**
605   * Indicates whether the element is clickable.
606   *
607   * @syscap SystemCapability.BarrierFree.Accessibility.Core
608   * @since 9
609   */
610  'clickable': boolean;
611  /**
612   * Indicates the component ID to which the element belongs.
613   *
614   * @syscap SystemCapability.BarrierFree.Accessibility.Core
615   * @since 9
616   */
617  'componentId': number;
618  /**
619   * Indicates the component type to which the element belongs.
620   *
621   * @syscap SystemCapability.BarrierFree.Accessibility.Core
622   * @since 9
623   */
624  'componentType': string;
625  /**
626   * Indicates the content.
627   *
628   * @syscap SystemCapability.BarrierFree.Accessibility.Core
629   * @since 9
630   */
631  'contents': Array<string>;
632  /**
633   * Indicates the index of the current item.
634   *
635   * @syscap SystemCapability.BarrierFree.Accessibility.Core
636   * @since 9
637   */
638  'currentIndex': number;
639  /**
640   * Indicates the description of the element.
641   *
642   * @syscap SystemCapability.BarrierFree.Accessibility.Core
643   * @since 9
644   */
645  'description': string;
646  /**
647   * Indicates whether the element is editable.
648   *
649   * @syscap SystemCapability.BarrierFree.Accessibility.Core
650   * @since 9
651   */
652  'editable': boolean;
653  /**
654   * Indicates the list index of the last item displayed on the screen.
655   *
656   * @syscap SystemCapability.BarrierFree.Accessibility.Core
657   * @since 9
658   */
659  'endIndex': number;
660  /**
661   * Indicates the string of error state.
662   *
663   * @syscap SystemCapability.BarrierFree.Accessibility.Core
664   * @since 9
665   */
666  'error': string;
667  /**
668   * Indicates whether the element is focusable.
669   *
670   * @syscap SystemCapability.BarrierFree.Accessibility.Core
671   * @since 9
672   */
673  'focusable': boolean;
674  /**
675   * Indicates the hint text.
676   *
677   * @syscap SystemCapability.BarrierFree.Accessibility.Core
678   * @since 9
679   */
680  'hintText': string;
681  /**
682   * Indicates the type of input text.
683   *
684   * @syscap SystemCapability.BarrierFree.Accessibility.Core
685   * @since 9
686   */
687  'inputType': number;
688  /**
689   * Indicates the inspector key.
690   *
691   * @syscap SystemCapability.BarrierFree.Accessibility.Core
692   * @since 9
693   */
694  'inspectorKey': string;
695  /**
696   * Indicates whether the element is active or not.
697   *
698   * @syscap SystemCapability.BarrierFree.Accessibility.Core
699   * @since 9
700   */
701  'isActive': boolean;
702  /**
703   * Indicates whether the element is enable or not.
704   *
705   * @syscap SystemCapability.BarrierFree.Accessibility.Core
706   * @since 9
707   */
708  'isEnable': boolean;
709  /**
710   * Indicates whether the element is hint state or not.
711   *
712   * @syscap SystemCapability.BarrierFree.Accessibility.Core
713   * @since 9
714   */
715  'isHint': boolean;
716  /**
717   * Indicates whether the element is focused or not.
718   *
719   * @syscap SystemCapability.BarrierFree.Accessibility.Core
720   * @since 9
721   */
722  'isFocused': boolean;
723  /**
724   * Indicates whether the element is password or not.
725   *
726   * @syscap SystemCapability.BarrierFree.Accessibility.Core
727   * @since 9
728   */
729  'isPassword': boolean;
730  /**
731   * Indicates whether the element is visible or not.
732   *
733   * @syscap SystemCapability.BarrierFree.Accessibility.Core
734   * @since 9
735   */
736  'isVisible': boolean;
737  /**
738   * Indicates the total count of the items.
739   *
740   * @syscap SystemCapability.BarrierFree.Accessibility.Core
741   * @since 9
742   */
743  'itemCount': number;
744  /**
745   * Indicates the last content.
746   *
747   * @syscap SystemCapability.BarrierFree.Accessibility.Core
748   * @since 9
749   */
750  'lastContent': string;
751  /**
752   * Indicates the display layer of the element.
753   *
754   * @syscap SystemCapability.BarrierFree.Accessibility.Core
755   * @since 9
756   */
757  'layer': number;
758  /**
759   * Indicates whether the element is long clickable.
760   *
761   * @syscap SystemCapability.BarrierFree.Accessibility.Core
762   * @since 9
763   */
764  'longClickable': boolean;
765  /**
766   * Indicates the page id.
767   *
768   * @syscap SystemCapability.BarrierFree.Accessibility.Core
769   * @since 9
770   */
771  'pageId': number;
772  /**
773   * Indicates the parent of the element.
774   *
775   * @syscap SystemCapability.BarrierFree.Accessibility.Core
776   * @since 9
777   */
778  'parent': AccessibilityElement;
779  /**
780   * Indicates whether the element supports multiple lines of text.
781   *
782   * @syscap SystemCapability.BarrierFree.Accessibility.Core
783   * @since 9
784   */
785  'pluralLineSupported': boolean;
786  /**
787   * Indicates the area of the element.
788   *
789   * @syscap SystemCapability.BarrierFree.Accessibility.Core
790   * @since 9
791   */
792  'rect': Rect;
793    /**
794   * Indicates the span of the element.
795   *
796   * @syscap SystemCapability.BarrierFree.Accessibility.Core
797   * @since 12
798   */
799  'span': Span;
800  /**
801   * Indicates the resource name of the element.
802   *
803   * @syscap SystemCapability.BarrierFree.Accessibility.Core
804   * @since 9
805   */
806  'resourceName': string;
807  /**
808   * Indicates the root element of the window element.
809   *
810   * @syscap SystemCapability.BarrierFree.Accessibility.Core
811   * @since 9
812   */
813  'rootElement': AccessibilityElement;
814  /**
815   * Indicates the display area of the element.
816   *
817   * @syscap SystemCapability.BarrierFree.Accessibility.Core
818   * @since 9
819   */
820  'screenRect': Rect;
821  /**
822   * Indicates whether the element is scrollable.
823   *
824   * @syscap SystemCapability.BarrierFree.Accessibility.Core
825   * @since 9
826   */
827  'scrollable': boolean;
828  /**
829   * Indicates whether the element is selected.
830   *
831   * @syscap SystemCapability.BarrierFree.Accessibility.Core
832   * @since 9
833   */
834  'selected': boolean;
835  /**
836   * Indicates the list index of the first item displayed on the screen.
837   *
838   * @syscap SystemCapability.BarrierFree.Accessibility.Core
839   * @since 9
840   */
841  'startIndex': number;
842  /**
843   * Indicates the text of the element.
844   *
845   * @syscap SystemCapability.BarrierFree.Accessibility.Core
846   * @since 9
847   */
848  'text': string;
849  /**
850   * Indicates the maximum length limit of the element text.
851   *
852   * @syscap SystemCapability.BarrierFree.Accessibility.Core
853   * @since 9
854   */
855  'textLengthLimit': number;
856  /**
857   * Indicates the unit of movement of the element text as it is read.
858   *
859   * @syscap SystemCapability.BarrierFree.Accessibility.Core
860   * @since 9
861   */
862  'textMoveUnit': accessibility.TextMoveUnit;
863  /**
864   * Indicates the action that triggered the element event.
865   *
866   * @syscap SystemCapability.BarrierFree.Accessibility.Core
867   * @since 9
868   */
869  'triggerAction': accessibility.Action;
870  /**
871   * Indicates the window type of the element.
872   *
873   * @syscap SystemCapability.BarrierFree.Accessibility.Core
874   * @since 9
875   */
876  'type': WindowType;
877  /**
878   * Indicates the maximum value.
879   *
880   * @syscap SystemCapability.BarrierFree.Accessibility.Core
881   * @since 9
882   */
883  'valueMax': number;
884  /**
885   * Indicates the minimum value.
886   *
887   * @syscap SystemCapability.BarrierFree.Accessibility.Core
888   * @since 9
889   */
890  'valueMin': number;
891  /**
892   * Indicates the current value.
893   *
894   * @syscap SystemCapability.BarrierFree.Accessibility.Core
895   * @since 9
896   */
897  'valueNow': number;
898  /**
899   * Indicates the window id.
900   *
901   * @syscap SystemCapability.BarrierFree.Accessibility.Core
902   * @since 9
903   */
904  'windowId': number;
905  /**
906   * Indicates the accessibility text.
907   *
908   * @syscap SystemCapability.BarrierFree.Accessibility.Core
909   * @since 12
910   */
911  'accessibilityText': string;
912};
913
914/**
915 * Indicates the direction of the search focus.
916 *
917 * @syscap SystemCapability.BarrierFree.Accessibility.Core
918 * @since 9
919 */
920type FocusDirection = 'up' | 'down' | 'left' | 'right' | 'forward' | 'backward';
921
922/**
923 * Indicates the type of the focus.
924 *
925 * @syscap SystemCapability.BarrierFree.Accessibility.Core
926 * @since 9
927 */
928type FocusType = 'accessibility' | 'normal';
929
930/**
931 * Indicates the type of the window.
932 *
933 * @syscap SystemCapability.BarrierFree.Accessibility.Core
934 * @since 9
935 */
936type WindowType = 'application' | 'system';
937
938/**
939 * Indicates rectangle.
940 *
941 * @typedef Rect
942 * @syscap SystemCapability.BarrierFree.Accessibility.Core
943 * @since 9
944 */
945interface Rect {
946  left: number;
947  top: number;
948  width: number;
949  height: number;
950}
951
952/**
953 * Indicates span info.
954 *
955 * @typedef Span
956 * @syscap SystemCapability.BarrierFree.Accessibility.Core
957 */
958interface Span {
959  spanId: number;
960  spanText: string;
961  accessibilityText: string;
962  accessibilityDescription: string;
963  accessibilityLevel: string;
964}
965