Code Health: Accessibility Cleanup
Identify and fix accessibility bugs in Android Java files where developers are
inadvertently violating the expected contract of the Android accessibility API.
Overview
The Android Accessibility API has many subtle rules that have changed over time.
Developers often write custom accessibility code based on the end user result
when testing with TalkBack, but don't actually honor the API contract which
would make the feature work with TalkBack and any other running assistive
technology. The goal of this work is to identify these common issues and anti-
patterns and proactively fix them in the code.
Goal: Identify common violations of the Android accessibility API and fix
them in Clank Java files.
Workflow
[!IMPORTANT] Execution Protocol: Execute all steps continuously in one
autonomous run, without skipping steps or pausing between files or steps. Stop
only at explicit
ask_questiongates or documented interactive stops. Use
rg(ripgrep) for searches.
Step 1: Workspace Preparation
Run the workspace preparation script:
python3 agents/projects/code-health/hub/scripts/prepare_workspace.py --stash
- If the script outputs
(stashed local changes), inform the user. - If the script exits non-zero, stop and report the error instead of continuing
on a dirty or diverged tree.
Step 2: Discovery & Batch Selection
Follow the
workflow.
Step 3: Refactoring & Implementation
Process the candidates by handling them one file at a time, and applying
modifications inside each file one instance at a time (rather than
refactoring all files or instances at once). This ensures stability and allows
for precise verification. Process all files and instances sequentially within
the same run, without pausing for user confirmation between edits, then proceed
directly to Step 4.
- Apply Changes: Make the changes directly.
- Read the candidate Java file to understand the class structure.
- Refactor the code according to the patterns in
patterns.md, or using known best practices.
- Check if any associated string resources (e.g.
R.string.accessibility_expanded_group) are now unused. If they are,
remove them from the corresponding .grd / .grsp resource files.
Step 4: Formatting & Automated Review
- Format & Lint: Run
python3 agents/projects/code-health/hub/scripts/format_and_lint.py (must
exit 0).
- Automated Review: Follow
Automated Review, passing
<SKILL_SPECIFIC_CLEANUP_RULES>.
Step 5: Verification
Follow the Verification workflow.
Step 6: Bug Tracking
- Bug Discovery & Creation: Execute the bug tracking workflow in
bug_discovery.md using the <SourceFileName>
and <SourceFilePath> from the candidate.
- Interactive Pause: Use
ask_questionto confirm whether to file a bug
or set <Bug ID> to "none" to skip. Do NOT proceed to Step 7 until
<Bug ID> is resolved.
Step 7: Submission
1. Prepare Commit Message
Ensure the full [Accessibility Cleanup] <Title> subject is at most 72
characters (omit .java or shorten the title, e.g.
Fix accessibility in <Component>, if needed), and generate ../commit. Do not
add [LSC] (this skill is not part of the LSC).
python3 agents/projects/code-health/hub/scripts/prepare_commit_message.py \
--skill accessibility-cleanup \
--title "Improve accessibility semantics in <Component>" \
--bug "<Bug ID>" \
--description - \
--out-commit ../commit <<'EOF'
<Concise description explaining what changed, why, and how.>
EOF
2. Validate Commit File
python3 agents/projects/code-health/hub/scripts/prepare_commit_message.py \
--skill accessibility-cleanup \
--validate ../commit \
--bug "<Bug ID>"
If validation fails, fix the commit title or description and re-run Steps 1–2
until validation exits 0.
3. Submit CL
Invoke the Submission workflow, passing:
- Branch Name:
cleanup-a11y-<ComponentName>(whereComponentNameis the
class name of the candidate file)
- Commit File:
../commit