• 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
16import type accessibility from './@ohos.accessibility';
17import type { AsyncCallback, Callback } from './@ohos.base';
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   * @constant
30   * Indicates the configuration of audio mono.
31   *
32   * @syscap SystemCapability.BarrierFree.Accessibility.Core
33   * @systemapi
34   * @since 10
35   */
36  const audioMono: Config<boolean>;
37  /**
38   * @constant
39   * Indicates the configuration of audio balance.
40   *
41   * @syscap SystemCapability.BarrierFree.Accessibility.Core
42   * @systemapi
43   * @since 10
44   */
45  const audioBalance: Config<number>;
46  /**
47   * Indicates the configuration of high-contrast text.
48   *
49   * @syscap SystemCapability.BarrierFree.Accessibility.Core
50   * @systemapi
51   * @since 9
52   */
53  var highContrastText: Config<boolean>;
54  /**
55   * Indicates the configuration of invert color.
56   *
57   * @syscap SystemCapability.BarrierFree.Accessibility.Core
58   * @systemapi
59   * @since 9
60   */
61  var invertColor: Config<boolean>;
62  /**
63   * Indicates the configuration of daltonization color filter.
64   *
65   * @syscap SystemCapability.BarrierFree.Accessibility.Core
66   * @systemapi
67   * @since 9
68   */
69  var daltonizationColorFilter: Config<DaltonizationColorFilter>;
70  /**
71   * Indicates the configuration of content timeout.
72   *
73   * @syscap SystemCapability.BarrierFree.Accessibility.Core
74   * @systemapi
75   * @since 9
76   */
77  var contentTimeout: Config<number>;
78  /**
79   * Indicates the configuration of animation state.
80   *
81   * @syscap SystemCapability.BarrierFree.Accessibility.Core
82   * @systemapi
83   * @since 9
84   */
85  var animationOff: Config<boolean>;
86  /**
87   * Indicates the configuration of brightness discount.
88   *
89   * @syscap SystemCapability.BarrierFree.Accessibility.Core
90   * @systemapi
91   * @since 9
92   */
93  var brightnessDiscount: Config<number>;
94  /**
95   * Indicates the configuration of mouse key state.
96   *
97   * @syscap SystemCapability.BarrierFree.Accessibility.Core
98   * @systemapi
99   * @since 9
100   */
101  var mouseKey: Config<boolean>;
102  /**
103   * Indicates the configuration of mouse auto click.
104   *
105   * @syscap SystemCapability.BarrierFree.Accessibility.Core
106   * @systemapi
107   * @since 9
108   */
109  var mouseAutoClick: Config<number>;
110  /**
111   * Indicates the configuration of short key state.
112   *
113   * @syscap SystemCapability.BarrierFree.Accessibility.Core
114   * @systemapi
115   * @since 9
116   */
117  var shortkey: Config<boolean>;
118  /**
119   * Indicates the configuration of short key target.
120   *
121   * @syscap SystemCapability.BarrierFree.Accessibility.Core
122   * @systemapi
123   * @since 9
124   */
125  var shortkeyTarget: Config<string>;
126  /**
127   * Indicates the configuration of captions state.
128   *
129   * @syscap SystemCapability.BarrierFree.Accessibility.Core
130   * @systemapi
131   * @since 9
132   */
133  var captions: Config<boolean>;
134  /**
135   * Indicates the configuration of captions style.
136   *
137   * @syscap SystemCapability.BarrierFree.Accessibility.Core
138   * @systemapi
139   * @since 9
140   */
141  var captionsStyle: Config<accessibility.CaptionsStyle>;
142
143  /**
144   * Enable the accessibility extension ability.
145   *
146   * @param { string } name Indicates the accessibility extension name, in "bundleName/abilityName" format.
147   * @param { Array<accessibility.Capability> } capability Indicates the ability.
148   * @returns { Promise<void> }
149   * @throws { BusinessError } 201 - Permission denied.
150   * @throws { BusinessError } 202 - Not system App.
151   * @throws { BusinessError } 401 - Input parameter error.
152   * @throws { BusinessError } 9300001 - Invalid bundle name or ability name.
153   * @throws { BusinessError } 9300002 - Target ability already enabled.
154   * @syscap SystemCapability.BarrierFree.Accessibility.Core
155   * @systemapi
156   * @since 9
157   */
158  function enableAbility(name: string, capability: Array<accessibility.Capability>): Promise<void>;
159
160  /**
161   * Enable the accessibility extension ability.
162   *
163   * @param { string } name Indicates the accessibility extension name, in "bundleName/abilityName" format.
164   * @param { Array<accessibility.Capability> } capability Indicates the ability.
165   * @param { AsyncCallback<void> } callback
166   * @throws { BusinessError } 201 - Permission denied.
167   * @throws { BusinessError } 202 - Not system App.
168   * @throws { BusinessError } 401 - Input parameter error.
169   * @throws { BusinessError } 9300001 - Invalid bundle name or ability name.
170   * @throws { BusinessError } 9300002 - Target ability already enabled.
171   * @syscap SystemCapability.BarrierFree.Accessibility.Core
172   * @systemapi
173   * @since 9
174   */
175  function enableAbility(
176    name: string,
177    capability: Array<accessibility.Capability>,
178    callback: AsyncCallback<void>
179  ): void;
180
181  /**
182   * Disable the accessibility extension ability.
183   *
184   * @param { string } name Indicates the accessibility extension name, in "bundleName/abilityName" format.
185   * @returns { Promise<void> }
186   * @throws { BusinessError } 201 - Permission denied.
187   * @throws { BusinessError } 202 - Not system App.
188   * @throws { BusinessError } 401 - Input parameter error.
189   * @throws { BusinessError } 9300001 - Invalid bundle name or ability name.
190   * @syscap SystemCapability.BarrierFree.Accessibility.Core
191   * @systemapi
192   * @since 9
193   */
194  function disableAbility(name: string): Promise<void>;
195
196  /**
197   * Disable the accessibility extension ability.
198   *
199   * @param { string } name Indicates the accessibility extension name, in "bundleName/abilityName" format.
200   * @param { AsyncCallback<void> } callback
201   * @throws { BusinessError } 201 - Permission denied.
202   * @throws { BusinessError } 202 - Not system App.
203   * @throws { BusinessError } 401 - Input parameter error.
204   * @throws { BusinessError } 9300001 - Invalid bundle name or ability name.
205   * @syscap SystemCapability.BarrierFree.Accessibility.Core
206   * @systemapi
207   * @since 9
208   */
209  function disableAbility(name: string, callback: AsyncCallback<void>): void;
210
211  /**
212   * Register the listener that watches for changes in the enabled status of accessibility extensions.
213   *
214   * @param { 'enabledAccessibilityExtensionListChange' } type Indicates the type of event.
215   * @param { Callback<void> } callback Indicates the listener.
216   * @throws { BusinessError } 202 - Not system App.
217   * @throws { BusinessError } 401 - Input parameter error.
218   * @syscap SystemCapability.BarrierFree.Accessibility.Core
219   * @systemapi
220   * @since 9
221   */
222  function on(type: 'enabledAccessibilityExtensionListChange', callback: Callback<void>): void;
223
224  /**
225   * Unregister listener that watches for changes in the enabled status of accessibility extensions.
226   *
227   * @param { 'enabledAccessibilityExtensionListChange' } type Indicates the type of event.
228   * @param { Callback<void> } callback Indicates the listener.
229   * @throws { BusinessError } 202 - Not system App.
230   * @throws { BusinessError } 401 - Input parameter error.
231   * @syscap SystemCapability.BarrierFree.Accessibility.Core
232   * @systemapi
233   * @since 9
234   */
235  function off(type: 'enabledAccessibilityExtensionListChange', callback?: Callback<void>): void;
236
237  /**
238   * Indicates setting, getting, and listening to changes in configuration.
239   *
240   * @typedef Config
241   * @syscap SystemCapability.BarrierFree.Accessibility.Core
242   * @systemapi
243   * @since 9
244   */
245  interface Config<T> {
246    /**
247     * Setting configuration value.
248     *
249     * @param { T } value Indicates the value.
250     * @returns { Promise<void> }
251     * @throws { BusinessError } 201 - Permission denied.
252     * @throws { BusinessError } 202 - Not system App.
253     * @throws { BusinessError } 401 - Input parameter error.
254     * @syscap SystemCapability.BarrierFree.Accessibility.Core
255     * @systemapi
256     * @since 9
257     */
258    set(value: T): Promise<void>;
259
260    /**
261     * Setting configuration value.
262     *
263     * @param { T } value Indicates the value.
264     * @param { AsyncCallback<void> } callback
265     * @throws { BusinessError } 201 - Permission denied.
266     * @throws { BusinessError } 202 - Not system App.
267     * @throws { BusinessError } 401 - Input parameter error.
268     * @syscap SystemCapability.BarrierFree.Accessibility.Core
269     * @systemapi
270     * @since 9
271     */
272    set(value: T, callback: AsyncCallback<void>): void;
273
274    /**
275     * Getting configuration value.
276     *
277     * @returns { Promise<T> }
278     * @throws { BusinessError } 201 - Permission denied.
279     * @throws { BusinessError } 202 - Not system App.
280     * @syscap SystemCapability.BarrierFree.Accessibility.Core
281     * @systemapi
282     * @since 9
283     */
284    get(): Promise<T>;
285
286    /**
287     * Getting configuration value.
288     *
289     * @param { AsyncCallback<T> } callback
290     * @throws { BusinessError } 201 - Permission denied.
291     * @throws { BusinessError } 202 - Not system App.
292     * @syscap SystemCapability.BarrierFree.Accessibility.Core
293     * @systemapi
294     * @since 9
295     */
296    get(callback: AsyncCallback<T>): void;
297
298    /**
299     * Register the listener to listen for configuration changes.
300     *
301     * @param { Callback<T> } callback Indicates the listener.
302     * @throws { BusinessError } 201 - Permission denied.
303     * @throws { BusinessError } 202 - Not system App.
304     * @throws { BusinessError } 401 - Input parameter error.
305     * @syscap SystemCapability.BarrierFree.Accessibility.Core
306     * @systemapi
307     * @since 9
308     */
309    on(callback: Callback<T>): void;
310
311    /**
312     * Unregister the listener to listen for configuration changes.
313     *
314     * @param { Callback<T> } callback Indicates the listener.
315     * @throws { BusinessError } 202 - Not system App.
316     * @syscap SystemCapability.BarrierFree.Accessibility.Core
317     * @systemapi
318     * @since 9
319     */
320    off(callback?: Callback<T>): void;
321  }
322
323  /**
324   * Indicates the type of daltonization color filter.
325   *
326   * @syscap SystemCapability.BarrierFree.Accessibility.Core
327   * @systemapi
328   * @since 9
329   */
330  type DaltonizationColorFilter = 'Normal' | 'Protanomaly' | 'Deuteranomaly' | 'Tritanomaly';
331}
332export default config;
333