• 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 9
31 */
32declare namespace config {
33  /**
34   * @constant
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   * @constant
44   * Indicates the configuration of audio mono.
45   *
46   * @syscap SystemCapability.BarrierFree.Accessibility.Core
47   * @systemapi
48   * @since 10
49   */
50  const audioMono: Config<boolean>;
51  /**
52   * @constant
53   * Indicates the configuration of audio balance.
54   *
55   * @syscap SystemCapability.BarrierFree.Accessibility.Core
56   * @systemapi
57   * @since 10
58   */
59  const audioBalance: Config<number>;
60  /**
61   * Indicates the configuration of high-contrast text.
62   *
63   * @syscap SystemCapability.BarrierFree.Accessibility.Core
64   * @systemapi
65   * @since 9
66   */
67  var 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   * Indicates setting, getting, and listening to changes in configuration.
363   *
364   * @typedef Config
365   * @syscap SystemCapability.BarrierFree.Accessibility.Core
366   * @systemapi
367   * @since 9
368   */
369  interface Config<T> {
370    /**
371     * Setting configuration value.
372     *
373     * @permission ohos.permission.WRITE_ACCESSIBILITY_CONFIG
374     * @param { T } value Indicates the value.
375     * @returns { Promise<void> }
376     * @throws { BusinessError } 201 - Permission verification failed.
377     *     The application does not have the permission required to call the API.
378     * @throws { BusinessError } 202 - Permission verification failed. A non-system application calls a system API.
379     * @throws { BusinessError } 401 - Input parameter error. Possible causes:
380     *     1. Mandatory parameters are left unspecified;
381     *     2. Incorrect parameter types;
382     *     3. Parameter verification failed.
383     * @syscap SystemCapability.BarrierFree.Accessibility.Core
384     * @systemapi
385     * @since 9
386     */
387    set(value: T): Promise<void>;
388
389    /**
390     * Setting configuration value.
391     *
392     * @permission ohos.permission.WRITE_ACCESSIBILITY_CONFIG
393     * @param { T } value Indicates the value.
394     * @param { AsyncCallback<void> } callback
395     * @throws { BusinessError } 201 - Permission verification failed.
396     *     The application does not have the permission required to call the API.
397     * @throws { BusinessError } 202 - Permission verification failed. A non-system application calls a system API.
398     * @throws { BusinessError } 401 - Input parameter error. Possible causes:
399     *     1. Mandatory parameters are left unspecified;
400     *     2. Incorrect parameter types;
401     *     3. Parameter verification failed.
402     * @syscap SystemCapability.BarrierFree.Accessibility.Core
403     * @systemapi
404     * @since 9
405     */
406    set(value: T, callback: AsyncCallback<void>): void;
407
408    /**
409     * Getting configuration value.
410     *
411     * @returns { Promise<T> }
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     * @syscap SystemCapability.BarrierFree.Accessibility.Core
416     * @systemapi
417     * @since 9
418     */
419    get(): Promise<T>;
420
421    /**
422     * Getting configuration value.
423     *
424     * @param { AsyncCallback<T> } callback
425     * @throws { BusinessError } 202 - Permission verification failed. A non-system application calls a system API.
426     * @syscap SystemCapability.BarrierFree.Accessibility.Core
427     * @systemapi
428     * @since 9
429     */
430    get(callback: AsyncCallback<T>): void;
431
432    /**
433     * Register the listener to listen for configuration changes.
434     *
435     * @permission ohos.permission.READ_ACCESSIBILITY_CONFIG
436     * @param { Callback<T> } callback Indicates the listener.
437     * @throws { BusinessError } 201 - Permission verification failed.
438     *     The application does not have the permission required to call the API.
439     * @throws { BusinessError } 202 - Permission verification failed. A non-system application calls a system API.
440     * @throws { BusinessError } 401 - Input parameter error. Possible causes:
441     *     1. Mandatory parameters are left unspecified;
442     *     2. Incorrect parameter types;
443     *     3. Parameter verification failed.
444     * @syscap SystemCapability.BarrierFree.Accessibility.Core
445     * @systemapi
446     * @since 9
447     */
448    on(callback: Callback<T>): void;
449
450    /**
451     * Unregister the listener to listen for configuration changes.
452     *
453     * @permission ohos.permission.READ_ACCESSIBILITY_CONFIG
454     * @param { Callback<T> } callback Indicates the listener.
455     * @throws { BusinessError } 201 - Permission verification failed.
456     *     The application does not have the permission required to call the API.
457     * @throws { BusinessError } 202 - Permission verification failed. A non-system application calls a system API.
458     * @syscap SystemCapability.BarrierFree.Accessibility.Core
459     * @systemapi
460     * @since 9
461     */
462    off(callback?: Callback<T>): void;
463  }
464
465  /**
466   * Indicates the type of daltonization color filter.
467   *
468   * @typedef {'Normal' | 'Protanomaly' | 'Deuteranomaly' | 'Tritanomaly'}
469   * @syscap SystemCapability.BarrierFree.Accessibility.Core
470   * @systemapi
471   * @since 9
472   */
473  type DaltonizationColorFilter = 'Normal' | 'Protanomaly' | 'Deuteranomaly' | 'Tritanomaly';
474
475  /**
476   * Indicates the type of click response time.
477   *
478   * @typedef {'Short' | 'Medium' | 'Long'}
479   * @syscap SystemCapability.BarrierFree.Accessibility.Core
480   * @systemapi
481   * @since 11
482   */
483  type ClickResponseTime = 'Short' | 'Medium' | 'Long';
484
485  /**
486   * Indicates the type of ignore repeat click interval.
487   *
488   * @typedef {'Shortest' | 'Short' | 'Medium' | 'Long' | 'Longest'}
489   * @syscap SystemCapability.BarrierFree.Accessibility.Core
490   * @systemapi
491   * @since 11
492   */
493  type RepeatClickInterval = 'Shortest' | 'Short' | 'Medium' | 'Long' | 'Longest';
494}
495export default config;
496