diff --git a/api/@ohos.accessibility.d.ts b/api/@ohos.accessibility.d.ts index 40faa01613bfa210110ca4338d4fa38168c9a222..50f45c02511d3221390c5f66ef819796005be0cf 100644 --- a/api/@ohos.accessibility.d.ts +++ b/api/@ohos.accessibility.d.ts @@ -1,5 +1,5 @@ /* - * Copyright (C) 2021 Huawei Device Co., Ltd. + * Copyright (C) 2021-2022 Huawei Device Co., Ltd. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at @@ -125,6 +125,19 @@ declare namespace accessibility { function getAbilityLists(abilityType: AbilityType, stateType: AbilityState): Promise>; + /** + * Queries the list of accessibility abilities. + * @since 9 + * @param abilityType The all type of the accessibility ability. + * @param stateType The state of the accessibility ability. {@code AbilityState} eg.installed + * @syscap SystemCapability.BarrierFree.Accessibility.Core + * @return Returns the list of abilityInfos. + */ + function getAbilityLists(abilityType: 'all', stateType: AbilityState, + callback: AsyncCallback>): void; + function getAbilityLists(abilityType: 'all', + stateType: AbilityState): Promise>; + /** * Send accessibility Event. * @since 7 @@ -283,6 +296,11 @@ declare namespace accessibility { */ readonly bundleName: string; + /* The target bundle name for the observation. + * @since 9 + */ + readonly targetBundleNames: Array; + /** * The type of the ability. * @since 7 diff --git a/api/@ohos.application.AccessibilityExtensionAbility.d.ts b/api/@ohos.application.AccessibilityExtensionAbility.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..b0d55706a89835d69acb147db0da50d47750b06f --- /dev/null +++ b/api/@ohos.application.AccessibilityExtensionAbility.d.ts @@ -0,0 +1,54 @@ +/* + * Copyright (c) 2022 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"), + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import accessibility from './@ohos.accessibility' +import AccessibilityExtensionContext, { AccessibilityElement } from './application/AccessibilityExtensionContext' +import inputEventClient from './@ohos.multimodalInput.inputEventClient' + +export default class AccessibilityExtensionAbility { + context: AccessibilityExtensionContext; + onConnect(): void; + onDisconnect(): void; + onAccessibilityEvent(event: AccessibilityEvent): void; + onKeyEvent(keyEvent: inputEventClient.KeyEvent): boolean; +} + +declare interface AccessibilityEvent { + eventType: accessibility.EventType | accessibility.WindowUpdateType | + TouchGuideType | GestureType | PageUpdateType; + target?: AccessibilityElement; + timeStamp?: number; +} + +declare class GesturePath { + constructor(durationTime: number) + points: Array; + durationTime: number; +} + +declare class GesturePoint { + constructor(positionX: number, positionY: number) + positionX: number; + positionY: number; +} + +type GestureType = 'left' | 'leftThenRight' | 'leftThenUp' | 'leftThenDown' | + 'right' | 'rightThenLeft' | 'rightThenUp' | 'rightThenDown' | + 'up' | 'upThenLeft' | 'upThenRight' | 'upThenDown' | + 'down' | 'downThenLeft' | 'downThenRight' | 'downThenUp'; + +type PageUpdateType = 'pageContentUpdate' | 'pageStateUpdate'; + +type TouchGuideType = 'touchBegin' | 'touchEnd'; \ No newline at end of file diff --git a/api/application/AccessibilityExtensionContext.d.ts b/api/application/AccessibilityExtensionContext.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..82fc30757ec3b114f105c9ec18938a8747f5ce9c --- /dev/null +++ b/api/application/AccessibilityExtensionContext.d.ts @@ -0,0 +1,133 @@ +/* + * Copyright (c) 2021-2022 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"), + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { Callback, AsyncCallback } from "../basic"; +import ExtensionContext from "./ExtensionContext"; +import accessibility from "../@ohos.accessibility"; +import { GesturePath } from "../@ohos.application.AccessibilityExtensionAbility"; + +export default class AccessibilityExtensionContext extends ExtensionContext { + setEventTypeFilter(type: Array, callback: AsyncCallback): boolean; + setEventTypeFilter(type: Array): Promise; + + setTargetBundleName(targetNames: Array, callback: AsyncCallback): boolean; + setTargetBundleName(targetNames: Array): Promise; + + getFocusElement(callback: AsyncCallback): void; + getFocusElement(isAccessibilityFocus: boolean, callback: AsyncCallback): void; + getFocusElement(isAccessibilityFocus?: boolean): Promise; + + getWindowRootElement(callback: AsyncCallback): void; + getWindowRootElement(windowId: number, callback: AsyncCallback): void; + getWindowRootElement(windowId?: number): Promise; + + getWindows(callback: AsyncCallback>): void; + getWindows(displayId: number, callback: AsyncCallback>): void; + getWindows(displayId?: number): Promise>; + + gestureInject(gesturePath: GesturePath, listener: Callback, callback: AsyncCallback): void; + gestureInject(gesturePath: GesturePath, listener: Callback): Promise; +} + +declare interface AccessibilityElement { + attributeNames(): Promise>; + attributeNames(callback: AsyncCallback>): void; + + attributeValue(attributeName: T): Promise; + attributeValue(attributeName: T, + callback: AsyncCallback): void; + + actionNames(): Promise>; + actionNames(callback: AsyncCallback>): void; + + performAction(actionName: string, parameters?: object): Promise; + performAction(actionName: string, callback: AsyncCallback): void; + performAction(actionName: string, parameters: object, callback: AsyncCallback): void; + + findElement(type: 'content', condition: string): Promise>; + findElement(type: 'content', condition: string, callback: AsyncCallback>): void + + findElement(type: 'focusType', condition: FocusType): Promise; + findElement(type: 'focusType', condition: FocusType, callback: AsyncCallback): void + + findElement(type: 'focusDirection', condition: FocusDirection): Promise; + findElement(type: 'focusDirection', condition: FocusDirection, callback: AsyncCallback): void +} + +type ElementAttributeValues = { + /************************/ + /* element info */ + /************************/ + 'componentId': number; //The id of the view which the node in. + 'parentId': number; + 'inspectorKey': string + 'bundleName': string; //The bundle name. + 'componentType': string; //The type of the event source component,such as button, chart. + 'inputType': number; //The type of the input text. + 'text': string; //The text of the node. + 'hintText': string; //The hint text of the node. + 'description': string; // The description of the node. + 'triggerAction': accessibility.Action; + 'textMoveUnit': accessibility.TextMoveUnit; //The movement step used for reading texts. + 'contents': Array; + 'lastContent': string; + // list + 'itemCount': number; //The total of the items. + 'currentIndex': number; //The index of the current item on the screen. + 'startIndex': number; ///The start index of listed items on the screen. + 'endIndex': number; //The end index of listed items on the screen. + 'resourceName': string; //The resource name of the node. + 'textLengthLimit': number; //The max text length of the node. + 'rect': Rect; //The rect of the node. + 'checkable': boolean; //Whether the node can be check. + 'checked': boolean; // Whether the node is checked. + 'focusable': boolean; //Whether the node can be focused. + 'isVisible': boolean; //Whether the node is visible. + 'selected': boolean; //Whether the node is selected. + 'clickable': boolean; //Whether the node can be click. + 'longClickable': boolean; //Whether the node can be long click. + 'isEnable': boolean; // Whether the node can be enable. + 'isPassword': boolean; //Whether the node is password. + 'scrollable': boolean; // Whether the node can be scrollable. + 'editable': boolean; // Whether the node can be editable. + 'pluralLineSupported': boolean; //Whether the node is multiline. + 'parent': AccessibilityElement; + 'children': Array; + /************************/ + /* window info */ + /************************/ + 'isActive': boolean; + 'screenRect': Rect; + 'layer': number; + 'type': WindowType; + 'rootElement': AccessibilityElement; + /************************/ + /* common */ + /************************/ + 'isFocused': boolean; +} + +type FocusDirection = 'up' | 'down' | 'left' | 'right' | 'forward' | 'backward'; + +type FocusType = 'accessibility' | 'normal'; + +interface Rect { + left: number; + top: number; + width: number; + height: number; +} + +type WindowType = 'application' | 'system';