Make 'none' AccessibilityRole return the class for View

Summary:
This changes the default behavior for a "NONE" accessibility role to match Googles implementation in ExploreByTouchHelper (https://cs.android.com/android/platform/superproject/main/+/main:frameworks/base/core/java/com/android/internal/widget/ExploreByTouchHelper.java;drc=c7585d0e2f27f00c47802a78422228a81cf2c939;l=56?q=ExploreByTouchHelper).

This also matches ReactNative's default behavior here as well:
https://www.internalfb.com/code/fbsource/[199b5d1c47b224f2891b8cba33da90c5c8714a81]/xplat/js/react-native-github/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/uimanager/ReactAccessibilityDelegate.java?lines=291

A role of "View" is a no-op behind the scenes for accessibility services, but making this a valid string rather than `null` will prevent potential crashed from systems expecting a string value to always exist from the "getClassName" method.

For context on how large of a potential problem this is, see this post:
https://fb.workplace.com/groups/sbteng/posts/1396301817590446

Reviewed By: ikenwoo

Differential Revision: D50864782

fbshipit-source-id: 8b176ed9427f62a1d039b012d10ea889df4777e3
This commit is contained in:
Brett Lavalla
2023-11-01 05:46:53 -07:00
committed by Facebook GitHub Bot
parent 0f3f4de25e
commit 254110bf02

View File

@@ -34,7 +34,7 @@ public class AccessibilityRoleUtil {
* <p>https://github.com/google/talkback/blob/master/compositor/src/main/res/raw/compositor.json
*/
public enum AccessibilityRole {
NONE(null, ""),
NONE("android.view.View", ""),
BUTTON("android.widget.Button", "Button"),
CHECK_BOX("android.widget.CompoundButton", "Check box"),
DROP_DOWN_LIST("android.widget.Spinner", "Drop down list"),