• 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 accessibility from './@ohos.accessibility';
17import { AsyncCallback, Callback } from './basic';
18
19/**
20 * Configuration of the accessibility.
21 *
22 * @since 9
23 * @syscap SystemCapability.BarrierFree.Accessibility.Core
24 * @systemapi
25 */
26declare namespace config {
27  /**
28   * Indicates the configuration of high-contrast text.
29   */
30  var highContrastText: Config<boolean>;
31  /**
32   * Indicates the configuration of invert color.
33   */
34  var invertColor: Config<boolean>;
35  /**
36   * Indicates the configuration of daltonization color filter.
37   */
38  var daltonizationColorFilter: Config<DaltonizationColorFilter>;
39  /**
40   * Indicates the configuration of content timeout.
41   */
42  var contentTimeout: Config<number>;
43  /**
44   * Indicates the configuration of animation state.
45   */
46  var animationOff: Config<boolean>;
47  /**
48   * Indicates the configuration of brightness discount.
49   */
50  var brightnessDiscount: Config<number>;
51  /**
52   * Indicates the configuration of mouse key state.
53   */
54  var mouseKey: Config<boolean>;
55  /**
56   * Indicates the configuration of mouse auto click.
57   */
58  var mouseAutoClick: Config<number>;
59  /**
60   * Indicates the configuration of short key state.
61   */
62  var shortkey: Config<boolean>;
63  /**
64   * Indicates the configuration of short key target.
65   */
66  var shortkeyTarget: Config<string>;
67  /**
68   * Indicates the configuration of captions state.
69   */
70  var captions: Config<boolean>;
71  /**
72   * Indicates the configuration of captions style.
73   */
74  var captionsStyle: Config<accessibility.CaptionsStyle>;
75
76  /**
77   * Enable the accessibility extension ability.
78   * @param name Indicates the accessibility extension name, in "bundleName/abilityName" format.
79   * @param capability Indicates the ability.
80   * @throws { BusinessError } 201 - Permission denied.
81   * @throws { BusinessError } 401 - Input parameter error.
82   * @throws { BusinessError } 9300001 - Invalid bundle name or ability name.
83   * @throws { BusinessError } 9300002 - Target ability already enabled.
84   */
85  function enableAbility(name: string, capability: Array<accessibility.Capability>): Promise<void>;
86  function enableAbility(name: string, capability: Array<accessibility.Capability>, callback: AsyncCallback<void>): void;
87
88  /**
89   * Disable the accessibility extension ability.
90   * @param name Indicates the accessibility extension name, in "bundleName/abilityName" format.
91   * @throws { BusinessError } 201 - Permission denied.
92   * @throws { BusinessError } 401 - Input parameter error.
93   * @throws { BusinessError } 9300001 - Invalid bundle name or ability name.
94   */
95  function disableAbility(name: string): Promise<void>;
96  function disableAbility(name: string, callback: AsyncCallback<void>): void;
97
98  /**
99   * Register the listener that watches for changes in the enabled status of accessibility extensions.
100   * @param type Indicates the type of event.
101   * @param callback Indicates the listener.
102   * @throws { BusinessError } 401 - Input parameter error.
103   */
104  function on(type: 'enabledAccessibilityExtensionListChange', callback: Callback<void>): void;
105
106  /**
107   * Unregister listener that watches for changes in the enabled status of accessibility extensions.
108   * @param type Indicates the type of event.
109   * @param callback Indicates the listener.
110   * @throws { BusinessError } 401 - Input parameter error.
111   */
112  function off(type: 'enabledAccessibilityExtensionListChange', callback?: Callback<void>): void;
113
114  /**
115   * Indicates setting, getting, and listening to changes in configuration.
116   */
117  interface Config<T> {
118    /**
119     * Setting configuration value.
120     * @param value Indicates the value.
121     * @throws { BusinessError } 201 - Permission denied.
122     * @throws { BusinessError } 401 - Input parameter error.
123     */
124    set(value: T): Promise<void>;
125    set(value: T, callback: AsyncCallback<void>): void;
126
127    /**
128     * Getting configuration value.
129     */
130    get(): Promise<T>;
131    get(callback: AsyncCallback<T>): void;
132
133    /**
134     * Register the listener to listen for configuration changes.
135     * @param callback Indicates the listener.
136     * @throws { BusinessError } 401 - Input parameter error.
137     */
138    on(callback: Callback<T>): void;
139
140    /**
141     * Unregister the listener to listen for configuration changes.
142     * @param callback Indicates the listener.
143     */
144    off(callback?: Callback<T>): void;
145  }
146
147  /**
148   * Indicates the type of daltonization color filter.
149   */
150  type DaltonizationColorFilter = 'Normal' | 'Protanomaly' | 'Deuteranomaly' | 'Tritanomaly';
151}
152export default config;