feat: Add getEnabledAccessibilityServices to AccessibilityInfo (Android) - #57864
feat: Add getEnabledAccessibilityServices to AccessibilityInfo (Android)#57864ecryptoguru wants to merge 2 commits into
Conversation
Add a new `AccessibilityInfo.getEnabledAccessibilityServices()` method that returns the list of currently enabled accessibility service IDs on Android, using `AccessibilityManager.getEnabledAccessibilityServiceList()`. This addresses the need to query which accessibility services a user has enabled, allowing apps to tailor their UI accordingly (e.g., disabling video autoplay when a screen reader service is active). Changes: - Add `getEnabledAccessibilityServices(feedbackTypeFlags?)` to the JS AccessibilityInfo API (returns Promise<Array<string>>) - Implement native Android module method in AccessibilityInfoModule.kt - Add optional method to NativeAccessibilityInfo Flow spec - Update TypeScript definitions (.d.ts) and generated ReactNativeApi.d.ts - Update Jest mock and add comprehensive unit tests - Add typetest coverage Closes react#30862 Generated with [Devin](https://devin.ai) Co-Authored-By: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com>
|
Hi @ecryptoguru! Thank you for your pull request and welcome to our community. Action RequiredIn order to merge any pull request (code, docs, etc.), we require contributors to sign our Contributor License Agreement, and we don't seem to have one on file for you. ProcessIn order for us to review and merge your suggested changes, please sign at https://code.facebook.com/cla. If you are contributing on behalf of someone else (eg your employer), the individual CLA may not be sufficient and your employer may need to sign the corporate CLA. Once the CLA is signed, our tooling will perform checks and validations. Afterwards, the pull request will be tagged with If you have received this in error or have any questions, please contact us at cla@meta.com. Thanks! |
|
Warning JavaScript API change detected This PR commits an update to
This change was flagged as: |
Summary
Add a new
AccessibilityInfo.getEnabledAccessibilityServices(feedbackTypeFlags?)method that returns the list of currently enabled accessibility service IDs on Android. This uses Android'sAccessibilityManager.getEnabledAccessibilityServiceList()under the hood.Closes #30862
Motivation
As described in issue #30862, it is useful to query what accessibility services a user has currently enabled. This allows apps to tailor their UI to the specific service — for example, disabling video autoplay when a screen reader service is active, since the audio would interrupt screen reader announcements.
The existing
isScreenReaderEnabled()method only detects Talkback specifically. This new method provides a general-purpose way to get all enabled accessibility services.Changes
AccessibilityInfo.js): AddedgetEnabledAccessibilityServices(feedbackTypeFlags: number = -1): Promise<Array<string>>. On Android, calls the native module; on other platforms, resolves to an empty array.AccessibilityInfoModule.kt): ImplementedgetEnabledAccessibilityServices()usingaccessibilityManager.getEnabledAccessibilityServiceList(feedbackTypeFlags), returning service IDs viaWritableNativeArray.NativeAccessibilityInfo.js): Added optionalgetEnabledAccessibilityServicesmethod to the TurboModule spec.AccessibilityInfo.d.ts): Added type declaration with@platform androidJSDoc.ReactNativeApi.d.ts): Regenerated viayarn build-types.jest-preset/jest/mocks/AccessibilityInfo.js): Added mock forgetEnabledAccessibilityServices.AccessibilityInfo-test.js): Added 4 test cases covering Android success, feedback type flags passthrough, native unavailability error, and iOS empty array.index.tsx): Added type usage test.API
feedbackTypeFlags: Optional AndroidAccessibilityServiceInfo.FEEDBACK_*flags bitmask. Defaults to-1(all feedback types).AccessibilityServiceInfo.getId()).Test plan
yarn jest AccessibilityInfo-test.js) — 42/42 tests passyarn build-typesregeneratesReactNativeApi.d.tscorrectlyChangelog:
[Android] [Added] - Add
getEnabledAccessibilityServicesmethod to AccessibilityInfo to query enabled accessibility service IDsGenerated with Devin