1/* 2 * Copyright (c) 2022-2023 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 { KeyEvent } from './@ohos.multimodalInput.keyEvent'; 23import type { 24 AccessibilityElement as _AccessibilityElement, 25 ElementAttributeValues as _ElementAttributeValues, 26 FocusDirection as _FocusDirection, 27 FocusType as _FocusType, 28 WindowType as _WindowType, 29 Rect as _Rect, 30 Parameter as _Parameter, 31} from './application/AccessibilityExtensionContext'; 32import type * as _AccessibilityExtensionContext from './application/AccessibilityExtensionContext'; 33import { AccessibilityEventType } from './@ohos.accessibility'; 34 35 36/** 37 * Indicates an accessibility element. 38 * Supports querying element attributes, requesting execution actions, and finding child elements by condition. 39 * 40 * @typedef {_AccessibilityElement} 41 * @syscap SystemCapability.BarrierFree.Accessibility.Core 42 * @since 10 43 */ 44export type AccessibilityElement = _AccessibilityElement; 45 46/** 47 * Indicates the possible attributes of the element and the type of the attribute value. 48 * 49 * @typedef {_ElementAttributeValues} 50 * @syscap SystemCapability.BarrierFree.Accessibility.Core 51 * @since 10 52 */ 53export type ElementAttributeValues = _ElementAttributeValues; 54 55/** 56 * Indicates the direction of the search focus. 57 * 58 * @typedef {_FocusDirection} 59 * @syscap SystemCapability.BarrierFree.Accessibility.Core 60 * @since 10 61 */ 62export type FocusDirection = _FocusDirection; 63 64/** 65 * Indicates the key of the attribute value. 66 * 67 * @typedef {keyof ElementAttributeValues} 68 * @syscap SystemCapability.BarrierFree.Accessibility.Core 69 * @since 10 70 */ 71export type ElementAttributeKeys = keyof ElementAttributeValues; 72 73/** 74 * Indicates the type of the focus. 75 * 76 * @typedef {_FocusType} 77 * @syscap SystemCapability.BarrierFree.Accessibility.Core 78 * @since 10 79 */ 80export type FocusType = _FocusType; 81 82/** 83 * Indicates the type of the window. 84 * 85 * @typedef {_WindowType} 86 * @syscap SystemCapability.BarrierFree.Accessibility.Core 87 * @since 10 88 */ 89export type WindowType = _WindowType; 90 91/** 92 * Indicates rectangle. 93 * 94 * @typedef {_Rect} 95 * @syscap SystemCapability.BarrierFree.Accessibility.Core 96 * @since 10 97 */ 98export type Rect = _Rect; 99 100/** 101 * Indicates executeAction parameter. 102 * 103 * @typedef {_Parameter} 104 * @syscap SystemCapability.BarrierFree.Accessibility.Core 105 * @since 20 106 */ 107export type Parameter = _Parameter; 108 109/** 110 * The accessibility extension context. Used to configure, query information, and inject gestures. 111 * 112 * @typedef {_AccessibilityExtensionContext.default} 113 * @syscap SystemCapability.BarrierFree.Accessibility.Core 114 * @since 10 115 */ 116 117export type AccessibilityExtensionContext = _AccessibilityExtensionContext.default; 118 119/** 120 * class of accessibility extension ability. 121 * 122 * @syscap SystemCapability.BarrierFree.Accessibility.Core 123 * @since 9 124 */ 125export default class AccessibilityExtensionAbility { 126 /** 127 * Indicates accessibility extension ability context. 128 * 129 * @type {AccessibilityExtensionContext} 130 * @syscap SystemCapability.BarrierFree.Accessibility.Core 131 * @since 9 132 */ 133 context: AccessibilityExtensionContext; 134 135 /** 136 * Called when extension ability is connected. 137 * 138 * @syscap SystemCapability.BarrierFree.Accessibility.Core 139 * @since 9 140 * @deprecated since 12 141 */ 142 onConnect(): void; 143 144 /** 145 * Called when extension ability is disconnected. 146 * 147 * @syscap SystemCapability.BarrierFree.Accessibility.Core 148 * @since 9 149 * @deprecated since 12 150 */ 151 onDisconnect(): void; 152 153 /** 154 * Called when an accessibility event occurs, such as when the user touches the application interface. 155 * 156 * @param { AccessibilityEvent } event Indicates an accessibility event. 157 * @syscap SystemCapability.BarrierFree.Accessibility.Core 158 * @since 9 159 * @deprecated since 12 160 */ 161 onAccessibilityEvent(event: AccessibilityEvent): void; 162 163 /** 164 * Called when a physical key is pressed, such as when the user presses the volume button . 165 * 166 * @param { KeyEvent } keyEvent Indicates the physical key event. 167 * @returns { boolean } 168 * @syscap SystemCapability.BarrierFree.Accessibility.Core 169 * @since 9 170 * @deprecated since 12 171 */ 172 onKeyEvent(keyEvent: KeyEvent): boolean; 173 174 /** 175 * Called when extension ability is connected. 176 * 177 * @permission ohos.permission.ACCESSIBILITY_EXTENSION_ABILITY 178 * @throws { BusinessError } 201 - Permission verification failed.The application does not have the permission required to call the API. 179 * @throws { BusinessError } 202 - Permission verification failed. A non-system application calls a system API. 180 * @syscap SystemCapability.BarrierFree.Accessibility.Core 181 * @systemapi 182 * @since 20 183 */ 184 onAccessibilityConnect(): void; 185 186 /** 187 * Called when extension ability is disconnected. 188 * 189 * @permission ohos.permission.ACCESSIBILITY_EXTENSION_ABILITY 190 * @throws { BusinessError } 201 - Permission verification failed.The application does not have the permission required to call the API. 191 * @throws { BusinessError } 202 - Permission verification failed. A non-system application calls a system API. 192 * @syscap SystemCapability.BarrierFree.Accessibility.Core 193 * @systemapi 194 * @since 20 195 */ 196 onAccessibilityDisconnect(): void; 197 198 /** 199 * Called when an accessibility event occurs, such as when the user touches the application interface. 200 * 201 * @permission ohos.permission.ACCESSIBILITY_EXTENSION_ABILITY 202 * @param { AccessibilityEventInfo } event Indicates an accessibility event. 203 * @throws { BusinessError } 201 - Permission verification failed.The application does not have the permission required to call the API. 204 * @throws { BusinessError } 202 - Permission verification failed. A non-system application calls a system API. 205 * @syscap SystemCapability.BarrierFree.Accessibility.Core 206 * @systemapi 207 * @since 20 208 */ 209 onAccessibilityEventInfo(event: AccessibilityEventInfo): void; 210 211 /** 212 * Called when a physical key is pressed, such as when the user presses the volume button . 213 * 214 * @permission ohos.permission.ACCESSIBILITY_EXTENSION_ABILITY 215 * @param { KeyEvent } keyEvent Indicates the physical key event. 216 * @returns { boolean } 217 * @throws { BusinessError } 201 - Permission verification failed.The application does not have the permission required to call the API. 218 * @throws { BusinessError } 202 - Permission verification failed. A non-system application calls a system API. 219 * @syscap SystemCapability.BarrierFree.Accessibility.Core 220 * @systemapi 221 * @since 20 222 */ 223 onAccessibilityKeyEvent(keyEvent: KeyEvent): boolean; 224} 225 226/** 227 * Indicates the accessibility event. 228 * It provides the event type and the target element of the event if any. 229 * 230 * @typedef AccessibilityEventInfo 231 * @syscap SystemCapability.BarrierFree.Accessibility.Core 232 * @systemapi 233 * @since 20 234 */ 235export declare interface AccessibilityEventInfo { 236 /** 237 * EventType 238 * 239 * @type { AccessibilityEventType } 240 * @syscap SystemCapability.BarrierFree.Accessibility.Core 241 * @systemapi 242 * @since 20 243 */ 244 eventType: AccessibilityEventType; 245 246 /** 247 * Target 248 * 249 * @type { ?AccessibilityElement } 250 * @syscap SystemCapability.BarrierFree.Accessibility.Core 251 * @systemapi 252 * @since 20 253 */ 254 target?: AccessibilityElement; 255 256 /** 257 * TimeStamp 258 * 259 * @type { ?number } 260 * @syscap SystemCapability.BarrierFree.Accessibility.Core 261 * @systemapi 262 * @since 20 263 */ 264 timestamp?: number; 265 266 /** 267 * The content of add/remove accessibility extraInfo text. 268 * 269 * @type { ?string } 270 * @syscap SystemCapability.BarrierFree.Accessibility.Core 271 * @systemapi 272 * @since 20 273 */ 274 extraInfo?: string; 275} 276 277/** 278 * Indicates the accessibility event. 279 * It provides the event type and the target element of the event if any. 280 * 281 * @typedef AccessibilityEvent 282 * @syscap SystemCapability.BarrierFree.Accessibility.Core 283 * @since 9 284 */ 285export declare interface AccessibilityEvent { 286 /** 287 * EventType 288 * 289 * @type { accessibility.EventType | accessibility.WindowUpdateType | TouchGuideType | GestureType | PageUpdateType } 290 * @syscap SystemCapability.BarrierFree.Accessibility.Core 291 * @since 9 292 */ 293 eventType: accessibility.EventType | accessibility.WindowUpdateType | TouchGuideType | GestureType | PageUpdateType; 294 295 /** 296 * Target 297 * 298 * @type { ?AccessibilityElement } 299 * @syscap SystemCapability.BarrierFree.Accessibility.Core 300 * @since 9 301 */ 302 target?: AccessibilityElement; 303 304 /** 305 * TimeStamp 306 * 307 * @type { ?number } 308 * @syscap SystemCapability.BarrierFree.Accessibility.Core 309 * @since 9 310 */ 311 timeStamp?: number; 312 313 /** 314 * ElementId 315 * 316 * @type { ?number } 317 * @syscap SystemCapability.BarrierFree.Accessibility.Core 318 * @since 12 319 */ 320 elementId?: number; 321 322 /** 323 * The content of announce accessibility text. 324 * 325 * @type { ?string } 326 * @syscap SystemCapability.BarrierFree.Accessibility.Core 327 * @since 12 328 */ 329 textAnnouncedForAccessibility?: string; 330 331 /** 332 * The content of add/remove accessibility extraInfo text. 333 * 334 * @type { ?string } 335 * @syscap SystemCapability.BarrierFree.Accessibility.Core 336 * @since 20 337 */ 338 extraInfo?: string; 339} 340 341/** 342 * Indicates the gesture type. 343 * value range: { 'left' | 'leftThenRight' | 'leftThenUp' | 'leftThenDown' | 344 * 'right' | 'rightThenLeft' | 'rightThenUp' | 'rightThenDown' | 345 * 'up' | 'upThenLeft' | 'upThenRight' | 'upThenDown' | 346 * 'down' | 'downThenLeft' | 'downThenRight' | 'downThenUp' } 347 * @syscap SystemCapability.BarrierFree.Accessibility.Core 348 * @since 9 349 */ 350/** 351 * Indicates the gesture type. 352 * value range: { 'left' | 'leftThenRight' | 'leftThenUp' | 'leftThenDown' | 353 * 'right' | 'rightThenLeft' | 'rightThenUp' | 'rightThenDown' | 354 * 'up' | 'upThenLeft' | 'upThenRight' | 'upThenDown' | 355 * 'down' | 'downThenLeft' | 'downThenRight' | 'downThenUp' | 356 * 'twoFingerSingleTap' | 'twoFingerDoubleTap' | 'twoFingerDoubleTapAndHold' | 'twoFingerTripleTap' | 357 * 'twoFingerTripleTapAndHold' | 'threeFingerSingleTap' | 'threeFingerDoubleTap' | 'threeFingerDoubleTapAndHold' | 358 * 'threeFingerTripleTap' | 'threeFingerTripleTapAndHold' | 'fourFingerSingleTap' | 'fourFingerDoubleTap' | 359 * 'fourFingerDoubleTapAndHold' | 'fourFingerTripleTap' | 'fourFingerTripleTapAndHold' | 360 * 'threeFingerSwipeUp' | 'threeFingerSwipeDown' | 'threeFingerSwipeLeft' | 'threeFingerSwipeRight' | 361 * 'fourFingerSwipeUp' | 'fourFingerSwipeDown' | 'fourFingerSwipeLeft' | 'fourFingerSwipeRight' } 362* @typedef {'left' | 'leftThenRight' | 'leftThenUp' | 'leftThenDown' | 'right' | 'rightThenLeft' | 'rightThenUp' | 'rightThenDown' | 'up' | 'upThenLeft' | 'upThenRight' | 'upThenDown' | 'down' | 'downThenLeft' | 'downThenRight' | 'downThenUp' | 'twoFingerSingleTap' | 'twoFingerDoubleTap' | 'twoFingerDoubleTapAndHold' | 'twoFingerTripleTap' | 'twoFingerTripleTapAndHold' | 'threeFingerSingleTap' | 'threeFingerDoubleTap' | 'threeFingerDoubleTapAndHold' | 'threeFingerTripleTap' | 'threeFingerTripleTapAndHold' | 'fourFingerSingleTap' | 'fourFingerDoubleTap' | 'fourFingerDoubleTapAndHold' | 'fourFingerTripleTap' | 'fourFingerTripleTapAndHold' | 'threeFingerSwipeUp' | 'threeFingerSwipeDown' | 'threeFingerSwipeLeft' | 'threeFingerSwipeRight' | 'fourFingerSwipeUp' | 'fourFingerSwipeDown' | 'fourFingerSwipeLeft' | 'fourFingerSwipeRight'} 363* @syscap SystemCapability.BarrierFree.Accessibility.Core 364* @since 11 365*/ 366type GestureType = 'left' | 'leftThenRight' | 'leftThenUp' | 'leftThenDown' | 367 'right' | 'rightThenLeft' | 'rightThenUp' | 'rightThenDown' | 368 'up' | 'upThenLeft' | 'upThenRight' | 'upThenDown' | 369 'down' | 'downThenLeft' | 'downThenRight' | 'downThenUp' | 370 'twoFingerSingleTap' | 'twoFingerDoubleTap' | 'twoFingerDoubleTapAndHold' | 'twoFingerTripleTap' | 371 'twoFingerTripleTapAndHold' | 'threeFingerSingleTap' | 'threeFingerDoubleTap' | 'threeFingerDoubleTapAndHold' | 372 'threeFingerTripleTap' | 'threeFingerTripleTapAndHold' | 'fourFingerSingleTap' | 'fourFingerDoubleTap' | 373 'fourFingerDoubleTapAndHold' | 'fourFingerTripleTap' | 'fourFingerTripleTapAndHold' | 374 'threeFingerSwipeUp' | 'threeFingerSwipeDown' | 'threeFingerSwipeLeft' | 'threeFingerSwipeRight' | 375 'fourFingerSwipeUp' | 'fourFingerSwipeDown' | 'fourFingerSwipeLeft' | 'fourFingerSwipeRight'; 376 377/** 378 * Indicates the page update type. 379 * 380 * @typedef {'pageContentUpdate' | 'pageStateUpdate'} 381 * @syscap SystemCapability.BarrierFree.Accessibility.Core 382 * @since 9 383 */ 384type PageUpdateType = 'pageContentUpdate' | 'pageStateUpdate'; 385 386/** 387 * Indicates the type of touch event during touch browsing. 388 * 389 * @typedef {'touchBegin' | 'touchEnd'} 390 * @syscap SystemCapability.BarrierFree.Accessibility.Core 391 * @since 9 392 */ 393type TouchGuideType = 'touchBegin' | 'touchEnd'; 394