ILifecycle, Contextpublic abstract class AccessibleAbility extends Ability
The accessibility application helps users use their devices and programs easily. AccessibilityEventInfo
will be called to send events when the UI status has any changes, for example, a button is clicked or focus is
gained. You can inherit this class to handle your interested events.
SystemCapability.Accessibility#ABILITYAbility.LayoutParamsHelper, Ability.WindowAttributeHelper| 限定符和类型 | 字段 | 说明 |
|---|---|---|
static int |
GLOBAL_ACTION_BACK |
Indicates a global action of returning to the previous page.
|
static int |
GLOBAL_ACTION_HOME |
Indicates a global action of returning to the home page.
|
static int |
GLOBAL_ACTION_LOCK_SCREEN |
Indicates a global action of locking the screen.
|
static int |
GLOBAL_ACTION_NOTIFICATIONS |
Indicates a global action of opening the notification panel.
|
static int |
GLOBAL_ACTION_POWER_DIALOG |
Indicates a global action of pressing and holding the power button.
|
static int |
GLOBAL_ACTION_QUICK_SETTINGS |
Indicates a global action of opening quick settings.
|
static int |
GLOBAL_ACTION_RECENTS |
Indicates a global action of displaying a list of recent tasks.
|
static int |
GLOBAL_ACTION_TAKE_SCREENSHOT |
Indicates a global action of taking a screenshot.
|
static int |
GLOBAL_ACTION_TOGGLE_SPLIT_SCREEN |
Indicates a global action of switching between split screens.
|
static int |
SHOW_MODE_AUTO |
Indicates to show the soft keyboard.
|
static int |
SHOW_MODE_HIDE |
Indicates to hide the soft keyboard.
|
static int |
SHOW_MODE_IGNORE_HARD_KEYBOARD |
Indicates to show the soft keyboard when using an external keyboard.
|
FORM_INVISIBLE, FORM_VISIBLECONTEXT_IGNORE_SECURITY, CONTEXT_INCLUDE_CODE, CONTEXT_RESOUCE_ONLY, CONTEXT_RESTRICTED, MODE_APPEND, MODE_PRIVATE| 构造器 | 说明 |
|---|---|
AccessibleAbility() |
| 限定符和类型 | 方法 | 说明 |
|---|---|---|
void |
disableAbility() |
Disables the accessibility service.
|
Optional<AccessibilityInfo> |
gainFocus(int focusType) |
Obtains the accessibility node that gains the focus.
|
boolean |
gestureSimulate(List<GesturePathDefine> gesturePathDefineList,
GestureResultListener listener) |
Sends customized gestures to the screen.
|
DisplayResizeController |
getDisplayResizeController() |
Obtains the controller for display resizing operations.
|
DisplayResizeController |
getDisplayResizeController(int displayId) |
Obtains the controller for display resizing operations.
|
Optional<AccessibilityInfo> |
getRootAccessibilityInfo() |
Obtains information about the accessibility root node.
|
SoftKeyBoardController |
getSoftKeyBoardController() |
Obtains the controller for the soft keyboard.
|
List<AccessibilityWindow> |
getWindows() |
Obtains the list of interactive windows on the device, in the layers they are visible to users.
|
protected void |
onAbilityConnected() |
Called when your accessibility service is successfully connected to the OS.
|
abstract void |
onAccessibilityEvent(AccessibilityEventInfo eventInfo) |
Called when an accessibility event occurs.
|
IRemoteObject |
onConnect(Intent intent) |
Called back when a Service ability is first connected to an ability.
|
protected boolean |
onGesture(int gestureId) |
Called when a user performs a specified gesture on the device that your accessibility application has requested
to be in touch exploration mode.
|
abstract void |
onInterrupt() |
Called when the accessibility service is interrupted.
|
protected boolean |
onKeyPressEvent(KeyEvent keyEvent) |
Called when a key event occurs, for example, a user presses the key to increase or decrease the volume.
|
boolean |
performCommonAction(int action) |
Executes a specified action.
|
addActionRoute, batchInsert, call, cancelBackgroundRunning, connectAbility, continueAbility, continueAbility, continueAbilityReversibly, continueAbilityReversibly, createPipeFile, delete, denormalizeUri, disconnectAbility, dispatchAccessibilityEventInfo, executeBatch, executeOperation, findComponentById, getAbilityName, getAbilityPackage, getAdmissionTransitionConcurEnabled, getAdmissionTransitionObject, getAVController, getBackTransitionConcurEnabled, getBackTransitionObject, getContinuationRegisterManager, getContinuationState, getCurrentFocus, getFileTypes, getIntent, getLayoutParams, getLifecycle, getOriginalDeviceId, getQuitTransitionObject, getReadmissionTransitionObject, getSharedItemAdmissionTransitionObject, getSharedItemBackTransitionObject, getSharedItemQuitTransitionObject, getSharedItemReadmissionTransitionObject, getState, getType, getVolumeTypeAdjustedByKey, getWindow, hasWindowFocus, insert, isTemporary, isTerminating, keepBackgroundRunning, normalizeUri, onAbilityResult, onAcquireFormState, onActive, onBackground, onBackPressed, onCastTempForm, onCommand, onCommand, onConfigurationUpdated, onCreateForm, onCreateForm, onDeleteForm, onDeleteForm, onDisconnect, onEventDispatch, onEventNotify, onForeground, onHotkeyTriggered, onInactive, onInitialized, onKeyDown, onKeyPressAndHold, onKeyUp, onLeaveForeground, onMemoryLevel, onMissionDeleted, onNewDescription, onNewIntent, onOrientationChanged, onPostActive, onPostStart, onReconnect, onRequestPermissionsFromUserResult, onRestoreAbilityState, onSaveAbilityState, onSetCaller, onStart, onStop, onStoreDataWhenConfigChange, onTopActiveAbilityChanged, onTouchEvent, onTriggerFormEvent, onTriggerFormEvent, onUnloadForm, onUpdateForm, onUpdateForm, onWindowFocusChanged, openFile, openRawFile, parsePredictionArgsReference, parseValuesBucketReference, postTask, query, reload, reverseContinueAbility, setAbilitySliceAnimator, setAdmissionTransitionConcurEnabled, setAdmissionTransitionObject, setAVController, setBackTransitionConcurEnabled, setBackTransitionObject, setFormNextRefreshTime, setIntent, setIsAmbientMode, setLayoutParams, setMainRoute, setQuitTransitionObject, setReadmissionTransitionObject, setResult, setSharedItemAdmissionTransitionObject, setSharedItemBackTransitionObject, setSharedItemQuitTransitionObject, setSharedItemReadmissionTransitionObject, setSwipeToDismiss, setUIContent, setUIContent, setVolumeTypeAdjustedByKey, setWindowBackgroundColor, shutdown, startAbility, startAbility, startAbility, startAbility, startAbilityForResult, startAbilityForResult, startAssistAbility, stopAbility, stopAssistAbility, supportHighPerformanceUI, terminateAbility, update, updateForm, updateForm, updateForm, updateFormattachBaseContext, canRequestPermission, compelVerifyCallerPermission, compelVerifyCallerUriPermission, compelVerifyPermission, compelVerifyPermission, compelVerifyUriPermission, compelVerifyUriPermission, compelVerifyUriPermission, createBundleContext, createParallelTaskDispatcher, createSerialTaskDispatcher, deleteFile, displayUnlockMissionMessage, getAbilityInfo, getAbilityManager, getAbilityPackageContext, getApplicationContext, getApplicationInfo, getAppType, getBundleCodePath, getBundleManager, getBundleName, getBundleResourcePath, getCacheDir, getCaller, getCallingAbility, getCallingBundle, getClassloader, getCodeCacheDir, getColor, getColorMode, getContext, getDatabaseDir, getDataDir, getDir, getDisplayOrientation, getDistributedDir, getElementName, getExternalCacheDir, getExternalCacheDirs, getExternalFilesDir, getExternalFilesDirs, getExternalMediaDirs, getFilesDir, getGlobalTaskDispatcher, getHapModuleInfo, getIntArray, getLastStoredDataWhenConfigChanged, getLocalClassName, getMainTaskDispatcher, getNoBackupFilesDir, getPattern, getPreferencesDir, getProcessInfo, getProcessName, getResourceManager, getResourceManager, getString, getString, getStringArray, getTheme, getThemeId, getUITaskDispatcher, init, isCredentialEncryptedStorage, isDeviceEncryptedStorage, isUpdatingConfigurations, lockMission, printDrawnCompleted, requestPermissionsFromUser, restart, setColorMode, setDisplayOrientation, setPattern, setShowOnLockScreen, setTheme, setTransitionAnimation, setWakeUpScreen, startAbilities, startAbility, startAbility, startAbility, switchToCredentialEncryptedStorageContext, switchToDeviceEncryptedStorageContext, terminateAbility, terminateAbilityResult, unlockMission, verifyCallingOrSelfPermission, verifyCallingPermission, verifyPermission, verifySelfPermissionpublic static final int GLOBAL_ACTION_BACK
public static final int GLOBAL_ACTION_HOME
public static final int GLOBAL_ACTION_LOCK_SCREEN
public static final int GLOBAL_ACTION_NOTIFICATIONS
public static final int GLOBAL_ACTION_POWER_DIALOG
public static final int GLOBAL_ACTION_QUICK_SETTINGS
public static final int GLOBAL_ACTION_RECENTS
public static final int GLOBAL_ACTION_TAKE_SCREENSHOT
public static final int GLOBAL_ACTION_TOGGLE_SPLIT_SCREEN
public static final int SHOW_MODE_AUTO
public static final int SHOW_MODE_HIDE
public static final int SHOW_MODE_IGNORE_HARD_KEYBOARD
public abstract void onAccessibilityEvent(AccessibilityEventInfo eventInfo)
When receiving an accessibility event, for example, AccessibilityEventInfo#TYPE_VIEW_CLICKED_EVENT,
you can implement this method to handle the event.
eventInfo - Indicates the accessibility event information.public abstract void onInterrupt()
You can implement this method to handle the interruption.
public final void disableAbility()
After the accessibility service is disabled by this method, it becomes disabled on the UI settings accordingly.
protected boolean onKeyPressEvent(KeyEvent keyEvent)
Changing the keyEvent value does not affect other services that receive this event. The return value
determines whether this event has been consumed by the current control. You can implement this method to filter
key events.
keyEvent - Indicates the key event to send.true if the event has been consumed; returns false otherwise. The event that has
been consumed will not be sent to the application.public final SoftKeyBoardController getSoftKeyBoardController()
SoftKeyBoardController instance.public final DisplayResizeController getDisplayResizeController()
DisplayResizeController instance.public final DisplayResizeController getDisplayResizeController(int displayId)
displayId - Indicates the ID of the display.DisplayResizeController instance.protected void onAbilityConnected()
protected boolean onGesture(int gestureId)
gestureId - Indicates the gesture ID.true if the gesture has been handled; returns false otherwise.public final boolean gestureSimulate(List<GesturePathDefine> gesturePathDefineList, GestureResultListener listener)
gesturePathDefineList - Indicates the path of the customized gestures to send.listener - Indicates the listener used to observe the gesture sending result.true if the gestures are successfully sent; returns false otherwise.public List<AccessibilityWindow> getWindows()
You need to configure the permission to search for the window content in the configuration file.
Permissions: SystemPermission.CONNECT_ACCESSIBILITY_ABILITY.
public Optional<AccessibilityInfo> getRootAccessibilityInfo()
This method will search all windows for view information about the accessibility root node, so that you need to configure the permission to search for the window content in the configuration file.
Permissions: SystemPermission.CONNECT_ACCESSIBILITY_ABILITY.
public Optional<AccessibilityInfo> gainFocus(int focusType)
focusType - Indicates the focus type.AccessibilityInfo.FOCUS_TYPE_INPUT,
AccessibilityInfo.FOCUS_TYPE_ACCESSIBILITYpublic final boolean performCommonAction(int action)
This action can be executed without any user operations, for example, going to the previous step, going to the home page, and taking a screenshot.
action - Indicates the action type.true if the action is successfully executed; returns false otherwise.GLOBAL_ACTION_BACK,
GLOBAL_ACTION_HOME,
GLOBAL_ACTION_RECENTS,
GLOBAL_ACTION_NOTIFICATIONS,
GLOBAL_ACTION_QUICK_SETTINGS,
GLOBAL_ACTION_POWER_DIALOG,
GLOBAL_ACTION_TOGGLE_SPLIT_SCREEN,
GLOBAL_ACTION_LOCK_SCREEN,
GLOBAL_ACTION_TAKE_SCREENSHOTpublic final IRemoteObject onConnect(Intent intent)
AbilityThis method is called only on Service abilities. You can override the method to return the proxy of a Service ability.