• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1/*
2 * Copyright (c) 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
16/**
17 * @file
18 * @kit AccessibilityKit
19 */
20
21import type accessibility from './@ohos.accessibility';
22import type { AsyncCallback, Callback } from './@ohos.base';
23
24/**
25 * Configuration of the accessibility.
26 *
27 * @namespace config
28 * @syscap SystemCapability.BarrierFree.Accessibility.Core
29 * @systemapi
30 * @since arkts {'1.1':'9', '1.2':'20'}
31 * @arkts 1.1&1.2
32 */
33declare namespace config {
34  /**
35   * Indicates the configuration of daltonization state.
36   *
37   * @syscap SystemCapability.BarrierFree.Accessibility.Core
38   * @systemapi
39   * @since 11
40   */
41  const daltonizationState: Config<boolean>;
42  /**
43   * Indicates the configuration of audio mono.
44   *
45   * @syscap SystemCapability.BarrierFree.Accessibility.Core
46   * @systemapi
47   * @since 10
48   */
49  const audioMono: Config<boolean>;
50  /**
51   * Indicates the configuration of audio balance.
52   *
53   * @syscap SystemCapability.BarrierFree.Accessibility.Core
54   * @systemapi
55   * @since 10
56   */
57  const audioBalance: Config<number>;
58  /**
59   * Indicates the configuration of high-contrast text.
60   *
61   * @type { Config<boolean> }
62   * @syscap SystemCapability.BarrierFree.Accessibility.Core
63   * @systemapi
64   * @since arkts {'1.1':'9', '1.2':'20'}
65   * @arkts 1.1&1.2
66   */
67  let highContrastText: Config<boolean>;
68  /**
69   * Indicates the configuration of invert color.
70   *
71   * @syscap SystemCapability.BarrierFree.Accessibility.Core
72   * @systemapi
73   * @since 9
74   */
75  var invertColor: Config<boolean>;
76  /**
77   * Indicates the configuration of daltonization color filter.
78   *
79   * @syscap SystemCapability.BarrierFree.Accessibility.Core
80   * @systemapi
81   * @since 9
82   */
83  var daltonizationColorFilter: Config<DaltonizationColorFilter>;
84  /**
85   * Indicates the configuration of content timeout.
86   *
87   * @syscap SystemCapability.BarrierFree.Accessibility.Core
88   * @systemapi
89   * @since 9
90   */
91  var contentTimeout: Config<number>;
92  /**
93   * Indicates the configuration of animation state.
94   *
95   * @syscap SystemCapability.BarrierFree.Accessibility.Core
96   * @systemapi
97   * @since 9
98   */
99  var animationOff: Config<boolean>;
100  /**
101   * Indicates the configuration of brightness discount.
102   *
103   * @syscap SystemCapability.BarrierFree.Accessibility.Core
104   * @systemapi
105   * @since 9
106   */
107  var brightnessDiscount: Config<number>;
108  /**
109   * Indicates the configuration of mouse key state.
110   *
111   * @syscap SystemCapability.BarrierFree.Accessibility.Core
112   * @systemapi
113   * @since 9
114   */
115  var mouseKey: Config<boolean>;
116  /**
117   * Indicates the configuration of mouse auto click.
118   *
119   * @syscap SystemCapability.BarrierFree.Accessibility.Core
120   * @systemapi
121   * @since 9
122   */
123  var mouseAutoClick: Config<number>;
124  /**
125   * Indicates the configuration of short key state.
126   *
127   * @syscap SystemCapability.BarrierFree.Accessibility.Core
128   * @systemapi
129   * @since 9
130   */
131  var shortkey: Config<boolean>;
132  /**
133   * Indicates the configuration of short key target.
134   *
135   * @syscap SystemCapability.BarrierFree.Accessibility.Core
136   * @systemapi
137   * @since 9
138   */
139  var shortkeyTarget: Config<string>;
140  /**
141   * Indicates the configuration of short key multi targets.
142   *
143   * @syscap SystemCapability.BarrierFree.Accessibility.Core
144   * @systemapi
145   * @since 11
146   */
147  const shortkeyMultiTargets: Config<Array<string>>;
148  /**
149   * Indicates the configuration of captions state.
150   *
151   * @syscap SystemCapability.BarrierFree.Accessibility.Core
152   * @systemapi
153   * @since 9
154   */
155  var captions: Config<boolean>;
156  /**
157   * Indicates the configuration of captions style.
158   *
159   * @syscap SystemCapability.BarrierFree.Accessibility.Core
160   * @systemapi
161   * @since 9
162   */
163  var captionsStyle: Config<accessibility.CaptionsStyle>;
164  /**
165   * Indicates the configuration of click response time.
166   *
167   * @syscap SystemCapability.BarrierFree.Accessibility.Core
168   * @systemapi
169   * @since 11
170   */
171  const clickResponseTime: Config<ClickResponseTime>;
172  /**
173   * Indicates the configuration of ignore repeat click.
174   *
175   * @syscap SystemCapability.BarrierFree.Accessibility.Core
176   * @systemapi
177   * @since 11
178   */
179  const ignoreRepeatClick: Config<boolean>;
180  /**
181   * Indicates the configuration of ignore repeat click interval.
182   *
183   * @syscap SystemCapability.BarrierFree.Accessibility.Core
184   * @systemapi
185   * @since 11
186   */
187  const repeatClickInterval: Config<RepeatClickInterval>;
188  /**
189   * Indicates the configuration of screen magnification.
190   *
191   * @syscap SystemCapability.BarrierFree.Accessibility.Core
192   * @systemapi
193   * @since 12
194   */
195  const screenMagnification: Config<boolean>;
196
197  /**
198   * Enable the accessibility extension ability.
199   *
200   * @permission ohos.permission.WRITE_ACCESSIBILITY_CONFIG
201   * @param { string } name Indicates the accessibility extension name, in "bundleName/abilityName" format.
202   * @param { Array<accessibility.Capability> } capability Indicates the ability.
203   * @returns { Promise<void> }
204   * @throws { BusinessError } 201 - Permission verification failed.
205   *     The application does not have the permission required to call the API.
206   * @throws { BusinessError } 202 - Permission verification failed. A non-system application calls a system API.
207   * @throws { BusinessError } 401 - Input parameter error. Possible causes:
208   *     1. Mandatory parameters are left unspecified;
209   *     2. Incorrect parameter types;
210   *     3. Parameter verification failed.
211   * @throws { BusinessError } 9300001 - Invalid bundle name or ability name.
212   * @throws { BusinessError } 9300002 - Target ability already enabled.
213   * @syscap SystemCapability.BarrierFree.Accessibility.Core
214   * @systemapi
215   * @since 9
216   */
217  function enableAbility(name: string, capability: Array<accessibility.Capability>): Promise<void>;
218
219  /**
220   * Enable the accessibility extension ability.
221   *
222   * @permission ohos.permission.WRITE_ACCESSIBILITY_CONFIG
223   * @param { string } name Indicates the accessibility extension name, in "bundleName/abilityName" format.
224   * @param { Array<accessibility.Capability> } capability Indicates the ability.
225   * @param { AsyncCallback<void> } callback
226   * @throws { BusinessError } 201 - Permission verification failed.
227   *     The application does not have the permission required to call the API.
228   * @throws { BusinessError } 202 - Permission verification failed. A non-system application calls a system API.
229   * @throws { BusinessError } 401 - Input parameter error. Possible causes:
230   *     1. Mandatory parameters are left unspecified;
231   *     2. Incorrect parameter types;
232   *     3. Parameter verification failed.
233   * @throws { BusinessError } 9300001 - Invalid bundle name or ability name.
234   * @throws { BusinessError } 9300002 - Target ability already enabled.
235   * @syscap SystemCapability.BarrierFree.Accessibility.Core
236   * @systemapi
237   * @since 9
238   */
239  function enableAbility(
240    name: string,
241    capability: Array<accessibility.Capability>,
242    callback: AsyncCallback<void>
243  ): void;
244
245  /**
246   * Disable the accessibility extension ability.
247   *
248   * @permission ohos.permission.WRITE_ACCESSIBILITY_CONFIG
249   * @param { string } name Indicates the accessibility extension name, in "bundleName/abilityName" format.
250   * @returns { Promise<void> }
251   * @throws { BusinessError } 201 - Permission verification failed.
252   *     The application does not have the permission required to call the API.
253   * @throws { BusinessError } 202 - Permission verification failed. A non-system application calls a system API.
254   * @throws { BusinessError } 401 - Input parameter error. Possible causes:
255   *     1. Mandatory parameters are left unspecified;
256   *     2. Incorrect parameter types;
257   *     3. Parameter verification failed.
258   * @throws { BusinessError } 9300001 - Invalid bundle name or ability name.
259   * @syscap SystemCapability.BarrierFree.Accessibility.Core
260   * @systemapi
261   * @since 9
262   */
263  function disableAbility(name: string): Promise<void>;
264
265  /**
266   * Disable the accessibility extension ability.
267   *
268   * @permission ohos.permission.WRITE_ACCESSIBILITY_CONFIG
269   * @param { string } name Indicates the accessibility extension name, in "bundleName/abilityName" format.
270   * @param { AsyncCallback<void> } callback
271   * @throws { BusinessError } 201 - Permission verification failed.
272   *     The application does not have the permission required to call the API.
273   * @throws { BusinessError } 202 - Permission verification failed. A non-system application calls a system API.
274   * @throws { BusinessError } 401 - Input parameter error. Possible causes:
275   *     1. Mandatory parameters are left unspecified;
276   *     2. Incorrect parameter types;
277   *     3. Parameter verification failed.
278   * @throws { BusinessError } 9300001 - Invalid bundle name or ability name.
279   * @syscap SystemCapability.BarrierFree.Accessibility.Core
280   * @systemapi
281   * @since 9
282   */
283  function disableAbility(name: string, callback: AsyncCallback<void>): void;
284
285  /**
286   * Register the listener that watches for changes in the enabled status of accessibility extensions.
287   *
288   * @permission ohos.permission.READ_ACCESSIBILITY_CONFIG
289   * @param { 'enabledAccessibilityExtensionListChange' } type Indicates the type of event.
290   * @param { Callback<void> } callback Indicates the listener.
291   * @throws { BusinessError } 201 - Permission verification failed.
292   *     The application does not have the permission required to call the API.
293   * @throws { BusinessError } 202 - Permission verification failed. A non-system application calls a system API.
294   * @throws { BusinessError } 401 - Input parameter error. Possible causes:
295   *     1. Mandatory parameters are left unspecified;
296   *     2. Incorrect parameter types;
297   *     3. Parameter verification failed.
298   * @syscap SystemCapability.BarrierFree.Accessibility.Core
299   * @systemapi
300   * @since 9
301   */
302  function on(type: 'enabledAccessibilityExtensionListChange', callback: Callback<void>): void;
303
304  /**
305   * Register the listener that watches for changes in the installed status of accessibility extensions.
306   *
307   * @permission ohos.permission.READ_ACCESSIBILITY_CONFIG
308   * @param { 'installedAccessibilityListChange' } type Indicates the type of event.
309   * @param { Callback<void> } callback Indicates the listener.
310   * @throws { BusinessError } 201 - Permission verification failed.
311   *     The application does not have the permission required to call the API.
312   * @throws { BusinessError } 202 - Permission verification failed. A non-system application calls a system API.
313   * @throws { BusinessError } 401 - Input parameter error. Possible causes:
314   *     1. Mandatory parameters are left unspecified;
315   *     2. Incorrect parameter types;
316   *     3. Parameter verification failed.
317   * @syscap SystemCapability.BarrierFree.Accessibility.Core
318   * @systemapi
319   * @since 12
320   */
321  function on(type: 'installedAccessibilityListChange', callback: Callback<void>): void;
322
323  /**
324   * Unregister listener that watches for changes in the enabled status of accessibility extensions.
325   *
326   * @permission ohos.permission.READ_ACCESSIBILITY_CONFIG
327   * @param { 'enabledAccessibilityExtensionListChange' } type Indicates the type of event.
328   * @param { Callback<void> } callback Indicates the listener.
329   * @throws { BusinessError } 201 - Permission verification failed.
330   *     The application does not have the permission required to call the API.
331   * @throws { BusinessError } 202 - Permission verification failed. A non-system application calls a system API.
332   * @throws { BusinessError } 401 - Input parameter error. Possible causes:
333   *     1. Mandatory parameters are left unspecified;
334   *     2. Incorrect parameter types;
335   *     3. Parameter verification failed.
336   * @syscap SystemCapability.BarrierFree.Accessibility.Core
337   * @systemapi
338   * @since 9
339   */
340  function off(type: 'enabledAccessibilityExtensionListChange', callback?: Callback<void>): void;
341
342  /**
343   * Unregister listener that watches for changes in the installed status of accessibility extensions.
344   *
345   * @permission ohos.permission.READ_ACCESSIBILITY_CONFIG
346   * @param { 'installedAccessibilityListChange' } type Indicates the type of event.
347   * @param { Callback<void> } callback Indicates the listener.
348   * @throws { BusinessError } 201 - Permission verification failed.
349   *     The application does not have the permission required to call the API.
350   * @throws { BusinessError } 202 - Permission verification failed. A non-system application calls a system API.
351   * @throws { BusinessError } 401 - Input parameter error. Possible causes:
352   *     1. Mandatory parameters are left unspecified;
353   *     2. Incorrect parameter types;
354   *     3. Parameter verification failed.
355   * @syscap SystemCapability.BarrierFree.Accessibility.Core
356   * @systemapi
357   * @since 12
358   */
359  function off(type: 'installedAccessibilityListChange', callback?: Callback<void>): void;
360
361  /**
362   * Set display magnification state.
363   *
364   * @permission ohos.permission.WRITE_ACCESSIBILITY_CONFIG
365   * @param { boolean } state Indicates that whether trigger display magnification.
366   * @throws { BusinessError } 201 - Permission verification failed. The application does not have the permission required to call the API.
367   * @throws { BusinessError } 202 - Permission verification failed. A non-system application calls a system API.
368   * @throws { BusinessError } 801 - Capability not supported. Failed to call the API due to limited device capabilities.
369   * @throws { BusinessError } 9300007 - Trigger magnification failed.
370   * @syscap SystemCapability.BarrierFree.Accessibility.Core
371   * @systemapi
372   * @since 20
373   */
374  function setMagnificationState(state: boolean): void;
375
376  /**
377   * Indicates setting, getting, and listening to changes in configuration.
378   *
379   * @typedef Config<T>
380   * @syscap SystemCapability.BarrierFree.Accessibility.Core
381   * @systemapi
382   * @since arkts {'1.1':'9', '1.2':'20'}
383   * @arkts 1.1&1.2
384   */
385  interface Config<T> {
386    /**
387     * Setting configuration value.
388     *
389     * @permission ohos.permission.WRITE_ACCESSIBILITY_CONFIG
390     * @param { T } value Indicates the value.
391     * @returns { Promise<void> }
392     * @throws { BusinessError } 201 - Permission verification failed.
393     *     The application does not have the permission required to call the API.
394     * @throws { BusinessError } 202 - Permission verification failed. A non-system application calls a system API.
395     * @throws { BusinessError } 401 - Input parameter error. Possible causes:
396     *     1. Mandatory parameters are left unspecified;
397     *     2. Incorrect parameter types;
398     *     3. Parameter verification failed.
399     * @syscap SystemCapability.BarrierFree.Accessibility.Core
400     * @systemapi
401     * @since arkts {'1.1':'9', '1.2':'20'}
402     * @arkts 1.1&1.2
403     */
404    set(value: T): Promise<void>;
405
406    /**
407     * Setting configuration value.
408     *
409     * @permission ohos.permission.WRITE_ACCESSIBILITY_CONFIG
410     * @param { T } value Indicates the value.
411     * @param { AsyncCallback<void> } callback
412     * @throws { BusinessError } 201 - Permission verification failed.
413     *     The application does not have the permission required to call the API.
414     * @throws { BusinessError } 202 - Permission verification failed. A non-system application calls a system API.
415     * @throws { BusinessError } 401 - Input parameter error. Possible causes:
416     *     1. Mandatory parameters are left unspecified;
417     *     2. Incorrect parameter types;
418     *     3. Parameter verification failed.
419     * @syscap SystemCapability.BarrierFree.Accessibility.Core
420     * @systemapi
421     * @since arkts {'1.1':'9', '1.2':'20'}
422     * @arkts 1.1&1.2
423     */
424    set(value: T, callback: AsyncCallback<void>): void;
425
426    /**
427     * Getting configuration value.
428     *
429     * @returns { Promise<T> }
430     * @throws { BusinessError } 201 - Permission verification failed.
431     *     The application does not have the permission required to call the API.
432     * @throws { BusinessError } 202 - Permission verification failed. A non-system application calls a system API.
433     * @syscap SystemCapability.BarrierFree.Accessibility.Core
434     * @systemapi
435     * @since arkts {'1.1':'9', '1.2':'20'}
436     * @arkts 1.1&1.2
437     */
438    get(): Promise<T>;
439
440    /**
441     * Getting configuration value.
442     *
443     * @param { AsyncCallback<T> } callback
444     * @throws { BusinessError } 202 - Permission verification failed. A non-system application calls a system API.
445     * @syscap SystemCapability.BarrierFree.Accessibility.Core
446     * @systemapi
447     * @since arkts {'1.1':'9', '1.2':'20'}
448     * @arkts 1.1&1.2
449     */
450    get(callback: AsyncCallback<T>): void;
451
452    /**
453     * Register the listener to listen for configuration changes.
454     *
455     * @permission ohos.permission.READ_ACCESSIBILITY_CONFIG
456     * @param { Callback<T> } callback Indicates the listener.
457     * @throws { BusinessError } 201 - Permission verification failed.
458     *     The application does not have the permission required to call the API.
459     * @throws { BusinessError } 202 - Permission verification failed. A non-system application calls a system API.
460     * @throws { BusinessError } 401 - Input parameter error. Possible causes:
461     *     1. Mandatory parameters are left unspecified;
462     *     2. Incorrect parameter types;
463     *     3. Parameter verification failed.
464     * @syscap SystemCapability.BarrierFree.Accessibility.Core
465     * @systemapi
466     * @since 9
467     */
468    on(callback: Callback<T>): void;
469
470    /**
471     * Unregister the listener to listen for configuration changes.
472     *
473     * @permission ohos.permission.READ_ACCESSIBILITY_CONFIG
474     * @param { Callback<T> } callback Indicates the listener.
475     * @throws { BusinessError } 201 - Permission verification failed.
476     *     The application does not have the permission required to call the API.
477     * @throws { BusinessError } 202 - Permission verification failed. A non-system application calls a system API.
478     * @syscap SystemCapability.BarrierFree.Accessibility.Core
479     * @systemapi
480     * @since 9
481     */
482    off(callback?: Callback<T>): void;
483  }
484
485  /**
486   * Indicates the type of daltonization color filter.
487   *
488   * @typedef {'Normal' | 'Protanomaly' | 'Deuteranomaly' | 'Tritanomaly'}
489   * @syscap SystemCapability.BarrierFree.Accessibility.Core
490   * @systemapi
491   * @since 9
492   */
493  type DaltonizationColorFilter = 'Normal' | 'Protanomaly' | 'Deuteranomaly' | 'Tritanomaly';
494
495  /**
496   * Indicates the type of click response time.
497   *
498   * @typedef {'Short' | 'Medium' | 'Long'}
499   * @syscap SystemCapability.BarrierFree.Accessibility.Core
500   * @systemapi
501   * @since 11
502   */
503  type ClickResponseTime = 'Short' | 'Medium' | 'Long';
504
505  /**
506   * Indicates the type of ignore repeat click interval.
507   *
508   * @typedef {'Shortest' | 'Short' | 'Medium' | 'Long' | 'Longest'}
509   * @syscap SystemCapability.BarrierFree.Accessibility.Core
510   * @systemapi
511   * @since 11
512   */
513  type RepeatClickInterval = 'Shortest' | 'Short' | 'Medium' | 'Long' | 'Longest';
514}
515export default config;
516