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