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..14fff65e81854d5ac7ec1d5a4f8b7e37e89c9eb7 --- /dev/null +++ b/api/@ohos.application.AccessibilityExtensionAbility.d.ts @@ -0,0 +1,125 @@ +/* + * 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' + +/** + * class of accessibility extension ability. + * + * @since 9 + * @syscap SystemCapability.BarrierFree.Accessibility.Core + */ +export default class AccessibilityExtensionAbility { + /** + * Indicates accessibility extension ability context. + */ + context: AccessibilityExtensionContext; + + /** + * Called when extension ability is connected. + */ + onConnect(): void; + + /** + * Called when extension ability is disconnected. + */ + onDisconnect(): void; + + /** + * Called when an accessibility event occurs, such as when the user touches the application interface. + * @param event Indicates an accessibility event. + */ + onAccessibilityEvent(event: AccessibilityEvent): void; + + /** + * Called when a physical key is pressed, such as when the user presses the volume button . + * @param keyEvent Indicates the physical key event. + */ + onKeyEvent(keyEvent: inputEventClient.KeyEvent): boolean; +} + +/** + * Indicates the accessibility event. + * + * It provides the event type and the target element of the event if any. + * @since 9 + * @syscap SystemCapability.BarrierFree.Accessibility.Core + */ +declare interface AccessibilityEvent { + eventType: accessibility.EventType | accessibility.WindowUpdateType | + TouchGuideType | GestureType | PageUpdateType; + target?: AccessibilityElement; + timeStamp?: number; +} + +/** + * Indicates the path of the gesture. + * @since 9 + * @syscap SystemCapability.BarrierFree.Accessibility.Core + */ + declare class GesturePath { + constructor(durationTime: number) + /** + * Indicates the position of the points that make up the gesture. + */ + points: Array; + /** + * Indicates the duration of the gesture. + */ + durationTime: number; +} + +/** + * Indicates the point of the gesture. + * @since 9 + * @syscap SystemCapability.BarrierFree.Accessibility.Core + */ +declare class GesturePoint { + constructor(positionX: number, positionY: number) + /** + * Indicates the X coordinate of point. + */ + positionX: number; + /** + * Indicates the Y coordinate of point. + */ + positionY: number; +} + +/** + * Indicates the gusture type. + * @since 9 + * @syscap SystemCapability.BarrierFree.Accessibility.Core + */ +type GestureType = 'left' | 'leftThenRight' | 'leftThenUp' | 'leftThenDown' | + 'right' | 'rightThenLeft' | 'rightThenUp' | 'rightThenDown' | + 'up' | 'upThenLeft' | 'upThenRight' | 'upThenDown' | + 'down' | 'downThenLeft' | 'downThenRight' | 'downThenUp'; + +/** + * Indicates the page update type. + * @since 9 + * @syscap SystemCapability.BarrierFree.Accessibility.Core + */ +type PageUpdateType = 'pageContentUpdate' | 'pageStateUpdate'; + +/** + * Indicates the type of touch event during touch browsing. + * @since 9 + * @syscap SystemCapability.BarrierFree.Accessibility.Core + */ +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..c4bce8b967108bba922a72516050a1c9851df73e --- /dev/null +++ b/api/application/AccessibilityExtensionContext.d.ts @@ -0,0 +1,333 @@ +/* + * 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"; + +/** + * The accessibility extension context. Used to configure, query information, and inject gestures. + * + * @since 9 + * @syscap SystemCapability.BarrierFree.Accessibility.Core + */ +export default class AccessibilityExtensionContext extends ExtensionContext { + /** + * Set the accessibility event type which is wanted. + * @param type Indicates the type of event. + */ + setEventTypeFilter(type: Array): Promise; + setEventTypeFilter(type: Array, callback: AsyncCallback): boolean; + + /** + * Set the name of the bundle name that is interested in sending the event. + * @param targetNames + */ + setTargetBundleName(targetNames: Array): Promise; + setTargetBundleName(targetNames: Array, callback: AsyncCallback): boolean; + + /** + * Get focus element. + * @param isAccessibilityFocus Indicates whether the acquired element has an accessibility focus. + */ + getFocusElement(isAccessibilityFocus?: boolean): Promise; + getFocusElement(callback: AsyncCallback): void; + getFocusElement(isAccessibilityFocus: boolean, callback: AsyncCallback): void; + + /** + * Get window root element. + * @param windowId Indicates the window ID. + */ + getWindowRootElement(windowId?: number): Promise; + getWindowRootElement(callback: AsyncCallback): void; + getWindowRootElement(windowId: number, callback: AsyncCallback): void; + + /** + * Get window list. + * @param displayId Indicates the display ID. + */ + getWindows(displayId?: number): Promise>; + getWindows(callback: AsyncCallback>): void; + getWindows(displayId: number, callback: AsyncCallback>): void; + + /** + * Inject gesture path events. + * @param gesturePath Indicates the gesture path. + * @param listener It is used to receive the result of gesture injection, + * true means success, otherwise means failure. + */ + gestureInject(gesturePath: GesturePath, listener: Callback): Promise; + gestureInject(gesturePath: GesturePath, listener: Callback, callback: AsyncCallback): void; +} + +/** + * Indicates an accessibility element. + * + * Supports querying element attributes, requesting execution actions, and finding child elements by condition. + * @since 9 + * @syscap SystemCapability.BarrierFree.Accessibility.Core + */ +declare interface AccessibilityElement { + /** + * Get a list of attribute names. + */ + attributeNames(): Promise>; + attributeNames(callback: AsyncCallback>): void; + + /** + * Get the value of an attribute. + * @param attributeName Indicates the attribute name. + */ + attributeValue(attributeName: T): Promise; + attributeValue(attributeName: T, + callback: AsyncCallback): void; + + /** + * Get a list of supported actions. + */ + actionNames(): Promise>; + actionNames(callback: AsyncCallback>): void; + + /** + * Perform the specified action. + * @param actionName Indicates the action name. + * @param parameters Indicates the parameters needed to execute the action. + */ + performAction(actionName: string, parameters?: object): Promise; + performAction(actionName: string, callback: AsyncCallback): void; + performAction(actionName: string, parameters: object, callback: AsyncCallback): void; + + /** + * Find elements that match the condition. + * @param type The type of query condition is content. + * @param condition Indicates the specific content to be queried. + */ + findElement(type: 'content', condition: string): Promise>; + findElement(type: 'content', condition: string, callback: AsyncCallback>): void + + /** + * Find elements that match the condition. + * @param type The type of query condition is focus type. + * @param condition Indicates the type of focus to query. + */ + findElement(type: 'focusType', condition: FocusType): Promise; + findElement(type: 'focusType', condition: FocusType, callback: AsyncCallback): void + + /** + * Find elements that match the condition. + * @param type The type of query condition is focus direction. + * @param condition Indicates the direction of search focus to query. + */ + findElement(type: 'focusDirection', condition: FocusDirection): Promise; + findElement(type: 'focusDirection', condition: FocusDirection, callback: AsyncCallback): void +} + +/** + * Indicates the possible attributes of the element and the type of the attribute value. + * @since 9 + * @syscap SystemCapability.BarrierFree.Accessibility.Core + */ +type ElementAttributeValues = { + /** + * Indicates the bundle name to which it belongs. + */ + 'bundleName': string; + /** + * Indicates whether the element is checkable. + */ + 'checkable': boolean; + /** + * Indicates whether the element is checked. + */ + 'checked': boolean; + /** + * Indicates all child elements. + */ + 'children': Array; + /** + * Indicates whether the element is clickable. + */ + 'clickable': boolean; + /** + * Indicates the component ID to which the element belongs. + */ + 'componentId': number; + /** + * Indicates the component type to which the element belongs. + */ + 'componentType': string; + /** + * Indicates the content. + */ + 'contents': Array; + /** + * Indicates the index of the current item. + */ + 'currentIndex': number; + /** + * Indicates the description of the element. + */ + 'description': string; + /** + * Indicates whether the element is editable. + */ + 'editable': boolean; + /** + * Indicates the list index of the last item displayed on the screen. + */ + 'endIndex': number; + /** + * Indicates whether the element is focusable. + */ + 'focusable': boolean; + /** + * Indicates the hint text. + */ + 'hintText': string; + /** + * Indicates the type of input text. + */ + 'inputType': number; + /** + * Indicates the inspector key. + */ + 'inspectorKey': string + /** + * Indicates whether the element is active or not. + */ + 'isActive': boolean; + /** + * Indicates whether the element is enable or not. + */ + 'isEnable': boolean; + /** + * Indicates whether the element is focused or not. + */ + 'isFocused': boolean; + /** + * Indicates whether the element is password or not. + */ + 'isPassword': boolean; + /** + * Indicates whether the element is visible or not. + */ + 'isVisible': boolean; + /** + * Indicates the total count of the items. + */ + 'itemCount': number; + /** + * Indicates the last content. + */ + 'lastContent': string; + /** + * Indicates the display layer of the element. + */ + 'layer': number; + /** + * Indicates whether the element is long clickable. + */ + 'longClickable': boolean; + /** + * Indicates the parent of the element. + */ + 'parent': AccessibilityElement; + /** + * Indicates whether the element supports multiple lines of text. + */ + 'pluralLineSupported': boolean; + /** + * Indicates the area of the element. + */ + 'rect': Rect; + /** + * Indicates the resource name of the element. + */ + 'resourceName': string; + /** + * Indicates the root element of the window element. + */ + 'rootElement': AccessibilityElement; + /** + * Indicates the display area of the element. + */ + 'screenRect': Rect; + /** + * Indicates whether the element is scrollable. + */ + 'scrollable': boolean; + /** + * Indicates whether the element is selected. + */ + 'selected': boolean; + /** + * Indicates the list index of the first item displayed on the screen. + */ + 'startIndex': number; + /** + * Indicates the text of the element. + */ + 'text': string; + /** + * Indicates the maximum length limit of the element text. + */ + 'textLengthLimit': number; + /** + * Indicates the unit of movement of the element text as it is read. + */ + 'textMoveUnit': accessibility.TextMoveUnit; + /** + * Indicates the action that triggered the element event. + */ + 'triggerAction': accessibility.Action; + /** + * Indicates the window type of the element. + */ + 'type': WindowType; +} + +/** +* Indicates the direction of the search focus. + * @since 9 + * @syscap SystemCapability.BarrierFree.Accessibility.Core + */ +type FocusDirection = 'up' | 'down' | 'left' | 'right' | 'forward' | 'backward'; + +/** + * Indicates the type of the focus. + * @since 9 + * @syscap SystemCapability.BarrierFree.Accessibility.Core + */ +type FocusType = 'accessibility' | 'normal'; + +/** + * Indicates the type of the window. + * @since 9 + * @syscap SystemCapability.BarrierFree.Accessibility.Core + */ +type WindowType = 'application' | 'system'; + +/** + * Indicates rectangle. + * @since 9 + * @syscap SystemCapability.BarrierFree.Accessibility.Core + */ +interface Rect { + left: number; + top: number; + width: number; + height: number; +} \ No newline at end of file