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
16import type accessibility from './@ohos.accessibility';
17import type { AsyncCallback, Callback } from './basic';
18
19/**
20 * Configuration of the accessibility.
21 *
22 * @namespace config
23 * @syscap SystemCapability.BarrierFree.Accessibility.Core
24 * @systemapi
25 * @since 9
26 */
27declare namespace config {
28  /**
29   * Indicates the configuration of high-contrast text.
30   *
31   * @syscap SystemCapability.BarrierFree.Accessibility.Core
32   * @systemapi
33   * @since 9
34   */
35  let highContrastText: Config<boolean>;
36  /**
37   * Indicates the configuration of invert color.
38   *
39   * @syscap SystemCapability.BarrierFree.Accessibility.Core
40   * @systemapi
41   * @since 9
42   */
43  let invertColor: Config<boolean>;
44  /**
45   * Indicates the configuration of daltonization state.
46   *
47   * @syscap SystemCapability.BarrierFree.Accessibility.Core
48   * @systemapi
49   * @since 10
50   */
51  let daltonizationState: Config<boolean>;
52  /**
53   * Indicates the configuration of daltonization color filter.
54   *
55   * @syscap SystemCapability.BarrierFree.Accessibility.Core
56   * @systemapi
57   * @since 9
58   */
59  let daltonizationColorFilter: Config<DaltonizationColorFilter>;
60  /**
61   * Indicates the configuration of content timeout.
62   *
63   * @syscap SystemCapability.BarrierFree.Accessibility.Core
64   * @systemapi
65   * @since 9
66   */
67  let contentTimeout: Config<number>;
68  /**
69   * Indicates the configuration of animation state.
70   *
71   * @syscap SystemCapability.BarrierFree.Accessibility.Core
72   * @systemapi
73   * @since 9
74   */
75  let animationOff: Config<boolean>;
76  /**
77   * Indicates the configuration of brightness discount.
78   *
79   * @syscap SystemCapability.BarrierFree.Accessibility.Core
80   * @systemapi
81   * @since 9
82   */
83  let brightnessDiscount: Config<number>;
84  /**
85   * Indicates the configuration of screen magnifier.
86   *
87   * @syscap SystemCapability.BarrierFree.Accessibility.Core
88   * @systemapi
89   * @since 9
90   */
91  let screenMagnifier: Config<boolean>;
92  /**
93   * Indicates the configuration of audio mono.
94   *
95   * @syscap SystemCapability.BarrierFree.Accessibility.Core
96   * @systemapi
97   * @since 9
98   */
99  let audioMono: Config<boolean>;
100  /**
101   * Indicates the configuration of audio balance.
102   *
103   * @syscap SystemCapability.BarrierFree.Accessibility.Core
104   * @systemapi
105   * @since 9
106   */
107  let audioBalance: 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  let 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  let 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  let 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  let 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  let 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  let 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  let captionsStyle: Config<accessibility.CaptionsStyle>;
164
165  /**
166   * Indicates the configuration of click response time.
167   *
168   * @syscap SystemCapability.BarrierFree.Accessibility.Core
169   * @systemapi
170   * @since 11
171   */
172  const clickResponseTime: Config<ClickResponseTime>;
173
174  /**
175   * Indicates the configuration of ignore repeat click.
176   *
177   * @syscap SystemCapability.BarrierFree.Accessibility.Core
178   * @systemapi
179   * @since 11
180   */
181  const ignoreRepeatClick: Config<boolean>;
182
183  /**
184   * Indicates the configuration of ignore repeat click time.
185   *
186   * @syscap SystemCapability.BarrierFree.Accessibility.Core
187   * @systemapi
188   * @since 11
189   */
190  const repeatClickInterval: Config<RepeatClickInterval>;
191
192  /**
193   * Enable the accessibility extension ability.
194   *
195   * @param { string } name Indicates the accessibility extension name, in "bundleName/abilityName" format.
196   * @param { Array<accessibility.Capability> } capability Indicates the ability.
197   * @returns { Promise<void> }
198   * @throws { BusinessError } 201 - Permission verification failed.
199   *                           The application does not have the permission required to call the API.
200   * @throws { BusinessError } 202 - Permission verification failed. A non-system application calls a system API.
201   * @throws { BusinessError } 401 - Parameter error. Possible causes:
202   *                           1. Mandatory parameters are left unspecified;
203   *                           2. Incorrect parameter types;
204   *                           3. Parameter verification failed.
205   * @throws { BusinessError } 9300001 - Invalid bundle name or ability name.
206   * @throws { BusinessError } 9300002 - Target ability already enabled.
207   * @syscap SystemCapability.BarrierFree.Accessibility.Core
208   * @systemapi
209   * @since 9
210   */
211  function enableAbility(name: string, capability: Array<accessibility.Capability>): Promise<void>;
212
213  /**
214   * Enable the accessibility extension ability.
215   *
216   * @param { string } name Indicates the accessibility extension name, in "bundleName/abilityName" format.
217   * @param { Array<accessibility.Capability> } capability Indicates the ability.
218   * @param { AsyncCallback<void> } callback
219   * @throws { BusinessError } 201 - Permission verification failed.
220   *                           The application does not have the permission required to call the API.
221   * @throws { BusinessError } 202 - Permission verification failed. A non-system application calls a system API.
222   * @throws { BusinessError } 401 - Parameter error. Possible causes:
223   *                           1. Mandatory parameters are left unspecified;
224   *                           2. Incorrect parameter types;
225   *                           3. Parameter verification failed.
226   * @throws { BusinessError } 9300001 - Invalid bundle name or ability name.
227   * @throws { BusinessError } 9300002 - Target ability already enabled.
228   * @syscap SystemCapability.BarrierFree.Accessibility.Core
229   * @systemapi
230   * @since 9
231   */
232  function enableAbility(
233    name: string,
234    capability: Array<accessibility.Capability>,
235    callback: AsyncCallback<void>
236  ): void;
237
238  /**
239   * Disable the accessibility extension ability.
240   *
241   * @param { string } name Indicates the accessibility extension name, in "bundleName/abilityName" format.
242   * @returns { Promise<void> }
243   * @throws { BusinessError } 201 - Permission verification failed.
244   *                           The application does not have the permission required to call the API.
245   * @throws { BusinessError } 202 - Permission verification failed. A non-system application calls a system API.
246   * @throws { BusinessError } 401 - Parameter error. Possible causes:
247   *                           1. Mandatory parameters are left unspecified;
248   *                           2. Incorrect parameter types;
249   *                           3. Parameter verification failed.
250   * @throws { BusinessError } 9300001 - Invalid bundle name or ability name.
251   * @syscap SystemCapability.BarrierFree.Accessibility.Core
252   * @systemapi
253   * @since 9
254   */
255  function disableAbility(name: string): Promise<void>;
256
257  /**
258   * Disable the accessibility extension ability.
259   *
260   * @param { string } name Indicates the accessibility extension name, in "bundleName/abilityName" format.
261   * @param { AsyncCallback<void> } callback
262   * @throws { BusinessError } 201 - Permission verification failed.
263   *                           The application does not have the permission required to call the API.
264   * @throws { BusinessError } 202 - Permission verification failed. A non-system application calls a system API.
265   * @throws { BusinessError } 401 - Parameter error. Possible causes:
266   *                           1. Mandatory parameters are left unspecified;
267   *                           2. Incorrect parameter types;
268   *                           3. Parameter verification failed.
269   * @throws { BusinessError } 9300001 - Invalid bundle name or ability name.
270   * @syscap SystemCapability.BarrierFree.Accessibility.Core
271   * @systemapi
272   * @since 9
273   */
274  function disableAbility(name: string, callback: AsyncCallback<void>): void;
275
276  /**
277   * Register the listener that watches for changes in the enabled status of accessibility extensions.
278   *
279   * @param { 'enabledAccessibilityExtensionListChange' } type Indicates the type of event.
280   * @param { Callback<void> } callback Indicates the listener.
281   * @throws { BusinessError } 202 - Permission verification failed. A non-system application calls a system API.
282   * @throws { BusinessError } 401 - Parameter error. Possible causes:
283   *                           1. Mandatory parameters are left unspecified;
284   *                           2. Incorrect parameter types;
285   *                           3. Parameter verification failed.
286   * @syscap SystemCapability.BarrierFree.Accessibility.Core
287   * @systemapi
288   * @since 9
289   */
290  function on(type: 'enabledAccessibilityExtensionListChange', callback: Callback<void>): void;
291
292  /**
293   * Deregister listener that watches for changes in the enabled status of accessibility extensions.
294   *
295   * @param { 'enabledAccessibilityExtensionListChange' } type Indicates the type of event.
296   * @param { Callback<void> } callback Indicates the listener.
297   * @throws { BusinessError } 202 - Permission verification failed. A non-system application calls a system API.
298   * @throws { BusinessError } 401 - Parameter error. Possible causes:
299   *                           1. Mandatory parameters are left unspecified;
300   *                           2. Incorrect parameter types;
301   *                           3. Parameter verification failed.
302   * @syscap SystemCapability.BarrierFree.Accessibility.Core
303   * @systemapi
304   * @since 9
305   */
306  function off(type: 'enabledAccessibilityExtensionListChange', callback?: Callback<void>): void;
307
308  /**
309   * Indicates setting, getting, and listening to changes in configuration.
310   *
311   * @typedef Config
312   * @syscap SystemCapability.BarrierFree.Accessibility.Core
313   * @systemapi
314   * @since 9
315   */
316  interface Config<T> {
317    /**
318     * Setting configuration value.
319     *
320     * @param { T } value Indicates the value.
321     * @returns { Promise<void> }
322     * @throws { BusinessError } 201 - Permission verification failed.
323     *                           The application does not have the permission required to call the API.
324     * @throws { BusinessError } 202 - Permission verification failed. A non-system application calls a system API.
325     * @throws { BusinessError } 401 - Parameter error. Possible causes:
326     *                           1. Mandatory parameters are left unspecified;
327     *                           2. Incorrect parameter types;
328     *                           3. Parameter verification failed.
329     * @syscap SystemCapability.BarrierFree.Accessibility.Core
330     * @systemapi
331     * @since 9
332     */
333    set(value: T): Promise<void>;
334
335    /**
336     * Setting configuration value.
337     *
338     * @param { T } value Indicates the value.
339     * @param { AsyncCallback<void> } callback
340     * @throws { BusinessError } 201 - Permission verification failed.
341     *                           The application does not have the permission required to call the API.
342     * @throws { BusinessError } 202 - Permission verification failed. A non-system application calls a system API.
343     * @throws { BusinessError } 401 - Parameter error. Possible causes:
344     *                           1. Mandatory parameters are left unspecified;
345     *                           2. Incorrect parameter types;
346     *                           3. Parameter verification failed.
347     * @syscap SystemCapability.BarrierFree.Accessibility.Core
348     * @systemapi
349     * @since 9
350     */
351    set(value: T, callback: AsyncCallback<void>): void;
352
353    /**
354     * Getting configuration value.
355     *
356     * @returns { Promise<T> }
357     * @throws { BusinessError } 201 - Permission verification failed.
358     *                           The application does not have the permission required to call the API.
359     * @throws { BusinessError } 202 - Permission verification failed. A non-system application calls a system API.
360     * @syscap SystemCapability.BarrierFree.Accessibility.Core
361     * @systemapi
362     * @since 9
363     */
364    get(): Promise<T>;
365
366    /**
367     * Getting configuration value.
368     *
369     * @param { AsyncCallback<T> } callback
370     * @throws { BusinessError } 201 - Permission verification failed.
371     *                           The application does not have the permission required to call the API.
372     * @throws { BusinessError } 202 - Permission verification failed. A non-system application calls a system API.
373     * @syscap SystemCapability.BarrierFree.Accessibility.Core
374     * @systemapi
375     * @since 9
376     */
377    get(callback: AsyncCallback<T>): void;
378
379    /**
380     * Register the listener to listen for configuration changes.
381     *
382     * @param { Callback<T> } callback Indicates the listener.
383     * @throws { BusinessError } 201 - Permission verification failed.
384     *                           The application does not have the permission required to call the API.
385     * @throws { BusinessError } 202 - Permission verification failed. A non-system application calls a system API.
386     * @throws { BusinessError } 401 - Parameter error. Possible causes:
387     *                           1. Mandatory parameters are left unspecified;
388     *                           2. Incorrect parameter types;
389     *                           3. Parameter verification failed.
390     * @syscap SystemCapability.BarrierFree.Accessibility.Core
391     * @systemapi
392     * @since 9
393     */
394    on(callback: Callback<T>): void;
395
396    /**
397     * Deregister the listener to listen for configuration changes.
398     *
399     * @param { Callback<T> } callback Indicates the listener.
400     * @throws { BusinessError } 202 - Permission verification failed. A non-system application calls a system API.
401     * @syscap SystemCapability.BarrierFree.Accessibility.Core
402     * @systemapi
403     * @since 9
404     */
405    off(callback?: Callback<T>): void;
406  }
407
408  /**
409   * Indicates the type of daltonization color filter.
410   *
411   * @systemapi
412   */
413  type DaltonizationColorFilter = 'Normal' | 'Protanomaly' | 'Deuteranomaly' | 'Tritanomaly';
414
415  /**
416   * Indicates the type of click response time.
417   *
418   * @systemapi
419   */
420  type ClickResponseTime = 'Short' | 'Medium' | 'Long';
421
422  /**
423   * Indicates the type of ignore repeat click interval.
424   *
425   * @systemapi
426   */
427  type RepeatClickInterval = 'Shortest' | 'Short' | 'Medium' | 'Long' | 'Longest';
428}
429export default config;
430