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 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 denied. 199 * @throws { BusinessError } 202 - Not system App. 200 * @throws { BusinessError } 401 - Input parameter error. 201 * @throws { BusinessError } 9300001 - Invalid bundle name or ability name. 202 * @throws { BusinessError } 9300002 - Target ability already enabled. 203 * @syscap SystemCapability.BarrierFree.Accessibility.Core 204 * @systemapi 205 * @since 9 206 */ 207 function enableAbility(name: string, capability: Array<accessibility.Capability>): Promise<void>; 208 209 /** 210 * Enable the accessibility extension ability. 211 * 212 * @param { string } name Indicates the accessibility extension name, in "bundleName/abilityName" format. 213 * @param { Array<accessibility.Capability> } capability Indicates the ability. 214 * @param { AsyncCallback<void> } callback 215 * @throws { BusinessError } 201 - Permission denied. 216 * @throws { BusinessError } 202 - Not system App. 217 * @throws { BusinessError } 401 - Input parameter error. 218 * @throws { BusinessError } 9300001 - Invalid bundle name or ability name. 219 * @throws { BusinessError } 9300002 - Target ability already enabled. 220 * @syscap SystemCapability.BarrierFree.Accessibility.Core 221 * @systemapi 222 * @since 9 223 */ 224 function enableAbility( 225 name: string, 226 capability: Array<accessibility.Capability>, 227 callback: AsyncCallback<void> 228 ): void; 229 230 /** 231 * Disable the accessibility extension ability. 232 * 233 * @param { string } name Indicates the accessibility extension name, in "bundleName/abilityName" format. 234 * @returns { Promise<void> } 235 * @throws { BusinessError } 201 - Permission denied. 236 * @throws { BusinessError } 202 - Not system App. 237 * @throws { BusinessError } 401 - Input parameter error. 238 * @throws { BusinessError } 9300001 - Invalid bundle name or ability name. 239 * @syscap SystemCapability.BarrierFree.Accessibility.Core 240 * @systemapi 241 * @since 9 242 */ 243 function disableAbility(name: string): Promise<void>; 244 245 /** 246 * Disable the accessibility extension ability. 247 * 248 * @param { string } name Indicates the accessibility extension name, in "bundleName/abilityName" format. 249 * @param { AsyncCallback<void> } callback 250 * @throws { BusinessError } 201 - Permission denied. 251 * @throws { BusinessError } 202 - Not system App. 252 * @throws { BusinessError } 401 - Input parameter error. 253 * @throws { BusinessError } 9300001 - Invalid bundle name or ability name. 254 * @syscap SystemCapability.BarrierFree.Accessibility.Core 255 * @systemapi 256 * @since 9 257 */ 258 function disableAbility(name: string, callback: AsyncCallback<void>): void; 259 260 /** 261 * Register the listener that watches for changes in the enabled status of accessibility extensions. 262 * 263 * @param { 'enabledAccessibilityExtensionListChange' } type Indicates the type of event. 264 * @param { Callback<void> } callback Indicates the listener. 265 * @throws { BusinessError } 202 - Not system App. 266 * @throws { BusinessError } 401 - Input parameter error. 267 * @syscap SystemCapability.BarrierFree.Accessibility.Core 268 * @systemapi 269 * @since 9 270 */ 271 function on(type: 'enabledAccessibilityExtensionListChange', callback: Callback<void>): void; 272 273 /** 274 * Deregister listener that watches for changes in the enabled status of accessibility extensions. 275 * 276 * @param { 'enabledAccessibilityExtensionListChange' } type Indicates the type of event. 277 * @param { Callback<void> } callback Indicates the listener. 278 * @throws { BusinessError } 202 - Not system App. 279 * @throws { BusinessError } 401 - Input parameter error. 280 * @syscap SystemCapability.BarrierFree.Accessibility.Core 281 * @systemapi 282 * @since 9 283 */ 284 function off(type: 'enabledAccessibilityExtensionListChange', callback?: Callback<void>): void; 285 286 /** 287 * Indicates setting, getting, and listening to changes in configuration. 288 * 289 * @typedef Config 290 * @syscap SystemCapability.BarrierFree.Accessibility.Core 291 * @systemapi 292 * @since 9 293 */ 294 interface Config<T> { 295 /** 296 * Setting configuration value. 297 * 298 * @param { T } value Indicates the value. 299 * @returns { Promise<void> } 300 * @throws { BusinessError } 201 - Permission denied. 301 * @throws { BusinessError } 202 - Not system App. 302 * @throws { BusinessError } 401 - Input parameter error. 303 * @syscap SystemCapability.BarrierFree.Accessibility.Core 304 * @systemapi 305 * @since 9 306 */ 307 set(value: T): Promise<void>; 308 309 /** 310 * Setting configuration value. 311 * 312 * @param { T } value Indicates the value. 313 * @param { AsyncCallback<void> } callback 314 * @throws { BusinessError } 201 - Permission denied. 315 * @throws { BusinessError } 202 - Not system App. 316 * @throws { BusinessError } 401 - Input parameter error. 317 * @syscap SystemCapability.BarrierFree.Accessibility.Core 318 * @systemapi 319 * @since 9 320 */ 321 set(value: T, callback: AsyncCallback<void>): void; 322 323 /** 324 * Getting configuration value. 325 * 326 * @returns { Promise<T> } 327 * @throws { BusinessError } 201 - Permission denied. 328 * @throws { BusinessError } 202 - Not system App. 329 * @syscap SystemCapability.BarrierFree.Accessibility.Core 330 * @systemapi 331 * @since 9 332 */ 333 get(): Promise<T>; 334 335 /** 336 * Getting configuration value. 337 * 338 * @param { AsyncCallback<T> } callback 339 * @throws { BusinessError } 201 - Permission denied. 340 * @throws { BusinessError } 202 - Not system App. 341 * @syscap SystemCapability.BarrierFree.Accessibility.Core 342 * @systemapi 343 * @since 9 344 */ 345 get(callback: AsyncCallback<T>): void; 346 347 /** 348 * Register the listener to listen for configuration changes. 349 * 350 * @param { Callback<T> } callback Indicates the listener. 351 * @throws { BusinessError } 201 - Permission denied. 352 * @throws { BusinessError } 202 - Not system App. 353 * @throws { BusinessError } 401 - Input parameter error. 354 * @syscap SystemCapability.BarrierFree.Accessibility.Core 355 * @systemapi 356 * @since 9 357 */ 358 on(callback: Callback<T>): void; 359 360 /** 361 * Deregister the listener to listen for configuration changes. 362 * 363 * @param { Callback<T> } callback Indicates the listener. 364 * @throws { BusinessError } 202 - Not system App. 365 * @syscap SystemCapability.BarrierFree.Accessibility.Core 366 * @systemapi 367 * @since 9 368 */ 369 off(callback?: Callback<T>): void; 370 } 371 372 /** 373 * Indicates the type of daltonization color filter. 374 * 375 * @systemapi 376 */ 377 type DaltonizationColorFilter = 'Normal' | 'Protanomaly' | 'Deuteranomaly' | 'Tritanomaly'; 378 379 /** 380 * Indicates the type of click response time. 381 * 382 * @systemapi 383 */ 384 type ClickResponseTime = 'Short' | 'Medium' | 'Long'; 385 386 /** 387 * Indicates the type of ignore repeat click interval. 388 * 389 * @systemapi 390 */ 391 type RepeatClickInterval = 'Shortest' | 'Short' | 'Medium' | 'Long' | 'Longest'; 392} 393export default config; 394