diff options
| -rw-r--r-- | core/java/android/view/View.java | 24 | ||||
| -rw-r--r-- | core/java/android/widget/TextView.java | 4 |
2 files changed, 19 insertions, 9 deletions
diff --git a/core/java/android/view/View.java b/core/java/android/view/View.java index 039237a7dc18..e996f4c40aef 100644 --- a/core/java/android/view/View.java +++ b/core/java/android/view/View.java @@ -7390,16 +7390,19 @@ public class View implements Drawable.Callback, KeyEvent.Callback, * This method only needs overloading if the node is marked as having extra data available. * </p> * - * @param info The info to which to add the extra data + * @param info The info to which to add the extra data. Never {@code null}. * @param extraDataKey A key specifying the type of extra data to add to the info. The * extra data should be added to the {@link Bundle} returned by - * the info's {@link AccessibilityNodeInfo#getExtras} method. - * @param arguments A {@link Bundle} holding any arguments relevant for this request. + * the info's {@link AccessibilityNodeInfo#getExtras} method. Never + * {@code null}. + * @param arguments A {@link Bundle} holding any arguments relevant for this request. May be + * {@code null} if the service provided no arguments. * * @see AccessibilityNodeInfo#setExtraAvailableData */ public void addExtraDataToAccessibilityNodeInfo( - AccessibilityNodeInfo info, String extraDataKey, Bundle arguments) { + @NonNull AccessibilityNodeInfo info, @NonNull String extraDataKey, + @Nullable Bundle arguments) { } /** @@ -24415,17 +24418,20 @@ public class View implements Drawable.Callback, KeyEvent.Callback, * the case where no accessibility delegate is set. * </p> * - * @param host The View hosting the delegate. - * @param info The info to which to add the extra data + * @param host The View hosting the delegate. Never {@code null}. + * @param info The info to which to add the extra data. Never {@code null}. * @param extraDataKey A key specifying the type of extra data to add to the info. The * extra data should be added to the {@link Bundle} returned by - * the info's {@link AccessibilityNodeInfo#getExtras} method. + * the info's {@link AccessibilityNodeInfo#getExtras} method. Never + * {@code null}. * @param arguments A {@link Bundle} holding any arguments relevant for this request. + * May be {@code null} if the if the service provided no arguments. * * @see AccessibilityNodeInfo#setExtraAvailableData */ - public void addExtraDataToAccessibilityNodeInfo( - View host, AccessibilityNodeInfo info, String extraDataKey, Bundle arguments) { + public void addExtraDataToAccessibilityNodeInfo(@NonNull View host, + @NonNull AccessibilityNodeInfo info, @NonNull String extraDataKey, + @Nullable Bundle arguments) { host.addExtraDataToAccessibilityNodeInfo(info, extraDataKey, arguments); } diff --git a/core/java/android/widget/TextView.java b/core/java/android/widget/TextView.java index 20e325cb6d9e..42f1a24c332e 100644 --- a/core/java/android/widget/TextView.java +++ b/core/java/android/widget/TextView.java @@ -10066,6 +10066,10 @@ public class TextView extends View implements ViewTreeObserver.OnPreDrawListener @Override public void addExtraDataToAccessibilityNodeInfo( AccessibilityNodeInfo info, String extraDataKey, Bundle arguments) { + // The only extra data we support requires arguments. + if (arguments == null) { + return; + } if (extraDataKey.equals(EXTRA_DATA_TEXT_CHARACTER_LOCATION_KEY)) { int positionInfoStartIndex = arguments.getInt( EXTRA_DATA_TEXT_CHARACTER_LOCATION_ARG_START_INDEX, -1); |