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