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