Skip to content

Add AccessibilityInfo API for isSwitchDeviceEnabled and isSpeakScreenEnabled #31346

@blavalla

Description

@blavalla

Description

This issue is very similar to issue #30862, #30863 and #30864, which will allow you to query what accessibility services a user has currently installed or enabled, and know when the state of these change. But those issues when resolved will only work on Android, as iOS has a pre-determined set of accessibility services, unlike Android which allows 3rd party services to exist.

The proposal here is to create a set of specific "one off" methods for the common services that exist between both platforms like SwitchAccess (Android)/SwitchControl (iOS) and SelectToSpeak (Android)/SpeakScreen (iOS). These (along with VoiceOver/Talkback which already work via the isScreenReaderEnabled method) are the most commonly used accessibility services which have an equivalent version on both platforms, and making an API specifically for them would solve the need for detection of services in ~90% of cases. Unfortunately, iOS does not have an API that will get the status of VoiceControl, or it (along with Androids VoiceAccess service) could be added as well. I've provided info below for VoiceAccess in case you wanted to make an Android-only API for this, with the assumption that Apple will add an API to detect this in later versions of iOS that we could take advantage of.

These methods would allow your to tailor your app's UI to the specific service. For example, if a user has a switch device service enabled, you may want to replace a gesture-based UI with one that is easier to trigger via single actions like click, as complex gestures often require extra steps to trigger via switch devices.

Right now, there is a method in the AccessibilityInfo API to detect VoiceOver/Talkback specifically (isScreenReaderEnabled with the screenreaderChanged event) which can act as a template for these other services.

React Native version:

v0.63

Expected Behavior

The AccessibilityInfo API should have some specific methods for determining the state of some common cross-platform accessibility services.

Android Details

To get the state of any accessibility service on Android, you could use the AccessibilityManager.getEnabledAccessibilityServiceList() method, and check for your service in the returned list. You could also use AccessibilityManager.getInstalledAccessibilityServiceList() to determine if the service you are targeting is even installed on the users device.

You would also want to set up a AccessibilityStateChangeListener that re-checks the enabled service list each time it's triggered, to update the internal state of the service you care about.

Below is a list of service ID's for different services in these categories.

SwitchDevice services:
com.android.switchaccess.SwitchAccessService (Google version)
com.samsung.accessibility.universalswitch.UniversalSwitchService (Samsung-specific fork)

Select to speak service:
com.google.android.accessibility.selecttospeak.SelectToSpeakService

VoiceAccess service (no iOS equivalent that can be detected):
com.google.android.apps.accessibility.voiceaccess.JustSpeakService

iOS Details

On iOS, both "SpeakScreen" and "SwitchControl" have their own methods that are used to detect their state, and their own listener that is triggered when the state changes.

Switch Control:
https://developer.apple.com/documentation/uikit/1615131-uiaccessibilityisswitchcontrolru?language=objc
https://developer.apple.com/documentation/uikit/uiaccessibilityswitchcontrolstatusdidchangenotification?language=objc

Speak Screen:
https://developer.apple.com/documentation/uikit/1615109-uiaccessibilityisspeakscreenenab?language=objc
https://developer.apple.com/documentation/uikit/uiaccessibilityspeakscreenstatusdidchangenotification?language=objc

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    Status

    Done

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions