commit | 4815aad91cc0a946f73176b2af0450d9d328490a | [log] [tgz] |
---|---|---|
author | Android Build Coastguard Worker <[email protected]> | Sat Jun 08 01:04:57 2024 +0000 |
committer | Android Build Coastguard Worker <[email protected]> | Sat Jun 08 01:04:57 2024 +0000 |
tree | e265d12670cfea811cd1eaaa77c50f56222daf62 | |
parent | 29e67733e7dfcdbaff85974ae3ae15fb121d1edd [diff] | |
parent | 7d21876cc56b701c121f7444701deb3e5dbc709d [diff] |
Snap for 11944020 from 7d21876cc56b701c121f7444701deb3e5dbc709d to 24Q3-release Change-Id: Idbc91b683751f83f4397c2b2033ea7ab480ccc44
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()); }