Skip to content

Add AccessibilityInfo.getEnabledAccessibilityServices on Android - #59234

Open
126punith wants to merge 1 commit into
react:mainfrom
126punith:android-get-enabled-accessibility-services
Open

126punith wants to merge 1 commit into
react:mainfrom
126punith:android-get-enabled-accessibility-services

Conversation

@126punith

Copy link
Copy Markdown

Summary:

Fixes #30862.

AccessibilityInfo.isAccessibilityServiceEnabled() tells an app whether any accessibility service is on, but not which ones. Apps sometimes need that to adapt their behavior. For example, an app may want to avoid auto-playing video audio while TalkBack is reading the screen.

This PR adds an Android-only method, AccessibilityInfo.getEnabledAccessibilityServices(). It returns a promise that resolves to the IDs of the enabled accessibility services, such as com.google.android.marvin.talkback/.TalkBackService, or an empty array when none are enabled.

Changes

  • TurboModule spec (NativeAccessibilityInfo.js): adds an optional getEnabledAccessibilityServices(onSuccess) method, matching the shape of isAccessibilityServiceEnabled.
  • Android (AccessibilityInfoModule.kt): implements the method with AccessibilityManager.getEnabledAccessibilityServiceList(AccessibilityServiceInfo.FEEDBACK_ALL_MASK) and returns each service's id as a WritableArray. If the manager is unavailable, it returns an empty array.
  • JavaScript API (AccessibilityInfo.js): adds getEnabledAccessibilityServices(): Promise<Array<string>>. The promise rejects on iOS, and when the native module or method is missing, using the same error-message pattern as isAccessibilityServiceEnabled().
  • Types: adds the declaration to types_DEPRECATED/.../AccessibilityInfo.d.ts and regenerates ReactNativeApi.d.ts with yarn build-types.
  • Jest preset mock (@react-native/jest-preset): adds getEnabledAccessibilityServices, which resolves to [].
  • C++ API snapshots: adds the generated getEnabledAccessibilityServices: entry to NativeAccessibilityInfoSpec in the four ReactApple*Cxx.api snapshots.

The API returns plain service ID strings rather than descriptor objects to keep the public surface small. Listing installed services is tracked separately in #30864.

Changelog:

[ANDROID] [ADDED] - Add AccessibilityInfo.getEnabledAccessibilityServices() to list the IDs of enabled accessibility services

Test Plan:

  • yarn test packages/react-native/Libraries/Components/AccessibilityInfo packages/jest-preset: 5 suites and 53 tests passed. New tests cover four cases: the native method is available, the native method is missing, the native module is null, and the call is made on iOS.
  • yarn flow-check: 0 errors.
  • yarn lint: passed.
  • yarn format-check-kotlin, plus Prettier on the changed JS/TS files: passed.
  • yarn build-types, then yarn test-generated-typescript: passed.
  • ./gradlew :packages:react-native:ReactAndroid:compileDebugKotlin: BUILD SUCCESSFUL. The generated NativeAccessibilityInfoSpec.java includes getEnabledAccessibilityServices(Callback).
  • C++ API snapshots: I added only the one NativeAccessibilityInfoSpec line that python -m scripts.cxx-api.parser generates. My local Doxygen version (1.18.0) differs from the one CI uses (1.16.1) and produces unrelated diffs, so I did not commit the rest of its output.
  • Not run: an on-device check in RNTester with TalkBack enabled.

Example usage:

const services = await AccessibilityInfo.getEnabledAccessibilityServices();
// ['com.google.android.marvin.talkback/.TalkBackService']

@meta-cla

meta-cla Bot commented Oct 20, 2026

Copy link
Copy Markdown

Hi @126punith!

Thank you for your pull request and welcome to our community.

Action Required

In 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.

Process

In 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 CLA signed. The tagging process may take up to 1 hour after signing. Please give it that time before contacting us about it.

If you have received this in error or have any questions, please contact us at cla@meta.com. Thanks!

@github-actions

Copy link
Copy Markdown

Warning

JavaScript API change detected

This PR commits an update to ReactNativeApi.d.ts, indicating a change to React Native's public JavaScript API.

  • Please include a clear changelog message.
  • This change will be subject to additional review.

This change was flagged as: POTENTIALLY_BREAKING

@126punith

Copy link
Copy Markdown
Author

Hi @126punith!

Thank you for your pull request and welcome to our community.

Action Required

In 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.

Process

In 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 CLA signed. The tagging process may take up to 1 hour after signing. Please give it that time before contacting us about it.

If you have received this in error or have any questions, please contact us at cla@meta.com. Thanks!

Hi! I've signed the CLA, so the bot should update the status shortly. Thanks for taking a look at this PR. I'm happy to make any changes or add more details if needed.

@126punith

Copy link
Copy Markdown
Author

Note on the API check: this change is purely additive. It adds a new Android-only method, AccessibilityInfo.getEnabledAccessibilityServices(): Promise<Array<string>>, and does not modify or remove any existing signatures. I kept the return type to plain service IDs to keep the API surface small, but I'm happy to adjust the shape (for example, return descriptor objects) if maintainers prefer.

@meta-cla

meta-cla Bot commented Oct 20, 2026

Copy link
Copy Markdown

Thank you for signing our Contributor License Agreement. We can now accept your code for this (and any) Meta Open Source project. Thanks!

@meta-cla meta-cla Bot added the CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. label Oct 20, 2026
@facebook-github-tools facebook-github-tools Bot added the Shared with Meta Applied via automation to indicate that an Issue or Pull Request has been shared with the team. label Oct 20, 2026

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. Shared with Meta Applied via automation to indicate that an Issue or Pull Request has been shared with the team.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Android: Enabled services

1 participant