commit | a0ebd6544ffa7dbbc65b014c5480a3bba37290ce | [log] [tgz] |
---|---|---|
author | Xin Li <delphij@google.com> | Fri Dec 13 18:20:07 2024 -0800 |
committer | Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com> | Fri Dec 13 18:20:07 2024 -0800 |
tree | 1c88b39ad9b2862ae31b14cfb891714d99a31999 | |
parent | e7b301d9a5f625506c8773ed14c6ad2e98c5ecdb [diff] | |
parent | 8f3789514e7854704ed2de7ec9915173c377babb [diff] |
[automerger skipped] Merge 24Q4 into AOSP main am: 8f3789514e -s ours am skip reason: Merged-In If9ceeb777d10e0409837c0bc78ea652f2335e242 with SHA-1 4c730accbe is already in history Original change: https://android-review.googlesource.com/c/platform/external/accessibility-test-framework/+/3413782 Change-Id: Ia17040d01fa1d04bf63a741264f7eccbd1e58f8f Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
To help people with disabilities access Android apps, developers of those apps need to consider how their apps will be presented to accessibility services. Some good practices can be checked by automated tools, such as if a View has a contentDescription. Other rules require human judgment, such as whether or not a contentDescription makes sense to all users.
For more information about Mobile Accessibility, see http://www.w3.org/WAI/mobile/.
This library collects various accessibility-related checks on View objects as well as AccessibilityNodeInfo objects (which the Android framework derives from Views and sends to AccessibilityServices).
The supplied gradle wrapper and build.gradle file can be used to build the Accessibility Test Framework or import the project into Android Studio.
$ ./gradlew build
Given a view, the following code runs all accessibility checks on all views in the hierarchy rooted at that view and throws an exception if any errors are found:
ImmutableSet<AccessibilityHierarchyCheck> checks = AccessibilityCheckPreset.getAccessibilityHierarchyChecksForPreset( AccessibilityCheckPreset.LATEST); AccessibilityHierarchyAndroid hierarchy = AccessibilityHierarchyAndroid.newBuilder(view).build(); List<AccessibilityHierarchyCheckResult> results = new ArrayList<>(); for (AccessibilityHierarchyCheck check : checks) { results.addAll(check.runCheckOnHierarchy(hierarchy)); } List<AccessibilityHierarchyCheckResult> errors = AccessibilityCheckResultUtils.getResultsForType( results, AccessibilityCheckResultType.ERROR); if (!errors.isEmpty()) { throw new RuntimeException(errors.get(0).getMessage().toString()); }