Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 4563f9df authored by Jacky Kao's avatar Jacky Kao Committed by Android (Google) Code Review
Browse files

Merge "Limitation the text location length of the A11y node" into sc-dev

parents 7277d358 bd462745
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -50825,6 +50825,7 @@ package android.view.accessibility {
    field @NonNull public static final android.os.Parcelable.Creator<android.view.accessibility.AccessibilityNodeInfo> CREATOR;
    field public static final String EXTRA_DATA_RENDERING_INFO_KEY = "android.view.accessibility.extra.DATA_RENDERING_INFO_KEY";
    field public static final String EXTRA_DATA_TEXT_CHARACTER_LOCATION_ARG_LENGTH = "android.view.accessibility.extra.DATA_TEXT_CHARACTER_LOCATION_ARG_LENGTH";
    field public static final int EXTRA_DATA_TEXT_CHARACTER_LOCATION_ARG_MAX_LENGTH = 20000; // 0x4e20
    field public static final String EXTRA_DATA_TEXT_CHARACTER_LOCATION_ARG_START_INDEX = "android.view.accessibility.extra.DATA_TEXT_CHARACTER_LOCATION_ARG_START_INDEX";
    field public static final String EXTRA_DATA_TEXT_CHARACTER_LOCATION_KEY = "android.view.accessibility.extra.DATA_TEXT_CHARACTER_LOCATION_KEY";
    field public static final int FOCUS_ACCESSIBILITY = 2; // 0x2
+14 −1
Original line number Diff line number Diff line
@@ -627,13 +627,18 @@ public class AccessibilityNodeInfo implements Parcelable {

    /**
     * Integer argument specifying the end index of the requested text location data. Must be
     * positive.
     * positive and no larger than {@link #EXTRA_DATA_TEXT_CHARACTER_LOCATION_ARG_LENGTH}.
     *
     * @see #EXTRA_DATA_TEXT_CHARACTER_LOCATION_KEY
     */
    public static final String EXTRA_DATA_TEXT_CHARACTER_LOCATION_ARG_LENGTH =
            "android.view.accessibility.extra.DATA_TEXT_CHARACTER_LOCATION_ARG_LENGTH";

    /**
     * The maximum allowed length of the requested text location data.
     */
    public static final int EXTRA_DATA_TEXT_CHARACTER_LOCATION_ARG_MAX_LENGTH = 20000;

    /**
     * Key used to request extra data for the rendering information.
     * The key requests that a {@link AccessibilityNodeInfo.ExtraRenderingInfo} be added to this
@@ -1038,6 +1043,14 @@ public class AccessibilityNodeInfo implements Parcelable {
     * recycled).
     */
    public boolean refreshWithExtraData(String extraDataKey, Bundle args) {
        // limits the text location length to make sure the rectangle array allocation avoids
        // the binder transaction failure and OOM crash.
        if (args.getInt(EXTRA_DATA_TEXT_CHARACTER_LOCATION_ARG_LENGTH, -1)
                > EXTRA_DATA_TEXT_CHARACTER_LOCATION_ARG_MAX_LENGTH) {
            args.putInt(EXTRA_DATA_TEXT_CHARACTER_LOCATION_ARG_LENGTH,
                    EXTRA_DATA_TEXT_CHARACTER_LOCATION_ARG_MAX_LENGTH);
        }

        args.putString(EXTRA_DATA_REQUESTED_KEY, extraDataKey);
        return refresh(args, true);
    }