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